Skip to content

Commit

Permalink
Overhaul action states and add icons to toolbar
Browse files Browse the repository at this point in the history
* Fixes #10981
  • Loading branch information
droidmonkey committed Oct 7, 2024
1 parent 684122c commit e07eb2c
Show file tree
Hide file tree
Showing 21 changed files with 430 additions and 440 deletions.
7 changes: 4 additions & 3 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/database-lock-all.svg
share/icons/application/scalable/actions/database-merge.svg
share/icons/application/scalable/actions/database-search.svg
share/icons/application/scalable/actions/database-settings.svg
share/icons/application/scalable/actions/dialog-close.svg
share/icons/application/scalable/actions/dialog-ok.svg
share/icons/application/scalable/actions/document-close.svg
Expand Down Expand Up @@ -243,9 +244,9 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/lock-open-alert.svg
share/icons/application/scalable/actions/lock-open.svg
share/icons/application/scalable/actions/lock.svg
Copyright: 2019 Austin Andrews <http://templarian.com/>
License: SIL OPEN FONT LICENSE Version 1.1
Comment: Taken from Material Design icon set (https://github.com/templarian/MaterialDesign/)
Copyright: 2023 Pictogrammers <https://pictogrammers.com/docs/general/about/>
License: Apache-2.0
Comment: Some icons are modified to fit KeePassXC design (https://pictogrammers.com/library/mdi/)

Files: src/streams/qtiocompressor.*
src/streams/QtIOCompressor
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion share/icons/application/scalable/actions/entry-delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion share/icons/application/scalable/actions/reports.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<file>application/scalable/actions/database-lock-all.svg</file>
<file>application/scalable/actions/database-merge.svg</file>
<file>application/scalable/actions/database-search.svg</file>
<file>application/scalable/actions/database-settings.svg</file>
<file>application/scalable/actions/dialog-close.svg</file>
<file>application/scalable/actions/dialog-ok.svg</file>
<file>application/scalable/actions/document-close.svg</file>
Expand Down
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,10 @@ Are you sure you want to continue with this file?.</source>
<source>Remote Sync</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Database Settings: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseSettingsWidgetBrowser</name>
Expand Down
2 changes: 1 addition & 1 deletion src/fdosecrets/objects/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ namespace FdoSecrets
}
// switch selected to current
m_databases->setCurrentWidget(dbWidget);
m_databases->showDatabaseSettings();
m_databases->showDatabaseSettings(true);

// open settings (switch from app settings to m_dbTabs)
m_plugin->emitRequestSwitchToDatabases();
Expand Down
20 changes: 14 additions & 6 deletions src/gui/DatabaseTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,19 +549,27 @@ bool DatabaseTabWidget::warnOnExport()
return ans == MessageBox::Yes;
}

void DatabaseTabWidget::showDatabaseSecurity()
void DatabaseTabWidget::showDatabaseReports(bool state)
{
currentDatabaseWidget()->switchToDatabaseSecurity();
if (state) {
currentDatabaseWidget()->switchToDatabaseReports();
} else {
currentDatabaseWidget()->switchToMainView();
}
}

void DatabaseTabWidget::showDatabaseReports()
void DatabaseTabWidget::showDatabaseSettings(bool state)
{
currentDatabaseWidget()->switchToDatabaseReports();
if (state) {
currentDatabaseWidget()->switchToDatabaseSettings();
} else {
currentDatabaseWidget()->switchToMainView();
}
}

void DatabaseTabWidget::showDatabaseSettings()
void DatabaseTabWidget::showDatabaseSecurity()
{
currentDatabaseWidget()->switchToDatabaseSettings();
currentDatabaseWidget()->switchToDatabaseSecurity();
}

#ifdef WITH_XC_BROWSER_PASSKEYS
Expand Down
4 changes: 2 additions & 2 deletions src/gui/DatabaseTabWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public slots:
void unlockAnyDatabaseInDialog(DatabaseOpenDialog::Intent intent);
void relockPendingDatabase();

void showDatabaseReports(bool state);
void showDatabaseSettings(bool state);
void showDatabaseSecurity();
void showDatabaseReports();
void showDatabaseSettings();
#ifdef WITH_XC_BROWSER_PASSKEYS
void showPasskeys();
void importPasskey();
Expand Down
52 changes: 33 additions & 19 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,26 @@ QSharedPointer<Database> DatabaseWidget::database() const

