5 from PyQt4.QtCore import Qt, SIGNAL, QEvent, QPoint, QSize
6 from PyQt4.QtGui import QMainWindow, QTabWidget, QSizePolicy, QIcon
17 def __init__(self, application=None, title="VISPA"):
23 QMainWindow.__init__(self)
26 self._tabWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
27 self._tabWidget.setUsesScrollButtons(
True)
30 self._tabWidget.setTabsClosable(
True)
32 if "vispa" in title.lower():
42 self.setWindowIcon(QIcon(
":/resources/vispabutton.png"))
43 self.setWindowTitle(title)
48 self._startupScreen.raise_()
70 """ Closes all tabs and exits program if succeeded.
72 logging.debug(
'MainWindow: closeEvent()')
73 self._application.closeAllFiles()
74 self._application.shutdownPlugins()
81 def addWindow(self, widget, width=None, height=None):
82 """ Add a new window and call the TabController to update the label of the window.
84 logging.debug(
'MainWindow: addWindow()')
85 widget.setMainWindow(self)
86 widget.setWindowFlags(Qt.Dialog)
89 widget.resize(width,height)
91 widget.resize(self._tabWidget.size())
92 widget.controller().updateLabel()
95 """ Add a new tab to the TabWidget and call the TabController to update the label of the Tab.
99 widget.setMainWindow(self)
100 self._tabWidget.addTab(widget,
'')
101 self._tabWidget.setCurrentWidget(widget)
102 widget.controller().updateLabel()
108 return [self._tabWidget.widget(i)
for i
in range(0, self._tabWidget.count())]
111 return (self._tabWidget.indexOf(widget) >= 0)
114 """ Load the window properties.
116 ini = self._application.ini()
118 if ini.has_option(
"window",
"width"):
119 width = ini.getint(
"window",
"width")
122 if ini.has_option(
"window",
"height"):
123 height = ini.getint(
"window",
"height")
126 self.resize(QSize(width, height))
127 if ini.has_option(
"window",
"maximized"):
128 if ini.getboolean(
"window",
"maximized"):
129 self.setWindowState(Qt.WindowMaximized)
130 if ini.has_option(
"window",
"fullScreen"):
131 if ini.getboolean(
"window",
"fullScreen"):
132 self.setWindowState(Qt.WindowFullScreen)
135 """ Save the window properties.
137 ini = self._application.ini()
138 if not ini.has_section(
"window"):
139 ini.add_section(
"window")
140 if not self.isMaximized()
and not self.isFullScreen():
141 ini.set(
"window",
"width", str(self.width()))
142 ini.set(
"window",
"height", str(self.height()))
143 ini.set(
"window",
"maximized", str(self.isMaximized()))
144 ini.set(
"window",
"fullScreen", str(self.isFullScreen()))
145 self._application.writeIni()
148 """ Emits activated() signal if correct event occures and if correct changeEvent occured before.
150 Also see changeEvent().
151 The Application shall connect to windowActivated().
153 QMainWindow.event(self, event)
156 self.emit(SIGNAL(
"windowActivated()"))
157 elif event.type()==QEvent.WindowActivate:
158 self.emit(SIGNAL(
"windowActivated()"))
162 """ Together with event() this function makes sure tabChanged() is called when the window is activated.
164 if event.type() == QEvent.ActivationChange
and self.isActiveWindow():
168 """ On Escape cancel all running operations.
171 if event.key() == Qt.Key_Escape:
173 QMainWindow.keyPressEvent(self, event)
176 QMainWindow.resizeEvent(self, event)
181 self._startupScreen.setVisible(show)
189 boundingRect = self._startupScreen.boundingRect()
190 deltaWidth = self.width() - boundingRect.width() - 20
191 deltaHeight = self.height() - boundingRect.height() - 80
193 if deltaWidth != 0
or deltaHeight != 0:
194 self._startupScreen.setMaximumSize(
max(1, self._startupScreen.width() + deltaWidth),
max(1, self._startupScreen.height() + deltaHeight))
195 boundingRect = self._startupScreen.boundingRect()
196 self._startupScreen.move(QPoint(0.5 * (self.width() - boundingRect.width()), 0.5 * (self.height() - boundingRect.height()) + 10) + self._startupScreen.pos() - boundingRect.topLeft())
202 """ Creates new analysis designer tab if that plugin was loaded.
206 plugin.newAnalysisDesignerTab()
209 """ Creates new pxl tab if that plugin was loaded.
218 currentRow=self._startupScreen._analysisDesignerRecentFilesList.currentRow()
220 files=self.
application().recentFilesFromPlugin(plugin)
221 if currentRow<=len(files):
224 filetypes = plugin.filetypes()
225 if len(filetypes) > 0:
226 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
231 currentRow=self._startupScreen._pxlEditorRecentFilesList.currentRow()
233 files=self.
application().recentFilesFromPlugin(plugin)
234 if currentRow<=len(files):
237 filetypes = plugin.filetypes()
238 if len(filetypes) > 0:
239 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
auto_ptr< JetDefinition::Plugin > plugin
const T & max(const T &a, const T &b)
def newAnalysisDesignerSlot
def setStartupScreenVisible
def updateStartupScreenGeometry