Plugins/VcsPlugins/vcsMercurial/HgBranchInputDialog.py

Sun, 09 Mar 2014 19:04:42 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 09 Mar 2014 19:04:42 +0100
changeset 3353
ddc966a494b0
child 3366
6084bb3c3911
permissions
-rw-r--r--

Added capability to commit a new branch directly without the need to select the commit menu entry.

# -*- coding: utf-8 -*-

# Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to enter the data for a branch operation.
"""

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog, QDialogButtonBox

from .Ui_HgBranchInputDialog import Ui_HgBranchInputDialog


class HgBranchInputDialog(QDialog, Ui_HgBranchInputDialog):
    """
    Class implementing a dialog to enter the data for a branch operation.
    """
    def __init__(self, branches, parent=None):
        """
        Constructor
        
        @param branches branch names to populate the branch list with
            (list of string)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.branchComboBox.addItems(sorted(branches))
        self.branchComboBox.setEditText("")
        
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
        
        self.resize(self.width(), self.minimumSizeHint().height())
    
    @pyqtSlot(str)
    def on_branchComboBox_editTextChanged(self, txt):
        """
        Private slot handling a change of the branch name.
        
        @param txt contents of the branch combo box (string)
        """
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
    
    def getData(self):
        """
        Public method to get the data.
        
        @return tuple of branch name (string) and a flag indicating to
            commit the branch (boolean)
        """
        return (self.branchComboBox.currentText(),
                self.commitCheckBox.isChecked())

eric ide

mercurial