Add install thumbnailer button

This commit is contained in:
2025-03-17 10:57:03 +01:00
parent f669baa8a6
commit 21675d9479
3 changed files with 37 additions and 1 deletions
+34
View File
@@ -4,6 +4,12 @@
#include <QLabel> #include <QLabel>
#include <QSettings> #include <QSettings>
#include <QApplication> #include <QApplication>
#include <QProcess>
#include <QCoreApplication>
#include <QFileInfo>
#include <QMessageBox>
#include <QDir>
#include <QPushButton>
#include "rawimage.h" #include "rawimage.h"
extern int DEFAULT_WIDTH; 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->setToolTip(tr("Set Best Fit zoom level when opening new image."));
m_bestFit->setChecked(BESTFIT); m_bestFit->setChecked(BESTFIT);
layout->addRow(tr("Image preload count"), m_preloadImages); layout->addRow(tr("Image preload count"), m_preloadImages);
layout->addRow(tr("Thumbnails size"), m_thumSize); layout->addRow(tr("Thumbnails size"), m_thumSize);
layout->addRow(tr("Saturation"), m_saturation); layout->addRow(tr("Saturation"), m_saturation);
@@ -88,8 +95,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
layout->addRow(m_qualityThumbnail); layout->addRow(m_qualityThumbnail);
layout->addRow(m_useNativeDialog); layout->addRow(m_useNativeDialog);
layout->addRow(m_bestFit); 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."))); //layout->addRow(new QLabel(tr("Changes in settings will take effect after program restart.")));
QDialogButtonBox *buttonBox = new QDialogButtonBox(this); QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
@@ -123,6 +138,25 @@ bool SettingsDialog::loadThumbsizes()
return OLD_THUMB_SIZE != THUMB_SIZE; 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() void SettingsDialog::saveSettings()
{ {
QSettings settings; QSettings settings;
+2
View File
@@ -13,6 +13,8 @@ public:
explicit SettingsDialog(QWidget *parent = nullptr); explicit SettingsDialog(QWidget *parent = nullptr);
static void loadSettings(); static void loadSettings();
static bool loadThumbsizes(); static bool loadThumbsizes();
public slots:
void installThumbnailer();
signals: signals:
void preloadChanged(int witdth); void preloadChanged(int witdth);
private: private:
+1 -1
View File
@@ -208,7 +208,7 @@ STDAPI DllRegisterServer()
} }
if (SUCCEEDED(hr)) 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. // viewed before registering this handler would otherwise show cached blank thumbnails.
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
} }