コード例 #1
0
ファイル: UpdateUI.py プロジェクト: cburgmer/eclectus
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(508, 94)
        self.verticalLayout = QtGui.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.dictionaryCombo = QtGui.QComboBox(Form)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.dictionaryCombo.sizePolicy().hasHeightForWidth())
        self.dictionaryCombo.setSizePolicy(sizePolicy)
        self.dictionaryCombo.setObjectName("dictionaryCombo")
        self.horizontalLayout.addWidget(self.dictionaryCombo)
        self.checkVersionButton = KPushButton(Form)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.checkVersionButton.sizePolicy().hasHeightForWidth())
        self.checkVersionButton.setSizePolicy(sizePolicy)
        self.checkVersionButton.setObjectName("checkVersionButton")
        self.horizontalLayout.addWidget(self.checkVersionButton)
        self.removeButton = KPushButton(Form)
        self.removeButton.setObjectName("removeButton")
        self.horizontalLayout.addWidget(self.removeButton)
        self.installButton = KPushButton(Form)
        self.installButton.setEnabled(False)
        self.installButton.setObjectName("installButton")
        self.horizontalLayout.addWidget(self.installButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.statusLabel = KSqueezedTextLabel(Form)
        self.statusLabel.setObjectName("statusLabel")
        self.verticalLayout.addWidget(self.statusLabel)
        self.progressBar = QtGui.QProgressBar(Form)
        self.progressBar.setProperty("value", QtCore.QVariant(24))
        self.progressBar.setInvertedAppearance(False)
        self.progressBar.setObjectName("progressBar")
        self.verticalLayout.addWidget(self.progressBar)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(kdecore.i18n("Form"))
        self.checkVersionButton.setToolTip(kdecore.i18n("Check the online resource for a newer version."))
        self.checkVersionButton.setWhatsThis(kdecore.i18n("Check the online resource for a newer version."))
        self.checkVersionButton.setText(kdecore.i18n("&Check for newer"))
        self.removeButton.setText(kdecore.i18n("&Remove"))
        self.installButton.setToolTip(kdecore.i18n("Download and install the selected dictionary."))
        self.installButton.setWhatsThis(kdecore.i18n("Download and install the selected dictionary."))
        self.installButton.setText(kdecore.i18n("&Install"))
コード例 #2
0
ファイル: main.py プロジェクト: juancarlospaco/pylou
class PylouApplet(Applet):

    """Main Applet containing the UI of Pylou."""

    def __init__(self, parent, args=None):
        """Init class."""
        Applet.__init__(self, parent)

    def init(self):
        """Start the Applet."""
        self._widget = None
        self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
        self.configurations = self.config()
        self._widget = PylouWidget(self)
        self._widget.init()
        self.setGraphicsWidget(self._widget)
        self.applet.setPassivePopup(True)
        self.setPopupIcon(QIcon.fromTheme("edit-find"))
        # for some odd reason this has to be called twice?
        self.setGraphicsWidget(self._widget)
        self.prepareConfigDialog()

    def update_db(self):
        """Update the DB."""
        return call("kdesudo --noignorebutton -c updatedb", shell=True)

    def prepareConfigDialog(self):
        """Prepare the Configuration Dialog."""
        self.bcolor, self.dialog = QColor(), KDialog()
        self.dialog.setWindowTitle(__package__ + "Settings")
        self.layBox = QGridLayout(self.dialog.mainWidget())
        self.title = KTitleWidget(self.dialog)
        self.title.setText(__doc__ + " !")
        self.title.setAutoHideTimeout(3000)
        self.FontButton = KFontRequester(self.dialog)
        self.tfont = QFont(QVariant(self.configurations.readEntry("TextFont",
                           QVariant(QFont()))))
        self.FontButton.setFont(self.tfont)
        self.ColorButton = KColorButton(self.dialog)
        self.tcolor = QColor(self.configurations.readEntry("TextColor",
                             QColor("#000").name()))
        self.ColorButton.setColor(self.tcolor)
        self.BColorButton = KColorButton(self.dialog)
        # button to update the DB via sudo updatedb

        self.UpdateDB = KPushButton("Update Database", self.dialog,
                                    clicked=lambda: self.update_db())
        self.UpdateDB.setToolTip("Database is Updated every Reboot and Daily!")
        self.Histor = KPushButton("Delete my History", self.dialog,
                                  clicked=delete_my_history)
        self.Histor.setToolTip("History is Deleted every Reboot !")
        # list of banned words separated by spaces
        self.banned = KTextEdit(self.dialog)
        self.banned.setPlainText(self.configurations.readEntry(
            "Banned", "sex p**n drugs suicide decapitate religion").toString())
        # set the colors
        cg = KConfig("kdeglobals")
        color = cg.group("Colors:View").readEntry(
            "BackgroundAlternate").split(",")
        self.bcolor = QColor(int(color[0]), int(color[1]), int(color[2]))
        self.BColorButton.setColor(self.bcolor)
        self.history_file_path_field = KLineEdit(HISTORY_FILE_PATH)
        self.history_file_path_field.setDisabled(True)
        self.python_file_path_field = KLineEdit(__file__)
        self.python_file_path_field.setDisabled(True)
        self.kill_baloo = QCheckBox("Disable Baloo")
        self.kill_baloo.setToolTip("Enable/Disable Desktop Search Indexing")
        self.kill_baloo.stateChanged.connect(lambda: call(
            DISABLE_BALOO_CMD.format(str(
                not self.kill_baloo.isChecked()).lower()), shell=True))
        self.kill_baloo.stateChanged.connect(lambda: QMessageBox.information(
            self.dialog, __doc__, """
            <b>Indexing Disabled, Baloo is Dead !
            """ if self.kill_baloo.isChecked() else """
            <b>Indexing Enabled, Baloo is Running !"""))
        self.updatez = KPushButton("Check for Updates", self.dialog,
                                   clicked=lambda: self.check_for_updates())
        self.updatez.setToolTip("Check for Pylou updates from the internet")
        self.home_sweet_home = QCheckBox("Only Search Home")
        self.home_sweet_home.setToolTip("Only Search on my Home folders")
        self.home_sweet_home.setChecked(
            bool(self.configurations.readEntry("Home", True)))
        # pack all widgets
        self.layBox.addWidget(self.title, 0, 1)
        self.layBox.addWidget(QLabel("Font"), 1, 0)
        self.layBox.addWidget(self.FontButton, 1, 1)
        self.layBox.addWidget(QLabel("Text Color"), 2, 0)
        self.layBox.addWidget(self.ColorButton, 2, 1)
        self.layBox.addWidget(QLabel("Alternate Color"), 3, 0)
        self.layBox.addWidget(self.BColorButton, 3, 1)
        self.layBox.addWidget(QLabel(), 4, 0)
        self.layBox.addWidget(QLabel("Mainteniance"), 5, 0)
        self.layBox.addWidget(self.UpdateDB, 5, 1)
        self.layBox.addWidget(QLabel("Privacy"), 6, 0)
        self.layBox.addWidget(self.Histor, 6, 1)
        self.layBox.addWidget(QLabel("History file"), 7, 0)
        self.layBox.addWidget(self.history_file_path_field, 7, 1)
        self.layBox.addWidget(QLabel(__package__ + "file"), 8, 0)
        self.layBox.addWidget(self.python_file_path_field, 8, 1)
        self.layBox.addWidget(QLabel("Banned Words"), 9, 0)
        self.layBox.addWidget(self.banned, 9, 1)
        self.layBox.addWidget(QLabel("SelfUpdating"), 10, 0)
        self.layBox.addWidget(self.updatez, 10, 1)
        self.layBox.addWidget(QLabel("<b>Disable Indexing"), 12, 0)
        self.layBox.addWidget(self.kill_baloo, 12, 1)
        self.layBox.addWidget(QLabel("Search Paths"), 13, 0)
        self.layBox.addWidget(self.home_sweet_home, 13, 1)
        # button box on the bottom
        self.dialog.setButtons(KDialog.ButtonCodes(
            KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Apply)))
        # connect
        self.dialog.applyClicked.connect(self.configAccepted)
        self.dialog.okClicked.connect(self.configAccepted)

    @pyqtSignature("configAccepted()")
    def configAccepted(self):
        """Save configuration settings."""
        self.tcolor = self.ColorButton.color()
        self.bcolor = self.BColorButton.color()
        self._widget.treeview.nativeWidget().setFont(self.tfont)
        self._widget.treeview.nativeWidget().setStyleSheet(
            "color:{};alternate-background-color:{}".format(
                self.tcolor.name(), self.bcolor.name()))
        self.configurations.writeEntry("TextColor", self.tcolor.name())
        self.configurations.writeEntry("AlternateBColor", self.bcolor.name())
        self.configurations.writeEntry("TextFont", QVariant(self.tfont))
        self.configurations.writeEntry("Banned", self.banned.toPlainText())
        self.configurations.writeEntry("Home",
                                       self.home_sweet_home.isChecked())

    def showConfigurationInterface(self):
        """Show configuration dialog."""
        self.dialog.show()
        self.dialog.raise_()

    def check_for_updates(self):
        """Method to check for updates from Git repo versus this version."""
        this_version = str(open(__file__).read())
        last_version = str(urlopen(__source__).read())
        if this_version != last_version:
            m = "Theres new Version available!<br>Download update from the web"
        else:
            m = "No new updates!<br>You have the lastest version of this app!."
        return QMessageBox.information(None, __doc__.title(), "<b>" + m)
