8 from PyQt4.QtGui import QDialog,QListWidget,QVBoxLayout,QHBoxLayout,QToolButton,QPushButton,QSplitter,QFileDialog,QMessageBox
13 from ToolDataAccessor
import standardToolsDir,ConfigToolBase
17 logging.debug(__name__ +
': __init__')
18 QDialog.__init__(self,parent)
24 self.setWindowFlags(Qt.Window)
25 self.setWindowTitle(
"Apply tool...")
29 logging.debug(__name__ +
': fill')
30 self.setLayout(QVBoxLayout())
40 self.layout().addLayout(bottom)
41 changedir=QPushButton(
"&Change tools directory...")
42 bottom.addWidget(changedir)
43 self.connect(changedir, SIGNAL(
'clicked()'), self.
changedir)
44 help=QPushButton(
"&Help")
45 bottom.addWidget(help)
46 self.connect(help, SIGNAL(
'clicked()'), self.
help)
48 cancel = QPushButton(
'&Cancel')
49 bottom.addWidget(cancel)
50 self.connect(cancel, SIGNAL(
'clicked()'), self.reject)
51 self.
ok=QPushButton(
"&Apply")
52 bottom.addWidget(self.
ok)
53 self.ok.setDefault(
True)
54 self.connect(self.
ok, SIGNAL(
'clicked()'), self.
apply)
57 self._toolList.clear()
59 toolsFiles = [os.path.join(self.
_toolsDir,f)
for f
in os.listdir(self.
_toolsDir)
if f.endswith(
".py")
and not f.startswith(
"_")]
61 for toolsFile
in toolsFiles:
62 pythonModule = os.path.splitext(os.path.basename(toolsFile))[0]
63 module=imp.load_source(pythonModule, toolsFile)
64 for name
in dir(module):
65 tool=getattr(module,name)
66 if inspect.isclass(tool)
and issubclass(tool,ConfigToolBase)
and not self._toolDataAccessor.label(tool)
in self._toolsDict.keys()
and not tool==ConfigToolBase:
67 self.
_toolsDict[self._toolDataAccessor.label(tool)]=tool
71 if len(self._toolsDict.keys())==0
and self.
_toolsDir==standardToolsDir:
72 logging.error(__name__ +
": Could not find any PAT tools. These will be available for the ConfigEditor in a future release.")
73 QCoreApplication.instance().errorMessage(
"Could not find any PAT tools. These will be available for the ConfigEditor in a future release.")
75 for item
in self._toolsDict.keys():
76 self._toolList.addItem(item)
77 self._toolList.sortItems()
80 if event.modifiers() == Qt.ControlModifier
and event.key() == Qt.Key_W:
82 QDialog.keyPressEvent(self, event)
90 self._properties.updateContent()
93 self._properties.setDataAccessor(accessor)
101 if not self.ok.hasFocus():
102 self._properties.clearFocus()
105 parameterErrors=self._toolDataAccessor.parameterErrors(self.
_selectedTool)
106 if len(parameterErrors)>0:
107 message=
"\n".
join([error
for error
in parameterErrors])
108 QCoreApplication.instance().errorMessage(message)
113 self._selectedTool.apply(self._toolDataAccessor.configDataAccessor().
process())
114 if not self._toolDataAccessor.configDataAccessor().
process().checkRecording():
116 logging.error(__name__ +
": Could not apply tool "+self._toolDataAccessor.label(self.
_selectedTool)+
" (problem with enable recording flag) Please restart the ConfigEditor.")
117 QCoreApplication.instance().errorMessage(
"Could not apply tool "+self._toolDataAccessor.label(self.
_selectedTool)+
" (problem with enable recording flag) Please restart the ConfigEditor.")
121 QCoreApplication.instance().errorMessage(
"Cannot apply tool "+self._toolDataAccessor.label(self.
_selectedTool)+
" (see log file for details):\n"+str(e))
124 logging.error(__name__ +
": Could not apply tool: No tool selected.")
125 QCoreApplication.instance().errorMessage(
"Cannot apply tool: No tool selected.")
127 self._toolDataAccessor.configDataAccessor().setProcess(self.
_processCopy)
132 filename = QFileDialog.getExistingDirectory(
133 self,
'Select a directory',self.
_toolsDir,QFileDialog.ShowDirsOnly)
134 if not filename.isEmpty():
139 QMessageBox.about(self,
'Info',
"This dialog let's you choose and configure a tool.\n 1. Select a tool on the left\n 2. Set the parameters on the right. If you hold the mouse over a parameter name a tooltip with a description of the parameter will show up.\n 3. Apply the tool. In case the tool has wrong parameters set an error message will be displayed.")
static std::string join(char **cmd)