Пример #1
0
 def __init__(self, amsn_core, parent=None):
     QtGui.QMainWindow.__init__(self, parent)
     self._amsn_core = amsn_core
     self.centralWidget = QtGui.QWidget(self)
     self.stackedLayout = QtGui.QStackedLayout()
     #self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
     self.centralWidget.setLayout(self.stackedLayout)
     self.setCentralWidget(self.centralWidget)
     self.opaqLayer = FadingWidget(QtCore.Qt.white, self)
     self.stackedLayout.addWidget(self.opaqLayer)
     QtCore.QObject.connect(self.opaqLayer,
                            QtCore.SIGNAL("fadeInCompleted()"),
                            self.__activateNewWidget)
     QtCore.QObject.connect(self.opaqLayer,
                            QtCore.SIGNAL("fadeOutCompleted()"),
                            self.__fadeIn)
     self.resize(230, 550)
Пример #2
0
 def __init__(self, amsn_core, parent=None):
     QMainWindow.__init__(self, parent)
     self._amsn_core = amsn_core
     self.centralWidget = QWidget(self)
     self.stackedLayout = QStackedLayout()
     #self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
     self.centralWidget.setLayout(self.stackedLayout)
     self.setCentralWidget(self.centralWidget)
     self.opaqLayer = FadingWidget(Qt.white, self)
     self.stackedLayout.addWidget(self.opaqLayer)
     QObject.connect(self.opaqLayer, SIGNAL("fadeInCompleted()"), self.__activateNewWidget)
     QObject.connect(self.opaqLayer, SIGNAL("fadeOutCompleted()"), self.__fadeIn)
     self.resize(230, 550)
Пример #3
0
class aMSNMainWindow(QMainWindow, base.aMSNMainWindow):
    def __init__(self, amsn_core, parent=None):
        QMainWindow.__init__(self, parent)
        self._amsn_core = amsn_core
        self.centralWidget = QWidget(self)
        self.stackedLayout = QStackedLayout()
        #self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
        self.centralWidget.setLayout(self.stackedLayout)
        self.setCentralWidget(self.centralWidget)
        self.opaqLayer = FadingWidget(Qt.white, self)
        self.stackedLayout.addWidget(self.opaqLayer)
        QObject.connect(self.opaqLayer, SIGNAL("fadeInCompleted()"), self.__activateNewWidget)
        QObject.connect(self.opaqLayer, SIGNAL("fadeOutCompleted()"), self.__fadeIn)
        self.resize(230, 550)

    def closeEvent(self, event):
        self._amsn_core.quit()

    def fadeIn(self, widget):
        widget.setAutoFillBackground(True)
        self.stackedLayout.addWidget(widget)
        self.stackedLayout.setCurrentWidget(self.opaqLayer)
        # Is there another widget in here?
        if self.stackedLayout.count() > 2:
            self.opaqLayer.fadeOut() # Fade out current active widget
        else:
            self.__fadeIn()

    def __fadeIn(self):
        # Delete old widget(s)
        while self.stackedLayout.count() > 2:
            widget = self.stackedLayout.widget(1)
            self.stackedLayout.removeWidget(widget)
            widget.deleteLater()
        self.opaqLayer.fadeIn()

    def __activateNewWidget(self):
        self.stackedLayout.setCurrentIndex(self.stackedLayout.count()-1)

    def show(self):
        self.setVisible(True)
        self._amsn_core.mainWindowShown()

    def hide(self):
        self.setVisible(False)

    def setTitle(self, title):
        self.setWindowTitle(title)

    def set_view(self, view):
        print "set_view request"

    def setMenu(self, menu):
        mb = QMenuBar()

        for item in menu.items:
            if item.type == "cascade":
                menu = mb.addMenu(item.label)
                for subitem in item.items:
                    menu.addAction(subitem.label)

        self.setMenuBar(mb)
