PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/tortoisehg/hgqt/pathedit.py

https://bitbucket.org/tortoisehg/hgtk/
Python | 51 lines | 31 code | 14 blank | 6 comment | 0 complexity | 71d023eee594016ce2de36af39ae3c4d MD5 | raw file
 1# pathedit.py
 2#
 3# Copyright 2010 Adrian Buehlmann <adrian@cadifra.com>
 4#
 5# This software may be used and distributed according to the terms of the
 6# GNU General Public License version 2 or any later version.
 7
 8from PyQt4.QtCore import *
 9from PyQt4.QtGui import *
10
11from tortoisehg.hgqt.i18n import _
12
13
14class PathEditDialog(QDialog):
15
16    def __init__(self, parent, alias, url_):
17        super(PathEditDialog, self).__init__(parent)
18        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
19
20        layout = QVBoxLayout()
21
22        self.setLayout(layout)
23        self.setWindowTitle(_("Edit Repository URL"))
24
25        form = QFormLayout()
26        layout.addLayout(form)
27        form.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
28
29        self.edit = QLineEdit(url_)
30        form.addRow(alias, self.edit)
31
32        BB = QDialogButtonBox
33        bb = QDialogButtonBox(BB.Ok|BB.Cancel)
34        layout.addWidget(bb)
35        bb.accepted.connect(self.accept)
36        bb.rejected.connect(self.reject)
37        bb.button(BB.Ok).setDefault(True)
38
39        self.setMinimumWidth(400)
40        h = self.sizeHint().height() + 6
41        self.setMaximumHeight(h)
42        self.setMinimumHeight(h)
43
44    def accept(self):
45        QDialog.accept(self)
46
47    def reject(self):
48        QDialog.reject(self)
49
50    def url(self):
51        return str(self.edit.text())