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 Jul 28, 2024
1 parent e48ef80 commit bf44f82
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 260 deletions.
1 change: 1 addition & 0 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
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.
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
32 changes: 24 additions & 8 deletions src/gui/DatabaseTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,25 +537,41 @@ bool DatabaseTabWidget::warnOnExport()
return ans == MessageBox::Yes;
}

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

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

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

#ifdef WITH_XC_BROWSER_PASSKEYS
void DatabaseTabWidget::showPasskeys()
void DatabaseTabWidget::showPasskeys(bool state)
{
currentDatabaseWidget()->switchToPasskeys();
if (state) {
currentDatabaseWidget()->switchToPasskeys();
} else {
currentDatabaseWidget()->switchToMainView();
}
}

void DatabaseTabWidget::importPasskey()
Expand Down
8 changes: 4 additions & 4 deletions src/gui/DatabaseTabWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public slots:
void unlockAnyDatabaseInDialog(DatabaseOpenDialog::Intent intent);
void relockPendingDatabase();

void showDatabaseSecurity();
void showDatabaseReports();
void showDatabaseSettings();
void showDatabaseSecurity(bool state);
void showDatabaseReports(bool state);
void showDatabaseSettings(bool state);
#ifdef WITH_XC_BROWSER_PASSKEYS
void showPasskeys();
void showPasskeys(bool state);
void importPasskey();
void importPasskeyToEntry();
void removePasskeyFromEntry();
Expand Down
25 changes: 18 additions & 7 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 = m_reportsDialog->onPassKeysPage() ? Mode::PassKeysMode : 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
8 changes: 6 additions & 2 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ class DatabaseWidget : public QStackedWidget
{
None,
ViewMode,
EditMode,
LockedMode
EditEntryMode,
EditGroupMode,
LockedMode,
ReportsMode,
PassKeysMode,
DatabaseSettingsMode
};

explicit DatabaseWidget(QSharedPointer<Database> db, QWidget* parent = nullptr);
Expand Down
Loading

0 comments on commit bf44f82

Please sign in to comment.