From c83ddaaedf0b40e0f3226353b548ac8cbb8a05c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20V=C3=A4nttinen?= Date: Sun, 29 May 2022 15:25:30 +0300 Subject: [PATCH] Show gray icon when no credentials are available (#1490) Show gray icon when there are no credentials --- .../content/keepassxc-browser.js | 4 + keepassxc-browser/content/ui.js | 2 +- keepassxc-browser/content/username-field.js | 7 ++ keepassxc-browser/icons/keepassxc-dark.svg | 93 ------------------- 4 files changed, 12 insertions(+), 94 deletions(-) delete mode 100644 keepassxc-browser/icons/keepassxc-dark.svg diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index ef6ea1d..97cd6f0 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -602,6 +602,8 @@ kpxc.receiveCredentialsIfNecessary = async function() { // If the database was locked, this is scope never met. In these cases the response is met at kpxc.detectDatabaseChange await sendMessage('page_set_manual_fill', ManualFill.NONE); await kpxc.retrieveCredentialsCallback(credentials); + + kpxcIcons.switchIcons(); return credentials; } @@ -776,6 +778,8 @@ const initContentScript = async function() { kpxc.rememberCredentials(creds.username, creds.password, creds.url, creds.oldCredentials); } + + kpxcIcons.switchIcons(); } catch (err) { logError('initContentScript error: ' + err); } diff --git a/keepassxc-browser/content/ui.js b/keepassxc-browser/content/ui.js index 15223ef..508a160 100644 --- a/keepassxc-browser/content/ui.js +++ b/keepassxc-browser/content/ui.js @@ -50,7 +50,7 @@ class Icon { } if (state === DatabaseState.UNLOCKED) { - this.icon.style.filter = 'saturate(100%)'; + this.icon.style.filter = kpxc.credentials.length === 0 ? 'saturate(0%)' : 'saturate(100%)'; } else { this.icon.style.filter = 'saturate(0%)'; } diff --git a/keepassxc-browser/content/username-field.js b/keepassxc-browser/content/username-field.js index 1e756ae..dc69427 100644 --- a/keepassxc-browser/content/username-field.js +++ b/keepassxc-browser/content/username-field.js @@ -47,6 +47,12 @@ class UsernameFieldIcon extends Icon { this.icon.classList.remove('lock', 'lock-moz', 'unlock', 'unlock-moz', 'disconnected', 'disconnected-moz'); this.icon.classList.add(getIconClassName(state)); this.icon.title = getIconText(state); + + if (kpxc.credentials.length === 0 && state === DatabaseState.UNLOCKED) { + this.icon.style.filter = 'saturate(0%)'; + } else { + this.icon.style.filter = 'saturate(100%)'; + } } } @@ -142,6 +148,7 @@ const getIconClassName = function(state = DatabaseState.UNLOCKED) { } else if (state === DatabaseState.DISCONNECTED) { return (isFirefox() ? 'lock-disconnected' : 'disconnected'); } + return (isFirefox() ? 'unlock-moz' : 'unlock'); }; diff --git a/keepassxc-browser/icons/keepassxc-dark.svg b/keepassxc-browser/icons/keepassxc-dark.svg deleted file mode 100644 index 7a756e5..0000000 --- a/keepassxc-browser/icons/keepassxc-dark.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - -