eric6/Plugins/VcsPlugins/vcsSubversion/SvnOptionsDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter options used to start a project in
8 the VCS.
9 """
10
11 from __future__ import unicode_literals
12
13 import os
14
15 from PyQt5.QtCore import QDir, pyqtSlot
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
17
18 from E5Gui.E5PathPicker import E5PathPickerModes
19
20 from .Ui_SvnOptionsDialog import Ui_SvnOptionsDialog
21 from .Config import ConfigSvnProtocols
22
23 import Utilities
24
25
26 class SvnOptionsDialog(QDialog, Ui_SvnOptionsDialog):
27 """
28 Class implementing a dialog to enter options used to start a project in the
29 repository.
30 """
31 def __init__(self, vcs, project, parent=None):
32 """
33 Constructor
34
35 @param vcs reference to the version control object
36 @param project reference to the project object
37 @param parent parent widget (QWidget)
38 """
39 super(SvnOptionsDialog, self).__init__(parent)
40 self.setupUi(self)
41
42 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode)
43
44 self.project = project
45
46 self.protocolCombo.addItems(ConfigSvnProtocols)
47
48 hd = Utilities.toNativeSeparators(QDir.homePath())
49 hd = os.path.join(hd, 'subversionroot')
50 self.vcsUrlPicker.setText(hd)
51
52 self.vcs = vcs
53
54 self.localPath = hd
55 self.networkPath = "localhost/"
56 self.localProtocol = True
57
58 msh = self.minimumSizeHint()
59 self.resize(max(self.width(), msh.width()), msh.height())
60
61 @pyqtSlot()
62 def on_vcsUrlPicker_pickerButtonClicked(self):
63 """
64 Private slot to display a repository browser dialog.
65 """
66 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog
67 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self)
68 dlg.start(
69 self.protocolCombo.currentText() + self.vcsUrlPicker.text())
70 if dlg.exec_() == QDialog.Accepted:
71 url = dlg.getSelectedUrl()
72 if url:
73 protocol = url.split("://")[0]
74 path = url.split("://")[1]
75 self.protocolCombo.setCurrentIndex(
76 self.protocolCombo.findText(protocol + "://"))
77 self.vcsUrlPicker.setText(path)
78
79 @pyqtSlot(str)
80 def on_protocolCombo_activated(self, protocol):
81 """
82 Private slot to switch the status of the directory selection button.
83
84 @param protocol selected protocol (string)
85 """
86 if protocol == "file://":
87 self.networkPath = self.vcsUrlPicker.text()
88 self.vcsUrlPicker.setText(self.localPath)
89 self.vcsUrlLabel.setText(self.tr("Pat&h:"))
90 self.localProtocol = True
91 else:
92 if self.localProtocol:
93 self.localPath = self.vcsUrlPicker.text()
94 self.vcsUrlPicker.setText(self.networkPath)
95 self.vcsUrlLabel.setText(self.tr("&URL:"))
96 self.localProtocol = False
97
98 @pyqtSlot(str)
99 def on_vcsUrlPicker_textChanged(self, txt):
100 """
101 Private slot to handle changes of the URL.
102
103 @param txt current text of the line edit (string)
104 """
105 enable = "://" not in txt
106 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
107
108 def getData(self):
109 """
110 Public slot to retrieve the data entered into the dialog.
111
112 @return a dictionary containing the data entered
113 """
114 scheme = self.protocolCombo.currentText()
115 url = self.vcsUrlPicker.text()
116 vcsdatadict = {
117 "url": '{0}{1}'.format(scheme, url),
118 "message": self.vcsLogEdit.text(),
119 "standardLayout": self.layoutCheckBox.isChecked(),
120 }
121 return vcsdatadict

eric ide

mercurial