News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

a Qt plugin : QtPregenForCB => AddOnForQt

Started by LETARTARE, February 10, 2015, 05:53:03 PM

Previous topic - Next topic

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

MortenMacFly

Quote from: oBFusCATed on February 13, 2015, 09:40:22 AM
Sorry, have no time to do it...
So you had no time but I had. Indeed, it works. I think you are wrong on that topic. And reverting a commit without proof that is does NOT work is not nice you know...  :(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

Morten:
I've not reverted it because it doesn't work, but because it is bad design (this is a personal opinion/vision).
I would have reverted it even if I've tried it and it has worked.
Obviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

p.s. Can you reason about why it works? How on earth the plugin matches correctly the id of the context menu items, when it has never requested them?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

LETARTARE

#18
@MortenMacFly
Thank you for taking the time to test this plugin.
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.

@oBFusCATed
Quotewhen it has never requested them
See 2-

1- It retrieves the ids menus created by the plugin 'CompilerGcc' by :
void QtPregen::BuildMenu(wxMenuBar* menuBar)
{
if (!IsAttached())
        return;

int pos = menuBar->FindMenu(_("Build"));
if (pos !=-1) {
wxMenu * builder = menuBar->GetMenu(pos);
m_IdBuild = builder->FindItem(_("Build"));
m_IdCompile = builder->FindItem(_("Compile current file"));
m_IdRun = builder->FindItem(_("Run"));
m_IdBuildRun = builder->FindItem(_("Build and run"));
m_IdRebuild = builder->FindItem(_("Rebuild"));
m_IdClean = builder->FindItem(_("Clean"));
}
}


2- It retrieves the ids context menus created by the plugin 'CompilerGcc' by :
void QtPregen::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if (!IsAttached())
        return;

// we 're only interested in m_project manager's menus
    if (!menu || type != mtProjectManager)
        return;

// right click on item menu ...else -> 0
    if (data) {
    FileTreeData::FileTreeDataKind typedata  = data->GetKind();
    // ... click project
bool preproject = typedata == FileTreeData::ftdkProject  ;
// ... click file
bool prefile = typedata == FileTreeData::ftdkFile ;

if (preproject)  {
// popup menu on a project
m_IdpClean  = menu->FindItem(_("Clean"));
m_IdpBuild  = menu->FindItem(_("Build"));
m_IdpRebuild  = menu->FindItem(_("Rebuild"));
}
else
if (prefile) {
// popup menu on a file
m_IdfBuild  = menu->FindItem(_("Build file"));
m_IdfClean  = menu->FindItem(_("Clean file"));
}
      }
}


3- Id are used to select the treatment  in :
void QtPregen::OnPrebuild(CodeBlocksEvent& event)
{
      int eventId = event.GetId();
      ....
}

Note that from one session to another, id's remain the same!
While compiling a new version of svn 'Code::Block'.

QuoteObviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

Well, how so ?
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

LETARTARE

#19
Hello,
- new 'QtPregenForCB-0.2.4'
- all private variables are prefixed with 'm_',
- improved user dialogs on error Qt utilities
Best regards
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

oBFusCATed

Quote from: LETARTARE on February 15, 2015, 09:04:54 AM
2- It retrieves the ids context menus created by the plugin 'CompilerGcc' by :
void QtPregen::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if (!IsAttached())
        return;

// we 're only interested in m_project manager's menus
    if (!menu || type != mtProjectManager)
        return;

// right click on item menu ...else -> 0
    if (data) {
    FileTreeData::FileTreeDataKind typedata  = data->GetKind();
    // ... click project
bool preproject = typedata == FileTreeData::ftdkProject  ;
// ... click file
bool prefile = typedata == FileTreeData::ftdkFile ;

if (preproject)  {
// popup menu on a project
m_IdpClean  = menu->FindItem(_("Clean"));
m_IdpBuild  = menu->FindItem(_("Build"));
m_IdpRebuild  = menu->FindItem(_("Rebuild"));
}
else
if (prefile) {
// popup menu on a file
m_IdfBuild  = menu->FindItem(_("Build file"));
m_IdfClean  = menu->FindItem(_("Clean file"));
}
      }
}

What  a really clever hack. I'm stunned!


Quote from: LETARTARE on February 15, 2015, 09:04:54 AM
QuoteObviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

Well, how so ?
1. Create new event or even two events. One for starting and one for finishing.
2. Make an enum with all the possible types of actions you're interested in
3. Inspect the switch in CompilerGCC::BuildStateManagement and in every interesting case statement fire the appropriate event.
4. Test if all this is reliable... And doesn't slow the build process.
5. Probably it will be good if these events can be used to cancel the build process.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

oBFusCATed

Quote from: LETARTARE on February 15, 2015, 09:04:54 AM
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.
I don't think there is a way.
Loggers have no name or id, so you cannot query them to obtain the index.
Only the one that has created them knows their index and can use them.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

LETARTARE

@oBFusCATed
QuoteWhat  a really clever hack. I'm stunned!
Sir, is it a mockery or not ?
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

oBFusCATed

Hm. I don't think it is a mockery. I'm just amazed what you've done to solve your problem.  8)

p.s. Keep in mind that English is not my native language, so I may use the inappropriate words at times.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

LETARTARE

Hello,
I would rather. I also use 'Google Translation' and that's why I asked for you. It's over.

Quote3. Inspect the switch in CompilerGCC::BuildStateManagement and in every interesting case statement fire the appropriate event.
I do not know what to do ?
Regards
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

oBFusCATed

This is how you send and event:

        CodeBlocksEvent evt(<event type>, <parameters>);
        Manager::Get()->ProcessEvent(evt);


And you have to create one or more new events.
To see how to do it inspect the sdk_events.h/cpp files to see how the other events are declared/defined.
Copy/paste/modify the code until it fits you needs and post a patch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

LETARTARE

Hello,
- new 'QtPregenForCB-0.4.2'
- it uses a new organization for use of two new events:
Quote'cbEVT_PRECOMPILER_STARTED' and
'cbEVT_PRECOMPILE_FILE'
I adapted 'CompilerGCC' to have a state machine with a state of more
QuotebsTargetPreGen
see 'CompilerGCC::GetNextStateBasedOnJob()' and 'CompilerGCC::BuildStateManagement()'

I provide a patch to svn 10118, see to :
https://github.com/LETARTARE/QtPregenForCB

Best regards
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

oBFusCATed

I hope you know that in the c++ world precompile and precompiled mean totally different things. So if these features stay, then you'll need to find better names.  Probably use a name similar to already use names like xxxxPreBuild.

Have you tried the solution I've proposed? What are its problems? Because the propose solution looks way more complex than it needs to be.

p.s. This struct "struct s_rebuild { bool workspace, clean, build; } ;" should be made public, if the code stays the same.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

LETARTARE

Thank you for watching.
I suspected that the names will be to adapt. No problem, I look...
I used what you recommended, but to treat all cases, I arrived at this solution.
I can have a workspace with very different projects (Compilers, libraries ...), and it works.
I can use context menus('Build file', ...).

QuoteThis struct "struct s_rebuild { bool workspace, clean, build; } ;" should be made public, if the code stays the same.
Of course, but I do not know where ?
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

oBFusCATed

Quote from: LETARTARE on February 21, 2015, 08:16:42 PM
I used what you recommended, but to treat all cases, I arrived at this solution.
What cases are not handled by my solution?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]