class EditableQMenu(QtGui.QMenuBar): ''' A menu which allows users to edit the text fields. Double click on them to see this in action. ''' def __init__(self, parent=None): QtGui.QMenuBar.__init__(self, parent) self.parser = Parser() self.setMouseTracking(True) def mousePressEvent(self, event): ''' slow down the click so that double clicks can be caught. ''' def pass_on(): QtGui.QMenuBar.mousePressEvent(self, event) action = self.actionAt(event.pos()) if not action: return QtCore.QTimer.singleShot(PAUSE_LENGTH, pass_on) action.trigger() def mouseDoubleClickEvent(self, event): action = self.actionAt(event.pos()) if not action: return if action.text() == "Options": return text, result = QtGui.QInputDialog.getText(self, "edit menu", "enter new name for this menu item", text=action.text()) if result: menu_item_uid = action.objectName() if menu_item_uid == 'item1': self.parser.set_value('menu_item_1', text) elif menu_item_uid == 'item2': self.parser.set_value('menu_item_2', text) elif menu_item_uid == 'item3': self.parser.set_value('menu_item_3', text) elif menu_item_uid == 'item4': self.parser.set_value('menu_item_4', text) elif menu_item_uid == 'item5': self.parser.set_value('menu_item_5', text) action.setText(text)
def __init__(self, dbname): self.parser = Parser() self._memcon = apsw.Connection(":memory:") self._dbname = dbname self._path_list = [] self._name_list = [] self._con = apsw.Connection(self._dbname) self._cursor = self._con.cursor() with self._memcon.backup("main", self._con, "main") as backup: while not backup.done: backup.step(100)
def createMenuActions(self): parser = Parser() self.menuAppAction = QtGui.QAction(parser.read_value('menu_item_1', 'Applications', 'str'), self.menuBar) self.menuAppAction.setObjectName('item1') self.menuInternetAction = QtGui.QAction(parser.read_value('menu_item_2', 'Internet', 'str'), self.menuBar) self.menuInternetAction.setObjectName('item2') self.menuMediaAction = QtGui.QAction(parser.read_value('menu_item_3', 'Media', 'str'), self.menuBar) self.menuMediaAction.setObjectName('item3') self.menuFavoritesAction = QtGui.QAction(parser.read_value('menu_item_4', 'Favorites', 'str'), self.menuBar) self.menuFavoritesAction.setObjectName('item4') self.menuSystem_UtilitiesAction = QtGui.QAction(parser.read_value('menu_item_5', 'System Utilities', 'str'), self.menuBar) self.menuSystem_UtilitiesAction.setObjectName('item5') self.menuOptionsAction = QtGui.QAction("Options", self.menuBar) self.menuBar.addAction(self.menuAppAction) self.menuBar.addAction(self.menuInternetAction) self.menuBar.addAction(self.menuMediaAction) self.menuBar.addAction(self.menuFavoritesAction) self.menuBar.addAction(self.menuSystem_UtilitiesAction) self.menuBar.addAction(self.menuOptionsAction)
def __init__(self, parent=None): QtGui.QMenuBar.__init__(self, parent) self.parser = Parser() self.setMouseTracking(True)
def __init__(self, main_window_instance=None, parent=None): super(Ui_Options, self).__init__(parent) self.setWindowTitle("pyLauncher | Options") self.main_window_instance = main_window_instance self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.resize(419, 243) self.pylMainTab = QtGui.QTabWidget(self) self.pylMainTab.setGeometry(QtCore.QRect(0, 10, 421, 241)) self.optionsMainTab = QtGui.QWidget() self.autoUpdatecheckBox = QtGui.QCheckBox(self.optionsMainTab) self.autoUpdatecheckBox.setGeometry(QtCore.QRect(10, 30, 161, 18)) self.startWithWindowsCheckbox = QtGui.QCheckBox(self.optionsMainTab) self.startWithWindowsCheckbox.setGeometry(QtCore.QRect(10, 70, 121, 18)) self.numberOfResultsDisplayed = QtGui.QSpinBox(self.optionsMainTab) self.numberOfResultsDisplayed.setGeometry(QtCore.QRect(350, 30, 46, 22)) self.checkBoxStayOnTop = QtGui.QCheckBox(self.optionsMainTab) self.checkBoxStayOnTop.setGeometry(QtCore.QRect(10, 110, 131, 18)) self.numResultDispalyed = QtGui.QLabel(self.optionsMainTab) self.numResultDispalyed.setGeometry(QtCore.QRect(190, 30, 141, 21)) self.tipsCheckBox = QtGui.QCheckBox("Show tips on start up", self.optionsMainTab) self.tipsCheckBox.setGeometry(10, 140, 131, 18) self.autoUpdatepyLauncher = QtGui.QCheckBox(self.optionsMainTab) self.autoUpdatepyLauncher.setGeometry(QtCore.QRect(190, 70, 161, 18)) self.transpLabel = QtGui.QLabel("Transparency:", self.optionsMainTab) self.transpLabel.setGeometry(QtCore.QRect(180, 111, 71, 20)) self.transparencySpinBox = QtGui.QDoubleSpinBox(self.optionsMainTab) self.transparencySpinBox.setGeometry(QtCore.QRect(260, 110, 62, 22)) self.transparencySpinBox.setMinimum(0.1) self.transparencySpinBox.setMaximum(1.0) self.transparencySpinBox.setDecimals(1) self.transparencySpinBox.setSingleStep(0.1) self.transparencySpinBox.setRange(0.1, 1.0) self.label_3 = QtGui.QLabel(self.optionsMainTab) self.label_3.setGeometry(QtCore.QRect(70, 150, 241, 61)) font = QtGui.QFont() font = QtGui.QFont() font.setFamily(_fromUtf8("Segoe Print")) font.setPointSize(28) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.pylMainTab.addTab(self.optionsMainTab, _fromUtf8("About pyLauncher")) self.pylPluginsTab = QtGui.QWidget() self.availPlugsBox = QtGui.QGroupBox(self.pylPluginsTab) self.availPlugsBox.setGeometry(QtCore.QRect(10, 20, 391, 181)) self.tableView = QtGui.QTableWidget(self.availPlugsBox) self.tableView.setGeometry(QtCore.QRect(10, 20, 371, 151)) self.tableView.setColumnCount(3) self.pylMainTab.addTab(self.pylPluginsTab, _fromUtf8("About pyLauncher2")) self.pylAbout = QtGui.QWidget() self.label = QtGui.QLabel(self.pylAbout) self.label.setGeometry(QtCore.QRect(80, 0, 241, 61)) font = QtGui.QFont() font.setFamily(_fromUtf8("Segoe Print")) font.setPointSize(28) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label_2 = QtGui.QLabel(self.pylAbout) self.label_2.setGeometry(QtCore.QRect(10, 20, 391, 181)) font = QtGui.QFont() self.label_2.setFont(font) self.label_2.setWordWrap(True) self.label_2.setIndent(7) self.label_2.setOpenExternalLinks(True) self.pylMainTab.addTab(self.pylAbout, _fromUtf8("About pyLauncher")) self.pylMainTab.setCurrentIndex(0) self.parser = Parser() if self.parser.read_value('auto_update', 'True', 'str') == 'True': self.autoUpdatepyLauncher.toggle() if self.parser.read_value('autosync', 'True', 'str') == 'True': self.autoUpdatecheckBox.toggle() if self.parser.read_value('autorun', 'True', 'str') == 'True': self.startWithWindowsCheckbox.toggle() if self.parser.read_value('always_on_top', 'True', 'str') == 'True': self.checkBoxStayOnTop.toggle() if self.parser.read_value('show_tips', 'True', 'str') == 'True': self.tipsCheckBox.toggle() self.numberOfResultsDisplayed.setValue(self.parser.read_value('max_results', 5, 'int')) self.numberOfResultsDisplayed.setMinimum(1) self.transparencySpinBox.setValue(self.parser.read_value('transparency', 0.8, 'float')) self.retranslateUi() self.setPluginInfo() QtCore.QMetaObject.connectSlotsByName(self) self.connectSignals()
class Ui_Options(QtGui.QWidget): def __init__(self, main_window_instance=None, parent=None): super(Ui_Options, self).__init__(parent) self.setWindowTitle("pyLauncher | Options") self.main_window_instance = main_window_instance self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.resize(419, 243) self.pylMainTab = QtGui.QTabWidget(self) self.pylMainTab.setGeometry(QtCore.QRect(0, 10, 421, 241)) self.optionsMainTab = QtGui.QWidget() self.autoUpdatecheckBox = QtGui.QCheckBox(self.optionsMainTab) self.autoUpdatecheckBox.setGeometry(QtCore.QRect(10, 30, 161, 18)) self.startWithWindowsCheckbox = QtGui.QCheckBox(self.optionsMainTab) self.startWithWindowsCheckbox.setGeometry(QtCore.QRect(10, 70, 121, 18)) self.numberOfResultsDisplayed = QtGui.QSpinBox(self.optionsMainTab) self.numberOfResultsDisplayed.setGeometry(QtCore.QRect(350, 30, 46, 22)) self.checkBoxStayOnTop = QtGui.QCheckBox(self.optionsMainTab) self.checkBoxStayOnTop.setGeometry(QtCore.QRect(10, 110, 131, 18)) self.numResultDispalyed = QtGui.QLabel(self.optionsMainTab) self.numResultDispalyed.setGeometry(QtCore.QRect(190, 30, 141, 21)) self.tipsCheckBox = QtGui.QCheckBox("Show tips on start up", self.optionsMainTab) self.tipsCheckBox.setGeometry(10, 140, 131, 18) self.autoUpdatepyLauncher = QtGui.QCheckBox(self.optionsMainTab) self.autoUpdatepyLauncher.setGeometry(QtCore.QRect(190, 70, 161, 18)) self.transpLabel = QtGui.QLabel("Transparency:", self.optionsMainTab) self.transpLabel.setGeometry(QtCore.QRect(180, 111, 71, 20)) self.transparencySpinBox = QtGui.QDoubleSpinBox(self.optionsMainTab) self.transparencySpinBox.setGeometry(QtCore.QRect(260, 110, 62, 22)) self.transparencySpinBox.setMinimum(0.1) self.transparencySpinBox.setMaximum(1.0) self.transparencySpinBox.setDecimals(1) self.transparencySpinBox.setSingleStep(0.1) self.transparencySpinBox.setRange(0.1, 1.0) self.label_3 = QtGui.QLabel(self.optionsMainTab) self.label_3.setGeometry(QtCore.QRect(70, 150, 241, 61)) font = QtGui.QFont() font = QtGui.QFont() font.setFamily(_fromUtf8("Segoe Print")) font.setPointSize(28) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.pylMainTab.addTab(self.optionsMainTab, _fromUtf8("About pyLauncher")) self.pylPluginsTab = QtGui.QWidget() self.availPlugsBox = QtGui.QGroupBox(self.pylPluginsTab) self.availPlugsBox.setGeometry(QtCore.QRect(10, 20, 391, 181)) self.tableView = QtGui.QTableWidget(self.availPlugsBox) self.tableView.setGeometry(QtCore.QRect(10, 20, 371, 151)) self.tableView.setColumnCount(3) self.pylMainTab.addTab(self.pylPluginsTab, _fromUtf8("About pyLauncher2")) self.pylAbout = QtGui.QWidget() self.label = QtGui.QLabel(self.pylAbout) self.label.setGeometry(QtCore.QRect(80, 0, 241, 61)) font = QtGui.QFont() font.setFamily(_fromUtf8("Segoe Print")) font.setPointSize(28) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label_2 = QtGui.QLabel(self.pylAbout) self.label_2.setGeometry(QtCore.QRect(10, 20, 391, 181)) font = QtGui.QFont() self.label_2.setFont(font) self.label_2.setWordWrap(True) self.label_2.setIndent(7) self.label_2.setOpenExternalLinks(True) self.pylMainTab.addTab(self.pylAbout, _fromUtf8("About pyLauncher")) self.pylMainTab.setCurrentIndex(0) self.parser = Parser() if self.parser.read_value('auto_update', 'True', 'str') == 'True': self.autoUpdatepyLauncher.toggle() if self.parser.read_value('autosync', 'True', 'str') == 'True': self.autoUpdatecheckBox.toggle() if self.parser.read_value('autorun', 'True', 'str') == 'True': self.startWithWindowsCheckbox.toggle() if self.parser.read_value('always_on_top', 'True', 'str') == 'True': self.checkBoxStayOnTop.toggle() if self.parser.read_value('show_tips', 'True', 'str') == 'True': self.tipsCheckBox.toggle() self.numberOfResultsDisplayed.setValue(self.parser.read_value('max_results', 5, 'int')) self.numberOfResultsDisplayed.setMinimum(1) self.transparencySpinBox.setValue(self.parser.read_value('transparency', 0.8, 'float')) self.retranslateUi() self.setPluginInfo() QtCore.QMetaObject.connectSlotsByName(self) self.connectSignals() def setPluginInfo(self): plugin_info = self.main_window_instance.getPluginInformation() self.tableView.setHorizontalHeaderLabels(['Plugin', 'Author', 'Version']) for plugin in plugin_info.keys(): plugin_info_list = plugin_info[plugin] lastrow = self.tableView.rowCount() self.tableView.insertRow(lastrow) self.tableView.setItem(lastrow, 0, QtGui.QTableWidgetItem(plugin_info_list[0])) self.tableView.setItem(lastrow, 1, QtGui.QTableWidgetItem(plugin_info_list[1])) self.tableView.setItem(lastrow, 2, QtGui.QTableWidgetItem(plugin_info_list[2])) def connectSignals(self): self.checkBoxStayOnTop.stateChanged.connect(self.stayOnTopCheckBox) self.startWithWindowsCheckbox.stateChanged.connect(self.autoStartCheckBox) self.autoUpdatecheckBox.stateChanged.connect(self._autoSyncCheckBox) self.numberOfResultsDisplayed.valueChanged.connect(self.updateNumberOfResults) self.autoUpdatepyLauncher.stateChanged.connect(self.autoUpdateStateChanged) self.transparencySpinBox.valueChanged.connect(self.updateTransparency) self.tipsCheckBox.stateChanged.connect(self.tipsCheckBoxState) def tipsCheckBoxState(self, state): if state == QtCore.Qt.Checked: self.parser.set_value('show_tips', 'True') else: self.parser.set_value('show_tips', 'False') def updateTransparency(self, value): self.parser.set_value('transparency', value) self.main_window_instance.setWindowOpacity(value) def autoUpdateStateChanged(self, state): if state == QtCore.Qt.Checked: self.parser.set_value('auto_update', 'True') else: self.parser.set_value('auto_update', 'False') def updateNumberOfResults(self): self.parser.set_value('max_results', self.numberOfResultsDisplayed.value()) def _autoSyncCheckBox(self, state): if state == QtCore.Qt.Checked: self.parser.set_value('autosync', 'True') else: self.parser.set_value('autosync', 'False') def autoStartCheckBox(self, state): if state == QtCore.Qt.Checked: self.parser.set_value('autorun', 'True') addToRegistry(os.path.realpath(sys.argv[0])) else: self.parser.set_value('autorun', 'False') removeFromRegistry() def stayOnTopCheckBox(self, state): if state == QtCore.Qt.Checked: self.parser.set_value('always_on_top', 'True') else: self.parser.set_value('always_on_top', 'False') def retranslateUi(self): self.autoUpdatecheckBox.setText(QtGui.QApplication.translate("Options", "Auto synchronise Catalog", None, QtGui.QApplication.UnicodeUTF8)) self.startWithWindowsCheckbox.setText(QtGui.QApplication.translate("Options", "Start with Windows", None, QtGui.QApplication.UnicodeUTF8)) self.checkBoxStayOnTop.setText(QtGui.QApplication.translate("Options", "Stay always on top", None, QtGui.QApplication.UnicodeUTF8)) self.numResultDispalyed.setText(QtGui.QApplication.translate("Options", "Number of results displayed:", None, QtGui.QApplication.UnicodeUTF8)) self.autoUpdatepyLauncher.setText(QtGui.QApplication.translate("Options", "Auto Update on new version", None, QtGui.QApplication.UnicodeUTF8)) self.label_3.setText(QtGui.QApplication.translate("Options", "pyLauncher", None, QtGui.QApplication.UnicodeUTF8)) self.pylMainTab.setTabText(self.pylMainTab.indexOf(self.optionsMainTab), QtGui.QApplication.translate("Options", "pyLauncher Main", None, QtGui.QApplication.UnicodeUTF8)) self.availPlugsBox.setTitle(QtGui.QApplication.translate("Options", "Available Plugins", None, QtGui.QApplication.UnicodeUTF8)) self.pylMainTab.setTabText(self.pylMainTab.indexOf(self.pylPluginsTab), QtGui.QApplication.translate("Options", "pyLauncher Plugins", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("Options", "pyLauncher", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("Options", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt; font-weight:600;\">pyLauncher</span><span style=\" font-size:10pt;\"> is a free utility for </span><span style=\" font-size:10pt; font-weight:600;\">Microsoft Window</span><span style=\" font-size:10pt;\">s designed to help you forget about your Start Menu, the Icons on your Desktop, </span></p>\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">and even your File Manager.</span></p>\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">If you want to help improve pyLauncher or fill a bug report please visit: </span><a href=\"https://github.com/BGS/pyLauncher\"><span style=\" font-size:10pt; text-decoration: underline; color:#0000ff;\">pyLauncher Home Page</span></a></p></body></html>", None, QtGui.QApplication.UnicodeUTF8)) self.pylMainTab.setTabText(self.pylMainTab.indexOf(self.pylAbout), QtGui.QApplication.translate("Options", "About pyLauncher", None, QtGui.QApplication.UnicodeUTF8))
class EngineInit(): def __init__(self, dbname): self.parser = Parser() self._memcon = apsw.Connection(":memory:") self._dbname = dbname self._path_list = [] self._name_list = [] self._con = apsw.Connection(self._dbname) self._cursor = self._con.cursor() with self._memcon.backup("main", self._con, "main") as backup: while not backup.done: backup.step(100) def syncMemDb(self): with self._memcon.backup("main", self._con, "main") as backup: backup.step() def getAppData(self, app_name): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM app_data where name MATCH '*%s*' LIMIT %s" % (app_name, self.parser.read_value('max_results', 5, 'int'))): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def getFavAppData(self): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM favorites"): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def getMenuAppData(self): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM applications"): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def getInternetAppData(self): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM internet"): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def getMediaAppData(self): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM media"): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def getSystem_UtilitiesAppData(self): self._path_list = [] self._name_list = [] for row in self._memcon.cursor().execute("SELECT name,path FROM sysutils"): self._path_list.append(row[1]) self._name_list.append(row[0]) return setModelData(self._path_list, self._name_list) def addApplication(self, index, table): try: if table == 'fav': self._cursor.execute('INSERT OR REPLACE INTO favorites VALUES (?,?)', (self._name_list[index], self._path_list[index])) elif table == 'app': self._cursor.execute('INSERT OR REPLACE INTO applications VALUES (?,?)', (self._name_list[index], self._path_list[index])) elif table == 'graph': self._cursor.execute('INSERT OR REPLACE INTO media VALUES (?,?)', (self._name_list[index], self._path_list[index])) elif table == 'sys_util': self._cursor.execute('INSERT OR REPLACE INTO sysutils VALUES (?,?)', (self._name_list[index], self._path_list[index])) elif table == 'internet': self._cursor.execute('INSERT OR REPLACE INTO internet VALUES (?,?)', (self._name_list[index], self._path_list[index])) except IndexError: pass #resync db with self._memcon.backup("main", self._con, "main") as backup: backup.step() def remApplication(self, index, table): try: if table == 'fav': self._cursor.execute('DELETE FROM favorites WHERE path="%s"' % self._path_list[index].strip()) elif table == 'app': self._cursor.execute('DELETE FROM applications WHERE path="%s"' % self._path_list[index].strip()) elif table == 'graph': self._cursor.execute('DELETE FROM media WHERE path="%s"' % self._path_list[index].strip()) elif table == 'sys_util': self._cursor.execute('DELETE FROM sysutils WHERE path="%s"' % self._path_list[index].strip()) elif table == 'internet': self._cursor.execute('DELETE FROM internet WHERE path="%s"' % self._path_list[index].strip()) except IndexError: pass #resync db with self._memcon.backup("main", self._con, "main") as backup: backup.step() def appExec(self, index): try: subprocess.Popen(self._path_list[index.row()], cwd=os.path.dirname(self._path_list[index.row()])) except WindowsError: self._cursor.execute('DELETE FROM app_data WHERE path="%s"' % self._path_list[index.row()].strip()) #resync db with self._memcon.backup("main", self._con, "main") as backup: backup.step() return False