From b9102aa7869ef144d161926d0062e7b843c0bdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Sun, 19 Sep 2021 11:59:58 +0200 Subject: [PATCH] Adapt CapturedWindowInfoDialog to Windows --- CMakeLists.txt | 4 +-- src/antimicrosettings.cpp | 2 ++ src/antimicrosettings.h | 2 ++ src/capturedwindowinfodialog.cpp | 43 +++++++++++++++++++++++++++++--- src/capturedwindowinfodialog.h | 4 +++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16fc77bef..f668d8ebd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,7 +407,7 @@ elseif(WIN32) src/winextras.cpp src/qtwinkeymapper.cpp src/winappprofiletimerdialog.cpp - # src/capturedwindowinfodialog.cpp + src/capturedwindowinfodialog.cpp src/eventhandlers/winsendinputeventhandler.cpp src/joykeyrepeathelper.cpp ) @@ -415,7 +415,7 @@ elseif(WIN32) src/winextras.h src/qtwinkeymapper.h src/winappprofiletimerdialog.h - # src/capturedwindowinfodialog.h + src/capturedwindowinfodialog.h src/eventhandlers/winsendinputeventhandler.h src/joykeyrepeathelper.h ) diff --git a/src/antimicrosettings.cpp b/src/antimicrosettings.cpp index fffcc58a4..35a7abbbb 100644 --- a/src/antimicrosettings.cpp +++ b/src/antimicrosettings.cpp @@ -20,6 +20,8 @@ #include +const bool AntiMicroSettings::defaultDisabledWinEnhanced = false; + AntiMicroSettings::AntiMicroSettings(const QString &fileName, Format format, QObject *parent) : QSettings(fileName, format, parent) { diff --git a/src/antimicrosettings.h b/src/antimicrosettings.h index cc9382e57..e2ef74768 100644 --- a/src/antimicrosettings.h +++ b/src/antimicrosettings.h @@ -35,6 +35,8 @@ class AntiMicroSettings : public QSettings QMutex *getLock(); QSettings &getCmdSettings(); + static const bool defaultDisabledWinEnhanced; + void applySettingsToLogger(CommandLineUtility &cmdutility, Logger *logger = nullptr); protected: diff --git a/src/capturedwindowinfodialog.cpp b/src/capturedwindowinfodialog.cpp index b43c7a222..3af7df516 100644 --- a/src/capturedwindowinfodialog.cpp +++ b/src/capturedwindowinfodialog.cpp @@ -23,9 +23,17 @@ #include #include -#include "x11extras.h" - +#ifdef Q_OS_WIN + #include "winextras.h" +#else + #include "x11extras.h" +#endif + +#ifdef Q_OS_WIN +CapturedWindowInfoDialog::CapturedWindowInfoDialog(QWidget *parent) +#else CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) +#endif : QDialog(parent) , ui(new Ui::CapturedWindowInfoDialog) { @@ -34,12 +42,20 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) selectedMatch = WindowNone; +#ifdef Q_OS_UNIX X11Extras *info = X11Extras::getInstance(); ui->winPathChoiceComboBox->setVisible(false); +#endif bool setRadioDefault = false; fullWinPath = false; +#ifdef Q_OS_WIN + ui->winClassCheckBox->setVisible(false); + ui->winClassLabel->setVisible(false); + ui->winClassHeadLabel->setVisible(false); +#else + winClass = info->getWindowClass(static_cast(window)); ui->winClassLabel->setText(winClass); @@ -54,8 +70,13 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) } ui->winPathChoiceComboBox->setVisible(false); +#endif - winName = info->getWindowTitle(static_cast(window)); +#ifdef Q_OS_WIN + winName = WinExtras::getCurrentWindowText(); +#else + winName = info->getWindowTitle(window); +#endif ui->winTitleLabel->setText(winName); @@ -70,7 +91,22 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) } ui->winPathLabel->clear(); +#ifdef Q_OS_WIN + winPath = WinExtras::getForegroundWindowExePath(); + ui->winPathLabel->setText(winPath); + + if (winPath.isEmpty()) + { + ui->winPathCheckBox->setEnabled(false); + ui->winPathCheckBox->setChecked(false); + } else + { + ui->winPathCheckBox->setChecked(true); + ui->winTitleCheckBox->setChecked(false); + setRadioDefault = true; + } +#elif defined(Q_OS_LINUX) int pid = info->getApplicationPid(static_cast(window)); if (pid > 0) @@ -95,6 +131,7 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) ui->winPathCheckBox->setEnabled(false); ui->winPathCheckBox->setChecked(false); } +#endif if (winClass.isEmpty() && winName.isEmpty() && winPath.isEmpty()) { diff --git a/src/capturedwindowinfodialog.h b/src/capturedwindowinfodialog.h index a695781c2..f77bd24af 100644 --- a/src/capturedwindowinfodialog.h +++ b/src/capturedwindowinfodialog.h @@ -32,7 +32,11 @@ class CapturedWindowInfoDialog : public QDialog Q_OBJECT public: +#ifdef Q_OS_WIN + explicit CapturedWindowInfoDialog(QWidget *parent = 0); +#else explicit CapturedWindowInfoDialog(long window, QWidget *parent = nullptr); +#endif ~CapturedWindowInfoDialog(); enum