1 from __future__
import absolute_import
6 from PyQt4.QtCore import Qt, SIGNAL, QEvent, QPoint, QSize
7 from PyQt4.QtGui import QMainWindow, QTabWidget, QSizePolicy, QIcon
10 from .
import Resources
18 def __init__(self, application=None, title="VISPA"):
24 QMainWindow.__init__(self)
27 self._tabWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
28 self._tabWidget.setUsesScrollButtons(
True)
31 self._tabWidget.setTabsClosable(
True)
33 if "vispa" in title.lower():
43 self.setWindowIcon(QIcon(
":/resources/vispabutton.png"))
44 self.setWindowTitle(title)
49 self._startupScreen.raise_()
71 """ Closes all tabs and exits program if succeeded.
73 logging.debug(
'MainWindow: closeEvent()')
74 self._application.closeAllFiles()
75 self._application.shutdownPlugins()
82 def addWindow(self, widget, width=None, height=None):
83 """ Add a new window and call the TabController to update the label of the window.
85 logging.debug(
'MainWindow: addWindow()')
86 widget.setMainWindow(self)
87 widget.setWindowFlags(Qt.Dialog)
90 widget.resize(width,height)
92 widget.resize(self._tabWidget.size())
93 widget.controller().updateLabel()
96 """ Add a new tab to the TabWidget and call the TabController to update the label of the Tab.
100 widget.setMainWindow(self)
101 self._tabWidget.addTab(widget,
'')
102 self._tabWidget.setCurrentWidget(widget)
103 widget.controller().updateLabel()
109 return [self._tabWidget.widget(i)
for i
in range(0, self._tabWidget.count())]
112 return (self._tabWidget.indexOf(widget) >= 0)
115 """ Load the window properties.
117 ini = self._application.ini()
119 if ini.has_option(
"window",
"width"):
120 width = ini.getint(
"window",
"width")
123 if ini.has_option(
"window",
"height"):
124 height = ini.getint(
"window",
"height")
127 self.resize(QSize(width, height))
128 if ini.has_option(
"window",
"maximized"):
129 if ini.getboolean(
"window",
"maximized"):
130 self.setWindowState(Qt.WindowMaximized)
131 if ini.has_option(
"window",
"fullScreen"):
132 if ini.getboolean(
"window",
"fullScreen"):
133 self.setWindowState(Qt.WindowFullScreen)
136 """ Save the window properties.
138 ini = self._application.ini()
139 if not ini.has_section(
"window"):
140 ini.add_section(
"window")
141 if not self.isMaximized()
and not self.isFullScreen():
142 ini.set(
"window",
"width", str(self.width()))
143 ini.set(
"window",
"height", str(self.height()))
144 ini.set(
"window",
"maximized", str(self.isMaximized()))
145 ini.set(
"window",
"fullScreen", str(self.isFullScreen()))
146 self._application.writeIni()
149 """ Emits activated() signal if correct event occures and if correct changeEvent occured before.
151 Also see changeEvent().
152 The Application shall connect to windowActivated().
154 QMainWindow.event(self, event)
157 self.emit(SIGNAL(
"windowActivated()"))
158 elif event.type()==QEvent.WindowActivate:
159 self.emit(SIGNAL(
"windowActivated()"))
163 """ Together with event() this function makes sure tabChanged() is called when the window is activated.
165 if event.type() == QEvent.ActivationChange
and self.isActiveWindow():
169 """ On Escape cancel all running operations.
172 if event.key() == Qt.Key_Escape:
174 QMainWindow.keyPressEvent(self, event)
177 QMainWindow.resizeEvent(self, event)
182 self._startupScreen.setVisible(show)
190 boundingRect = self._startupScreen.boundingRect()
191 deltaWidth = self.width() - boundingRect.width() - 20
192 deltaHeight = self.height() - boundingRect.height() - 80
194 if deltaWidth != 0
or deltaHeight != 0:
195 self._startupScreen.setMaximumSize(
max(1, self._startupScreen.width() + deltaWidth),
max(1, self._startupScreen.height() + deltaHeight))
196 boundingRect = self._startupScreen.boundingRect()
197 self._startupScreen.move(QPoint(0.5 * (self.width() - boundingRect.width()), 0.5 * (self.height() - boundingRect.height()) + 10) + self._startupScreen.pos() - boundingRect.topLeft())
203 """ Creates new analysis designer tab if that plugin was loaded.
207 plugin.newAnalysisDesignerTab()
210 """ Creates new pxl tab if that plugin was loaded.
219 currentRow=self._startupScreen._analysisDesignerRecentFilesList.currentRow()
221 files=self.
application().recentFilesFromPlugin(plugin)
222 if currentRow<=len(files):
225 filetypes = plugin.filetypes()
226 if len(filetypes) > 0:
227 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
232 currentRow=self._startupScreen._pxlEditorRecentFilesList.currentRow()
234 files=self.
application().recentFilesFromPlugin(plugin)
235 if currentRow<=len(files):
238 filetypes = plugin.filetypes()
239 if len(filetypes) > 0:
240 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
auto_ptr< JetDefinition::Plugin > plugin
def newAnalysisDesignerSlot
def setStartupScreenVisible
def updateStartupScreenGeometry