Beispiel #1
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self,parent)
        self.parent = parent

        self.settings =  QSettings()

        try:
            self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
            self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
            isMAEMO = True
        except:
            isMAEMO = False
        self.setWindowTitle("KhtSync About")
        
        #Resize window if not maemo
        if not isMAEMO:
            self.resize(800, 600)        

        aboutScrollArea =  QScrollArea(self)
        aboutScrollArea.setWidgetResizable(True)
        awidget =  QWidget(aboutScrollArea)
        awidget.setMinimumSize(480,600)
        awidget.setSizePolicy(  QSizePolicy.Expanding,  QSizePolicy.Expanding)
        aboutScrollArea.setSizePolicy(  QSizePolicy.Expanding,  QSizePolicy.Expanding)
        #Kinetic scroller is available on Maemo and should be on meego
        try:
            scroller = aboutScrollArea.property("kineticScroller") #.toPyObject()
            scroller.setEnabled(True)
        except:
            pass

        aboutLayout =  QVBoxLayout(awidget)

        aboutIcon =  QLabel()
        aboutIcon.setPixmap( QIcon.fromTheme('khtsync').pixmap(128,128))
        aboutIcon.setAlignment( Qt.AlignCenter or Qt.AlignHCenter )
        aboutIcon.resize(128,128)
        aboutLayout.addWidget(aboutIcon)

        aboutLabel =  QLabel('''<center><b>KhtSync</b> %s
                                   <br><br>A tool to sync folder over SSH
                                   <br>Licenced under GPLv3
                                   <br>By Beno&icirc;t HERVIER (Khertan) 
                                   <br><br><br><b>Bugtracker : </b>http://khertan.net/khtsync:bugs
                                   <br><b>Sources : </b>http://gitorious.org/khtsync                                   
                                   <br><b>Www : </b>http://khertan.net/khtsync                                   
                                   </center>''' % __version__)

        aboutLayout.addWidget(aboutLabel)
        self.bugtracker_button =  QPushButton('BugTracker')
        self.bugtracker_button.clicked.connect(self.open_bugtracker)
        self.website_button =  QPushButton('Website')
        self.website_button.clicked.connect(self.open_website)
        awidget2 =  QWidget()
        buttonLayout =  QHBoxLayout(awidget2)        
        buttonLayout.addWidget(self.bugtracker_button)
        buttonLayout.addWidget(self.website_button)
        aboutLayout.addWidget(awidget2)
        
        awidget.setLayout(aboutLayout)
        aboutScrollArea.setWidget(awidget)
        self.setCentralWidget(aboutScrollArea)
        self.show()        
