Show entry count in status bar

Closes #3963
This commit is contained in:
Jonathan White 2022-09-05 12:56:10 -04:00
parent 79ac8b3c95
commit f32dc96757
3 changed files with 24 additions and 7 deletions

View File

@ -200,7 +200,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)));
@ -1041,12 +1040,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)
@ -1508,6 +1501,8 @@ void DatabaseWidget::onGroupChanged()
m_shareLabel->setVisible(false);
}
#endif
emit groupChanged();
}
void DatabaseWidget::onDatabaseModified()

View File

@ -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
@ -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,
@ -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);
@ -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();
}
@ -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;

View File

@ -147,6 +147,7 @@ private slots:
void agentEnabled(bool enabled);
void updateTrayIcon();
void updateProgressBar(int percentage, QString message);
void updateEntryCountLabel();
void focusSearchWidget();
private:
@ -182,6 +183,7 @@ private:
QPointer<SearchWidget> m_searchWidget;
QPointer<QProgressBar> m_progressBar;
QPointer<QLabel> m_progressBarLabel;
QPointer<QLabel> m_statusBarLabel;
Q_DISABLE_COPY(MainWindow)