def __init__(self, app): QMainWindow.__init__(self) try: for font in os.listdir(CWD + 'fonts'): try: QFontDatabase.addApplicationFont(CWD + 'fonts/' + font) except Exception, e: print e except OSError: pass if os.path.isfile(CWD + 'config/style.qss'): self.setStyleSheet(file(CWD + 'config/style.qss', 'r').read()) self.centralwidget = QWidget(self) self.horizontalLayout_2 = QHBoxLayout(self.centralwidget) self.setCentralWidget(self.centralwidget) self.statusBar = QStatusBar(self) self.setStatusBar(self.statusBar) self.toolBar = QToolBar(self) self.toolBar.setObjectName('toolBar') self._afterMWInit() WinterApp.__init__(self) self.api.toolBar = self.toolBar self.api.statusBar = self.statusBar self.api.dialog = self.dialog self.api.notify = self.notify self.sideBar = WinterSideBar(self) self.statusBar.addPermanentWidget(QWidget().setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding)) self._afterAppInit() if self.config.options.debug: self.debugger = WinterQtDebug(self) self.api.debugger = self.debugger self.createAction('warning', self.tr('Debugger'), 'toggleDebug', keyseq=QKeySequence( self.debugger.config.options.debug_shortcut), toolbar=True) self.flag = WinterFlag() self.flag.setIcon( self.api.icons['green'], self.tr('Toggle debug panel: %s' % self.debugger.config.options.debug_shortcut)) self.connect(self.flag, SIGNAL('clicked()'), self.toggleDebug) self.statusBar.addPermanentWidget(self.flag) self.api.setFlag = self.flag.setIcon screen = QDesktopWidget().screenGeometry() QMainWindow.setGeometry(self, 0, 0, screen.width(), screen.height()) self.setWindowTitle(self.config.info['title']) self.setWindowIcon(QIcon(self.api.icons['app'])) for we in WinterEditor.objects.all(): we._afterAppInit() # self.statusBar.showMessage('Done. Switch modes: F4') if self.config.options.plugins: self.pm.activateAll() self.api.info(self.tr('Plugins initialised')) self.sm = SettingsManager(self) self.createAction('configure', self.tr('Settings'), self.sm.show, keyseq=QKeySequence('Ctrl+P'), toolbar=True) self.smflag = WinterFlag() self.smflag.setIcon(self.api.icons['configure'], self.tr('Options: Ctrl+P')) self.connect(self.smflag, SIGNAL('clicked()'), self.sm.show) self.statusBar.addPermanentWidget(self.smflag) self.api.info('Application initialised') self.createAction('about', self.tr('About'), 'about', keyseq=QKeySequence.HelpContents, toolbar=True) self.addToolBar(Qt.TopToolBarArea, self.toolBar) if not self.config.options.ui.tb_show: self.toolBar.hide() self.qs = QSettings('winterside', self.config.info.title) # self.restoreGeometry(self.qs.value("geometry").toByteArray()) #todo: fix # self.restoreState(self.qs.value("windowState").toByteArray()) self.signalMapper = QSignalMapper(self) self.toolBar.setIconSize( QSize(self.config.options.ui.tbicon_size, self.config.options.ui.tbicon_size)) self.toolBar.setMovable(self.config.options.ui.tb_movable) self.resize(self.config.options.ui.width, self.config.options.ui.height) self.api.sm = self.sm self.config.add(self) scriptfiles = ['init.ws', 'hotkeys.ws'] for fname in scriptfiles: path = self.api.CWD + 'scripts/' + fname if os.path.isfile(path): self.script.executeFile(path)