Beispiel #2
0
class WelcomeWindow( QMainWindow):
    """
        The welcome window
    """
    
    def __init__(self, parent=None):
        QMainWindow.__init__(self,None)
        self.parent = parent
                 
        #This is for the case we aren't on Maemo
        try:
            self.setAttribute( Qt.WA_Maemo5AutoOrientation, True)
            self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
            self.isMaemo = True
        except AttributeError:
            self.isMaemo = False
            self.resize(800,600)
        self.setupMain(self.isMaemo)
        self.setupMenu()        

        self.setCentralWidget(self.scrollArea)

        self.setWindowTitle("KhtEditor")

    def do_about(self):
        """
            Display about dialog from parent
        """
        
        self.parent.about(self)

    def enterEvent(self,event):
        """
            Redefine the enter event to refresh recent file list
        """        
        self.refreshMain()
        
    def refreshMain(self):
        """
            Refresh the recent files list
        """        
        recentfiles = RecentFiles().get()
        print self._layout.count()
        for index in range(0,self._layout.count()-4):
            recentFileButton = self._layout.itemAt(index+4).widget()
            try:                
                if self.isMaemo:
                    recentFileButton.setText(os.path.basename(unicode(recentfiles[index]).encode('utf-8')).decode('utf-8'))
                    recentFileButton.setValueText(os.path.abspath(unicode(recentfiles[index]).encode('utf-8')).decode('utf-8'))         
                else:
                    recentFileButton.setText(os.path.abspath(unicode(recentfiles[index]).encode('utf-8')).decode('utf-8'))

            except StandardError:
                recentFileButton.setDisabled(True)
        

    def setupMain(self, isMaemo=False):
        """
            GUI Initialization
        """
        
        self.scrollArea =  QScrollArea(self)
        self.scrollArea.setWidgetResizable(True)
        awidget =  QWidget(self.scrollArea)
        if isMaemo:
            awidget.setMinimumSize(480,1000)
        awidget.setSizePolicy(  QSizePolicy.Expanding,  QSizePolicy.Expanding)
        self.scrollArea.setSizePolicy(  QSizePolicy.Expanding,  QSizePolicy.Expanding)
   
        #Kinetic scroller is available on Maemo and should be on meego
        try:
            scroller = self.scrollArea.property("kineticScroller") #.toPyObject()
            scroller.setEnabled(True)
        except:
            pass
            
        self._layout =  QVBoxLayout(awidget)
        
        self.icon =  QLabel()
        self.icon.setPixmap( QPixmap(os.path.join(os.path.dirname(__file__) ,'icons','khteditor.png')).scaledToHeight(64))
        self.icon.setAlignment( Qt.AlignCenter or Qt.AlignHCenter )
        self.icon.resize(70,70)
        
        self.label =  QLabel("KhtEditor Version "+self.parent.version)
        self.label.setAlignment( Qt.AlignCenter or Qt.AlignHCenter )

        self._layout.addWidget(self.icon)
        self._layout.addWidget(self.label)

        self._layout_button =  QHBoxLayout()        
        self.new_button =  QPushButton("New")
        self.new_button.clicked.connect(self.parent.newFile)
        self.open_button =  QPushButton("Open")
        self.open_button.clicked.connect(self.parent.openFile)
        self._layout_button.addWidget(self.new_button)
        self._layout_button.addWidget(self.open_button)
        self._layout.addLayout(self._layout_button)

        label =  QLabel("Recent Files")
        label.setAlignment( Qt.AlignCenter or Qt.AlignHCenter )

        self._layout.addWidget(label)

        awidget.setLayout(self._layout)
        self.scrollArea.setWidget(awidget)
        for index in range(10):
            if isMaemo:
                recentFileButton = QtMaemo5.QMaemo5ValueButton()
            else:
                recentFileButton =  QPushButton()
            recentFileButton.clicked.connect(Curry(self.openRecentFile,recentFileButton))
            self._layout.addWidget(recentFileButton)

    def openRecentFile(self,button, Useless=None):
        """
            Call back which open a recent file
        """
        
        if self.isMaemo:
            self.setAttribute( Qt.WA_Maemo5ShowProgressIndicator,True)
        self.parent.openRecentFile(button)
        if self.isMaemo:
            self.setAttribute( Qt.WA_Maemo5ShowProgressIndicator,False)

    def setupMenu(self):
        """
            Initialization of the maemo menu
        """
        
        fileMenu =  QMenu(self.tr("&Menu"), self)
        self.menuBar().addMenu(fileMenu)

        fileMenu.addAction(self.tr("&New..."), self.parent.newFile,
                 QKeySequence(self.tr("Ctrl+N", "New")))
        fileMenu.addAction(self.tr("&Open..."), self.parent.openFile,
                 QKeySequence(self.tr("Ctrl+O", "Open")))
        fileMenu.addAction(self.tr("&Preferences..."), self.showPrefs)
        fileMenu.addAction(self.tr("&About"), self.do_about)
        
    def showPrefs(self):
        """
            Call the parent class to show window
        """
        self.parent.showPrefs(self)
