def __init__(self, parent=None): super(KeyBoard, self).__init__(parent) self.setupUi(self) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.m_pDetailWidget = DetailWidget() self.m_pDetailWidget.signalText.connect(self.slot_text) self.btn_0.clicked.connect(self.on_btn_f0_clicked) self.btn_1.clicked.connect(self.on_btn_f1_clicked) self.btn_2.clicked.connect(self.on_btn_f2_clicked) self.btn_3.clicked.connect(self.on_btn_f3_clicked) self.btn_4.clicked.connect(self.on_btn_f4_clicked) self.btn_5.clicked.connect(self.on_btn_f5_clicked) self.btn_6.clicked.connect(self.on_btn_f6_clicked) self.btn_7.clicked.connect(self.on_btn_f7_clicked) self.btn_8.clicked.connect(self.on_btn_f8_clicked) self.btn_9.clicked.connect(self.on_btn_f9_clicked) # self.btn_Sym.clicked.connect(self.on_btn_sym_clicked) self.btn_Sma.clicked.connect(self.on_btn_sma_clicked) self.btn_Cap.clicked.connect(self.on_btn_cap_clicked) self.btn_Num.clicked.connect(self.on_btn_num_clicked) self.btn_Space.clicked.connect(self.on_btn_space_clicked) self.btn_Point.clicked.connect(self.on_btn_point_clicked) self.btn_Hide.clicked.connect(self.on_btn_hide_clicked) self.btn_Show.clicked.connect(self.on_btn_show_clicked) self.btn_Del.clicked.connect(self.on_btn_del_clicked) self.btn_Again.clicked.connect(self.on_btn_again_clicked) self.btn_Wrap.clicked.connect(self.on_btn_wrap_clicked) self.btn_Sure.clicked.connect(self.on_btn_sure_clicked)
def initUI(self): """ Initialize gui components. Create dock widgets. """ # self.resize(300, 300) self.setWindowTitle("UserPass Manager " + AppSettings.APP_VERSION) self.resize(1000, 600) self.center() # create main splitter, splits passwords table and gorups self._main_splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.setCentralWidget(self._main_splitter) # create groups widget with label, and groups groups_mw = QtGui.QWidget() groups_vl = QtGui.QVBoxLayout() groups_mw.setLayout(groups_vl) # create label groups_label = QtGui.QLabel("<b>" + tr("Groups") + "</b>") groups_vl.addWidget(groups_label) # create groups tree widget self._groups_tw = GroupsWidget(self) groups_vl.addWidget(self._groups_tw) self._main_splitter.addWidget(groups_mw) # create password central widget self._passwords_cw = QtGui.QWidget() self._main_splitter.addWidget(self._passwords_cw) self._main_splitter.setStretchFactor(1, 1) # create passwords layout, will contain passwords table and detail widget with spliter self._passwords_vl = QtGui.QVBoxLayout() self._passwords_cw.setLayout(self._passwords_vl) # add table widget self._passwords_table = PasswordsWidget(self) # create password and detail splitter self._passwd_splitter = QtGui.QSplitter(QtCore.Qt.Vertical) # create label passwdords_label = QtGui.QLabel("<b>" + tr("Passwords") + "</b>") self._passwords_vl.addWidget(passwdords_label) # add splitter to layout self._passwords_vl.addWidget(self._passwd_splitter) # create detail widget self._detail_w = DetailWidget(self, self._passwords_table._show_pass) # add widgets to splitter self._passwd_splitter.addWidget(self._passwords_table) self._passwd_splitter.addWidget(self._detail_w) # set stretch factor for password table self._passwd_splitter.setStretchFactor(0, 1)
class KeyBoard(QWidget, Ui_KeyBoard): signalShowText = QtCore.pyqtSignal(str) def __init__(self, parent=None): super(KeyBoard, self).__init__(parent) self.setupUi(self) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.m_pDetailWidget = DetailWidget() self.m_pDetailWidget.signalText.connect(self.slot_text) self.btn_0.clicked.connect(self.on_btn_f0_clicked) self.btn_1.clicked.connect(self.on_btn_f1_clicked) self.btn_2.clicked.connect(self.on_btn_f2_clicked) self.btn_3.clicked.connect(self.on_btn_f3_clicked) self.btn_4.clicked.connect(self.on_btn_f4_clicked) self.btn_5.clicked.connect(self.on_btn_f5_clicked) self.btn_6.clicked.connect(self.on_btn_f6_clicked) self.btn_7.clicked.connect(self.on_btn_f7_clicked) self.btn_8.clicked.connect(self.on_btn_f8_clicked) self.btn_9.clicked.connect(self.on_btn_f9_clicked) # self.btn_Sym.clicked.connect(self.on_btn_sym_clicked) self.btn_Sma.clicked.connect(self.on_btn_sma_clicked) self.btn_Cap.clicked.connect(self.on_btn_cap_clicked) self.btn_Num.clicked.connect(self.on_btn_num_clicked) self.btn_Space.clicked.connect(self.on_btn_space_clicked) self.btn_Point.clicked.connect(self.on_btn_point_clicked) self.btn_Hide.clicked.connect(self.on_btn_hide_clicked) self.btn_Show.clicked.connect(self.on_btn_show_clicked) self.btn_Del.clicked.connect(self.on_btn_del_clicked) self.btn_Again.clicked.connect(self.on_btn_again_clicked) self.btn_Wrap.clicked.connect(self.on_btn_wrap_clicked) self.btn_Sure.clicked.connect(self.on_btn_sure_clicked) # 鼠標事件 def mousePressEvent(self, event): global m_pPoint m_pPoint = event.globalPos() - self.pos() event.accept() # 鼠標事件 def mouseMoveEvent(self, event): self.move(event.globalPos() - m_pPoint) event.accept() # 鼠標事件 def enterEvent(self, event): self.setCursor(Qt.PointingHandCursor) event.accept() # 鼠標事件 def leaveEvent(self, event): self.setCursor(Qt.ArrowCursor) event.accept() # 0鍵 def on_btn_f0_clicked(self): global str_key global m_nType if m_nType == 1: str_key += "0" self.btn_Show.setText(str_key) elif m_nType == 2: str_key += " " self.btn_Show.setText(str_key) elif m_nType == 3: str_key += "△" self.btn_Show.setText(str_key) # 1鍵 def on_btn_f1_clicked(self): global str_key if m_nType == 1: str_key += "1" self.btn_Show.setText(str_key) elif m_nType == 2: qstr = ',;?;!;' strList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(strList) m_pPoint = self.btn_1.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "@" self.btn_Show.setText(str_key) #2鍵 def on_btn_f2_clicked(self): global str_key if m_nType == 1: str_key += "2" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'A;B;C;' else: qstr = 'a;b;c;' qList = qstr.split(';') print(qList) self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_2.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "%" self.btn_Show.setText(str_key) # 3鍵 def on_btn_f3_clicked(self): global str_key if m_nType == 1: str_key += "3" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'D;E;F;' else: qstr = 'd;e;f;' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_3.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "!" self.btn_Show.setText(str_key) # 4鍵 def on_btn_f4_clicked(self): global str_key if m_nType == 1: str_key += "4" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'G;H;I;' else: qstr = 'g;h;i;' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_4.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "+" self.btn_Show.setText(str_key) # 5鍵 def on_btn_f5_clicked(self): global str_key if m_nType == 1: str_key += "5" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'J;K;L;' else: qstr = 'j;k;l;' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_5.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "*" self.btn_Show.setText(str_key) # 6鍵 def on_btn_f6_clicked(self): global str_key if m_nType == 1: str_key += "6" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'O;M;N;' else: qstr = 'o;m;n;' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_6.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "√" self.btn_Show.setText(str_key) # 7鍵 def on_btn_f7_clicked(self): global str_key if m_nType == 1: str_key += "7" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'P;Q;R;S' else: qstr = 'p;q;r;s' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_7.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "-" self.btn_Show.setText(str_key) # 8鍵 def on_btn_f8_clicked(self): global str_key if m_nType == 1: str_key += "8" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'T;U;V;' else: qstr = 't;u;v;' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_8.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "/" self.btn_Show.setText(str_key) # 9鍵 def on_btn_f9_clicked(self): global str_key if m_nType == 1: str_key += "9" self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): qstr = 'W;X;Y;Z' else: qstr = 'w;x;y;z' qList = qstr.split(';') self.m_pDetailWidget.set_small_pad_text(qList) m_pPoint = self.btn_9.pos() + self.pos() self.m_pDetailWidget.move(m_pPoint.x(), m_pPoint.y() - 35) elif m_nType == 3: str_key += "×" self.btn_Show.setText(str_key) # 數字模式 def on_btn_num_clicked(self): global m_nType m_nType = 1 self.init_pad_text(1) self.btn_Space.setCheckable(False) self.btn_Space.setChecked(False) # 大寫 def on_btn_cap_clicked(self): global m_nType m_nType = 2 self.btn_Space.setCheckable(True) self.btn_Space.setChecked(True) self.init_pad_text(2) # 小寫 def on_btn_sma_clicked(self): global m_nType m_nType = 2 self.btn_Space.setCheckable(True) self.btn_Space.setChecked(False) self.init_pad_text(2) # 符號 def on_btn_sym_clicked(self): global m_nType m_nType = 3 self.init_pad_text(3) self.btn_Space.setCheckable(False) self.btn_Space.setChecked(False) # 回退 def on_btn_del_clicked(self): global str_key str_key = self.btn_Show.text() str_key = str_key[0:len(str_key) - 1] self.btn_Show.setText(str_key) # 清除 def on_btn_again_clicked(self): global str_key str_key = "" self.btn_Show.setText(str_key) # 換行 def on_btn_wrap_clicked(self): global str_key str_key += "\n" self.btn_Show.setText(str_key) # 關閉 def on_btn_hide_clicked(self): self.on_btn_again_clicked() self.hide() self.m_pDetailWidget.hide() # 顯示 def on_btn_show_clicked(self): global str_key self.signalShowText.emit(self.btn_Show.text()) str_key = "" self.btn_Show.setText("") # 空格 def on_btn_space_clicked(self): global str_key if m_nType == 1: str_key += " " self.btn_Show.setText(str_key) elif m_nType == 2: if self.btn_Space.isChecked(): self.on_btn_cap_clicked() else: self.on_btn_sma_clicked() else: str_key += " " self.btn_Show.setText(str_key) #點 def on_btn_point_clicked(self): global str_key str_key += "." self.btn_Show.setText(str_key) # 確定 def on_btn_sure_clicked(self): global str_key self.signalShowText.emit(self.btn_Show.text()) str_key = "" self.btn_Show.setText("") # 初始化鍵盤 def init_pad_text(self, m_type): if m_type == 1: qstr = '1;2;3;4;5;6;7;8;9;└┘;0' qList = qstr.split(';') self.set_pad_text(qList) elif m_type == 2: if self.btn_Space.isChecked(): qstr = ',?!;ABC;DEF;GHI;JKL;OMN;PQRS;TUV;WXYZ;shift;└┘' qList = qstr.split(';') self.set_pad_text(qList) else: qstr = ',?!;abc;def;ghi;jkl;omn;pqrs;tuv;wxyz;shift;└┘' qList = qstr.split(';') self.set_pad_text(qList) elif m_type == 3: qstr = '@;%;!;+;*;√;-;/;×;└┘;△' qList = qstr.split(';') self.set_pad_text(qList) # 設置鍵盤字符 def set_pad_text(self, strlist): self.btn_1.setText(strlist[0]) self.btn_2.setText(strlist[1]) self.btn_3.setText(strlist[2]) self.btn_4.setText(strlist[3]) self.btn_5.setText(strlist[4]) self.btn_6.setText(strlist[5]) self.btn_7.setText(strlist[6]) self.btn_8.setText(strlist[7]) self.btn_9.setText(strlist[8]) self.btn_Space.setText(strlist[9]) self.btn_0.setText(strlist[10]) # 接收小鍵盤數據 def slot_text(self, str_text): global str_key str_key += str_text self.btn_Show.setText(str_key)
class MainWindow(QtGui.QMainWindow): """ MainWindow class represents main window. """ # public attr: _db_ctrl = None def __init__(self, db_ctrl, user = None): self._db_ctrl = db_ctrl self._user = user super(MainWindow, self).__init__() self._close_act = None self.initUI() self.createActions() self.createMenu() self.initConections() def closeEvent(self, event): """ Do matters on close event. In example delete clipboard. """ logging.debug("deleting clipboard") QtGui.QApplication.clipboard().clear() try: logging.info("removing tmp dir: '%s'", AppSettings.TMP_PATH) # remove tmp files shutil.rmtree(AppSettings.decodePath(AppSettings.TMP_PATH)) except Exception as e: logging.exception(e) InfoMsgBoxes.showErrorMsg(e) def initUI(self): """ Initialize gui components. Create dock widgets. """ # self.resize(300, 300) self.setWindowTitle("UserPass Manager " + AppSettings.APP_VERSION) self.resize(1000, 600) self.center() # create main splitter, splits passwords table and gorups self._main_splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.setCentralWidget(self._main_splitter) # create groups widget with label, and groups groups_mw = QtGui.QWidget() groups_vl = QtGui.QVBoxLayout() groups_mw.setLayout(groups_vl) # create label groups_label = QtGui.QLabel("<b>" + tr("Groups") + "</b>") groups_vl.addWidget(groups_label) # create groups tree widget self._groups_tw = GroupsWidget(self) groups_vl.addWidget(self._groups_tw) self._main_splitter.addWidget(groups_mw) # create password central widget self._passwords_cw = QtGui.QWidget() self._main_splitter.addWidget(self._passwords_cw) self._main_splitter.setStretchFactor(1, 1) # create passwords layout, will contain passwords table and detail widget with spliter self._passwords_vl = QtGui.QVBoxLayout() self._passwords_cw.setLayout(self._passwords_vl) # add table widget self._passwords_table = PasswordsWidget(self) # create password and detail splitter self._passwd_splitter = QtGui.QSplitter(QtCore.Qt.Vertical) # create label passwdords_label = QtGui.QLabel("<b>" + tr("Passwords") + "</b>") self._passwords_vl.addWidget(passwdords_label) # add splitter to layout self._passwords_vl.addWidget(self._passwd_splitter) # create detail widget self._detail_w = DetailWidget(self, self._passwords_table._show_pass) # add widgets to splitter self._passwd_splitter.addWidget(self._passwords_table) self._passwd_splitter.addWidget(self._detail_w) # set stretch factor for password table self._passwd_splitter.setStretchFactor(0, 1) def setUserReloadShow(self, username, master): """ Load user from database and reload items. """ user_ctrl = UserController(self._db_ctrl) username = str(username.toUtf8()) master = str(master.toUtf8()) self._user = user_ctrl.selectByNameMaster(username, master) if (self._user): self.reloadItems() else: logging.error("something wrong, can't log in user.") self.show() def initConections(self): """ Initialize all connections, handling events. @requires: initUI() first """ # create connection to update table view self._groups_tw.signalGroupSelChanged.connect(self._passwords_table.showPasswords) self._groups_tw.signalGroupSelChanged.connect(self._detail_w.handleTypePassword) self._passwords_table.signalShowDetailPasswd.connect(self._detail_w.setPassword) # show edit passwd dialog self._passwords_table.signalEditPasswd.connect(self.showEditPasswdDialog) self._groups_tw.signalEditPasswd.connect(self.showEditPasswdDialog) # enable/disable delete action, depends on selection type in tree widget self._groups_tw.signalGroupSelChanged.connect(self.enDisPassGrpActions) # enable/disable delete action with selection password talbe self._passwords_table.signalSelChangedTypeId.connect(self.enDisPassGrpActions) def createActions(self): """ Initialize all actions, i.e. Close, Save etc. """ # init close self._close_act = QtGui.QAction(tr("&Close"), self) self._close_act.setShortcuts(QtGui.QKeySequence.Close) self._close_act.setToolTip(tr("Close application")) # connect to slot self._close_act.triggered.connect(QtCore.QCoreApplication.instance().quit) # init about action self._about_act = QtGui.QAction(tr("About"), self) self._about_act.setToolTip(tr("About UserPass Manager")) self._about_act.triggered.connect(self.aboutDialog) # new password action self._new_passwd = QtGui.QAction(tr("New"), self) self._new_passwd.setShortcuts(QtGui.QKeySequence.New) self._new_passwd.setToolTip(tr("Add new password to DB")) self._new_passwd.triggered.connect(self.showNewPasswdDialog) # displayed in groups tree self._new_passwd_g = QtGui.QAction(tr("New password"), self) self._new_passwd_g.setToolTip(tr("Add new password to DB")) self._new_passwd_g.triggered.connect(self.showNewPasswdDialog) # delete password action self._del_passwd = QtGui.QAction(tr("Delete"), self) self._del_passwd.setShortcuts(QtGui.QKeySequence.Delete) self._del_passwd.setToolTip(tr("Delete password from DB")) self._del_passwd.setDisabled(True) self._del_passwd.triggered.connect(self.deletePassword) # displayed in groups tree self._del_passwd_g = QtGui.QAction(tr("Delete password"), self) self._del_passwd_g.setToolTip(tr("Delete password from DB")) self._del_passwd_g.setDisabled(True) self._del_passwd_g.triggered.connect(self.deletePassword) # new group action self._new_group = QtGui.QAction(tr("New"), self) self._new_group.setToolTip(tr("Add new group to DB")) self._new_group.triggered.connect(self.showNewGroupDialog) # new group action in groups tree right click menu self._new_group_g = QtGui.QAction(tr("New group"), self) self._new_group_g.setToolTip(tr("Add new group to DB")) self._new_group_g.triggered.connect(self.showNewGroupDialog) # edit group action self._edit_group = QtGui.QAction(tr("Edit"), self) self._edit_group.setToolTip(tr("Edit selected group")) self._edit_group.setDisabled(True) self._edit_group.triggered.connect(self.showEditGroupDialog) # edit group action in groups tree right click menu self._edit_group_g = QtGui.QAction(tr("Edit group"), self) self._edit_group_g.setToolTip(tr("Edit selected group")) self._edit_group_g.setDisabled(True) self._edit_group_g.triggered.connect(self.showEditGroupDialog) # delete group in groups tree self._del_group = QtGui.QAction(tr("Delete"), self) self._del_group.setToolTip(tr("Delete group from DB")) self._del_group.setDisabled(True) self._del_group.triggered.connect(self.deleteGroup) # delete group displayed in groups tree self._del_group_g = QtGui.QAction(tr("Delete group"), self) self._del_group_g.setToolTip(tr("Delete group from DB")) self._del_group_g.setDisabled(True) self._del_group_g.triggered.connect(self.deleteGroup) # add to table actions self._passwords_table.addAction(self._new_passwd) self._passwords_table.addAction(self._del_passwd) # add to groups tree actions self._groups_tw.addAction(self._new_passwd_g) self._groups_tw.addAction(self._del_passwd_g) self._groups_tw.addAction(self._new_group_g) self._groups_tw.addAction(self._edit_group_g) self._groups_tw.addAction(self._del_group_g) def enDisPassGrpActions(self, item_type, item_id): """ Disable delete password action. """ if (item_type == self._groups_tw._TYPE_PASS): self._del_passwd.setEnabled(True) self._del_passwd_g.setEnabled(True) else: self._del_passwd.setEnabled(False) self._del_passwd_g.setEnabled(False) if (item_type == self._groups_tw._TYPE_GROUP): self._del_group.setEnabled(True) self._del_group_g.setEnabled(True) self._edit_group.setEnabled(True) self._edit_group_g.setEnabled(True) else: self._del_group.setEnabled(False) self._del_group_g.setEnabled(False) self._edit_group.setEnabled(False) self._edit_group_g.setEnabled(False) def createMenu(self): """ Initialize menu, add actions to menu. """ # create menu bar menubar = QtGui.QMenuBar() self.setMenuBar(menubar) # create menu options and add actions file_menu = self.menuBar().addMenu(tr("&File")) file_menu.addAction(self._close_act) password_menu = self.menuBar().addMenu(tr("Password")) password_menu.addAction(self._new_passwd) password_menu.addAction(self._del_passwd) group_menu = self.menuBar().addMenu(tr("Group")) group_menu.addAction(self._new_group) group_menu.addAction(self._edit_group) group_menu.addAction(self._del_group) settings_menu = self.menuBar().addMenu(tr("Settings")) about_menu = self.menuBar().addMenu(tr("About")) about_menu.addAction(self._about_act) def center(self): """ Center window. """ # get frame geometry wg = self.frameGeometry() # get screen center cs = QtGui.QDesktopWidget().availableGeometry().center() wg.moveCenter(cs) self.move(wg.topLeft()) def aboutDialog(self): QtGui.QMessageBox(QtGui.QMessageBox.Information, tr("About"), tr("ABOUT_TEXT_1") + " " + AppSettings.APP_VERSION + "\n" + tr("ABOUT_TEXT_2") + """ MIT License Copyright (c) 2013-2016 Frantisek Uhrecky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.""").exec_() def showEditPasswdDialog(self, p_id): """ Show edit password dialog. @param p_id: password id to edit """ edit_dialog = EditPasswdDialog(self, p_id, self._passwords_table._show_pass) edit_dialog.signalPasswdSaved.connect(self.reloadItems) edit_dialog.exec_() def showNewPasswdDialog(self): """ Password dialog to add new password. """ new_pass_dialog = NewPasswdDialog(self, self._groups_tw.currentItemGroupID(), self._passwords_table._show_pass) if (new_pass_dialog.exec_() == QtGui.QDialog.Accepted): # all done self.reloadItems() def showNewGroupDialog(self): """ Group dialog to add new password. """ new_group_dialog = NewGroupDialog(self) if (new_group_dialog.exec_() == QtGui.QDialog.Accepted): # all done self.reloadItems() def deletePassword(self): """ Delete password from database. """ # frist check tree widget title = self._groups_tw.currentPasswordTitle() p_id = self._groups_tw.currentPasswordId() # also chck in table widget if (not title): title = self._passwords_table.currentItemTitle() p_id = self._passwords_table.currentItemID() logging.debug("delete password title: %s, ID: %i", title, p_id) if (title != False): msg = QtGui.QMessageBox(QtGui.QMessageBox.Question, title ,tr("Do you want delete password '") + title + "'?") msg.addButton(QtGui.QMessageBox.Yes) msg.addButton(QtGui.QMessageBox.No) ret = msg.exec_() if (ret == QtGui.QMessageBox.Yes): # delete password self._passwords_table.deletePassword(p_id) self.reloadItems() logging.debug("Not password selected title: %s", title) def deleteGroup(self): """ Delete group from database and also all passwords in this group, if foreign key are enabled. """ # frist check tree widget title = self._groups_tw.currentItemGroupName() g_id = self._groups_tw.currentItemGroupID() logging.debug("delete group title: %s, ID: %i", title, g_id) if (title != False): msg = QtGui.QMessageBox(QtGui.QMessageBox.Question, title ,tr("Do you want delete group '") + title + "' and also containing passwords?") msg.addButton(QtGui.QMessageBox.Yes) msg.addButton(QtGui.QMessageBox.No) ret = msg.exec_() if (ret == QtGui.QMessageBox.Yes): # delete password self._groups_tw.deleteGroup(g_id) self.reloadItems() logging.debug("Not group selected title: %s", title) def showEditGroupDialog(self): """ Edit selected group. """ g_id = self._groups_tw.currentItemGroupID() if (g_id): # is group selected edit_group_dialog = EditGroupDialog(self, g_id) if (edit_group_dialog.exec_() == QtGui.QDialog.Accepted): # all done self.reloadItems() def reloadItems(self, p_id = -1): """ Reload groups, passwords. @param p_id: password id to display, if is < 0, doesn't display """ try: self._groups_tw.reloadItems() self._passwords_table.reloadItems() if (p_id >= 0): self._detail_w.setPassword(p_id) else: self._detail_w.setHidden(True) except Exception as e: logging.exception(e) InfoMsgBoxes.showErrorMsg(e)