Thu, 23 Feb 2017 18:44:25 +0100
Reworked the Mercurial checkout dialog.
# -*- coding: utf-8 -*- # Copyright (c) 2010 - 2017 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the Mercurial Options Dialog for a new project from the repository. """ from __future__ import unicode_literals from PyQt5.QtCore import pyqtSlot, QUrl from PyQt5.QtWidgets import QDialog, QDialogButtonBox from E5Gui.E5PathPicker import E5PathPickerModes from .Ui_HgNewProjectOptionsDialog import Ui_HgNewProjectOptionsDialog from .Config import ConfigHgSchemes import Utilities import Preferences class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog): """ Class implementing the Options Dialog for a new project from the repository. """ def __init__(self, vcs, parent=None): """ Constructor @param vcs reference to the version control object @param parent parent widget (QWidget) """ super(HgNewProjectOptionsDialog, self).__init__(parent) self.setupUi(self) self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode) self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) ipath = Preferences.getMultiProject("Workspace") or \ Utilities.getHomeDir() self.__initPaths = [ Utilities.fromNativeSeparators(ipath), Utilities.fromNativeSeparators(ipath) + "/", ] self.vcsProjectDirPicker.setText(self.__initPaths[0]) self.lfNoteLabel.setVisible(vcs.isExtensionActive("largefiles")) self.largeCheckBox.setVisible(vcs.isExtensionActive("largefiles")) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(str) def on_vcsProjectDirPicker_textChanged(self, txt): """ Private slot to handle a change of the project directory. @param txt name of the project directory (string) """ self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( bool(txt) and Utilities.fromNativeSeparators(txt) not in self.__initPaths) @pyqtSlot(str) def on_vcsUrlPicker_textChanged(self, txt): """ Private slot to handle changes of the URL. @param txt current text of the line edit (string) """ url = QUrl.fromUserInput(txt) enable = url.isValid() and url.scheme() in ConfigHgSchemes self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file") def getData(self): """ Public slot to retrieve the data entered into the dialog. @return a tuple of a string (project directory) and a dictionary containing the data entered. """ url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/")) vcsdatadict = { "url": url.toString(QUrl.None_), "revision": self.vcsRevisionEdit.text(), "largefiles": self.largeCheckBox.isChecked(), } return (self.vcsProjectDirPicker.text(), vcsdatadict)