Beispiel #3
0
class WelcomeWindow(QMainWindow):
    """
        The welcome window
    """
    def __init__(self, parent=None):
        QMainWindow.__init__(self, None)
        self.parent = parent

        #This is for the case we aren't on Maemo
        try:
            self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
            self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
            self.isMaemo = True
        except AttributeError:
            self.isMaemo = False
            self.resize(800, 600)
        self.setupMain(self.isMaemo)
        self.setupMenu()

        self.setCentralWidget(self.scrollArea)

        self.setWindowTitle("KhtEditor")

    def do_about(self):
        """
            Display about dialog from parent
        """

        self.parent.about(self)

    def enterEvent(self, event):
        """
            Redefine the enter event to refresh recent file list
        """
        self.refreshMain()

    def refreshMain(self):
        """
            Refresh the recent files list
        """
        recentfiles = RecentFiles().get()
        print self._layout.count()
        for index in range(0, self._layout.count() - 4):
            recentFileButton = self._layout.itemAt(index + 4).widget()
            try:
                if self.isMaemo:
                    recentFileButton.setText(
                        os.path.basename(
                            unicode(recentfiles[index]).encode(
                                'utf-8')).decode('utf-8'))
                    recentFileButton.setValueText(
                        os.path.abspath(
                            unicode(recentfiles[index]).encode(
                                'utf-8')).decode('utf-8'))
                else:
                    recentFileButton.setText(
                        os.path.abspath(
                            unicode(recentfiles[index]).encode(
                                'utf-8')).decode('utf-8'))

            except StandardError:
                recentFileButton.setDisabled(True)

    def setupMain(self, isMaemo=False):
        """
            GUI Initialization
        """

        self.scrollArea = QScrollArea(self)
        self.scrollArea.setWidgetResizable(True)
        awidget = QWidget(self.scrollArea)
        if isMaemo:
            awidget.setMinimumSize(480, 1000)
        awidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.scrollArea.setSizePolicy(QSizePolicy.Expanding,
                                      QSizePolicy.Expanding)

        #Kinetic scroller is available on Maemo and should be on meego
        try:
            scroller = self.scrollArea.property(
                "kineticScroller")  #.toPyObject()
            scroller.setEnabled(True)
        except:
            pass

        self._layout = QVBoxLayout(awidget)

        self.icon = QLabel()
        self.icon.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(__file__), 'icons',
                             'khteditor.png')).scaledToHeight(64))
        self.icon.setAlignment(Qt.AlignCenter or Qt.AlignHCenter)
        self.icon.resize(70, 70)

        self.label = QLabel("KhtEditor Version " + self.parent.version)
        self.label.setAlignment(Qt.AlignCenter or Qt.AlignHCenter)

        self._layout.addWidget(self.icon)
        self._layout.addWidget(self.label)

        self._layout_button = QHBoxLayout()
        self.new_button = QPushButton("New")
        self.new_button.clicked.connect(self.parent.newFile)
        self.open_button = QPushButton("Open")
        self.open_button.clicked.connect(self.parent.openFile)
        self._layout_button.addWidget(self.new_button)
        self._layout_button.addWidget(self.open_button)
        self._layout.addLayout(self._layout_button)

        label = QLabel("Recent Files")
        label.setAlignment(Qt.AlignCenter or Qt.AlignHCenter)

        self._layout.addWidget(label)

        awidget.setLayout(self._layout)
        self.scrollArea.setWidget(awidget)
        for index in range(10):
            if isMaemo:
                recentFileButton = QtMaemo5.QMaemo5ValueButton()
            else:
                recentFileButton = QPushButton()
            recentFileButton.clicked.connect(
                Curry(self.openRecentFile, recentFileButton))
            self._layout.addWidget(recentFileButton)

    def openRecentFile(self, button, Useless=None):
        """
            Call back which open a recent file
        """

        if self.isMaemo:
            self.setAttribute(Qt.WA_Maemo5ShowProgressIndicator, True)
        self.parent.openRecentFile(button)
        if self.isMaemo:
            self.setAttribute(Qt.WA_Maemo5ShowProgressIndicator, False)

    def setupMenu(self):
        """
            Initialization of the maemo menu
        """

        fileMenu = QMenu(self.tr("&Menu"), self)
        self.menuBar().addMenu(fileMenu)

        fileMenu.addAction(self.tr("&New..."), self.parent.newFile,
                           QKeySequence(self.tr("Ctrl+N", "New")))
        fileMenu.addAction(self.tr("&Open..."), self.parent.openFile,
                           QKeySequence(self.tr("Ctrl+O", "Open")))
        fileMenu.addAction(self.tr("&Preferences..."), self.showPrefs)
        fileMenu.addAction(self.tr("&About"), self.do_about)

    def showPrefs(self):
        """
            Call the parent class to show window
        """
        self.parent.showPrefs(self)
