macgitver / MacGitverModules

DEPRECATED: Modules for MacGitver
5 stars 1 forks source link

Custom Commands #65

Open scunz opened 11 years ago

scunz commented 11 years ago

Waiting for:

antis81 commented 10 years ago

@scunz Hm, I'd like to work on this branch, but it doesn't compile at present. I see no way to "know" the matching commits in depending modules. Instead of trying around to find the matching commit(s) where everything worked I'd simply rebase it onto development. Seems like a reasonable general method to solve this situation, what do you think?

scunz commented 10 years ago

Actually, I think of this branch as "waiting for further features" at the moment, so I'd request you to discuss what you want to change in advance.

As for not compiling; I'll have a look into that. Should be 20 minutes until I'm through with the Qt4/5 stuff for WebKit...

scunz commented 10 years ago

Also note: As long as Jenkins is broken, all of the nice automation is gone... We'll have to integrate commits into submodules manually... I will also take care of the current stage in a second. :-)

scunz commented 10 years ago

@antis81, YES, rebasing to development would have been the right choice in this case. I actually did that and force-pushed it here...

antis81 commented 10 years ago

Also note: As long as Jenkins is broken, all of the nice automation is gone... We'll have to integrate commits into submodules manually... I will also take care of the current stage in a second. :-)

Yes, already notice that :). No Problem ( see PM -> unfortunately, this will probably not work for Jenkins ).

antis81 commented 10 years ago

Actually, I think of this branch as "waiting for further features" at the moment, so I'd request you to discuss what you want to change in advance.

Actually I don't know yet :). I plan to look into the branch, find what might be missing and then put it in a task (the todo list like always :) ) or discuss it here.

scunz commented 10 years ago

Okay. So what is missing:

antis81 commented 10 years ago

@scunz Put your points to the top TODO list. We need some activation context to control to which menu(s) a command is visible. Do we have that already?

Other than that I plan to implement something like this in the menu:

antis81 commented 10 years ago

@scunz Not sure how to proceed on this one. I think it is a good idea to wait for your RM changes first. Further I thought of moving the "context" part into libHeaven. One idea would be, to register a context within the hid file of the menu itself. Means something like that:

...
    ActionGroup CustomActionsRepo {
      CustomCommands {
        Contexts Repository, Global;
      };
    };

    ActionGroup CustomActionsSM {
      CustomCommands {
        Contexts Submodule, Global;
      };
    };

    Menu CtxMenuRepo {

        Action      Activate;
        Separator;
        MergePlace  RepoRootCtx;
        Separator;
        Action      Close;

        Separator;
        ActionGroup CustomCommandsRepo;

    };

    Menu CtxMenuSMRepo {

        Action      Activate;
        Separator;
        MergePlace  RepoSubCtx;

        Separator;
        ActionGroup CustomCommandsSM;
    };

The compiled "contexts" could be shown as available in the settings page. Maybe even with a descriptive, translateable text. What do you think? It is basically a raw idea though.

scunz commented 10 years ago

Are your action groups referring to macgitver/libHeaven#15? These are totally different things, actually: Just wrapping QActionGroup objects around Heaven::Action (Which was required to have radio buttons inside menus => which in turn was required for the switching logic in the new history tool bar).

However, I was thinking along this lines: When the RM is finished, every visible object will have a RM::Base object derivate. We will have to change the RepoTree and the RefsTree to acknowledge for that. And when we've done that, we can turn any of those two tree's QModelIndexes into a RM::Base. Now, consider this:

Heaven::Menu* RM::Base::getContextMenu() {
    Heaven::Menu* menu = MacGitver::repoMan().getContextMenuFor(this);
    menu->setActivationContext(this); // <- This doesn't work atm
    // because ActivationContexts must be
    // QObject-Pointers and I've removed QObject inheritance.
    return menu;
}

// and the hic:
Ui RepoMan {
    Menu CtxBranch {
        MergePlace CtxBranchMP;
    };
    Menu CtxTag {
        MergePlace CtxTagMP;
    };
    // and so on
};

// and again C++:
Heaven::Menu* RM::RepoMan::getContextMenuFor(RM::Base* obj) {
    switch(obj->type()) {
    case BranchType: return mmuCtxBranch;
    case TagType: return mmuCtxTag;
    // ...
    }
}

Actually, I already have some code prepared that extends this concept to Working Tree and Index. If I can get that done, we'll be having a really cool basis to build some features upon...

However, your post inspired me to some thinking. Give me a day or two. Your idea might help me solve some problems that I still see here...

antis81 commented 10 years ago

Are your action groups referring to macgitver/libHeaven#15? ...

Yes, actually I misunderstood the QActionGroup mechanism. But fortunately you understood what I mean and set it in the right context :smile:. Two more topics I see here:

Hope this sounds plausible enough. Also, we need to rebase this branch on top of mgv/develop again in respect of your cmake cleanup ( sorry, I did a pull on the umbrella project :innocent: ).

scunz commented 10 years ago

MGV should make fetch definitively more prominent than pull ^^ Why don't you pull with --rebase instead? It is way more convenient.

As we know the available activation context providers at compile time, using some Context template class rather than the "item-object" itself together with setActivationContext(const Context &ctx) feels more convenient.

Still need to think more about that. Giving it directly from the hid has a charm on its own. But I'm not sure that this would be right.

What if we want to allow CustomCommands for a commit or a "branch label" within the history view? Means, the provider object does not necessarily inherit RM::Base.

Actually, we're having a "commit-cache" in Mod-History anyway. We could as well move that to the RepoMan and have it accessible everywhere. This would mean, that RM::Commit would become objects which are not all created at once, but lazy populated on demand. Well, this idea is good indeed: This would allow us to keep the commit cache when we have to redo the revwalk in history-view.... We just would revwalk and get the commit ids and then reuse the already populated commit objects from repo man (which would then contain the details rather than the cache in history view).

We should allow usage of item constants within a custom command (e.g.: $OID, $NAME, etc.). Maybe the above mentioned Context class could provide these by connecting a name to a class method (or a slot). Ok?

I'm not sure where to get those from. Another thing that needs some thinking. But what we could definitively do, would be to populate the usual GIT-environment variables... (Maybe add a checkbox for that inside the config page).

After all, this RepoMan thingie is getting very large - and there is no end in sight. Actually, this code should have been written as the first code for MGV. I'm tempted to just merge that code and go on incrementally from there.

antis81 commented 10 years ago

I'm tempted to just merge that code and go on incrementally from there.

Think that's the best we can do :+1:.

scunz commented 10 years ago

@antis81, this Context Menu stuff is now in the RepoMan branch

scunz commented 10 years ago

Actually, you could rebase this upon the repoman work and just go ahead ^^

antis81 commented 10 years ago

Ok, I'll rebase it there :).