DatabaseWidget::Mode DatabaseWidget::currentMode() const
{
if (currentWidget() == nullptr) {
return Mode::None;
} else if (currentWidget() == m_mainWidget) {
return Mode::ViewMode;
} else if (currentWidget() == m_databaseOpenWidget) {
return Mode::LockedMode;
auto mode = Mode::None;
auto widget = currentWidget();
if (widget == m_mainWidget) {
mode = Mode::ViewMode;
} else if (widget == m_databaseOpenWidget) {
mode = Mode::LockedMode;
} else if (widget == m_reportsDialog) {
mode = Mode::ReportsMode;
} else if (widget == m_databaseSettingDialog) {
mode = Mode::DatabaseSettingsMode;
} else if (widget == m_editEntryWidget) {
mode = Mode::EditEntryMode;
} else if (widget == m_editGroupWidget) {
mode = Mode::EditGroupMode;
} else {
return Mode::EditMode;
// We are missing a condition if we reach here
Q_ASSERT(false);
}

return mode;
}

bool DatabaseWidget::isLocked() const
Expand Down Expand Up @@ -1014,7 +1025,7 @@ void DatabaseWidget::openUrlForEntry(Entry* entry)
}
}

Entry* DatabaseWidget::currentSelectedEntry()
Entry* DatabaseWidget::currentSelectedEntry() const
{
if (currentWidget() == m_editEntryWidget) {
return m_editEntryWidget->currentEntry();
Expand Down Expand Up @@ -1516,14 +1527,18 @@ void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::Mod

void DatabaseWidget::switchToDatabaseReports()
{
m_reportsDialog->load(m_db);
setCurrentWidget(m_reportsDialog);
if (currentMode() != Mode::ReportsMode) {
m_reportsDialog->load(m_db);
setCurrentWidget(m_reportsDialog);
}
}

void DatabaseWidget::switchToDatabaseSettings()
{
m_databaseSettingDialog->load(m_db);
setCurrentWidget(m_databaseSettingDialog);
if (currentMode() != Mode::DatabaseSettingsMode) {
m_databaseSettingDialog->load(m_db);
setCurrentWidget(m_databaseSettingDialog);
}
}

void DatabaseWidget::switchToOpenDatabase()
Expand Down Expand Up @@ -1865,16 +1880,13 @@ void DatabaseWidget::onEntryChanged(Entry* entry)

bool DatabaseWidget::canCloneCurrentGroup() const
{
bool isRootGroup = m_db->rootGroup() == m_groupView->currentGroup();
// bool isRecycleBin = isRecycleBinSelected();

return !isRootGroup;
auto currentGroup = m_groupView->currentGroup();
return currentGroup != m_db->rootGroup() && currentGroup != m_db->metadata()->recycleBin();
}

bool DatabaseWidget::canDeleteCurrentGroup() const
{
bool isRootGroup = m_db->rootGroup() == m_groupView->currentGroup();
return !isRootGroup;
return currentGroup() != m_db->rootGroup();
}

Group* DatabaseWidget::currentGroup() const
Expand Down Expand Up @@ -2483,7 +2495,9 @@ void DatabaseWidget::hideMessage()

bool DatabaseWidget::isRecycleBinSelected() const
{
return m_groupView->currentGroup() && m_groupView->currentGroup() == m_db->metadata()->recycleBin();
auto group = currentGroup();
auto entry = currentSelectedEntry();
return (group && group->isRecycled()) || (entry && entry->isRecycled());
}

void DatabaseWidget::emptyRecycleBin()
Expand Down
9 changes: 6 additions & 3 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ class DatabaseWidget : public QStackedWidget
{
None,
ViewMode,
EditMode,
LockedMode
EditEntryMode,
EditGroupMode,
LockedMode,
ReportsMode,
DatabaseSettingsMode
};

explicit DatabaseWidget(QSharedPointer<Database> db, QWidget* parent = nullptr);
Expand Down Expand Up @@ -106,7 +109,7 @@ class DatabaseWidget : public QStackedWidget
QStringList customEntryAttributes() const;
bool isEditWidgetModified() const;
void clearAllWidgets();
Entry* currentSelectedEntry();
Entry* currentSelectedEntry() const;
bool currentEntryHasTitle();
bool currentEntryHasUsername();
bool currentEntryHasPassword();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/EditWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ EditWidget::EditWidget(QWidget* parent)
setModified(false);

m_ui->messageWidget->setHidden(true);
m_ui->headerLabel->setHidden(true);

QFont headerLabelFont = m_ui->headerLabel->font();
headerLabelFont.setBold(true);
Expand Down Expand Up @@ -118,6 +119,7 @@ void EditWidget::setCurrentPage(int index)

void EditWidget::setHeadline(const QString& text)
{
m_ui->headerLabel->setHidden(text.isEmpty());
m_ui->headerLabel->setText(text);
}

Expand Down
Loading

0 comments on commit e07eb2c

Please sign in to comment.