Skip to content

Commit

Permalink
Show entry count in status bar
Browse files Browse the repository at this point in the history
Closes #3963
  • Loading branch information
droidmonkey committed Sep 3, 2022
1 parent 646034e commit 8e02451
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
connect(m_previewView, SIGNAL(entryUrlActivated(Entry*)), SLOT(openUrlForEntry(Entry*)));
connect(m_entryView, SIGNAL(viewStateChanged()), SIGNAL(entryViewStateChanged()));
connect(m_groupView, SIGNAL(groupSelectionChanged()), SLOT(onGroupChanged()));
connect(m_groupView, SIGNAL(groupSelectionChanged()), SIGNAL(groupChanged()));
connect(m_groupView, &GroupView::groupFocused, this, [this] { m_previewView->setGroup(currentGroup()); });
connect(m_entryView, SIGNAL(entryActivated(Entry*,EntryModel::ModelColumn)),
SLOT(entryActivationSignalReceived(Entry*,EntryModel::ModelColumn)));
Expand Down Expand Up @@ -1053,12 +1052,6 @@ void DatabaseWidget::switchToMainView(bool previousDialogAccepted)
// Workaround: ensure entries are focused so search doesn't reset
m_entryView->setFocus();
}

if (sender() == m_entryView || sender() == m_editEntryWidget) {
onEntryChanged(m_entryView->currentEntry());
} else if (sender() == m_groupView || sender() == m_editGroupWidget) {
onGroupChanged();
}
}

void DatabaseWidget::switchToHistoryView(Entry* entry)
Expand Down Expand Up @@ -1486,6 +1479,8 @@ void DatabaseWidget::onGroupChanged()
m_shareLabel->setVisible(false);
}
#endif

emit groupChanged();
}

void DatabaseWidget::onDatabaseModified()
Expand Down
20 changes: 20 additions & 0 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "gui/Icons.h"
#include "gui/MessageBox.h"
#include "gui/SearchWidget.h"
#include "gui/entry/EntryView.h"
#include "gui/osutils/OSUtils.h"

#ifdef WITH_XC_UPDATECHECK
Expand Down Expand Up @@ -431,6 +432,11 @@ MainWindow::MainWindow()
m_actionMultiplexer.connect(SIGNAL(entrySelectionChanged()), this, SLOT(setMenuActionState()));
m_actionMultiplexer.connect(SIGNAL(groupContextMenuRequested(QPoint)), this, SLOT(showGroupContextMenu(QPoint)));
m_actionMultiplexer.connect(SIGNAL(entryContextMenuRequested(QPoint)), this, SLOT(showEntryContextMenu(QPoint)));
m_actionMultiplexer.connect(SIGNAL(groupChanged()), this, SLOT(updateEntryCountLabel()));
m_actionMultiplexer.connect(SIGNAL(databaseUnlocked()), this, SLOT(updateEntryCountLabel()));
m_actionMultiplexer.connect(SIGNAL(databaseModified()), this, SLOT(updateEntryCountLabel()));
m_actionMultiplexer.connect(SIGNAL(searchModeActivated()), this, SLOT(updateEntryCountLabel()));
m_actionMultiplexer.connect(SIGNAL(listModeActivated()), this, SLOT(updateEntryCountLabel()));

// Notify search when the active database changes or gets locked
connect(m_ui->tabWidget,
Expand Down Expand Up @@ -653,6 +659,7 @@ MainWindow::MainWindow()
connect(qApp, SIGNAL(openFile(QString)), this, SLOT(openDatabase(QString)));
connect(qApp, SIGNAL(quitSignalReceived()), this, SLOT(appExit()), Qt::DirectConnection);

// Setup the status bar
statusBar()->setFixedHeight(24);
m_progressBarLabel = new QLabel(statusBar());
m_progressBarLabel->setVisible(false);
Expand All @@ -665,6 +672,8 @@ MainWindow::MainWindow()
m_progressBar->setMaximum(100);
statusBar()->addPermanentWidget(m_progressBar);
connect(clipboard(), SIGNAL(updateCountdown(int, QString)), this, SLOT(updateProgressBar(int, QString)));
m_statusBarLabel = new QLabel(statusBar());
statusBar()->addPermanentWidget(m_statusBarLabel);

restoreConfigState();
}
Expand Down Expand Up @@ -1546,6 +1555,17 @@ void MainWindow::updateProgressBar(int percentage, QString message)
}
}

void MainWindow::updateEntryCountLabel()
{
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
if (dbWidget && dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode) {
int numEntries = dbWidget->entryView()->model()->rowCount();
m_statusBarLabel->setText(tr("%1 Entry(s)", "", numEntries).arg(numEntries));
} else {
m_statusBarLabel->setText("");
}
}

void MainWindow::obtainContextFocusLock()
{
m_contextMenuFocusLock = true;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private slots:
void agentEnabled(bool enabled);
void updateTrayIcon();
void updateProgressBar(int percentage, QString message);
void updateEntryCountLabel();
void focusSearchWidget();

private:
Expand Down Expand Up @@ -182,6 +183,7 @@ private slots:
QPointer<SearchWidget> m_searchWidget;
QPointer<QProgressBar> m_progressBar;
QPointer<QLabel> m_progressBarLabel;
QPointer<QLabel> m_statusBarLabel;

Q_DISABLE_COPY(MainWindow)

Expand Down
1 change: 0 additions & 1 deletion src/gui/group/GroupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ GroupView::GroupView(Database* db, QWidget* parent)
// clang-format off
connect(this, SIGNAL(expanded(QModelIndex)), SLOT(expandedChanged(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), SLOT(expandedChanged(QModelIndex)));
connect(this, SIGNAL(clicked(QModelIndex)), SIGNAL(groupSelectionChanged()));
connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(syncExpandedState(QModelIndex,int,int)));
connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SIGNAL(groupSelectionChanged()));
Expand Down

0 comments on commit 8e02451

Please sign in to comment.