From 21675d94792fe4c944a19dd51f38659a54e9a462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Mon, 17 Mar 2025 10:57:03 +0100 Subject: [PATCH] Add install thumbnailer button --- settingsdialog.cpp | 34 ++++++++++++++++++++++++++++++++++ settingsdialog.h | 2 ++ thumbnailer/Dll.cpp | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 3e87b1c..8cc99ed 100644 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -4,6 +4,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include "rawimage.h" extern int DEFAULT_WIDTH; @@ -80,6 +86,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) m_bestFit->setToolTip(tr("Set Best Fit zoom level when opening new image.")); m_bestFit->setChecked(BESTFIT); + layout->addRow(tr("Image preload count"), m_preloadImages); layout->addRow(tr("Thumbnails size"), m_thumSize); layout->addRow(tr("Saturation"), m_saturation); @@ -88,8 +95,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) layout->addRow(m_qualityThumbnail); layout->addRow(m_useNativeDialog); layout->addRow(m_bestFit); + +#ifdef Q_OS_WIN64 + QPushButton *installThumbnailer = new QPushButton(tr("Install"), this); + installThumbnailer->setToolTip(tr("This will install thumnail generation for FITS and XISF files in File Explorer")); + connect(installThumbnailer, &QPushButton::clicked, this, &SettingsDialog::installThumbnailer); + layout->addRow(tr("Install thumbnailer"), installThumbnailer); +#endif //layout->addRow(new QLabel(tr("Changes in settings will take effect after program restart."))); + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); @@ -123,6 +138,25 @@ bool SettingsDialog::loadThumbsizes() return OLD_THUMB_SIZE != THUMB_SIZE; } +void SettingsDialog::installThumbnailer() +{ +#ifdef Q_OS_WIN64 + QString path = QCoreApplication::instance()->applicationDirPath() + "/tenmonthumbnailer.dll"; + if(!QFileInfo::exists(path)) + { + QMessageBox::critical(this, tr("Missing dll"), tr("Can't find ") + path); + return; + } + + QProcess regsvr; + int ret = regsvr.execute("regsvr32.exe", {"/s", path}); + if(ret) + { + QMessageBox::critical(this, tr("Error"), tr("Failed to register thumbnailer. %1").arg(ret)); + } +#endif +} + void SettingsDialog::saveSettings() { QSettings settings; diff --git a/settingsdialog.h b/settingsdialog.h index 2d8855b..6ec950d 100644 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -13,6 +13,8 @@ public: explicit SettingsDialog(QWidget *parent = nullptr); static void loadSettings(); static bool loadThumbsizes(); +public slots: + void installThumbnailer(); signals: void preloadChanged(int witdth); private: diff --git a/thumbnailer/Dll.cpp b/thumbnailer/Dll.cpp index 356fb90..3dffe73 100644 --- a/thumbnailer/Dll.cpp +++ b/thumbnailer/Dll.cpp @@ -208,7 +208,7 @@ STDAPI DllRegisterServer() } if (SUCCEEDED(hr)) { - // This tells the shell to invalidate the thumbnail cache. This is important because any .recipe files + // This tells the shell to invalidate the thumbnail cache. This is important because any .xisf files // viewed before registering this handler would otherwise show cached blank thumbnails. SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); }