From: Markus Heidelberg <markus.heidelberg@web.de>
To: Marco Costalba <mcostalba@gmail.com>
Cc: git@vger.kernel.org, Markus Heidelberg <markus.heidelberg@web.de>
Subject: [PATCH QGit 4/4] Create a separate submenu for tags
Date: Sat, 6 Jun 2009 13:57:51 +0200 [thread overview]
Message-ID: <1244289471-698-5-git-send-email-markus.heidelberg@web.de> (raw)
It is more logical and hierarchical correct not to begin listing tags in
the existing submenu. The remaining space of the main context menu is
halved for the branches and tags to be displayed before the submenu has
to be created.
A little downside is that now you can get 2 "More..." submenus for
branches and tags instead of only 1.
Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
---
src/mainimpl.cpp | 38 ++++++++++++++++++++++++++------------
1 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp
index 38bbfbe..9613fac 100644
--- a/src/mainimpl.cpp
+++ b/src/mainimpl.cpp
@@ -1138,7 +1138,8 @@ static int cntMenuEntries(const QMenu& menu) {
void MainImpl::doContexPopup(SCRef sha) {
QMenu contextMenu(this);
- QMenu contextSubMenu("More...", this);
+ QMenu contextBrnMenu("More branches...", this);
+ QMenu contextTagMenu("More tags...", this);
QMenu contextRmtMenu("Remote branches", this);
connect(&contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(goRef_triggered(QAction*)));
@@ -1193,35 +1194,48 @@ void MainImpl::doContexPopup(SCRef sha) {
if (!contextRmtMenu.isEmpty())
contextMenu.addMenu(&contextRmtMenu);
+ // halve the possible remaining entries for branches and tags
+ int remainingEntries = (MAX_MENU_ENTRIES - cntMenuEntries(contextMenu));
+ int tagEntries = remainingEntries / 2;
+ int brnEntries = remainingEntries - tagEntries;
+
+ // display more branches, if there are few tags
+ if (tagEntries > tn.count())
+ tagEntries = tn.count();
+
+ // one branch less because of the "More branches..." submenu
+ if ((bn.count() > brnEntries) && tagEntries)
+ tagEntries++;
+
if (!bn.empty())
contextMenu.addSeparator();
FOREACH_SL (it, bn) {
- if (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES
- || (*it == bn.last() && contextSubMenu.isEmpty() && tn.empty()))
+ if (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES - tagEntries
+ || (*it == bn.last() && contextBrnMenu.isEmpty()))
act = contextMenu.addAction(*it);
else
- act = contextSubMenu.addAction(*it);
+ act = contextBrnMenu.addAction(*it);
act->setData("Ref");
}
+ if (!contextBrnMenu.isEmpty())
+ contextMenu.addMenu(&contextBrnMenu);
+
if (!tn.empty())
- if (!contextSubMenu.isEmpty())
- contextSubMenu.addSeparator();
- else
- contextMenu.addSeparator();
+ contextMenu.addSeparator();
FOREACH_SL (it, tn) {
if (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES
- || (*it == tn.last() && contextSubMenu.isEmpty()))
+ || (*it == tn.last() && contextTagMenu.isEmpty()))
act = contextMenu.addAction(*it);
else
- act = contextSubMenu.addAction(*it);
+ act = contextTagMenu.addAction(*it);
act->setData("Ref");
}
- if (!contextSubMenu.isEmpty())
- contextMenu.addMenu(&contextSubMenu);
+ if (!contextTagMenu.isEmpty())
+ contextMenu.addMenu(&contextTagMenu);
}
contextMenu.exec(QCursor::pos());
}
--
1.6.3.2.213.g30b07
reply other threads:[~2009-06-06 11:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244289471-698-5-git-send-email-markus.heidelberg@web.de \
--to=markus.heidelberg@web.de \
--cc=git@vger.kernel.org \
--cc=mcostalba@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).