Discussion:
[thg-dev] [PATCH 0 of 1 ] make qnew/qrefresh possible in stand-alone commit dialog
Sune Foldager
2011-11-23 14:35:41 UTC
Permalink
Ok, this is a stab at making the stand-alone commit dialog support MQ the same way the embedded one does. It basically uses the same approach, but places the combo-button in the "dialog button bar position", as the Commit button has in that dialog, instead of at the top right.

I have tested all the scenarios I can come up with, so I am fairly sure it works, but someone should have a second look at the code. Some comments:

- The commit.commitButtonEnable.connect(commitbtn.setEnabled) line I moved, is not really used after the change, since the only situation the button was disabled, was when we had an MQ patch at the top. This will now trigger a proper MQ combo-button. I left it in anyway, but we might get rid of it.

- I made the 'Commit' text bold for the non-MQ case, to conform with the MQ button as well as the Commit button in the embedded version.

- The rev='.' is necessary to correctly trigger QRefresh instead of QNew as default action when there's a patch on top.

-Sune
Sune Foldager
2011-11-23 14:35:42 UTC
Permalink
# HG changeset patch
# User Sune Foldager <***@cyanite.org>
# Date 1322051347 -3600
# Node ID b55d1560742fadea424da46c6bba9fa65d2cec63
# Parent f4ad534ad78c14321282fa2488656cd46f424b0f
commit: make stand-alone dialog support mq

diff -r f4ad534ad78c -r b55d1560742f tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py Fri Nov 18 00:24:15 2011 -0600
+++ b/tortoisehg/hgqt/commit.py Wed Nov 23 13:29:07 2011 +0100
@@ -141,7 +141,7 @@
vbox.addLayout(hbox, 0)
self.buttonHBox = hbox

- if embedded and 'mq' in self.repo.extensions():
+ if 'mq' in self.repo.extensions():
self.hasmqbutton = True
pnhbox = QHBoxLayout()
self.pnlabel = QLabel()
@@ -1100,7 +1100,7 @@
toplayout.setContentsMargins(5, 5, 5, 0)
layout.addLayout(toplayout)

- commit = CommitWidget(repo, pats, opts, False, self)
+ commit = CommitWidget(repo, pats, opts, False, self, rev='.')
toplayout.addWidget(commit, 1)

self.statusbar = cmdui.ThgStatusBar(self)
@@ -1109,16 +1109,25 @@
commit.linkActivated.connect(self.linkActivated)

BB = QDialogButtonBox
- bb = QDialogButtonBox(BB.Ok|BB.Close|BB.Discard)
- bb.accepted.connect(self.accept)
+ bb = QDialogButtonBox(BB.Close|BB.Discard)
bb.rejected.connect(self.reject)
bb.button(BB.Discard).setText('Undo')
bb.button(BB.Discard).clicked.connect(commit.rollback)
bb.button(BB.Close).setDefault(False)
bb.button(BB.Discard).setDefault(False)
- bb.button(BB.Ok).setDefault(True)
- self.commitButton = bb.button(BB.Ok)
- self.commitButton.setText(_('Commit', 'action button'))
+ if commit.hasmqbutton:
+ self.commitButton = commit.mqSetupButton()
+ bb.addButton(self.commitButton, BB.AcceptRole)
+ else:
+ self.commitButton = commitbtn = bb.addButton(BB.Ok)
+ commitbtn.setDefault(True)
+ commitbtn.setText(_('Commit', 'action button'))
+ f = commitbtn.font()
+ f.setWeight(QFont.Bold)
+ commitbtn.setFont(f)
+ commit.commitButtonEnable.connect(commitbtn.setEnabled)
+ bb.accepted.connect(self.accept)
+
self.bb = bb

toplayout.addWidget(self.bb)
@@ -1129,7 +1138,6 @@
commit.loadSettings(s, 'committool')
repo.repositoryChanged.connect(self.updateUndo)
commit.commitComplete.connect(self.postcommit)
- commit.commitButtonEnable.connect(self.commitButton.setEnabled)

self.setWindowTitle(_('%s - commit') % repo.displayname)
self.commit = commit

Loading...