eric7/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.py

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

eric ide

mercurial