Source

thg-qt-mq / formlay.diff

# HG changeset patch
# Parent f421234ed66a8da243491184d3a4d7725d064ad0
update: use QFormLayout for simplicity

diff --git a/tortoisehg/hgqt/update.py b/tortoisehg/hgqt/update.py
--- a/tortoisehg/hgqt/update.py
+++ b/tortoisehg/hgqt/update.py
@@ -30,20 +30,15 @@ class UpdateDialog(QDialog):
         self._finished = False
         self.repo = repo
 
-        # base layout box
-        box = QVBoxLayout()
-        box.setSpacing(6)
-
-        ## main layout grid
-        self.grid = QGridLayout()
-        self.grid.setSpacing(6)
-        box.addLayout(self.grid)
+        lay = QFormLayout()
+        lay.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
+        lay.setSpacing(6)
 
         ### target revision combo
         self.rev_combo = combo = QComboBox()
         combo.setEditable(True)
-        self.grid.addWidget(QLabel(_('Update to:')), 0, 0)
-        self.grid.addWidget(combo, 0, 1)
+        combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+        lay.addRow(_('Update to:'), combo)
 
         if rev is None:
             rev = self.repo.dirstate.branch()
@@ -65,31 +60,25 @@ class UpdateDialog(QDialog):
         style = csinfo.labelstyle(contents=items, width=350, selectable=True)
         factory = csinfo.factory(self.repo, style=style)
         self.target_info = factory()
-        self.grid.addWidget(QLabel(_('Target:')), 1, 0, Qt.AlignLeft | Qt.AlignTop)
-        self.grid.addWidget(self.target_info, 1, 1)
+        lay.addRow(_('Target:'), self.target_info)
 
         ### parent revision info
         self.ctxs = self.repo[None].parents()
         if len(self.ctxs) == 2:
             self.p1_info = factory()
-            self.grid.addWidget(QLabel(_('Parent 1:')), 2, 0, Qt.AlignLeft | Qt.AlignTop)
-            self.grid.addWidget(self.p1_info, 2, 1)
+            lay.addRow(_('Parent 1:'), self.p1_info)
             self.p2_info = factory()
-            self.grid.addWidget(QLabel(_('Parent 2:')), 3, 0, Qt.AlignLeft | Qt.AlignTop)
-            self.grid.addWidget(self.p2_info, 3, 1)
+            lay.addRow(_('Parent 2:'), self.p2_info)
         else:
             self.p1_info = factory()
-            self.grid.addWidget(QLabel(_('Parent:')), 2, 0, Qt.AlignLeft | Qt.AlignTop)
-            self.grid.addWidget(self.p1_info, 2, 1)
+            lay.addRow(_('Parent:'), self.p1_info)
 
         ### options
         self.optbox = QVBoxLayout()
         self.optbox.setSpacing(6)
         expander = qtlib.ExpanderLabel(_('Options:'), False)
         expander.expanded.connect(self.show_options)
-        row = self.grid.rowCount()
-        self.grid.addWidget(expander, row, 0, Qt.AlignLeft | Qt.AlignTop)
-        self.grid.addLayout(self.optbox, row, 1)
+        lay.addRow(expander, self.optbox)
 
         self.verbose_chk = QCheckBox(_('List updated files (--verbose)'))
         self.discard_chk = QCheckBox(_('Discard local changes, no backup '
@@ -127,7 +116,7 @@ class UpdateDialog(QDialog):
         self.cmd.output.connect(self.output)
         self.cmd.makeLogVisible.connect(self.makeLogVisible)
         self.cmd.progress.connect(self.progress)
-        box.addWidget(self.cmd)
+        lay.addRow(self.cmd)
 
         ## bottom buttons
         buttons = QDialogButtonBox()
@@ -144,14 +133,14 @@ class UpdateDialog(QDialog):
         self.detail_btn.setAutoDefault(False)
         self.detail_btn.setCheckable(True)
         self.detail_btn.toggled.connect(self.detail_toggled)
-        box.addWidget(buttons)
+        lay.addRow(buttons)
 
         # signal handlers
         self.rev_combo.editTextChanged.connect(self.update_info)
         self.discard_chk.toggled.connect(self.update_info)
 
         # dialog setting
-        self.setLayout(box)
+        self.setLayout(lay)
         self.setWindowTitle(_('Update - %s') % self.repo.displayname)
         self.setWindowIcon(qtlib.geticon('hg-update'))