def __addBasicActions(self): """ basic action """ self.regAction("gotohome",\ QAction(QIcon(getPath("iconDir",'home.png')),QApplication.translate("default", "MainTab"),self,triggered=self.__evt_home)) self.regAction("close",\ QAction(QIcon(getPath("iconDir",'close.png')),QApplication.translate("default", "Close"),self,triggered=self.__evt_close_tab)) self.regAction("perferences",\ QAction(QIcon(getPath("iconDir",'settings.png')),QApplication.translate("default", "Preferences..."),self,triggered=self.__evt_preferences)) self.regAction("plguinInfos", \ QAction(QApplication.translate("default","Plugin Infos..."),self,triggered=lambda : PluginInfoDialog(self).show())) self.regAction("plguinRequest", \ QAction(QApplication.translate("default","Available plugins..."),self,triggered=lambda : PluginRequestDialog(self).show())) self.getAction("gotohome").setShortcut(Prefs.new().getShortcut( "gotohome", "Ctrl+H")) self.getAction("close").setShortcut(Prefs.new().getShortcut( "close", "Ctrl+W")) self.getAction("perferences").setShortcut(Prefs.new().getShortcut( "perferences", "")) self.getAction("plguinInfos").setShortcut(Prefs.new().getShortcut( "plguinInfos", "")) self.getAction("plguinRequest").setShortcut(Prefs.new().getShortcut( "plguinRequest", ""))
def __init__(self,parent = None): """ Constructor """ QDialog.__init__(self,parent) self.setupUi(self) #center this window screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) self.baseConfigItem={ "applicationPage":[QApplication.translate("ApplicationPage","Application"),getPath("iconDir","preferences-application.png"),"sklib.ui.cpages.applicationPage",None], "shortcutsPage":[QApplication.translate("ShortcutsPage","Shortcuts"),getPath("iconDir","preferences-shortcuts.png"),"sklib.ui.cpages.shortcutsPage","applicationPage"], } #read from plugins for plugin in PluginAdapter().new().getPlugins(): if hasattr(plugin,"getConfigPages"): ptems = plugin.getConfigPages() for pkey in ptems.keys(): if not self.baseConfigItem.__contains__(pkey): self.baseConfigItem[pkey]=ptems[pkey] #end plugin parse self.itmDict = {} self.setupTreeList() self.btn.button(QDialogButtonBox.Apply).setEnabled(False) QObject.connect(self.configItemList, SIGNAL("itemClicked (QTreeWidgetItem *,int)"),self.evt_click) QObject.connect(self.btn, SIGNAL("clicked (QAbstractButton *)"),self.evt_btn_click)
def __evt_contextmenu(self,point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) action = QAction(QApplication.translate("default","Install plugins..."),self,triggered=lambda:self.__evt_install_plugin(item)) menu.addAction(action) action = QAction(QApplication.translate("default","Uninstall plugins..."),self) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
def __init__(self): """ (1) Add a tabWidget (2) Setup the main Window (3) Some basic event slot (4) read datas(menus , actions) """ QMainWindow.__init__(self) # attrs # Notice: These attributes can not be put outside init method self.__actions = {} self.__menus = {} self.__globalActionGroup = QActionGroup(self) #the main widget(Tab) that show all things self.tabs = MainTabWidget(self) self.setCentralWidget(self.tabs) view = SKMainTabShow(self, self.tabs) self.tabs.addTab(view, QIcon(getPath("iconDir", 'main.png')), QApplication.translate("default", "MainTab")) QObject.connect(self, SIGNAL("updateWindows()"), self.__updateWindows) self.__addBasicMenus() self.__addBasicActions()
def __init__(self): """ (1) Add a tabWidget (2) Setup the main Window (3) Some basic event slot (4) read datas(menus , actions) """ QMainWindow.__init__(self) # attrs # Notice: These attributes can not be put outside init method self.__actions = {} self.__menus = {} self.__globalActionGroup = QActionGroup(self) #the main widget(Tab) that show all things self.tabs = MainTabWidget(self) self.setCentralWidget(self.tabs) view = SKMainTabShow(self,self.tabs) self.tabs.addTab(view,QIcon(getPath("iconDir",'main.png')),QApplication.translate("default", "MainTab")) QObject.connect(self, SIGNAL("updateWindows()"),self.__updateWindows) self.__addBasicMenus() self.__addBasicActions()
def __init__(self, coding): """ Constructor """ ERR = QApplication.translate( "CodingError", "The coding '%1' is wrong for the given text.") self.errorMessage = ERR.arg(coding)
def __init__(self, dlg): """ Constructor """ QWidget.__init__(self) self.setupUi(self) #center this window screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.shortcutsList.header().setResizeMode(0, QHeaderView.ResizeToContents) self.dlg = dlg self.shortcutDialog = ShortcutDialog() self.__setupActions(QApplication.translate("default", "Global"), Seeking.new().getActions()) self.__setupPlugins() QObject.connect(self.shortcutsList,\ SIGNAL("itemDoubleClicked (QTreeWidgetItem *,int)"),\ self.__evt_dbclick) QObject.connect(self.shortcutsList, SIGNAL("itemChanged (QTreeWidgetItem *,int)"), self.__has_change) QObject.connect(self.searchEdit, SIGNAL("textChanged (const QString&)"), self.__search) QObject.connect(self.shortcutDialog, SIGNAL("shortcutChanged"), self.__shortcut)
def __init__(self,dlg): """ Constructor """ QWidget.__init__(self) self.setupUi(self) #center this window screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) self.shortcutsList.header().setResizeMode(0,QHeaderView.ResizeToContents) self.dlg = dlg self.shortcutDialog = ShortcutDialog() self.__setupActions(QApplication.translate("default","Global"),Seeking.new().getActions()) self.__setupPlugins() QObject.connect(self.shortcutsList,\ SIGNAL("itemDoubleClicked (QTreeWidgetItem *,int)"),\ self.__evt_dbclick) QObject.connect(self.shortcutsList, SIGNAL("itemChanged (QTreeWidgetItem *,int)"),self.__has_change) QObject.connect(self.searchEdit,SIGNAL("textChanged (const QString&)"),self.__search) QObject.connect(self.shortcutDialog,SIGNAL("shortcutChanged"),self.__shortcut)
def __evt_contextmenu(self, point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) action = QAction(QApplication.translate("default", "Install plugins..."), self, triggered=lambda: self.__evt_install_plugin(item)) menu.addAction(action) action = QAction( QApplication.translate("default", "Uninstall plugins..."), self) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
def __addBasicActions(self): """ basic action """ self.regAction("gotohome",\ QAction(QIcon(getPath("iconDir",'home.png')),QApplication.translate("default", "MainTab"),self,triggered=self.__evt_home)) self.regAction("close",\ QAction(QIcon(getPath("iconDir",'close.png')),QApplication.translate("default", "Close"),self,triggered=self.__evt_close_tab)) self.regAction("perferences",\ QAction(QIcon(getPath("iconDir",'settings.png')),QApplication.translate("default", "Preferences..."),self,triggered=self.__evt_preferences)) self.regAction("plguinInfos", \ QAction(QApplication.translate("default","Plugin Infos..."),self,triggered=lambda : PluginInfoDialog(self).show())) self.regAction("plguinRequest", \ QAction(QApplication.translate("default","Available plugins..."),self,triggered=lambda : PluginRequestDialog(self).show())) self.getAction("gotohome").setShortcut(Prefs.new().getShortcut("gotohome","Ctrl+H")) self.getAction("close").setShortcut(Prefs.new().getShortcut("close","Ctrl+W")) self.getAction("perferences").setShortcut(Prefs.new().getShortcut("perferences","")) self.getAction("plguinInfos").setShortcut(Prefs.new().getShortcut("plguinInfos","")) self.getAction("plguinRequest").setShortcut(Prefs.new().getShortcut("plguinRequest",""))
def __evt_contextmenu(self, point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) if item.text(4) == "True": action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False)) #core plugin not allowed disabled action.setEnabled(not PluginAdapter.new().getPluginByName( item.text(0)).packageName == "__core__") else: action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True)) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
def __evt_contextmenu(self,point): """ show the right menu """ item = self.pluginList.currentItem() if item: menu = QMenu(self) if item.text(4)=="True": action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False)) #core plugin not allowed disabled action.setEnabled(not PluginAdapter.new().getPluginByName(item.text(0)).packageName == "__core__") else: action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\ triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True)) menu.addAction(action) menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
def getPercentReplacementHelp(): """ Function to get the help text for the supported %-codes. @returns help text (QString) """ return QApplication.translate( "Utilities", """<p>You may use %-codes as placeholders in the string.""" """ Supported codes are:""" """<table>""" """<tr><td>%C</td><td>column of the cursor of the current editor</td></tr>""" """<tr><td>%D</td><td>directory of the current editor</td></tr>""" """<tr><td>%F</td><td>filename of the current editor</td></tr>""" """<tr><td>%H</td><td>home directory of the current user</td></tr>""" """<tr><td>%L</td><td>line of the cursor of the current editor</td></tr>""" """<tr><td>%P</td><td>path of the current project</td></tr>""" """<tr><td>%S</td><td>selected text of the current editor</td></tr>""" """<tr><td>%U</td><td>username of the current user</td></tr>""" """<tr><td>%%</td><td>the percent sign</td></tr>""" """</table>""" """</p>""")
def __addBasicMenus(self): """ basic menus """ #menu bar that plugins can call self.regMenu("file",\ self.menuBar().addMenu(QApplication.translate("default", "&File"))) self.regMenu("edit",\ self.menuBar().addMenu(QApplication.translate("default", "Edit"))) self.regMenu("settings",\ self.menuBar().addMenu(QApplication.translate("default", "Settings"))) self.regMenu("window",\ self.menuBar().addMenu(QApplication.translate("default", "Window"))) self.regMenu("plugins",\ self.menuBar().addMenu(QApplication.translate("default", "Plugins"))) self.regMenu("help",\ self.menuBar().addMenu(QApplication.translate("AboutSeeking", "Help")))
def __evt_changeLanguage(self,locale): Prefs.new().setLanguage(locale) QMessageBox.information(self,"Success",QApplication.translate("default","Success , this Will take effect at the next time"))
def beginFinalInit(self): """ @see: startup Notice the __init__ method . we just setup the basic widget. And after the language , style ,plugins etc had loaded . we call this method . Never call it unless you know what's it """ #when at linux platform . the icon is not visible at menu . for key in self.__actions.keys(): self.__actions.get(key).setIconVisibleInMenu(True) #--------------->>Seeking init <<-----------------# # __init__ menu self.getMenu("settings").addAction(self.getAction("perferences")) #i18n , must restart program to make it in use action_languages = QAction( QIcon(getPath('iconDir', 'languages.png')), QApplication.translate("default", "Languages"), self) action_languages.setIconVisibleInMenu(True) menu_languages = QMenu(self) trans_dir = QDir(getPrccisePath("transDir", "", "coredir")) fileNames = trans_dir.entryList(['i18n*.qm'], QDir.Files, QDir.Name) qmFiles = [trans_dir.filePath(fn) for fn in fileNames] for qmf in qmFiles: translator = QTranslator() translator.load(qmf) action = menu_languages.addAction( translator.translate("default", "English")) action.triggered.connect(lambda re, locale=translator.translate( "default", "locale"): self.__evt_changeLanguage(locale)) action_languages.setMenu(menu_languages) self.getMenu("settings").addAction(action_languages) #style menu use signalmapper action_style = QAction(QIcon(getPath('iconDir', 'style.png')), QApplication.translate("default", "Style"), self) action_style.setIconVisibleInMenu(True) menu_style = QMenu(self) for style_item in QStyleFactory.keys(): action = menu_style.addAction(style_item) action.triggered.connect( lambda re, style_item=style_item: changeStyle(style_item)) action_style.setMenu(menu_style) self.getMenu("settings").addAction(action_style) menu_plugin = self.getMenu("plugins") menu_plugin.addAction(self.getAction("plguinInfos")) menu_plugin.addSeparator() menu_plugin.addAction(self.getAction("plguinRequest")) #--------------->>Seeking init <<-----------------# # __init__ toolbar toolBar = self.addToolBar(QApplication.translate("default", "common")) toolBar.addAction(self.getAction("perferences")) toolBar.addAction(self.getAction("close")) toolBar.addAction(self.getAction("gotohome")) toolBar.addAction(self.getAction("help")) #--------------->>Seeking init <<-----------------# # __init__ status bar self.statusBar().showMessage("Seeking ...") #--------------->>Seeking init <<-----------------# #Effects of a loading progress . #Results appear in the tab of the interior, the window has no effect on the global self.overlay = Overlay(self.centralWidget()) self.overlay.hide() #--------------->>Seeking init <<-----------------# #other self.emit(SIGNAL('updateWindows()'))
def __evt_changeLanguage(self, locale): Prefs.new().setLanguage(locale) QMessageBox.information( self, "Success", QApplication.translate( "default", "Success , this Will take effect at the next time"))
def beginFinalInit(self): """ @see: startup Notice the __init__ method . we just setup the basic widget. And after the language , style ,plugins etc had loaded . we call this method . Never call it unless you know what's it """ #when at linux platform . the icon is not visible at menu . for key in self.__actions.keys(): self.__actions.get(key).setIconVisibleInMenu(True) #--------------->>Seeking init <<-----------------# # __init__ menu self.getMenu("settings").addAction(self.getAction("perferences")) #i18n , must restart program to make it in use action_languages = QAction(QIcon(getPath('iconDir','languages.png')),QApplication.translate("default", "Languages"),self) action_languages.setIconVisibleInMenu(True) menu_languages = QMenu(self) trans_dir = QDir(getPrccisePath("transDir","","coredir")) fileNames = trans_dir.entryList(['i18n*.qm'], QDir.Files,QDir.Name) qmFiles = [trans_dir.filePath(fn) for fn in fileNames] for qmf in qmFiles: translator = QTranslator() translator.load(qmf) action = menu_languages.addAction(translator.translate("default", "English")) action.triggered.connect(lambda re,locale=translator.translate("default", "locale"):self.__evt_changeLanguage(locale)) action_languages.setMenu(menu_languages) self.getMenu("settings").addAction(action_languages) #style menu use signalmapper action_style = QAction(QIcon(getPath('iconDir','style.png')),QApplication.translate("default", "Style"),self) action_style.setIconVisibleInMenu(True) menu_style = QMenu(self) for style_item in QStyleFactory.keys(): action = menu_style.addAction(style_item) action.triggered.connect(lambda re,style_item=style_item:changeStyle(style_item)) action_style.setMenu(menu_style) self.getMenu("settings").addAction(action_style) menu_plugin = self.getMenu("plugins") menu_plugin.addAction(self.getAction("plguinInfos")) menu_plugin.addSeparator() menu_plugin.addAction(self.getAction("plguinRequest")) #--------------->>Seeking init <<-----------------# # __init__ toolbar toolBar = self.addToolBar(QApplication.translate("default","common")) toolBar.addAction(self.getAction("perferences")) toolBar.addAction(self.getAction("close")) toolBar.addAction(self.getAction("gotohome")) toolBar.addAction(self.getAction("help")) #--------------->>Seeking init <<-----------------# # __init__ status bar self.statusBar().showMessage("Seeking ...") #--------------->>Seeking init <<-----------------# #Effects of a loading progress . #Results appear in the tab of the interior, the window has no effect on the global self.overlay = Overlay(self.centralWidget()) self.overlay.hide() #--------------->>Seeking init <<-----------------# #other self.emit(SIGNAL('updateWindows()'))