Пример #4
0
class aMSNMainWindow(QtGui.QMainWindow, base.aMSNMainWindow):
    def __init__(self, amsn_core, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self._amsn_core = amsn_core
        self.centralWidget = QtGui.QWidget(self)
        self.stackedLayout = QtGui.QStackedLayout()
        #self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
        self.centralWidget.setLayout(self.stackedLayout)
        self.setCentralWidget(self.centralWidget)
        self.opaqLayer = FadingWidget(QtCore.Qt.white, self)
        self.stackedLayout.addWidget(self.opaqLayer)
        QtCore.QObject.connect(self.opaqLayer,
                               QtCore.SIGNAL("fadeInCompleted()"),
                               self.__activateNewWidget)
        QtCore.QObject.connect(self.opaqLayer,
                               QtCore.SIGNAL("fadeOutCompleted()"),
                               self.__fadeIn)
        self.resize(230, 550)

    def closeEvent(self, event):
        self._amsn_core.quit()

    def fadeIn(self, widget):
        widget.setAutoFillBackground(True)
        self.stackedLayout.addWidget(widget)
        self.stackedLayout.setCurrentWidget(self.opaqLayer)
        # Is there another widget in here?
        if self.stackedLayout.count() > 2:
            self.opaqLayer.fadeOut()  # Fade out current active widget
        else:
            self.__fadeIn()

    def __fadeIn(self):
        # Delete old widget(s)
        while self.stackedLayout.count() > 2:
            widget = self.stackedLayout.widget(1)
            self.stackedLayout.removeWidget(widget)
            widget.deleteLater()
        self.opaqLayer.fadeIn()

    def __activateNewWidget(self):
        self.stackedLayout.setCurrentIndex(self.stackedLayout.count() - 1)

    def __on_show(self):
        self._amsn_core.main_window_shown()

    def show(self):
        self.setVisible(True)
        self._amsn_core.idler_add(self.__on_show)

    def hide(self):
        self.setVisible(False)

    def set_title(self, title):
        self.setWindowTitle(title)

    def set_view(self, view):
        print "set_view request"

    def set_menu(self, menu):
        mb = QtGui.QMenuBar()

        common.create_menu_items_from_view(mb, menu.items)

        self.setMenuBar(mb)
Пример #5
0
class aMSNMainWindow(QtGui.QMainWindow, base.aMSNMainWindow):
    def __init__(self, amsn_core, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self._amsn_core = amsn_core
        self.centralWidget = QtGui.QWidget(self)
        self.stackedLayout = QtGui.QStackedLayout()
        # self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
        self.centralWidget.setLayout(self.stackedLayout)
        self.setCentralWidget(self.centralWidget)
        self.opaqLayer = FadingWidget(QtCore.Qt.white, self)
        self.stackedLayout.addWidget(self.opaqLayer)
        QtCore.QObject.connect(self.opaqLayer, QtCore.SIGNAL("fadeInCompleted()"), self.__activateNewWidget)
        QtCore.QObject.connect(self.opaqLayer, QtCore.SIGNAL("fadeOutCompleted()"), self.__fadeIn)
        self.resize(230, 550)

    def closeEvent(self, event):
        self._amsn_core.quit()

    def fadeIn(self, widget):
        widget.setAutoFillBackground(True)
        self.stackedLayout.addWidget(widget)
        self.stackedLayout.setCurrentWidget(self.opaqLayer)
        # Is there another widget in here?
        if self.stackedLayout.count() > 2:
            self.opaqLayer.fadeOut()  # Fade out current active widget
        else:
            self.__fadeIn()

    def __fadeIn(self):
        # Delete old widget(s)
        while self.stackedLayout.count() > 2:
            widget = self.stackedLayout.widget(1)
            self.stackedLayout.removeWidget(widget)
            widget.deleteLater()
        self.opaqLayer.fadeIn()

    def __activateNewWidget(self):
        self.stackedLayout.setCurrentIndex(self.stackedLayout.count() - 1)

    def __on_show(self):
        self._amsn_core.main_window_shown()

    def show(self):
        self.setVisible(True)
        self._amsn_core.idler_add(self.__on_show)

    def hide(self):
        self.setVisible(False)

    def set_title(self, title):
        self.setWindowTitle(title)

    def set_view(self, view):
        print "set_view request"

    def set_menu(self, menu):
        mb = QtGui.QMenuBar()

        common.create_menu_items_from_view(mb, menu.items)

        self.setMenuBar(mb)
Пример #6
0
class aMSNMainWindow(QMainWindow, base.aMSNMainWindow):
    def __init__(self, amsn_core, parent=None):
        QMainWindow.__init__(self, parent)
        self._amsn_core = amsn_core
        self.centralWidget = QWidget(self)
        self.stackedLayout = QStackedLayout()
        #self.stackedLayout.setStackingMode(QStackedLayout.StackAll)
        self.centralWidget.setLayout(self.stackedLayout)
        self.setCentralWidget(self.centralWidget)
        self.opaqLayer = FadingWidget(Qt.white, self)
        self.stackedLayout.addWidget(self.opaqLayer)
        QObject.connect(self.opaqLayer, SIGNAL("fadeInCompleted()"), self.__activateNewWidget)
        QObject.connect(self.opaqLayer, SIGNAL("fadeOutCompleted()"), self.__fadeIn)
        self.resize(230, 550)

    def closeEvent(self, event):
        self._amsn_core.quit()

    def fadeIn(self, widget):
        widget.setAutoFillBackground(True)
        self.stackedLayout.addWidget(widget)
        self.stackedLayout.setCurrentWidget(self.opaqLayer)
        # Is there another widget in here?
        if self.stackedLayout.count() > 2:
            self.opaqLayer.fadeOut() # Fade out current active widget
        else:
            self.__fadeIn()

    def __fadeIn(self):
        # Delete old widget(s)
        while self.stackedLayout.count() > 2:
            widget = self.stackedLayout.widget(1)
            self.stackedLayout.removeWidget(widget)
            widget.deleteLater()
        self.opaqLayer.fadeIn()

    def __activateNewWidget(self):
        self.stackedLayout.setCurrentIndex(self.stackedLayout.count()-1)

    def __on_show(self):
        self._amsn_core.main_window_shown()

    def show(self):
        self.setVisible(True)
        self._amsn_core.idler_add(self.__on_show)

    def hide(self):
        self.setVisible(False)

    def set_title(self, title):
        self.setWindowTitle(title)

    def set_view(self, view):
        print "set_view request"

    def set_menu(self, menu):
        mb = QMenuBar()
        
        self.create_menu_items_from_view(mb, menu.items)
        
        self.setMenuBar(mb)


    def create_menu_items_from_view(self, menu, items):
        # TODO: images & radio groups, for now only basic representation
        for item in items:
            if item.type is MenuItemView.COMMAND:
                it = QAction(item.label, menu)
                QObject.connect(it, SIGNAL("triggered()"), item.command)
                menu.addAction(it)
            elif item.type is MenuItemView.CASCADE_MENU:
                men = QMenu(item.label, menu)
                self.create_menu_items_from_view(men, item.items)
                menu.addMenu(men)
            elif item.type is MenuItemView.SEPARATOR:
                menu.addSeparator()
            elif item.type is MenuItemView.CHECKBUTTON:
                it = QAction(item.label, menu)
                it.setCheckable(True)
                if item.checkbox: #TODO : isn't it checkbox_value instead of checkbox ? By the way the MenuItemView constructor doesn't store the checkbox_value passed to it
                    it.setChecked(True)
                QObject.connect(it, SIGNAL("triggered()"), item.command)
                menu.addAction(it)
            elif item.type is MenuItemView.RADIOBUTTON:
                it = QAction(item.label, menu)
                it.setCheckable(True)
                if item.checkbox: 
                    it.setChecked(True)
                QObject.connect(it, SIGNAL("triggered()"), item.command)
            elif item.type is MenuItemView.RADIOBUTTONGROUP:
                group = QActionGroup(menu)
                self.create_menu_items_from_view(group, item.items)
                menu.addActions(group)