Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
   def initItemData(self, icon, name, item_id, tooltip, item_type, item_grp_id):
       """
           Initialize item data.
           
           @param icon: item icon data
           @param name: item name
           @param item_id: item group
           @param tooltip: tooltip string
           @param item_type: item type (pass, group, all)
           
           @return: QTreeWidgetItem object
       """
       item = QtGui.QTreeWidgetItem()
       
       # load image to display mode
       pix = QtGui.QPixmap()
       pix.loadFromData(icon)
 
       item.setIcon(self.__COL_ICON, QtGui.QIcon(pix))
       item.setText(self.__COL_NAME, QtCore.QString.fromUtf8(tr(name)))
       item.setData(self.__COL_NAME, QtCore.Qt.ToolTipRole, QtCore.QString.fromUtf8(tr(tooltip)))
       item.setData(self.__COL_ID, QtCore.Qt.DisplayRole, item_id)
       item.setData(self.__COL_TYPE, QtCore.Qt.DisplayRole, item_type)
       item.setData(self.__COL_GRP_ID, QtCore.Qt.DisplayRole, item_grp_id)
       
       return item
Ejemplo n.º 3
0
 def initUi(self):
     """
         Initialize UI components.
     """
     SaveDialog.initUi(self)
     
     logging.info("initializing UI components.")
     
     # create lables
     name_label = QtGui.QLabel("<b>" + tr("Name:") + "</b>")
     description_label = QtGui.QLabel("<b>" + tr("Description:") + "</b>")
     icon_label = QtGui.QLabel("<b>" + tr("Icon:") + "</b>")
     
     self._layout_gl.addWidget(name_label, 0, 0)
     self._layout_gl.addWidget(description_label, 1, 0)
     self._layout_gl.addWidget(icon_label, 2, 0)
     
     # create inputs
     self._name = QtGui.QLineEdit()
     self._desc = QtGui.QLineEdit()
     self._icons = QtGui.QComboBox()
     
     self._layout_gl.addWidget(self._name, 0, 1)
     self._layout_gl.addWidget(self._desc, 1, 1)
     self._layout_gl.addWidget(self._icons, 2, 1)
Ejemplo n.º 4
0
 def getTableColumns():
     """
         Return minimum table columns.
         
         @return: list of column names
     """
     return [tr("Title"), tr("Username"), tr("Password"), tr("Url")]
Ejemplo n.º 5
0
 def initUi(self):
     """
         Initialize Ui components.
     """
     # not maximize, minimize buttons
     self.setWindowFlags(QtCore.Qt.Tool);
     
     main_layout = QtGui.QVBoxLayout()
     self.setLayout(main_layout)
 
     # create grid layout
     self._layout_gl = QtGui.QGridLayout()
     
     main_layout.addLayout(self._layout_gl)
     
     # create buttons
     self.__button_box = QtGui.QDialogButtonBox()
     
     self.__save_button = QtGui.QPushButton(tr("&Save"))
     self.__save_button.setEnabled(False)
     
     self.__cancel_button = QtGui.QPushButton(tr("&Cancel"))
     
     self.__button_box.addButton(self.__save_button, QtGui.QDialogButtonBox.AcceptRole)
     self.__button_box.addButton(self.__cancel_button, QtGui.QDialogButtonBox.RejectRole)
     
     main_layout.addWidget(self.__button_box, 0, QtCore.Qt.AlignRight)
Ejemplo n.º 6
0
 def getVisibleColumns():
     """
         Return visible table columns.
         
         @return: list of column names
     """
     return [tr("Title"), tr("Username"), tr("Password"), tr("Url"), tr("Comment"), 
             tr("C. Date"), tr("M. Date"), tr("E. Date"), tr("Group"), tr("Att. Name"), tr("Expire")]
Ejemplo n.º 7
0
 def setGroup(self):
     """
         Set loaded group to inputs.
     """
     # set names
     self._name.setText(QtCore.QString.fromUtf8(tr(self.__group._name)))
     self._desc.setText(QtCore.QString.fromUtf8(tr(self.__group._description)))
     
     # load icons and set current icon
     self.loadIcons(self.__group._icon._id)
Ejemplo n.º 8
0
    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_()
