eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.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) 2014 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for the repo conversion.
8 """
9
10 from __future__ import unicode_literals
11
12 import os
13
14 from PyQt5.QtCore import pyqtSlot
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
16
17 from E5Gui.E5PathPicker import E5PathPickerModes
18
19 from .Ui_LfConvertDataDialog import Ui_LfConvertDataDialog
20
21 from . import getDefaults
22
23 import Utilities
24
25
26 class LfConvertDataDialog(QDialog, Ui_LfConvertDataDialog):
27 """
28 Class implementing a dialog to enter the data for the repo conversion.
29 """
30 def __init__(self, currentPath, mode, parent=None):
31 """
32 Constructor
33
34 @param currentPath directory name of the current project (string)
35 @param mode dialog mode (string, one of 'largefiles' or 'normal')
36 @param parent reference to the parent widget (QWidget)
37 """
38 super(LfConvertDataDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.newProjectPicker.setMode(E5PathPickerModes.DirectoryMode)
42
43 self.__defaults = getDefaults()
44 self.__currentPath = Utilities.toNativeSeparators(currentPath)
45
46 self.currentProjectLabel.setPath(currentPath)
47 self.newProjectPicker.setText(os.path.dirname(currentPath))
48
49 self.lfFileSizeSpinBox.setValue(self.__defaults["minsize"])
50 self.lfFilePatternsEdit.setText(" ".join(self.__defaults["pattern"]))
51
52 if mode == 'normal':
53 self.lfFileSizeSpinBox.setEnabled(False)
54 self.lfFilePatternsEdit.setEnabled(False)
55
56 msh = self.minimumSizeHint()
57 self.resize(max(self.width(), msh.width()), msh.height())
58
59 @pyqtSlot(str)
60 def on_newProjectPicker_textChanged(self, txt):
61 """
62 Private slot to handle editing of the new project directory.
63
64 @param txt new project directory name (string)
65 """
66 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
67 txt and Utilities.toNativeSeparators(txt) != os.path.dirname(
68 self.__currentPath))
69
70 def getData(self):
71 """
72 Public method to retrieve the entered data.
73
74 @return tuple containing the new project directory name (string),
75 minimum file size (integer) and file patterns (list of string)
76 """
77 patterns = self.lfFilePatternsEdit.text().split()
78 if set(patterns) == set(self.__defaults["pattern"]):
79 patterns = []
80
81 return (
82 self.newProjectPicker.text(),
83 self.lfFileSizeSpinBox.value(),
84 patterns,
85 )

eric ide

mercurial