Beispiel #4
0
class KhtSettings(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.parent = parent

        try:
            self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
            self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
            isMaemo = True
        except:
            isMaemo = False
        self.setWindowTitle("KhtEditor Prefs")

        #Resize window if not maemo
        if not isMaemo:
            self.resize(800, 600)

        self.settings = QSettings()

        self.setupGUI()
        self.loadPrefs()

    def loadPrefs(self):
        for checkBox in self.plugins_widgets:
            if self.settings.value(checkBox.text().split(' ')[0]) != None:
                checkBox.setCheckState(
                    int(self.settings.value(checkBox.text().split(' ')[0])))
        if self.settings.value('FontName'):
            self.fontName.setCurrentFont(self.settings.value('FontName'))
        if self.settings.value("FontSize"):
            self.fontSize.setValue(int(self.settings.value("FontSize")))
        if self.settings.value('WrapLine'):
            self.wrapLine.setCheckState(int(self.settings.value('WrapLine')))
        if self.settings.value('qt18720'):
            self.qt18720.setCheckState(int(self.settings.value('qt18720')))

    def savePrefs(self):
        for checkBox in self.plugins_widgets:
            self.settings.setValue(checkBox.text().split(' ')[0],
                                   checkBox.checkState())
        self.settings.setValue('FontName', self.fontName.currentFont())
        self.settings.setValue('FontSize', self.fontSize.value())
        self.settings.setValue('WrapLine', self.wrapLine.checkState())
        self.settings.setValue('qt18720', self.qt18720.checkState())

    def closeEvent(self, widget, *args):
        self.savePrefs()

    def setupGUI(self):
        self.scrollArea = QScrollArea(self)
        self.scrollArea.setWidgetResizable(True)

        self.aWidget = QWidget(self.scrollArea)
        self._main_layout = QGridLayout(self.aWidget)
        self.aWidget.setMinimumSize(480, 800)
        self.aWidget.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        self.scrollArea.setSizePolicy(QSizePolicy.Expanding,
                                      QSizePolicy.Expanding)
        self.scrollArea.setWidget(self.aWidget)
        try:
            scroller = self.scrollArea.property(
                "kineticScroller")  #.toPyObject()
            scroller.setEnabled(True)
        except:
            pass
        gridIndex = 0

        self._main_layout.addWidget(QLabel('Font :'), gridIndex, 0)
        gridIndex += 1

        self.fontName = QFontComboBox()
        self._main_layout.addWidget(self.fontName, gridIndex, 0)
        gridIndex += 1
        self.fontSize = QSpinBox()
        self._main_layout.addWidget(self.fontSize, gridIndex, 0)
        gridIndex += 1

        self._main_layout.addWidget(QLabel('Plugins :'), gridIndex, 0)
        gridIndex += 1

        init_plugin_system()

        self.plugins_widgets = []
        for plugin in find_plugins():
            aCheckBox = QCheckBox(plugin.__name__ + ' ' + plugin.__version__)
            self.plugins_widgets.append(aCheckBox)
            self._main_layout.addWidget(aCheckBox, gridIndex, 0)
            gridIndex += 1

        self._main_layout.addWidget(QLabel('Others preferences :'), gridIndex,
                                    0)
        gridIndex += 1
        self.wrapLine = QCheckBox('Wrap Lines')
        self._main_layout.addWidget(self.wrapLine, gridIndex, 0)
        gridIndex += 1
        self.qt18720 = QCheckBox('Work Arround QTBUG-18720')
        self._main_layout.addWidget(self.qt18720, gridIndex, 0)
        gridIndex += 1

        self.aWidget.setLayout(self._main_layout)
        self.setCentralWidget(self.scrollArea)
Beispiel #5
0
class KhtSettings(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.parent = parent

        try:
            self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
            self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
            isMaemo = True
        except:
            isMaemo = False
        self.setWindowTitle("KhtEditor Prefs")

        # Resize window if not maemo
        if not isMaemo:
            self.resize(800, 600)

        self.settings = QSettings()

        self.setupGUI()
        self.loadPrefs()

    def loadPrefs(self):
        for checkBox in self.plugins_widgets:
            if self.settings.value(checkBox.text().split(" ")[0]) != None:
                checkBox.setCheckState(int(self.settings.value(checkBox.text().split(" ")[0])))
        if self.settings.value("FontName"):
            self.fontName.setCurrentFont(self.settings.value("FontName"))
        if self.settings.value("FontSize"):
            self.fontSize.setValue(int(self.settings.value("FontSize")))
        if self.settings.value("WrapLine"):
            self.wrapLine.setCheckState(int(self.settings.value("WrapLine")))
        if self.settings.value("qt18720"):
            self.qt18720.setCheckState(int(self.settings.value("qt18720")))

    def savePrefs(self):
        for checkBox in self.plugins_widgets:
            self.settings.setValue(checkBox.text().split(" ")[0], checkBox.checkState())
        self.settings.setValue("FontName", self.fontName.currentFont())
        self.settings.setValue("FontSize", self.fontSize.value())
        self.settings.setValue("WrapLine", self.wrapLine.checkState())
        self.settings.setValue("qt18720", self.qt18720.checkState())

    def closeEvent(self, widget, *args):
        self.savePrefs()

    def setupGUI(self):
        self.scrollArea = QScrollArea(self)
        self.scrollArea.setWidgetResizable(True)

        self.aWidget = QWidget(self.scrollArea)
        self._main_layout = QGridLayout(self.aWidget)
        self.aWidget.setMinimumSize(480, 800)
        self.aWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.scrollArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.scrollArea.setWidget(self.aWidget)
        try:
            scroller = self.scrollArea.property("kineticScroller")  # .toPyObject()
            scroller.setEnabled(True)
        except:
            pass
        gridIndex = 0

        self._main_layout.addWidget(QLabel("Font :"), gridIndex, 0)
        gridIndex += 1

        self.fontName = QFontComboBox()
        self._main_layout.addWidget(self.fontName, gridIndex, 0)
        gridIndex += 1
        self.fontSize = QSpinBox()
        self._main_layout.addWidget(self.fontSize, gridIndex, 0)
        gridIndex += 1

        self._main_layout.addWidget(QLabel("Plugins :"), gridIndex, 0)
        gridIndex += 1

        init_plugin_system()

        self.plugins_widgets = []
        for plugin in find_plugins():
            aCheckBox = QCheckBox(plugin.__name__ + " " + plugin.__version__)
            self.plugins_widgets.append(aCheckBox)
            self._main_layout.addWidget(aCheckBox, gridIndex, 0)
            gridIndex += 1

        self._main_layout.addWidget(QLabel("Others preferences :"), gridIndex, 0)
        gridIndex += 1
        self.wrapLine = QCheckBox("Wrap Lines")
        self._main_layout.addWidget(self.wrapLine, gridIndex, 0)
        gridIndex += 1
        self.qt18720 = QCheckBox("Work Arround QTBUG-18720")
        self._main_layout.addWidget(self.qt18720, gridIndex, 0)
        gridIndex += 1

        self.aWidget.setLayout(self._main_layout)
        self.setCentralWidget(self.scrollArea)