Ejemplo n.º 9
0
 def initUI(self):
     """
         Initilize UI components.
     """
     layout_gl = QtGui.QGridLayout()
     self.setLayout(layout_gl)
     
     title_label = QtGui.QLabel("<b>" + tr("Title:") + "</b>")
     username_label = QtGui.QLabel("<b>" + tr("Username:"******"</b>")
     passwd_label = QtGui.QLabel("<b>" + tr("Password:"******"</b>")
     url_label = QtGui.QLabel("<b>" + tr("URL:")  + "</b>")
     c_date_label = QtGui.QLabel("<b>" + tr("Creation date:") + "</b>")
     m_date_label = QtGui.QLabel("<b>" + tr("Modification date:") + "</b>")
     e_date_label = QtGui.QLabel("<b>" + tr("Expiration date:") + "</b>")
     comment_label = QtGui.QLabel("<b>" + tr("Comment:") + "</b>")
     attachment_label = QtGui.QLabel("<b>" + tr("Attachment:") + "</b>")
     
     layout_gl.addWidget(title_label, 0, 0)
     layout_gl.addWidget(username_label, 1, 0)
     layout_gl.addWidget(passwd_label, 2, 0)
     layout_gl.addWidget(url_label, 3, 0)
     layout_gl.addWidget(c_date_label, 0, 2)
     layout_gl.addWidget(m_date_label, 1, 2)
     layout_gl.addWidget(e_date_label, 2, 2)
     layout_gl.addWidget(attachment_label, 4, 0)
     layout_gl.addWidget(comment_label, 5, 0)
     
     self.__title = QtGui.QLabel()
     self.__username = QtGui.QLabel()
     self.__passwd = QtGui.QLabel()
     self.__url = QtGui.QLabel()
     self.__c_date = QtGui.QLabel()
     self.__m_date = QtGui.QLabel()
     self.__e_date = QtGui.QLabel()
     self.__comment = QtGui.QTextEdit()
     self.__comment.setLineWrapMode(QtGui.QTextEdit.NoWrap)
     self.__comment.setMaximumHeight(100)
     self.__comment.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
     
     self.__attachment = QtGui.QLabel()
     
     layout_gl.addWidget(self.__title, 0, 1)
     layout_gl.addWidget(self.__username, 1, 1)
     layout_gl.addWidget(self.__passwd, 2, 1)
     layout_gl.addWidget(self.__url, 3, 1, 1, 3)
     layout_gl.addWidget(self.__c_date, 0, 3)
     layout_gl.addWidget(self.__m_date, 1, 3)
     layout_gl.addWidget(self.__e_date, 2, 3)
     layout_gl.addWidget(self.__attachment, 4, 1)
     layout_gl.addWidget(self.__comment, 5, 1, 1, 3)
     
     layout_gl.setColumnStretch(1, 1)
     layout_gl.setColumnStretch(3, 1)
     
     # hide, it is none passwd clicked
     self.setHidden(True)
Ejemplo n.º 10
0
 def enLogIn(self, b = True):
     """
         Enable or disable password input, show checkbox and login button.
     """
     logging.debug("enabling login: %s", b)
     
     self._passwd.setEnabled(b)
     self._show_passwd_check.setEnabled(b)
     self.__login_button.setEnabled(b)
     
     if (not b):
         self.setWindowTitle(tr("Database not selected."))
     else:
         self.setWindowTitle(tr("Log in: ") + QtCore.QString.fromUtf8(os.path.basename(AppSettings.readDbFilePath())))
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
 def initUi(self):
     """
         Initialize UI.
     """
     GroupDialog.initUi(self)
     
     self.setWindowTitle(QtCore.QString.fromUtf8(tr("Edit group")) + ": " + QtCore.QString.fromUtf8(tr(self.__group._name)))
Ejemplo n.º 13
0
 def logIn(self):
     """
         Read input lines and login user if possible.
     """
     logging.debug("logging user ...")
     
     try:
         path = AppSettings.readDbFilePath()
         self.__db_ctrl.connectDB(path)
         
         login_ctrl = LoginController(self.__db_ctrl)
         
         username = AppSettings.USER_NAME
         master = str(self._passwd.text().toUtf8())
         
         logged_user = login_ctrl.logInUser(username, master)
         
         if (logged_user):
             self.signalSuccessfullyLogged.emit(QtCore.QString.fromUtf8(username), QtCore.QString.fromUtf8(master))
             
             self.close()
         else:
             # sleep for a while
             time.sleep(AppSettings.WRONG_PASWD_SLEEP)
             
             # show message
             QtGui.QMessageBox(QtGui.QMessageBox.Critical, tr("Wrong credentials!"), tr("Username or password are wrong.")).exec_()
     except Exception as e:
         InfoMsgBoxes.showErrorMsg(e)
Ejemplo n.º 14
0
 def loadAttachment(self):
     """
         Exec filedialog, open file and get absolute file path and name.
     """
     try:
         home_loc = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.HomeLocation)
         file_path = QtGui.QFileDialog.getOpenFileName(self, tr("Open attachment"), home_loc)
         
         if (not file_path.isEmpty()):
             file_path = str(file_path.toUtf8())
             file_name = os.path.basename(file_path)
             
             logging.info("attachment file path: %s", file_path)
             logging.info("attachment file name: %s", file_name)
             
             # set attachment name
             self._att_name.setText(QtCore.QString.fromUtf8(file_name))
             
             # read binary data
             data = self.readFile(file_path)
             
             if (data):
                 self._attachment_data = data
                 self.enableSaveButton()
         else:
             logging.debug("file not selected")
     except Exception as e:
         logging.exception(e)
         
         InfoMsgBoxes.showErrorMsg(e)
Ejemplo n.º 15
0
 def initUi(self):
     """
         Initialize UI components
     """
     # first call parent initialization.
     GroupDialog.initUi(self)
     
     self.setWindowTitle(tr("Add new group"))
Ejemplo n.º 16
0
 def openAttachment(self):
     """
         Open attachment using desktop services.
     """
     try:
         tmp_file = AppSettings.TMP_PATH + str(self._att_name.text().toUtf8())
         logging.info("saving attachment to tmp file: '%s'", tmp_file)
         
         self.writeFile(tmp_file)
         
         if (not QtGui.QDesktopServices.openUrl(QtCore.QUrl.fromLocalFile(QtCore.QString.fromUtf8(tmp_file)))):
             # not succesfully opened
             QtGui.QMessageBox(QtGui.QMessageBox.Information, tr("Something wrong!"), tr("Can't open file '") + QtCore.QString.fromUtf8(tmp_file) + "\n" + 
                               tr("Save it to disk and open with selected program.")).exec_()
     except Exception as e:
         logging.exception(e)
         
         InfoMsgBoxes.showErrorMsg(e)
Ejemplo n.º 17
0
 def checkVersion(self):
     """
         Check opened database version, if neccessaary and posible, then convert to current.
     """
     version = self.getAppDBVersion()
     
     if ((version == False) or (version < AppSettings.APP_DB_VERSION)):
         # need to be converted
         logging.info("need to convert from version: '%s'", version)
         converter = ConvertDb(self)
         
         converter.convertDbToV1(self._database)
         
         InfoMsgBoxes.showInfoMsg(tr("Database successfully converted to new version."))
Ejemplo n.º 18
0
 def initItems(self):
     """
         Initialize groups tree items. Load items from DB.
     """
     logging.debug("Adding items to tree.")
     group_ctrl = GroupController(self.__parent._db_ctrl)
     passwd_ctrl = PasswdController(self.__parent._db_ctrl, self.__parent._user._master)
     icon_ctrl = IconController(self.__parent._db_ctrl)
     
     groups = group_ctrl.selectAll()
     
     # group, that contains all passwords
     all_group = self.initItemData(icon_ctrl.selectByName("userpass")._icon, 
                                   tr("All"), -1, tr("All passwords group."), self._TYPE_ALL, -1)
     self.addTopLevelItem(all_group)
     
     # add cildren, all passwords to group all
     passwords = passwd_ctrl.selectByUserId(self.__parent._user._id)
     
     for passwd in passwords:
         child = self.initItemData(passwd._grp._icon._icon, passwd._title, passwd._id, passwd._comment, self._TYPE_PASS, passwd._grp._id)
         
         all_group.addChild(child)
     
     # insert groups to tree
     for group in groups:
         item = self.initItemData(group._icon._icon, tr(group._name), group._id, group._description, self._TYPE_GROUP, group._id)
         
         self.addTopLevelItem(item)
         
         # add cildren, all passwords to group all
         passwords = passwd_ctrl.selectByUserGrpId(self.__parent._user._id, group._id)
         
         for passwd in passwords:
             child = self.initItemData(passwd._grp._icon._icon, passwd._title, passwd._id, passwd._comment, self._TYPE_PASS, passwd._grp._id)
         
             item.addChild(child)
Ejemplo n.º 19
0
 def selectDB(self):
     """
         Select database file.
     """
     dir_path = AppSettings.APP_ABS_ROOT + AppSettings.DEFAULT_DB
     file_path = QtGui.QFileDialog.getOpenFileName(self, tr("Select database"), QtCore.QString.fromUtf8(dir_path))
     
     if (not file_path.isEmpty()):
         db_path = str(file_path.toUtf8())
         
         logging.debug("database file path: %s", db_path)
         
         # write to setting file
         AppSettings.writeDbFilePath(db_path)
         
         self.enLogIn()
     else:
         logging.debug("database not selected")
Ejemplo n.º 20
0
 def selectFile(self):
     """
         Select DB file.
     """
     dir_path = AppSettings.APP_ABS_ROOT + AppSettings.DEFAULT_DB
     
     file_path = QtGui.QFileDialog.getSaveFileName(self, tr("Save DB file"), QtCore.QString.fromUtf8(dir_path))
     
     logging.debug("save db to file: %s", file_path)
     
     if (not file_path.isEmpty()):
         file_path = str(file_path.toUtf8())
         logging.debug("db file path: %s", file_path)
         
         self._db_file_path.setText(QtCore.QString.fromUtf8(file_path))
         
         if (os.path.exists(file_path)):
             logging.debug("removing existing file: '%s'", file_path)
             os.remove(file_path)
     else:
         logging.debug("db file not selected")
Ejemplo n.º 21
0
 def loadIcons(self, i_id = False):
     """
         Load icons from DB to combobox. If is set i_id seti as current.
         
         @param i_id: current icon ID
     """
     # set groups combobox
     icon_ctrl = IconController(self.__db_ctrl)
     
     icons = icon_ctrl.selectAll()
     # tmp index
     tmp = 0
     # have to increment tmp
     inc_tmp = True
     
     # fill combobox
     for icon in icons:
         logging.info("adding icon ID: %d", icon._id)
         
         # load icon
         pix = QtGui.QPixmap()
         pix.loadFromData(icon._icon)
         
         # add item with icon, name and icon ID
         self._icons.addItem(QtGui.QIcon(pix), tr(icon._name), icon._id)
         
         if (i_id):
             # if a dont have curent index
             if (icon._id != i_id and inc_tmp):
                 tmp += 1
                 
                 logging.info("temp icon index: %d, icon._id: %d, i_id: %d", tmp, icon._id, i_id)
             else:
                 if inc_tmp:
                     logging.info("icon found")
                     inc_tmp = False
     # set current group
     if (i_id):
         self._icons.setCurrentIndex(tmp)
Ejemplo n.º 22
0
 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)
