From 311e7802e522a2b44517758c948d80258a6006b3 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 25 Feb 2017 02:34:47 +0100 Subject: [PATCH 1/5] Don't show error message when trying to reload a locked database --- src/gui/DatabaseWidget.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 1ccf35dd4..8a7b2cf3b 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1061,8 +1061,7 @@ void DatabaseWidget::reloadDatabaseFile() // Merge the old database into the new one m_db->setEmitModified(false); db->merge(m_db); - } - else { + } else { // Since we are accepting the new file as-is, internally mark as unmodified // TODO: when saving is moved out of DatabaseTabWidget, this should be replaced m_databaseModified = false; @@ -1086,16 +1085,9 @@ void DatabaseWidget::reloadDatabaseFile() restoreGroupEntryFocus(groupBeforeReload, entryBeforeReload); } - else { - MessageBox::critical(this, tr("Autoreload Failed"), - tr("Could not parse or unlock the new database file while attempting" - " to autoreload this database.")); - } - } - else { + } else { MessageBox::critical(this, tr("Autoreload Failed"), - tr("Could not open the new database file while attempting to autoreload" - " this database.")); + tr("Could not open the new database file while attempting to autoreload this database.")); } // Rewatch the database file From 4ec2fe556aad61dc5691f760d9ff9733baaa001b Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 25 Feb 2017 03:40:49 +0100 Subject: [PATCH 2/5] Fix impossible dialog by providing a proper question with approriate answers, resolves #202 --- src/gui/DatabaseTabWidget.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index c425332f7..8042c1130 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "autotype/AutoType.h" #include "core/Config.h" @@ -157,21 +158,29 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, // for now silently ignore if we can't create a lock file // due to lack of permissions if (lockFile->error() != QLockFile::PermissionError) { - QMessageBox::StandardButton result = MessageBox::question(this, tr("Open database"), - tr("The database you are trying to open is locked by another instance of KeePassXC.\n" - "Do you want to open it anyway? Alternatively the database is opened read-only."), - QMessageBox::Yes | QMessageBox::No); + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Database already opened")); + msgBox.setText(tr("The database you are trying to open is locked by another instance of KeePassXC.\n\n" + "Do you want to open it anyway?")); + msgBox.setIcon(QMessageBox::Question); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + auto readOnlyButton = msgBox.addButton(tr("Open read-only"), QMessageBox::AcceptRole); + msgBox.setDefaultButton(readOnlyButton); + msgBox.setEscapeButton(QMessageBox::No); + auto result = msgBox.exec(); - if (result == QMessageBox::No) { + if (msgBox.clickedButton() == readOnlyButton) { dbStruct.readOnly = true; delete lockFile; lockFile = nullptr; - } - else { + } else if (result == QMessageBox::Yes) { // take over the lock file if possible if (lockFile->removeStaleLockFile()) { lockFile->tryLock(); } + } else { + return; } } } From 6e2254c13d631f28feb5c34cba755b3019331f67 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 25 Feb 2017 16:09:26 +0100 Subject: [PATCH 3/5] Don't fall back to ugly Qt close icon --- src/gui/KMessageWidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index e2c22574c..522a72f54 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -20,6 +20,8 @@ */ #include "KMessageWidget.h" +#include "core/FilePath.h" + #include #include #include @@ -89,7 +91,7 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr) QAction *closeAction = new QAction(q); closeAction->setText(KMessageWidget::tr("&Close")); closeAction->setToolTip(KMessageWidget::tr("Close message")); - closeAction->setIcon(q->style()->standardIcon(QStyle::SP_DialogCloseButton)); + closeAction->setIcon(FilePath::instance()->icon("actions", "dialog-close")); QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide())); From 84f2520924ce1f91f60d1c82bf865c9ed0ff5172 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 25 Feb 2017 16:18:36 +0100 Subject: [PATCH 4/5] Fix message widget style on OS X --- src/gui/KMessageWidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index 522a72f54..a6bfa04bc 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -98,6 +98,12 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr) closeButton = new QToolButton(content); closeButton->setAutoRaise(true); closeButton->setDefaultAction(closeAction); +#ifdef Q_OS_MAC + closeButton->setStyleSheet("QToolButton { background: transparent;" + "border-radius: 2px; padding: 3px; }" + "QToolButton::hover, QToolButton::focus {" + "border: 1px solid rgb(90, 200, 250); }"); +#endif q->setMessageType(KMessageWidget::Information); } @@ -287,7 +293,11 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) } // Colors +#ifdef Q_OS_MAC + fg = palette().light().color(); +#else fg = palette().highlightedText().color(); +#endif bg0 = bg1.lighter(110); bg2 = bg1.darker(110); border = darkShade(bg1); From 9ba88838ba99ab104dc0149006089045327e2737 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 25 Feb 2017 21:42:55 +0100 Subject: [PATCH 5/5] Use white close icon and add more padding to message widget --- .../16x16/actions/message-close.png | Bin 0 -> 457 bytes .../22x22/actions/message-close.png | Bin 0 -> 457 bytes share/icons/svg/message-close.svg | 65 ++++++++++++++++++ src/gui/KMessageWidget.cpp | 7 +- 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 share/icons/application/16x16/actions/message-close.png create mode 100644 share/icons/application/22x22/actions/message-close.png create mode 100644 share/icons/svg/message-close.svg diff --git a/share/icons/application/16x16/actions/message-close.png b/share/icons/application/16x16/actions/message-close.png new file mode 100644 index 0000000000000000000000000000000000000000..4b2f9ca4d7840c5c8a181bddcf779c88f1bee2b7 GIT binary patch literal 457 zcmV;)0XF`LP)T(Rc?!;7lrb z3nc1N-70%V!L6SQddQ@yo*9Ptl3C2WuCITptHvoJU|-UOq%%o}k~-d+N_v&_AZh5F zo5dI*unr7>FN&1_eV|?hZ2^xZfT3Q1gBY{}Oe;WBeFAN3`%hayQ%!(c7CeXyTI4_$ zeoUy|D*LP_Y63KX;|P4=y@ml#fTn;OBk%_}^%EZf-+_0M@#aSSm4KmPtXAa#>B_Bd zmhJ?+M@$P|1`6<|$X2pi9ZSLXvzqUeDo2Te_fWt8dKC91p_?S{R=~Ak29`H)FOj6)tGD(^6)mx)>l;@K+C?Y%SJ!00DUIb=!0YF zv7S&%GoTCXh8&kOK~vJXf2^PBNYcnTmss(Cf&p^D#659M00000NkvXXu0mjfp<%a# literal 0 HcmV?d00001 diff --git a/share/icons/application/22x22/actions/message-close.png b/share/icons/application/22x22/actions/message-close.png new file mode 100644 index 0000000000000000000000000000000000000000..4b2f9ca4d7840c5c8a181bddcf779c88f1bee2b7 GIT binary patch literal 457 zcmV;)0XF`LP)T(Rc?!;7lrb z3nc1N-70%V!L6SQddQ@yo*9Ptl3C2WuCITptHvoJU|-UOq%%o}k~-d+N_v&_AZh5F zo5dI*unr7>FN&1_eV|?hZ2^xZfT3Q1gBY{}Oe;WBeFAN3`%hayQ%!(c7CeXyTI4_$ zeoUy|D*LP_Y63KX;|P4=y@ml#fTn;OBk%_}^%EZf-+_0M@#aSSm4KmPtXAa#>B_Bd zmhJ?+M@$P|1`6<|$X2pi9ZSLXvzqUeDo2Te_fWt8dKC91p_?S{R=~Ak29`H)FOj6)tGD(^6)mx)>l;@K+C?Y%SJ!00DUIb=!0YF zv7S&%GoTCXh8&kOK~vJXf2^PBNYcnTmss(Cf&p^D#659M00000NkvXXu0mjfp<%a# literal 0 HcmV?d00001 diff --git a/share/icons/svg/message-close.svg b/share/icons/svg/message-close.svg new file mode 100644 index 000000000..44b643072 --- /dev/null +++ b/share/icons/svg/message-close.svg @@ -0,0 +1,65 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index a6bfa04bc..b88c3bc12 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -91,7 +91,7 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr) QAction *closeAction = new QAction(q); closeAction->setText(KMessageWidget::tr("&Close")); closeAction->setToolTip(KMessageWidget::tr("Close message")); - closeAction->setIcon(FilePath::instance()->icon("actions", "dialog-close")); + closeAction->setIcon(FilePath::instance()->icon("actions", "message-close", false)); QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide())); @@ -293,11 +293,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) } // Colors -#ifdef Q_OS_MAC fg = palette().light().color(); -#else - fg = palette().highlightedText().color(); -#endif bg0 = bg1.lighter(110); bg2 = bg1.darker(110); border = darkShade(bg1); @@ -311,6 +307,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) "border-radius: 5px;" "border: 1px solid %4;" "margin: %5px;" + "padding: 5px;" "}" ".QLabel { color: %6; }" ))