Exemplo n.º 1
0
    def show(self):

        # Can we display it on the right?
        if (QDesktopWidget().width() - mw.pos().x() - mw.width() - self.width() - 50) > 0:
            self.move(mw.pos().x() + mw.width() + 50, mw.pos().y() - 100)

        # Can we display it on the left?
        elif (QDesktopWidget().width() - mw.pos().x() + self.width() + 50) < QDesktopWidget().width():
            self.move(mw.pos().x() - self.width() - 50, mw.pos().y() - 100)

        # Show window
        super(AnkiEmperor, self).show()
Exemplo n.º 2
0
    def show(self):

        # Can we display it on the right?
        if (QDesktopWidget().width() - mw.pos().x() - mw.width() -
                self.width() - 50) > 0:
            self.move(mw.pos().x() + mw.width() + 50, mw.pos().y() - 100)

        # Can we display it on the left?
        elif (QDesktopWidget().width() - mw.pos().x() + self.width() +
              50) < QDesktopWidget().width():
            self.move(mw.pos().x() - self.width() - 50, mw.pos().y() - 100)

        # Show window
        super(AnkiEmperor, self).show()
Exemplo n.º 3
0
    def add_dock(self, title, w):
        class DockableWithClose(QDockWidget):
            closed = pyqtSignal()

            def closeEvent(self, evt):
                self.closed.emit()
                QDockWidget.closeEvent(self, evt)

            def resizeEvent(self, evt):
                assert isinstance(evt, QResizeEvent)
                Config.doc_size = (evt.size().width(), evt.size().height())
                super(DockableWithClose, self).resizeEvent(evt)
                evt.accept()

            def sizeHint(self):
                return QSize(Config.doc_size[0], Config.doc_size[1])

        dock = DockableWithClose(title, mw)
        dock.setObjectName(title)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        dock.setFeatures(QDockWidget.DockWidgetClosable)
        dock.setWidget(w)
        dock.setContentsMargins(10, 10, 10, 10)
        if mw.width() < 600:
            mw.resize(QSize(600, mw.height()))
        mw.addDockWidget(Qt.RightDockWidgetArea, dock)
        return dock
Exemplo n.º 4
0
 def _addDockable(self, title, w):
     dock = QDockWidget(title, mw)
     dock.setObjectName(title)
     dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
     dock.setFeatures(QDockWidget.DockWidgetClosable)
     dock.setWidget(w)
     if mw.width() < 600:
         mw.resize(QSize(600, mw.height()))
     mw.addDockWidget(Qt.RightDockWidgetArea, dock)
     return dock
Exemplo n.º 5
0
 def _addDockable(self, title, w):
     dock = QDockWidget(title, mw)
     dock.setObjectName(title)
     dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
     dock.setFeatures(QDockWidget.DockWidgetClosable)
     dock.setWidget(w)
     if mw.width() < 600:
         mw.resize(QSize(600, mw.height()))
     mw.addDockWidget(Qt.RightDockWidgetArea, dock)
     return dock
Exemplo n.º 6
0
 def _addDockable(self, title, w):
     class DockableWithClose(QDockWidget):
         def closeEvent(self, evt):
             self.emit(SIGNAL("closed"))
             QDockWidget.closeEvent(self, evt)
     dock = DockableWithClose(title, mw)
     dock.setObjectName(title)
     dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
     dock.setFeatures(QDockWidget.DockWidgetClosable)
     dock.setWidget(w)
     if mw.width() < 600:
         mw.resize(QSize(600, mw.height()))
     mw.addDockWidget(Qt.RightDockWidgetArea, dock)
     return dock
Exemplo n.º 7
0
    def __init__(self):
        menu=None
        for a in mw.form.menubar.actions():
            if '&Debug' == a.text():
                menu=a.menu()
                menu.addSeparator()
                break
        if not menu:
            menu=mw.form.menubar.addMenu('&Debug')

        mw.setCorner(Qt.BottomRightCorner, Qt.RightDockWidgetArea)
        mw.setCorner(Qt.BottomLeftCorner, Qt.LeftDockWidgetArea)
        if mw.width() < 600: mw.resize(QSize(600, mw.height()))

        act=QAction("WM: Reset Workspace", mw)
        act.triggered.connect(self.reset)
        menu.addAction(act)

        self.wmDMChkBox=QAction("WM: Dual Monitors", mw)
        self.wmDMChkBox.setCheckable(True)
        self.wmDMChkBox.triggered.connect(self.dualMonSetup)
        menu.addAction(self.wmDMChkBox)

        act=QAction("WM: Freeze CCard View", mw)
        act.setCheckable(True)
        act.triggered.connect(self.freezeUpdates)
        menu.addAction(act)

        act=QAction("WM: Force Refresh", mw)
        act.triggered.connect(lambda:self.refresh(night_mode_state))
        menu.addAction(act)

        self.wmChkBox=QAction("Warrior Mode", mw)
        self.wmChkBox.setCheckable(True)
        self.wmChkBox.setShortcut(QKeySequence(HOTKEY))
        self.wmChkBox.triggered.connect(self.toggle)
        menu.addAction(self.wmChkBox)

        addHook('profileLoaded', self.onProfileLoaded)
        addHook('unloadProfile', self.onUnloadProfile)
        addHook("night_mode_state_changed", self.refresh)