Ejemplo n.º 23
0
 def loadGroups(self, g_id = False):
     """
         Load available groups to combobox
     """
     # set groups combobox
     group_ctrl = GroupController(self.__db_ctrl)
     
     groups = group_ctrl.selectAll()
     # tmp index
     tmp = 0
     # have to increment tmp
     inc_tmp = True
     
     # fill combobox
     for group in groups:
         logging.info("adding group ID: %d", group._id)
         
         # load icon
         pix = QtGui.QPixmap()
         pix.loadFromData(group._icon._icon)
         
         # add item with icon, name and group ID
         self._group.addItem(QtGui.QIcon(pix), tr(group._name), group._id)
         
         if (g_id):
             # if a dont have curent group
             if (group._id != g_id and inc_tmp):
                 tmp += 1
                 
                 logging.info("temp group index: %d, group._id: %d, g_id: %d", tmp, group._id, g_id)
             else:
                 if inc_tmp:
                     logging.info("group found")
                     inc_tmp = False
     # set current group
     if (g_id):
         self._group.setCurrentIndex(tmp)
Ejemplo n.º 24
0
 def setPassword(self, p_id):
     """
         Show password detail with id p_id.
         
         @param p_id: password ID
     """
     logging.debug("password details ID: %i", p_id)
     
     passwd_ctrl = PasswdController(self.__parent._db_ctrl, self.__parent._user._master)
     
     # select password
     passwd = passwd_ctrl.selectById(p_id)[0]
     
     if (not passwd):
         return
     
     self.__title.setText(QtCore.QString.fromUtf8(passwd._title))
     
     if (self._show_pass):
         self.__username.setText(QtCore.QString.fromUtf8(passwd._username))
         self.__passwd.setText(QtCore.QString.fromUtf8(passwd._passwd))
     else:
         self.__username.setText("******")
         self.__passwd.setText("******")
     self.__url.setText(QtCore.QString.fromUtf8(passwd._url))
     self.__c_date.setText(str(datetime.datetime.fromtimestamp(passwd._c_date).strftime("%Y-%m-%d %H:%M:%S")))
     self.__m_date.setText(str(datetime.datetime.fromtimestamp(passwd._m_date).strftime("%Y-%m-%d %H:%M:%S")))
     
     if (passwd._expire == "false"):
         self.__e_date.setText(tr("Never"))
     else:
         self.__e_date.setText(str(datetime.datetime.fromtimestamp(passwd._e_date).strftime("%Y-%m-%d %H:%M:%S")))
     self.__comment.setText(QtCore.QString.fromUtf8(passwd._comment))
     self.__attachment.setText(QtCore.QString.fromUtf8(passwd._att_name))
     
     # now show details
     self.setHidden(False)
