def save(self): """ Handle save event . Before saved , checked if has password set . The password is encrypt with pyDes """ if self.bufferon(): # get the password password = "" password1 = self.password1.text() password2 = self.password2.text() if not password1 == "" or not password2 == "": if password1 == password2: password = password1 else: QMessageBox.warning(Seeking.new(), "error", "Not match") return # loading effert Seeking.new().overlay.show() # if it's a new yeahdoc item instance if self.keepme() is "" or self.keepme().startswith(":"): idx = "~" # notice we contact the str at __init__ method else: idx = self.keepme().split('~')[0] # Values title = self.titleInput.text() content = self.__htmlWYSIWYG.accessPoint().mainFrame().toHtml() img = self.flagBtn.text() tags = self.tagsInput.text() categoryid = self.classlist.itemData(self.classlist.currentIndex()) # Just save will change it , update opreation will just repeat it self.setKeepme( YeahdocDatasSupply().bb_save(categoryid.toString(), title, tags, img, content, password, idx) + \ self.__Y_MARK_SUBFIX) # in order to make the suitable width of tab. title = "%s.." % title[0:8] if len(title) > 8 else title index = Seeking.new().tabs.indexOf(self) Seeking.new().tabs.setTabIcon(index, QIcon(getPath("iconDir", "yeahdoc/flag/%s" % img))) Seeking.new().tabs.setTabText(index, title) self.setBufferon(False) Seeking().new().overlay.hidestop() else: pass self.baseUrl = getMyBaseUrl() + "yeahdoc-images/" + self.keepme().split("~")[0] self.__htmlWYSIWYG.setBaseUrl(self.baseUrl)
def download(self): """ download the image of the document """ self.save() Seeking.new().overlay.show() value = self.__htmlWYSIWYG.accessPoint().mainFrame().toHtml() number, value = downloadImages(value, self.baseUrl) if number != 0: self.__htmlWYSIWYG.fill(value) self.setBufferon(True) self.onbuffer() Seeking().new().overlay.hidestop()
def activate(): def _evt_list(): list_view = AdapterTodoList() list_view.execute("Todo List") sk = Seeking.new() sk.regAction( "__todolist", QAction(QIcon(getPath('iconDir', 'todo/todolist.png')), "Show the todo list", Seeking.new(), triggered=_evt_list)) toolbar = sk.addToolBar("TODOLIST") toolbar.addAction(sk.getAction("__todolist")) sk.getMenu("file").addAction(sk.getAction("__todolist")) sk.getMenu("file").addSeparator()
def __initData(self): """ If the `url` is supplied , I will read datas from db and render it otherwise , I just show a empty entry . and noramlly ,setHtml->"" to make it editable """ # setup The classlist for item in YeahdocDatasSupply().bc_list(): self.classlist.addItem(item['title'], item['id']) # the flag menu self.flagBtn = RichFlagButton(self) self.linelayout.insertWidget(0, self.flagBtn) # if not new . if self.keepme() and not self.keepme().startswith(":"): self.baseUrl = getMyBaseUrl() + "yeahdoc-images/" + self.keepme().split("~")[0] self.__htmlWYSIWYG.setBaseUrl(self.baseUrl) yeahdoc = YeahdocDatasSupply().bb_read1(self.keepme().split("~")[0]) content = yeahdoc['content'] if yeahdoc["lock"] == 1: password, ok = QInputDialog(self).getText(self, "", "", QLineEdit.Password, "") if ok: try: content = sk_decode(content, password) self.password1.setText(password) self.password2.setText(password) except: QMessageBox.warning(Seeking.new(), "error", "Error password") raise Exception else: raise Exception else: self.password1.setText("") self.password2.setText("") self.flagBtn.setIcon(QIcon(getPath("iconDir", "yeahdoc/flag/%s" % yeahdoc['img']))) self.flagBtn.setText(yeahdoc['img']) self.titleInput.setText(yeahdoc['title']) self.__htmlWYSIWYG.fill(content) # flag restore for i in range(self.classlist.count()): if self.classlist.itemData(i) == yeahdoc['categoryid']: self.classlist.setCurrentIndex(i) break else: self.titleInput.setText("") self.__htmlWYSIWYG.fill("")
def activate(): def _evt_help(self): """ Help event """ Help().execute(QApplication.translate("AboutSeeking", "Help"), QIcon(getPath("iconDir", 'help.png'))) def _evt_checkupdate(self): """ Check update """ Update().execute(QApplication.translate("AboutSeeking", "Check for Updates..."), QIcon(getPath("iconDir", 'help.png'))) def _evt_bug(self): """ Bug event """ Bug().execute(QApplication.translate("AboutSeeking", "Report bug"), QIcon(getPath("iconDir", 'help.png'))) def _evt_showversions(self): """ Show versions """ ShowVersions().execute(QApplication.translate("AboutSeeking", "Show Versions"), QIcon(getPath("iconDir", 'help.png'))) def _evt_aboutseeking(self): """ About Seeking """ About(Seeking.new()).show() sk = Seeking.new() sk.regAction("help", \ QAction(QIcon(getPath("iconDir", 'help.png')), QApplication.translate("AboutSeeking", "Help"), sk, triggered=_evt_help)) menu_about = sk.getMenu("help") menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "About Seeking"), sk, \ triggered=_evt_aboutseeking)) menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "About Qt"), sk, \ triggered=qApp.aboutQt)) menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "Show Versions"), sk, \ triggered=_evt_showversions)) menu_about.addSeparator() menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "Check for Updates..."), sk, \ triggered=_evt_checkupdate)) menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "Report bug"), sk, \ triggered=_evt_bug)) menu_about.addSeparator() menu_about.addAction(QAction(QApplication.translate("AboutSeeking", "What's This?"), sk, triggered=QWhatsThis.enterWhatsThisMode)) menu_about.addAction(sk.getAction("help"))
def activate(): def _evt_list(): list_view = AdapterTodoList() list_view.execute("Todo List") sk = Seeking.new() sk.regAction("__todolist", QAction(QIcon(getPath('iconDir', 'todo/todolist.png')), "Show the todo list", Seeking.new(), triggered=_evt_list)) toolbar = sk.addToolBar("TODOLIST") toolbar.addAction(sk.getAction("__todolist")) sk.getMenu("file").addAction(sk.getAction("__todolist")) sk.getMenu("file").addSeparator()
def activate(): def evt_adminscan(): Scanner() def evt_portscan(): PortScanner() sk = Seeking.new() sk.regAction( "__webadminscan", QAction(QIcon(getPath('pluginsDir', 'webscan/admin.png')), "Admin Scan", Seeking.new(), triggered=evt_adminscan)) sk.regAction( "__portscan", QAction(QIcon(getPath('pluginsDir', 'webscan/port.png')), "Port Scan", Seeking.new(), triggered=evt_portscan)) toolbar = sk.addToolBar("WebScan") toolbar.addAction(sk.getAction("__webadminscan")) toolbar.addAction(sk.getAction("__portscan"))
def activate(): """ used to make use of the plugin """ def __evt_new(): """ new yeahdoc evt """ yeahdoc = AdapterYeahdocItemViewerAndEditor(":new[Yeahdoc]") yeahdoc.setBufferon(True) yeahdoc.execute(":new[Yeahdoc]", QIcon(getPath('iconDir', 'yeahdoc/btn-new.png'))) def __evt_list(): """ show yeahdoc list """ yeahdoclist = AdapterMainYeahdocListView() yeahdoclist.execute(QApplication.translate("YeahdocList", "Yeahdoc"), QIcon(getPath('iconDir', 'yeahdoc/btn-list.png'))) # setup the mainwindow UI # New global action can be added to the list of global action sk = Seeking.new() sk.regAction("__yeahdoc_new", \ QAction(QIcon(getPath('iconDir', 'yeahdoc/btn-new.png')), \ QApplication.translate("YeahdocEditor", "New Yeahdoc"), sk, \ triggered=__evt_new)) sk.regAction("__yeahdoc_list", \ QAction(QIcon(getPath('iconDir', 'yeahdoc/btn-list.png')), \ QApplication.translate("YeahdocList", "Yeahdoc"), sk, \ triggered=__evt_list)) # set default shortcut sk.getAction("__yeahdoc_new").setShortcut(Prefs.new().getShortcut( "__yeahdoc_new", "Ctrl+N")) sk.getAction("__yeahdoc_list").setShortcut(Prefs.new().getShortcut( "__yeahdoc_list", "Ctrl+L")) # global toolbar toolbar = sk.addToolBar(QApplication.translate("Yeahdoc", "Yeahdoc")) toolbar.addAction(sk.getAction("__yeahdoc_new")) toolbar.addAction(sk.getAction("__yeahdoc_list")) # global menu sk.getMenu("file").addAction(sk.getAction("__yeahdoc_new")) sk.getMenu("file").addAction(sk.getAction("__yeahdoc_list")) sk.getMenu("file").addSeparator()
def __evt_password(self, setmode, password, repassword): """ set the password of the item. """ item = self.yeahdoclisttree.currentItem() if item and password: try: d = YeahdocDatasSupply().bb_read1(item.getMark())["content"] if setmode: if password == repassword: YeahdocDatasSupply().bb_lock(item.getMark(), password) QMessageBox.information(Seeking.new(), "Success", "%s Success" % QApplication.translate("YeahdocEditor", "Encrypt")) item.setIcon(3, QIcon(getPath("iconDir", "yeahdoc/lock.png"))) else: QMessageBox.warning(Seeking.new(), "error", "Not match") else: YeahdocDatasSupply().bb_unlock(item.getMark(), password) QMessageBox.information(Seeking.new(), "Success", "%s Success" % QApplication.translate("YeahdocEditor", "Decrypt")) item.setIcon(3, QIcon(None)) except Exception as e: raise e QMessageBox.warning(Seeking.new(), "error", "Error password")
def activate(): def evt_adminscan(): Scanner() def evt_portscan(): PortScanner() sk = Seeking.new() sk.regAction("__webadminscan", QAction(QIcon(getPath('pluginsDir', 'webscan/admin.png')), "Admin Scan", Seeking.new(), triggered=evt_adminscan)) sk.regAction("__portscan", QAction(QIcon(getPath('pluginsDir', 'webscan/port.png')), "Port Scan", Seeking.new(), triggered=evt_portscan)) toolbar = sk.addToolBar("WebScan") toolbar.addAction(sk.getAction("__webadminscan")) toolbar.addAction(sk.getAction("__portscan"))
def _evt_aboutseeking(self): """ About Seeking """ About(Seeking.new()).show()
def __evt_browser(self): directory = QFileDialog.getExistingDirectory(Seeking().new(), "Store Dir", self.config.getStoreDir(), QFileDialog.ShowDirsOnly) if directory: self.storedir.setText(directory)