コード例 #3
0
ファイル: __init__.py プロジェクト: Alwnikrotikz/lilykde
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        parent.addPage(self, i18n("Parts"))

        # The part types overview widget.
        v = KVBox()
        self.addWidget(v)
        QLabel('<b>{0}</b>'.format(i18n("Available parts:")), v)
        allParts = QTreeWidget(v)
        addButton = KPushButton(KStandardGuiItem.add(), v)
        addButton.setToolTip(i18n("Add selected part to your score."))

        # The listbox with selected parts
        v = KVBox()
        self.addWidget(v)
        QLabel('<b>{0}</b>'.format(i18n("Score:")), v)
        score = QListWidget(v)
        self.score = score  # so the partList method can find us
        h = KHBox(v)
        removeButton = KPushButton(KStandardGuiItem.remove(), h)
        upButton = QToolButton(h)
        upButton.setIcon(KIcon("go-up"))
        downButton = QToolButton(h)
        downButton.setIcon(KIcon("go-down"))

        # The StackedWidget with settings
        partSettings = QStackedWidget()
        self.addWidget(partSettings)
        
        self.setStretchFactor(0, 1)
        self.setStretchFactor(1, 1)
        self.setStretchFactor(2, 1)
        self.setSizes((100, 100, 100))

        allParts.setSelectionMode(QTreeWidget.ExtendedSelection)
        allParts.setRootIsDecorated(False)
        allParts.headerItem().setHidden(True)
        score.setSelectionMode(QListWidget.ExtendedSelection)
        score.setDragDropMode(QListWidget.InternalMove)

        class PartItem(QListWidgetItem):
            """
            A part from the score, instantiating a config widget as well.
            """
            def __init__(self, partClass):
                name = partClass.name() # partClass.name is a ki18n object
                QListWidgetItem.__init__(self, name, score)
                self.w = QGroupBox(name)
                partSettings.addWidget(self.w)
                self.part = partClass()
                layout = QVBoxLayout(self.w)
                self.part.widgets(layout)
                layout.addStretch(1)
                if score.count() == 1:
                    score.setCurrentRow(0)
                    self.setSelected(True)
                parent.enableButton(KPageDialog.Try, True)

            def showSettingsWidget(self):
                partSettings.setCurrentWidget(self.w)

            def remove(self):
                if score.count() == 1:
                    parent.enableButton(KPageDialog.Try, False)
                sip.delete(self.w)
                sip.delete(self) # TODO: check if necessary
        
        @allParts.itemDoubleClicked.connect
        def addPart(item, col):
            if hasattr(item, "partClass"):
                PartItem(item.partClass)
        
        @allParts.itemClicked.connect
        def toggleExpand(item, col):
            item.setExpanded(not item.isExpanded())

        @addButton.clicked.connect
        def addSelectedParts():
            for item in allParts.selectedItems():
                PartItem(item.partClass)

        @removeButton.clicked.connect
        def removeSelectedParts():
            for item in score.selectedItems():
                item.remove()

        def keepSel(func):
            """
            Restore the selection and current element after reordering parts.
            """
            def decorator():
                selItems = score.selectedItems()
                curItem = score.currentItem()
                func()
                score.setCurrentItem(curItem)
                for i in selItems:
                    i.setSelected(True)
            return decorator
            
        @upButton.clicked.connect
        @keepSel
        def moveUp():
            """ Move selected parts up. """
            for row in range(1, score.count()):
                if score.item(row).isSelected():
                    item = score.takeItem(row)
                    score.insertItem(row - 1, item)

        @downButton.clicked.connect
        @keepSel
        def moveDown():
            """ Move selected parts down. """
            for row in range(score.count() - 1, -1, -1):
                if score.item(row).isSelected():
                    item = score.takeItem(row)
                    score.insertItem(row + 1, item)

        @score.currentItemChanged.connect
        def showItem(cur, prev):
            if cur:
                cur.showSettingsWidget()

        from frescobaldi_app.scorewiz.parts import categories
        for name, parts in categories():
            group = QTreeWidgetItem(allParts, [name])
            group.setFlags(Qt.ItemIsEnabled)
            group.setIcon(0, KIcon("inode-directory"))
            for part in parts:
                p = QTreeWidgetItem(group, [part.name()])
                p.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
                p.partClass = part