Skip to content

Commit

Permalink
Adapt CapturedWindowInfoDialog to Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed Sep 19, 2021
1 parent 1746340 commit b9102aa
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ elseif(WIN32)
src/winextras.cpp
src/qtwinkeymapper.cpp
src/winappprofiletimerdialog.cpp
# src/capturedwindowinfodialog.cpp
src/capturedwindowinfodialog.cpp
src/eventhandlers/winsendinputeventhandler.cpp
src/joykeyrepeathelper.cpp
)
LIST(APPEND antimicrox_HEADERS
src/winextras.h
src/qtwinkeymapper.h
src/winappprofiletimerdialog.h
# src/capturedwindowinfodialog.h
src/capturedwindowinfodialog.h
src/eventhandlers/winsendinputeventhandler.h
src/joykeyrepeathelper.h
)
Expand Down
2 changes: 2 additions & 0 deletions src/antimicrosettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <QDebug>

const bool AntiMicroSettings::defaultDisabledWinEnhanced = false;

AntiMicroSettings::AntiMicroSettings(const QString &fileName, Format format, QObject *parent)
: QSettings(fileName, format, parent)
{
Expand Down
2 changes: 2 additions & 0 deletions src/antimicrosettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AntiMicroSettings : public QSettings
QMutex *getLock();
QSettings &getCmdSettings();

static const bool defaultDisabledWinEnhanced;

void applySettingsToLogger(CommandLineUtility &cmdutility, Logger *logger = nullptr);

protected:
Expand Down
43 changes: 40 additions & 3 deletions src/capturedwindowinfodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
#include <QPushButton>
#include <QWidget>

#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)
{
Expand All @@ -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>(window));
ui->winClassLabel->setText(winClass);

Expand All @@ -54,8 +70,13 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent)
}

ui->winPathChoiceComboBox->setVisible(false);
#endif

winName = info->getWindowTitle(static_cast<Window>(window));
#ifdef Q_OS_WIN
winName = WinExtras::getCurrentWindowText();
#else
winName = info->getWindowTitle(window);
#endif

ui->winTitleLabel->setText(winName);

Expand All @@ -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>(window));

if (pid > 0)
Expand All @@ -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())
{
Expand Down
4 changes: 4 additions & 0 deletions src/capturedwindowinfodialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9102aa

Please sign in to comment.