Esempio n. 1
0
 def getMethod(self, key, module='main'):
     return WinterApp.getMethod(self, key, module)
Esempio n. 2
0
    def __init__(self, app):
        QMainWindow.__init__(self)
        self.setObjectName('MainWindow')
        try:
            for font in os.listdir(CWD + 'fonts'):
                try:
                    QFontDatabase.addApplicationFont(CWD + 'fonts/' + font)
                except Exception as e:
                    print(e)
        except OSError:
            pass

        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

        if os.path.isfile(VAULT + 'themes/%s/style.css' %
                          self.config.options.ui.theme):
            self.setStyleSheet(
                open(
                    VAULT +
                    'themes/%s/style.css' % self.config.options.ui.theme,
                    'r').read())

        if os.path.isfile(CWD + 'themes/%s/style.css' %
                          self.config.options.ui.theme):
            self.setStyleSheet(
                open(
                    CWD + 'themes/%s/style.css' % self.config.options.ui.theme,
                    'r').read())

        theme_variants = ['system']
        if os.path.isdir(CWD + 'themes/'):
            for d in os.listdir(CWD + 'themes/'):
                theme_variants.append(d)
        if os.path.isdir(VAULT + 'themes/'):
            for d in os.listdir(VAULT + 'themes/'):
                theme_variants.append(d)
        self.config.options.ui.theme_variants = list(set(theme_variants))

        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']))

        if hasattr(WinterEditor, 'objects'):
            for we in WinterEditor.objects.all():
                if isinstance(we, WinterEditor):  # temp fix
                    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('Winterstone', 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)
Esempio n. 3
0
    def __init__(self, app):
        QMainWindow.__init__(self)
        self.setObjectName('MainWindow')
        try:
            for font in os.listdir(CWD + 'fonts'):
                try:
                    QFontDatabase.addApplicationFont(CWD + 'fonts/' + font)
                except Exception as e:
                    print(e)
        except OSError:
            pass

        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

        if os.path.isfile(VAULT + 'themes/%s/style.css' % self.config.options.ui.theme):
            self.setStyleSheet(open(VAULT + 'themes/%s/style.css' % self.config.options.ui.theme, 'r').read())

        if os.path.isfile(CWD + 'themes/%s/style.css' % self.config.options.ui.theme):
            self.setStyleSheet(open(CWD + 'themes/%s/style.css' % self.config.options.ui.theme, 'r').read())

        theme_variants = ['system']
        if os.path.isdir(CWD + 'themes/'):
            for d in os.listdir(CWD + 'themes/'):
                theme_variants.append(d)
        if os.path.isdir(VAULT + 'themes/'):
            for d in os.listdir(VAULT + 'themes/'):
                theme_variants.append(d)
        self.config.options.ui.theme_variants = list(set(theme_variants))

        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']))

        if hasattr(WinterEditor, 'objects'):
            for we in WinterEditor.objects.all():
                if isinstance(we, WinterEditor):  # temp fix
                    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('Winterstone', 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)
Esempio n. 4
0
 def getMethod(self, key, module='main'):
     return WinterApp.getMethod(self, key, module)