/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. from PyQt4.QtCore import *
  8. from PyQt4.QtGui import *
  9. from tortoisehg.hgqt.i18n import _
  10. class PathEditDialog(QDialog):
  11. def __init__(self, parent, alias, url_):
  12. super(PathEditDialog, self).__init__(parent)
  13. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  14. layout = QVBoxLayout()
  15. self.setLayout(layout)
  16. self.setWindowTitle(_("Edit Repository URL"))
  17. form = QFormLayout()
  18. layout.addLayout(form)
  19. form.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
  20. self.edit = QLineEdit(url_)
  21. form.addRow(alias, self.edit)
  22. BB = QDialogButtonBox
  23. bb = QDialogButtonBox(BB.Ok|BB.Cancel)
  24. layout.addWidget(bb)
  25. bb.accepted.connect(self.accept)
  26. bb.rejected.connect(self.reject)
  27. bb.button(BB.Ok).setDefault(True)
  28. self.setMinimumWidth(400)
  29. h = self.sizeHint().height() + 6
  30. self.setMaximumHeight(h)
  31. self.setMinimumHeight(h)
  32. def accept(self):
  33. QDialog.accept(self)
  34. def reject(self):
  35. QDialog.reject(self)
  36. def url(self):
  37. return str(self.edit.text())