1 from __future__
import absolute_import
2 from builtins
import range
7 from PyQt4.QtCore import Qt, SIGNAL, QEvent, QPoint, QSize
8 from PyQt4.QtGui import QMainWindow, QTabWidget, QSizePolicy, QIcon
11 from .
import Resources
19 def __init__(self, application=None, title="VISPA"):
25 QMainWindow.__init__(self)
28 self._tabWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
29 self._tabWidget.setUsesScrollButtons(
True)
32 self._tabWidget.setTabsClosable(
True)
34 if "vispa" in title.lower():
44 self.setWindowIcon(QIcon(
":/resources/vispabutton.png"))
45 self.setWindowTitle(title)
50 self._startupScreen.raise_()
72 """ Closes all tabs and exits program if succeeded. 74 logging.debug(
'MainWindow: closeEvent()')
75 self._application.closeAllFiles()
76 self._application.shutdownPlugins()
83 def addWindow(self, widget, width=None, height=None):
84 """ Add a new window and call the TabController to update the label of the window. 86 logging.debug(
'MainWindow: addWindow()')
87 widget.setMainWindow(self)
88 widget.setWindowFlags(Qt.Dialog)
91 widget.resize(width,height)
93 widget.resize(self._tabWidget.size())
94 widget.controller().updateLabel()
97 """ Add a new tab to the TabWidget and call the TabController to update the label of the Tab. 101 widget.setMainWindow(self)
102 self._tabWidget.addTab(widget,
'')
103 self._tabWidget.setCurrentWidget(widget)
104 widget.controller().updateLabel()
110 return [self._tabWidget.widget(i)
for i
in range(0, self._tabWidget.count())]
113 return (self._tabWidget.indexOf(widget) >= 0)
116 """ Load the window properties. 118 ini = self._application.ini()
120 if ini.has_option(
"window",
"width"):
121 width = ini.getint(
"window",
"width")
123 width = self.WINDOW_WIDTH
124 if ini.has_option(
"window",
"height"):
125 height = ini.getint(
"window",
"height")
127 height = self.WINDOW_HEIGHT
128 self.resize(QSize(width, height))
129 if ini.has_option(
"window",
"maximized"):
130 if ini.getboolean(
"window",
"maximized"):
131 self.setWindowState(Qt.WindowMaximized)
132 if ini.has_option(
"window",
"fullScreen"):
133 if ini.getboolean(
"window",
"fullScreen"):
134 self.setWindowState(Qt.WindowFullScreen)
137 """ Save the window properties. 139 ini = self._application.ini()
140 if not ini.has_section(
"window"):
141 ini.add_section(
"window")
142 if not self.isMaximized()
and not self.isFullScreen():
143 ini.set(
"window",
"width",
str(self.width()))
144 ini.set(
"window",
"height",
str(self.height()))
145 ini.set(
"window",
"maximized",
str(self.isMaximized()))
146 ini.set(
"window",
"fullScreen",
str(self.isFullScreen()))
147 self._application.writeIni()
150 """ Emits activated() signal if correct event occures and if correct changeEvent occured before. 152 Also see changeEvent(). 153 The Application shall connect to windowActivated(). 155 QMainWindow.event(self, event)
158 self.emit(SIGNAL(
"windowActivated()"))
159 elif event.type()==QEvent.WindowActivate:
160 self.emit(SIGNAL(
"windowActivated()"))
164 """ Together with event() this function makes sure tabChanged() is called when the window is activated. 166 if event.type() == QEvent.ActivationChange
and self.isActiveWindow():
170 """ On Escape cancel all running operations. 173 if event.key() == Qt.Key_Escape:
175 QMainWindow.keyPressEvent(self, event)
178 QMainWindow.resizeEvent(self, event)
183 self._startupScreen.setVisible(show)
191 boundingRect = self._startupScreen.boundingRect()
192 deltaWidth = self.width() - boundingRect.width() - 20
193 deltaHeight = self.height() - boundingRect.height() - 80
195 if deltaWidth != 0
or deltaHeight != 0:
196 self._startupScreen.setMaximumSize(
max(1, self._startupScreen.width() + deltaWidth),
max(1, self._startupScreen.height() + deltaHeight))
197 boundingRect = self._startupScreen.boundingRect()
198 self._startupScreen.move(QPoint(0.5 * (self.width() - boundingRect.width()), 0.5 * (self.height() - boundingRect.height()) + 10) + self._startupScreen.pos() - boundingRect.topLeft())
204 """ Creates new analysis designer tab if that plugin was loaded. 208 plugin.newAnalysisDesignerTab()
211 """ Creates new pxl tab if that plugin was loaded. 220 currentRow=self._startupScreen._analysisDesignerRecentFilesList.currentRow()
222 files=self.
application().recentFilesFromPlugin(plugin)
223 if currentRow<=len(files):
226 filetypes = plugin.filetypes()
227 if len(filetypes) > 0:
228 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
233 currentRow=self._startupScreen._pxlEditorRecentFilesList.currentRow()
235 files=self.
application().recentFilesFromPlugin(plugin)
236 if currentRow<=len(files):
239 filetypes = plugin.filetypes()
240 if len(filetypes) > 0:
241 self.
application().openFileDialog(filetypes[0].fileDialogFilter())
def closeEvent(self, event)
def isTabWidget(self, widget)
def openAnalysisFileSlot(self, checked=False)
def newPxlSlot(self, checked=False)
def changeEvent(self, event)
def __init__(self, application=None, title="VISPA")
unique_ptr< JetDefinition::Plugin > plugin
def setStartupScreenVisible(self, show)
def keyPressEvent(self, event)
def openPxlFileSlot(self, checked=False)
def resizeEvent(self, event)
def createStartupScreen(self)
def newAnalysisDesignerSlot(self, checked=False)
def addWindow(self, widget, width=None, height=None)
def updateStartupScreenGeometry(self)