|
|
@ -324,7 +324,7 @@ void KeepassMainWindow::setupMenus(){ |
|
|
|
SysTrayMenu->addSeparator(); |
|
|
|
SysTrayMenu->addSeparator(); |
|
|
|
SysTrayMenu->addAction(FileExitAction); |
|
|
|
SysTrayMenu->addAction(FileExitAction); |
|
|
|
SysTray->setContextMenu(SysTrayMenu); |
|
|
|
SysTray->setContextMenu(SysTrayMenu); |
|
|
|
SysTray->setToolTip(QString("%1 %2 - %3").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC, (IsLocked) ? tr("Locked") : tr("Unlocked"))); |
|
|
|
updateTrayTooltip(); |
|
|
|
|
|
|
|
|
|
|
|
#define _add_import(name){\ |
|
|
|
#define _add_import(name){\ |
|
|
|
QAction* import=new QAction(this);\
|
|
|
|
QAction* import=new QAction(this);\
|
|
|
@ -467,9 +467,8 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ |
|
|
|
if(db->load(filename, dbReadOnly)){ |
|
|
|
if(db->load(filename, dbReadOnly)){ |
|
|
|
if (IsLocked) |
|
|
|
if (IsLocked) |
|
|
|
resetLock(); |
|
|
|
resetLock(); |
|
|
|
currentFile = filename; |
|
|
|
updateCurrentFile(filename); |
|
|
|
saveLastFilename(filename); |
|
|
|
saveLastFilename(filename); |
|
|
|
setWindowTitle(QString("%1[*] - KeePassX").arg(filename)); |
|
|
|
|
|
|
|
GroupView->createItems(); |
|
|
|
GroupView->createItems(); |
|
|
|
EntryView->showGroup(NULL); |
|
|
|
EntryView->showGroup(NULL); |
|
|
|
setStateFileOpen(true); |
|
|
|
setStateFileOpen(true); |
|
|
@ -509,7 +508,7 @@ void KeepassMainWindow::fakeOpenDatabase(const QString& filename){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
config->setLastFile(filename); |
|
|
|
config->setLastFile(filename); |
|
|
|
currentFile = filename; |
|
|
|
updateCurrentFile(filename); |
|
|
|
setLock(); |
|
|
|
setLock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -538,8 +537,8 @@ bool KeepassMainWindow::closeDatabase(bool lock){ |
|
|
|
db->close(); |
|
|
|
db->close(); |
|
|
|
delete db; |
|
|
|
delete db; |
|
|
|
db=NULL; |
|
|
|
db=NULL; |
|
|
|
if (!dbReadOnly && QFile::exists(currentFile+".lock")){ |
|
|
|
if (!dbReadOnly && QFile::exists(currentFilePath+".lock")){ |
|
|
|
if (!QFile::remove(currentFile+".lock")) |
|
|
|
if (!QFile::remove(currentFilePath+".lock")) |
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove database lock file.")); |
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove database lock file.")); |
|
|
|
} |
|
|
|
} |
|
|
|
EntryView->db=NULL; |
|
|
|
EntryView->db=NULL; |
|
|
@ -553,9 +552,9 @@ bool KeepassMainWindow::closeDatabase(bool lock){ |
|
|
|
IsLocked = true; |
|
|
|
IsLocked = true; |
|
|
|
setStateFileOpen(false); |
|
|
|
setStateFileOpen(false); |
|
|
|
if (!lock){ |
|
|
|
if (!lock){ |
|
|
|
setWindowTitle(APP_DISPLAY_NAME); |
|
|
|
updateCurrentFile(QString()); |
|
|
|
currentFile.clear(); |
|
|
|
|
|
|
|
QuickSearchEdit->setText(""); |
|
|
|
QuickSearchEdit->setText(""); |
|
|
|
|
|
|
|
updateTrayTooltip(); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -573,8 +572,7 @@ void KeepassMainWindow::OnFileNewKdb(){ |
|
|
|
db=db_new; |
|
|
|
db=db_new; |
|
|
|
db->setKey(dlg.password(),dlg.keyFile()); |
|
|
|
db->setKey(dlg.password(),dlg.keyFile()); |
|
|
|
db->generateMasterKey(); |
|
|
|
db->generateMasterKey(); |
|
|
|
currentFile.clear(); |
|
|
|
updateCurrentFile(QString()); |
|
|
|
setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); |
|
|
|
|
|
|
|
GroupView->db=db; |
|
|
|
GroupView->db=db; |
|
|
|
EntryView->db=db; |
|
|
|
EntryView->db=db; |
|
|
|
GroupView->createItems(); |
|
|
|
GroupView->createItems(); |
|
|
@ -656,10 +654,9 @@ void KeepassMainWindow::setStateFileOpen(bool IsOpen){ |
|
|
|
EditAutoTypeAction->setEnabled(false); |
|
|
|
EditAutoTypeAction->setEnabled(false); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
/*else{
|
|
|
|
|
|
|
|
OnGroupSelectionChanged(); |
|
|
|
updateWindowTitle(); |
|
|
|
OnEntrySelectionChanged(); |
|
|
|
updateTrayTooltip(); |
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -674,6 +671,7 @@ void KeepassMainWindow::setStateFileModified(bool mod){ |
|
|
|
FileSaveAction->setIcon(getIcon("filesave")); |
|
|
|
FileSaveAction->setIcon(getIcon("filesave")); |
|
|
|
else |
|
|
|
else |
|
|
|
FileSaveAction->setIcon(getIcon("filesavedisabled")); |
|
|
|
FileSaveAction->setIcon(getIcon("filesavedisabled")); |
|
|
|
|
|
|
|
updateWindowTitle(); |
|
|
|
setWindowModified(mod); |
|
|
|
setWindowModified(mod); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -921,13 +919,29 @@ bool KeepassMainWindow::OnFileSaveAs(){ |
|
|
|
tr("Save Database..."),QStringList()<<tr("KeePass Databases (*.kdb)")<< tr("All Files (*)")); |
|
|
|
tr("Save Database..."),QStringList()<<tr("KeePass Databases (*.kdb)")<< tr("All Files (*)")); |
|
|
|
if (filename.isEmpty() || filename.compare(".kdb", Qt::CaseInsensitive)==0) |
|
|
|
if (filename.isEmpty() || filename.compare(".kdb", Qt::CaseInsensitive)==0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFile lock(filename+".lock"); |
|
|
|
|
|
|
|
if (!lock.open(QIODevice::WriteOnly)){ |
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't create database lock file.")); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!db->changeFile(filename)){ |
|
|
|
if(!db->changeFile(filename)){ |
|
|
|
showErrMsg(QString("%1\n%2").arg(tr("File could not be saved.")).arg(db->getError())); |
|
|
|
showErrMsg(QString("%1\n%2").arg(tr("File could not be saved.")).arg(db->getError())); |
|
|
|
db->changeFile(QString()); |
|
|
|
QFile::remove( filename+".lock" ); |
|
|
|
//setWindowTitle(tr("KeePassX - [unsaved]").arg(filename));
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
setWindowTitle(QString("%1[*] - KeePassX").arg(filename)); |
|
|
|
|
|
|
|
|
|
|
|
if (!dbReadOnly && QFile::exists(currentFilePath+".lock")){ |
|
|
|
|
|
|
|
if (!QFile::remove(currentFilePath+".lock")) |
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove database lock file.")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbReadOnly = false; |
|
|
|
|
|
|
|
updateCurrentFile(filename); |
|
|
|
|
|
|
|
updateWindowTitle(); |
|
|
|
|
|
|
|
updateTrayTooltip(); |
|
|
|
|
|
|
|
|
|
|
|
return OnFileSave(); |
|
|
|
return OnFileSave(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -976,7 +990,6 @@ void KeepassMainWindow::OnImport(QAction* action){ |
|
|
|
GroupView->db=db; |
|
|
|
GroupView->db=db; |
|
|
|
EntryView->db=db; |
|
|
|
EntryView->db=db; |
|
|
|
setupDatabaseConnections(db); |
|
|
|
setupDatabaseConnections(db); |
|
|
|
setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); |
|
|
|
|
|
|
|
GroupView->createItems(); |
|
|
|
GroupView->createItems(); |
|
|
|
EntryView->showGroup(NULL); |
|
|
|
EntryView->showGroup(NULL); |
|
|
|
setStateFileOpen(true); |
|
|
|
setStateFileOpen(true); |
|
|
@ -1109,15 +1122,8 @@ void KeepassMainWindow::OnExtrasSettings(){ |
|
|
|
ViewShowToolbarAction->setText(tr("Show &Toolbar")); |
|
|
|
ViewShowToolbarAction->setText(tr("Show &Toolbar")); |
|
|
|
EntryView->retranslateColumns(); |
|
|
|
EntryView->retranslateColumns(); |
|
|
|
GroupView->retranslateUi(); |
|
|
|
GroupView->retranslateUi(); |
|
|
|
if (FileOpen) { |
|
|
|
updateWindowTitle(); |
|
|
|
if (db->file()) |
|
|
|
updateTrayTooltip(); |
|
|
|
setWindowTitle(QString("%1[*] - KeePassX").arg(db->file()->fileName())); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
setWindowTitle(APP_DISPLAY_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setStatusBarMsg(statusbarState); |
|
|
|
setStatusBarMsg(statusbarState); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1276,7 +1282,7 @@ void KeepassMainWindow::OnUnLockWorkspace(){ |
|
|
|
if(IsLocked){ |
|
|
|
if(IsLocked){ |
|
|
|
if (InUnLock) return; |
|
|
|
if (InUnLock) return; |
|
|
|
InUnLock = true; |
|
|
|
InUnLock = true; |
|
|
|
if ( openDatabase(currentFile,true) ){ |
|
|
|
if ( openDatabase(currentFilePath,true) ){ |
|
|
|
QTreeWidgetItem* item = GroupView->invisibleRootItem(); |
|
|
|
QTreeWidgetItem* item = GroupView->invisibleRootItem(); |
|
|
|
if (lockGroup.size()>0){ |
|
|
|
if (lockGroup.size()>0){ |
|
|
|
for (int i=0; i<lockGroup.size(); i++){ |
|
|
|
for (int i=0; i<lockGroup.size(); i++){ |
|
|
@ -1316,7 +1322,6 @@ void KeepassMainWindow::OnUnLockWorkspace(){ |
|
|
|
void KeepassMainWindow::OnLockClose(){ |
|
|
|
void KeepassMainWindow::OnLockClose(){ |
|
|
|
resetLock(); |
|
|
|
resetLock(); |
|
|
|
setStateFileOpen(false); |
|
|
|
setStateFileOpen(false); |
|
|
|
setWindowTitle(APP_DISPLAY_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void KeepassMainWindow::setLock(){ |
|
|
|
void KeepassMainWindow::setLock(){ |
|
|
@ -1326,9 +1331,9 @@ void KeepassMainWindow::setLock(){ |
|
|
|
setCentralWidget(LockedCentralWidget); |
|
|
|
setCentralWidget(LockedCentralWidget); |
|
|
|
LockedCentralWidget->setVisible(true); |
|
|
|
LockedCentralWidget->setVisible(true); |
|
|
|
SysTray->setIcon(getIcon("keepassx_locked")); |
|
|
|
SysTray->setIcon(getIcon("keepassx_locked")); |
|
|
|
SysTray->setToolTip(QString("%1 %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) + " - " + tr("Locked")); |
|
|
|
|
|
|
|
FileUnLockWorkspaceAction->setText(tr("Un&lock Workspace")); |
|
|
|
FileUnLockWorkspaceAction->setText(tr("Un&lock Workspace")); |
|
|
|
IsLocked=true; |
|
|
|
IsLocked=true; |
|
|
|
|
|
|
|
updateTrayTooltip(); |
|
|
|
setStateFileOpen(false); |
|
|
|
setStateFileOpen(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1341,9 +1346,9 @@ void KeepassMainWindow::resetLock(){ |
|
|
|
setCentralWidget(NormalCentralWidget); |
|
|
|
setCentralWidget(NormalCentralWidget); |
|
|
|
NormalCentralWidget->setVisible(true); |
|
|
|
NormalCentralWidget->setVisible(true); |
|
|
|
SysTray->setIcon(getIcon("keepassx_large")); |
|
|
|
SysTray->setIcon(getIcon("keepassx_large")); |
|
|
|
SysTray->setToolTip(QString("%1 %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) + " - " + tr("Unlocked")); |
|
|
|
|
|
|
|
FileUnLockWorkspaceAction->setText(tr("&Lock Workspace")); |
|
|
|
FileUnLockWorkspaceAction->setText(tr("&Lock Workspace")); |
|
|
|
IsLocked=false; |
|
|
|
IsLocked=false; |
|
|
|
|
|
|
|
updateTrayTooltip(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void KeepassMainWindow::OnInactivityTimer(){ |
|
|
|
void KeepassMainWindow::OnInactivityTimer(){ |
|
|
@ -1447,3 +1452,32 @@ void KeepassMainWindow::setStatusBarMsg(StatusBarMsg statusBarMsg) { |
|
|
|
statusbarState = statusBarMsg; |
|
|
|
statusbarState = statusBarMsg; |
|
|
|
StatusBarGeneral->setText(text); |
|
|
|
StatusBarGeneral->setText(text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeepassMainWindow::updateWindowTitle() { |
|
|
|
|
|
|
|
if (!IsLocked && !FileOpen) |
|
|
|
|
|
|
|
setWindowTitle( QString("%1 - %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) ); |
|
|
|
|
|
|
|
else if (currentFilePath.isEmpty()) |
|
|
|
|
|
|
|
setWindowTitle( QString("[%1][*] - %2").arg(tr("new"), APP_DISPLAY_NAME) ); |
|
|
|
|
|
|
|
else if (IsLocked) |
|
|
|
|
|
|
|
setWindowTitle( QString("%1 (%2) - %3").arg(currentFilePath, tr("locked"), APP_DISPLAY_NAME) ); |
|
|
|
|
|
|
|
else if (ModFlag) |
|
|
|
|
|
|
|
setWindowTitle( QString("%1[*] - %2").arg(currentFilePath, APP_DISPLAY_NAME) ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
setWindowTitle( QString("%1 - %2").arg(currentFilePath, APP_DISPLAY_NAME) ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeepassMainWindow::updateTrayTooltip() { |
|
|
|
|
|
|
|
if (!IsLocked && !FileOpen) |
|
|
|
|
|
|
|
SysTray->setToolTip(QString("%1 - %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC)); |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
QString tooltip = QString("%1 - %2").arg(APP_DISPLAY_NAME, currentFileName); |
|
|
|
|
|
|
|
if (IsLocked) |
|
|
|
|
|
|
|
tooltip.append( QString(" (%1)").arg(tr("locked")) ); |
|
|
|
|
|
|
|
SysTray->setToolTip(tooltip); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeepassMainWindow::updateCurrentFile(const QString& filePath) { |
|
|
|
|
|
|
|
currentFilePath = filePath; |
|
|
|
|
|
|
|
currentFileName = QFileInfo(filePath).fileName(); |
|
|
|
|
|
|
|
} |
|
|
|