aboutsummaryrefslogtreecommitdiff
path: root/qdeduper
diff options
context:
space:
mode:
Diffstat (limited to 'qdeduper')
-rw-r--r--qdeduper/mingui.cpp20
-rw-r--r--qdeduper/mingui.hpp4
-rw-r--r--qdeduper/sigdb_qt.cpp5
-rw-r--r--qdeduper/sigdb_qt.hpp2
4 files changed, 30 insertions, 1 deletions
diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp
index 3d11e36..c9ca2f8 100644
--- a/qdeduper/mingui.cpp
+++ b/qdeduper/mingui.cpp
@@ -29,12 +29,12 @@
#include <QAction>
#include <QSplitter>
#include <QString>
+#include <QTimer>
#include <QScrollArea>
#include <QListView>
#include <QProgressDialog>
#include <QStandardItemModel>
#include <QLabel>
-#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QStatusBar>
#include <QPixmap>
@@ -84,6 +84,7 @@ DeduperMainWindow::DeduperMainWindow()
this->setup_menu();
this->update_actions();
sb = this->statusBar();
+ sb->addPermanentWidget(dbramusg = new QLabel());
sb->addPermanentWidget(permamsg = new QLabel());
QLabel *opm = new QLabel();
opm->setText("placeholder status bar text");
@@ -136,12 +137,16 @@ DeduperMainWindow::DeduperMainWindow()
lv->setFont(fnt);
infopanel->setFont(fnt);
pdlb->setFont(fnt);
+ rampupd = new QTimer(this);
+ rampupd->setInterval(1000);
+ QObject::connect(rampupd, &QTimer::timeout, this, &DeduperMainWindow::update_memusg);
sr = new SettingsRegistry(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qdeduperrc"));
int generalt = sr->register_tab("General");
sr->register_int_option(generalt, "min_image_dim", "Minimal Dimension in Image View", 16, 4096, 64);
sr->register_int_option(generalt, "thread_count", "Number of Threads (0 = Automatic)", 0, 4096, 0);
sr->register_bool_option(generalt, "toolbar_text", "Show Text in Toolbar Buttons", true);
+ sr->register_bool_option(generalt, "show_memory_usage", "Show Database Engine Memory Usage", false);
int sigt = sr->register_tab("Signature");
sr->register_double_option(sigt, "signature/threshold", "Distance Threshold", 0, 1, 0.3);
prefdlg = new PreferenceDialog(sr, this);
@@ -770,6 +775,19 @@ void DeduperMainWindow::apply_prefs()
id->set_min_height(sr->get_option_int("min_image_dim"));
tb->setToolButtonStyle(sr->get_option_bool("toolbar_text") ? Qt::ToolButtonStyle::ToolButtonTextBesideIcon
: Qt::ToolButtonStyle::ToolButtonIconOnly);
+ if (sr->get_option_bool("show_memory_usage"))
+ this->rampupd->start();
+ else
+ {
+ this->rampupd->stop();
+ this->dbramusg->setText(QString());
+ }
+}
+
+void DeduperMainWindow::update_memusg()
+{
+ if (this->sdb)
+ dbramusg->setText(QString("Database memory usage: %1").arg(QLocale::system().formattedDataSize(this->sdb->db_memory_usage())));
}
void DeduperMainWindow::sort_reassign_hotkeys()
diff --git a/qdeduper/mingui.hpp b/qdeduper/mingui.hpp
index 5686c3e..d675d47 100644
--- a/qdeduper/mingui.hpp
+++ b/qdeduper/mingui.hpp
@@ -23,6 +23,7 @@ class QProgressDialog;
class QSplitter;
class QStandardItemModel;
class QToolBar;
+class QTimer;
class FileScanner;
class ImageItemDelegate;
class SettingsRegistry;
@@ -44,6 +45,7 @@ private:
QSplitter *l;
QTextEdit *infopanel;
QLabel *permamsg;
+ QLabel *dbramusg;
QStatusBar *sb;
QListView *lv;
QToolBar *tb = nullptr;
@@ -56,6 +58,7 @@ private:
FileScanner *fsc = nullptr;
SettingsRegistry *sr = nullptr;
PreferenceDialog *prefdlg = nullptr;
+ QTimer *rampupd = nullptr;
std::unordered_set<fs::path> marked;
int sort_role;
Qt::SortOrder sort_order;
@@ -95,6 +98,7 @@ public Q_SLOTS:
void show_group(size_t gid);
void show_marked();
void apply_prefs();
+ void update_memusg();
Q_SIGNALS:
void next();
void prev();
diff --git a/qdeduper/sigdb_qt.cpp b/qdeduper/sigdb_qt.cpp
index 2128f8d..aff7312 100644
--- a/qdeduper/sigdb_qt.cpp
+++ b/qdeduper/sigdb_qt.cpp
@@ -187,3 +187,8 @@ bool SignatureDB::save(const fs::path &p)
{
return sdb->to_db_file(p);
}
+
+int64_t SignatureDB::db_memory_usage()
+{
+ return sdb->db_memory_usage();
+}
diff --git a/qdeduper/sigdb_qt.hpp b/qdeduper/sigdb_qt.hpp
index 39b57b7..a1203be 100644
--- a/qdeduper/sigdb_qt.hpp
+++ b/qdeduper/sigdb_qt.hpp
@@ -51,6 +51,8 @@ public:
bool load(const fs::path &p);
bool save(const fs::path &p);
+
+ int64_t db_memory_usage();
Q_SIGNALS:
void image_scanned(size_t n);
};