Ejemplo n.º 25
0
 def saveAttachment(self):
     """
         Save attachment to disk.
     """
     try:
         home_loc = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.HomeLocation)
         home_loc = QtCore.QString.fromUtf8(home_loc + os.path.sep)
         home_loc.append(self._att_name.text())
         file_path = QtGui.QFileDialog.getSaveFileName(self, tr("Open attachment"), home_loc)
         
         logging.info("save attachment to file: %s", file_path)
         
         if (not file_path.isEmpty()):
             file_path = str(file_path.toUtf8())
             logging.info("attachment file path: %s", file_path)
             
             # write data to disk
             self.writeFile(file_path)
         else:
             logging.info("file not selected")
     except Exception as e:
         logging.exception(e)
         
         InfoMsgBoxes.showErrorMsg(e)
Ejemplo n.º 26
0
 def initUI(self):
     """
         Initialize UI components.
     """
     self.setWindowTitle(tr("Create Database"))
     self.setFixedSize(500, 150)
     
     # create main grid layout
     layout_gl = QtGui.QGridLayout()
     self.setLayout(layout_gl)
     
     # labels
     db_path_label = QtGui.QLabel("<b>" + tr("DB file path:") + "</b>")
     layout_gl.addWidget(db_path_label, 0, 0)
     
     passwd_label = QtGui.QLabel("<b>" + tr("New master password:"******"</b>")
     layout_gl.addWidget(passwd_label, 1, 0)
 
     # db line edit
     self._db_file_path = QtGui.QLineEdit()
 
     db_layout_hl = QtGui.QHBoxLayout()
     db_layout_hl.addWidget(self._db_file_path)
     
     # select file button
     self._select_db_button = QtGui.QPushButton(tr("Select file"))
     db_layout_hl.addWidget(self._select_db_button)
 
     layout_gl.addLayout(db_layout_hl, 0, 1)
     
     # password edit line
     self._passwd = QtGui.QLineEdit()
     
     # hide password
     self._passwd.setEchoMode(QtGui.QLineEdit.Password)
     
     # password layout
     passwd_hl = QtGui.QHBoxLayout()
     
     # add password edit line to layout
     passwd_hl.addWidget(self._passwd)
     
     # password visibility check box
     self._show_passwd_check = QtGui.QCheckBox(tr("Show"))
     self._show_passwd_check.setChecked(False)
     passwd_hl.addWidget(self._show_passwd_check)
     
     layout_gl.addLayout(passwd_hl, 1, 1)
     
     # create buttons
     self._button_box = QtGui.QDialogButtonBox()
     
     self.__create_button = QtGui.QPushButton(tr("&Create"))
     self.__create_button.setEnabled(False)
     
     self.__close_button = QtGui.QPushButton(tr("&Close"))
     
     self._button_box.addButton(self.__create_button, QtGui.QDialogButtonBox.AcceptRole)
     self._button_box.addButton(self.__close_button, QtGui.QDialogButtonBox.RejectRole)
     
     layout_gl.addWidget(self._button_box, 2, 1)
     
     # db button box
     self._db_button_box = QtGui.QDialogButtonBox()
 
     self.__open_db = QtGui.QPushButton(tr("Open Database"))
     self.__create_db = QtGui.QPushButton(tr("Create Database"))
Ejemplo n.º 27
0
    def initUI(self):
        """
            Initialize UI components.
        """
        self.setWindowTitle(tr("Log in: ") + QtCore.QString.fromUtf8(os.path.basename(AppSettings.readDbFilePath())))
        self.setFixedSize(500, 100)
        
        # create main grid layout
        layout_gl = QtGui.QGridLayout()
        self.setLayout(layout_gl)
        
        # labels
#         username_label = QtGui.QLabel("<b>" + tr("Username:"******"</b>")
        passwd_label = QtGui.QLabel("<b>" + tr("Password:"******"</b>")
        
        # add to layout
#         layout_gl.addWidget(username_label, 0, 0)
        layout_gl.addWidget(passwd_label, 0, 0)
        
#         self._username = QtGui.QLineEdit()
#         layout_gl.addWidget(self._username, 0, 1)
        
        self._passwd = QtGui.QLineEdit()
        
        # hide password
        self._passwd.setEchoMode(QtGui.QLineEdit.Password)
        
        # password layout
        passwd_hl = QtGui.QHBoxLayout()
        
        # add password edit line to layout
        passwd_hl.addWidget(self._passwd)
        
        # password visibility check box
        self._show_passwd_check = QtGui.QCheckBox(tr("Show"))
        self._show_passwd_check.setChecked(False)
        passwd_hl.addWidget(self._show_passwd_check)
        
        layout_gl.addLayout(passwd_hl, 0, 1)
        
        # create buttons
        self._button_box = QtGui.QDialogButtonBox()
        
        self.__login_button = QtGui.QPushButton(tr("&Log In"))
        self.__login_button.setEnabled(False)
        
        self.__close_button = QtGui.QPushButton(tr("&Close"))
        
        self._button_box.addButton(self.__login_button, QtGui.QDialogButtonBox.AcceptRole)
        self._button_box.addButton(self.__close_button, QtGui.QDialogButtonBox.RejectRole)
        
#         layout_gl.addWidget(self._button_box, 1, 1)
        
        # db button layout
        db_buttons_hl = QtGui.QHBoxLayout()
    
        self.__open_db = QtGui.QPushButton(tr("Open Database"))
        self.__create_db = QtGui.QPushButton(tr("Create Database"))
        
        db_buttons_hl.addWidget(self.__open_db)
        db_buttons_hl.addWidget(self.__create_db)
        db_buttons_hl.addWidget(self._button_box)
        
        layout_gl.addLayout(db_buttons_hl, 1, 0, 1, 2)
Ejemplo n.º 28
0
def showErrorMsg(msg):
    """
        Display error message box.
    """
    QtGui.QMessageBox(QtGui.QMessageBox.Critical, tr("Something is wrong!"), tr("Something is wrong in program. Sorry.") + 
            "\n\n" + QtCore.QString.fromUtf8(str(msg))).exec_()
Ejemplo n.º 29
0
    def initUi(self):
        """
            Initilize UI components.
        """
        SaveDialog.initUi(self)

        title_label = QtGui.QLabel("<b>" + tr("Title:") + "</b>")
        username_label = QtGui.QLabel("<b>" + tr("Username:"******"</b>")
        passwd_label = QtGui.QLabel("<b>" + tr("Password:"******"</b>")
        url_label = QtGui.QLabel("<b>" + tr("URL:")  + "</b>")
        
        if (self.__edit):
            # if it is edit dialog display
            layout_offset = 0
            
            c_date_label = QtGui.QLabel("<b>" + tr("Creation date:") + "</b>")
            m_date_label = QtGui.QLabel("<b>" + tr("Modification date:") + "</b>")
            
            self._layout_gl.addWidget(c_date_label, 4, 0)
            self._layout_gl.addWidget(m_date_label, 5, 0)
            
            self._c_date = QtGui.QLabel()
            self._m_date = QtGui.QLabel()
            
            self._layout_gl.addWidget(self._c_date, 4, 1)
            self._layout_gl.addWidget(self._m_date, 5, 1)
        else:
            layout_offset = -2
            
        e_date_label = QtGui.QLabel("<b>" + tr("Expiration date:") + "</b>")
        comment_label = QtGui.QLabel("<b>" + tr("Comment:") + "</b>")
        attachment_label = QtGui.QLabel("<b>" + tr("Attachment:") + "</b>")
        group_label = QtGui.QLabel("<b>" + tr("Groups:") + "</b>")
        
        self._layout_gl.addWidget(title_label, 0, 0)
        self._layout_gl.addWidget(username_label, 1, 0)
        self._layout_gl.addWidget(passwd_label, 2, 0)
        self._layout_gl.addWidget(url_label, 3, 0)
        self._layout_gl.addWidget(e_date_label, 6 + layout_offset, 0)
        self._layout_gl.addWidget(attachment_label, 7 + layout_offset, 0)
        self._layout_gl.addWidget(comment_label, 9 + layout_offset, 0)
        self._layout_gl.addWidget(group_label, 10 + layout_offset, 0)
        
        self._title = QtGui.QLineEdit()
        self._username = QtGui.QLineEdit()
        self._passwd = QtGui.QLineEdit()
        
        if (not self.__show_pass):
            self._passwd.setEchoMode(QtGui.QLineEdit.Password)
        
        # password layout
        passwd_hl = QtGui.QHBoxLayout()
        passwd_hl.addWidget(self._passwd)
        
        # password visibility check box
        self._show_passwd_check = QtGui.QCheckBox(tr("Show"))
        self._show_passwd_check.setChecked(self.__show_pass)

        # password QR code
        self._qr_button = QtGui.QPushButton(tr("QR"))

        passwd_hl.addWidget(self._show_passwd_check)
        passwd_hl.addWidget(self._qr_button)
              
        self._url = QtGui.QLineEdit()
        self._e_date = QtGui.QLineEdit()
        self._comment = QtGui.QTextEdit()
        self._comment.setLineWrapMode(QtGui.QTextEdit.NoWrap)
        self._comment.setMaximumHeight(200)
        self._group = QtGui.QComboBox()
        self._att_name = QtGui.QLineEdit()
        self._att_name.setEnabled(False)
        
        self._layout_gl.addWidget(self._title, 0, 1)
        self._layout_gl.addWidget(self._username, 1, 1)
        self._layout_gl.addLayout(passwd_hl, 2, 1)
        self._layout_gl.addWidget(self._url, 3, 1)
        
        # attachment vertical layout
        att_vl = QtGui.QVBoxLayout()
        
        # attachment layout
        att_hl_1 = QtGui.QHBoxLayout()
        att_hl_2 = QtGui.QHBoxLayout()
        
        att_vl.addLayout(att_hl_1)
        att_vl.addLayout(att_hl_2)
        
        # open file button
        self._att_button = QtGui.QPushButton(tr("Load"))
        self._att_del_button = QtGui.QPushButton(tr("Delete"))
        self._att_save_button = QtGui.QPushButton(tr("Download"))
        self._att_open_button = QtGui.QPushButton(tr("Open"))
        
        self._att_del_button.setEnabled(False)
        self._att_save_button.setEnabled(False)
        self._att_open_button.setEnabled(False)
        
        att_hl_1.addWidget(self._att_button)
        att_hl_1.addWidget(self._att_del_button)
        att_hl_2.addWidget(self._att_save_button)
        att_hl_2.addWidget(self._att_open_button)
        
        self._layout_gl.addWidget(self._att_name, 7 + layout_offset, 1)
        self._layout_gl.addLayout(att_vl, 8 + layout_offset, 1)
        self._layout_gl.addWidget(self._comment, 9 + layout_offset, 1)
        self._layout_gl.addWidget(self._group, 10 + layout_offset, 1)
        
        # date time edit
        self._e_date_edit = QtGui.QDateTimeEdit()
        self._e_date_edit.setCalendarPopup(True)
        
        # expiration date can't be lower than current date
        self._e_date_edit.setMinimumDateTime(QtCore.QDateTime.currentDateTime())
        
        # create never check box
        self._e_date_never = QtGui.QCheckBox(tr("Never"))
        
        # create horizontal layout for date selector and never check box
        e_date_hl = QtGui.QHBoxLayout()
        e_date_hl.addWidget(self._e_date_edit)
        e_date_hl.addWidget(self._e_date_never)
        
        # add to main layout
        self._layout_gl.addLayout(e_date_hl, 6 + layout_offset, 1)
Ejemplo n.º 30
0
def showInfoMsg(msg):
    """
        Display error message box.
    """
    QtGui.QMessageBox(QtGui.QMessageBox.Information, tr("Information"), QtCore.QString.fromUtf8(str(msg))).exec_()