Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor logging #176

Merged
merged 6 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ set(antimicrox_SOURCES
src/logger.cpp
src/mainsettingsdialog.cpp
src/mainwindow.cpp
src/messagehandler.cpp
src/mousedialog/mouseaxissettingsdialog.cpp
src/mousedialog/mousebuttonsettingsdialog.cpp
src/mousedialog/mousecontrolsticksettingsdialog.cpp
Expand Down Expand Up @@ -304,7 +303,6 @@ set(antimicrox_HEADERS
src/logger.h
src/mainsettingsdialog.h
src/mainwindow.h
src/messagehandler.h
src/mousedialog/mouseaxissettingsdialog.h
src/mousedialog/mousebuttonsettingsdialog.h
src/mousedialog/mousecontrolsticksettingsdialog.h
Expand Down
17 changes: 1 addition & 16 deletions src/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "common.h"
#include "eventhandlerfactory.h"
#include "messagehandler.h"

#include <SDL2/SDL_gamecontroller.h>
#include <SDL2/SDL_version.h>
Expand All @@ -39,24 +38,14 @@ AboutDialog::AboutDialog(QWidget *parent)
, ui(new Ui::AboutDialog)
{
ui->setupUi(this);

qInstallMessageHandler(MessageHandler::myMessageOutput);

ui->versionLabel->setText(PadderCommon::programVersion);
fillInfoTextBrowser();
}

AboutDialog::~AboutDialog()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

delete ui;
}
AboutDialog::~AboutDialog() { delete ui; }

void AboutDialog::fillInfoTextBrowser()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QStringList finalInfoText = QStringList();

finalInfoText.append(tr("Program Version %1").arg(PadderCommon::programVersion));
Expand Down Expand Up @@ -113,8 +102,6 @@ void AboutDialog::fillInfoTextBrowser()

void AboutDialog::changeEvent(QEvent *event)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

if (event->type() == QEvent::LanguageChange)
retranslateUi();

Expand All @@ -123,8 +110,6 @@ void AboutDialog::changeEvent(QEvent *event)

void AboutDialog::retranslateUi()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

ui->retranslateUi(this);

ui->versionLabel->setText(PadderCommon::programVersion);
Expand Down
66 changes: 7 additions & 59 deletions src/addeditautoprofiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "autoprofileinfo.h"
#include "common.h"
#include "inputdevice.h"
#include "messagehandler.h"

#ifdef WITH_X11
#include "capturedwindowinfodialog.h"
Expand All @@ -46,8 +45,6 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMi
, ui(new Ui::AddEditAutoProfileDialog)
{
ui->setupUi(this);

qInstallMessageHandler(MessageHandler::myMessageOutput);
setAttribute(Qt::WA_DeleteOnClose);

this->info = info;
Expand Down Expand Up @@ -134,17 +131,10 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(QWidget *parent)
{
}

AddEditAutoProfileDialog::~AddEditAutoProfileDialog()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

delete ui;
}
AddEditAutoProfileDialog::~AddEditAutoProfileDialog() { delete ui; }

void AddEditAutoProfileDialog::openProfileBrowseDialog()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QString lookupDir = PadderCommon::preferredProfileDir(settings);
QString filename =
QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, QString("Config Files (*.amgp *.xml)"));
Expand All @@ -155,8 +145,6 @@ void AddEditAutoProfileDialog::openProfileBrowseDialog()

void AddEditAutoProfileDialog::openApplicationBrowseDialog()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QString filename = QFileDialog::getOpenFileName(this, tr("Select Program"), QDir::homePath(), QString());

if (!filename.isNull() && !filename.isEmpty())
Expand All @@ -168,23 +156,15 @@ void AddEditAutoProfileDialog::openApplicationBrowseDialog()
}
}

AutoProfileInfo *AddEditAutoProfileDialog::getAutoProfile() const
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

return info;
}
AutoProfileInfo *AddEditAutoProfileDialog::getAutoProfile() const { return info; }

void AddEditAutoProfileDialog::saveAutoProfileInformation()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

info->setProfileLocation(ui->profileLineEdit->text());
int deviceIndex = ui->devicesComboBox->currentIndex();

if (deviceIndex > 0)
{

// Assume that if the following is not true, the GUID should
// not be changed.
if (!ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole).isNull())
Expand All @@ -208,8 +188,6 @@ void AddEditAutoProfileDialog::saveAutoProfileInformation()

void AddEditAutoProfileDialog::checkForReservedUniques(int index)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QVariant data = ui->devicesComboBox->itemData(index);

if (index == 0)
Expand All @@ -231,40 +209,19 @@ void AddEditAutoProfileDialog::checkForReservedUniques(int index)
}
}

QString AddEditAutoProfileDialog::getOriginalUniqueID() const
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

return originalUniqueID;
}

QString AddEditAutoProfileDialog::getOriginalExe() const
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

return originalExe;
}
QString AddEditAutoProfileDialog::getOriginalUniqueID() const { return originalUniqueID; }

QString AddEditAutoProfileDialog::getOriginalWindowClass() const
{
qInstallMessageHandler(MessageHandler::myMessageOutput);
QString AddEditAutoProfileDialog::getOriginalExe() const { return originalExe; }

return originalWindowClass;
}
QString AddEditAutoProfileDialog::getOriginalWindowClass() const { return originalWindowClass; }

QString AddEditAutoProfileDialog::getOriginalWindowName() const
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

return originalWindowName;
}
QString AddEditAutoProfileDialog::getOriginalWindowName() const { return originalWindowName; }

/**
* @brief Display a simple message box and attempt to capture a window using the mouse
*/
void AddEditAutoProfileDialog::showCaptureHelpWindow()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);
#ifdef WITH_X11

if (QApplication::platformName() == QStringLiteral("xcb"))
Expand Down Expand Up @@ -301,10 +258,7 @@ void AddEditAutoProfileDialog::showCaptureHelpWindow()
*/
void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility *util)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

#ifdef WITH_X11
if (QApplication::platformName() == QStringLiteral("xcb"))
#ifdef WITH_X11 if (QApplication::platformName() == QStringLiteral("xcb"))
{
long targetWindow = util->getTargetWindow();
bool escaped = !util->hasFailed();
Expand Down Expand Up @@ -356,8 +310,6 @@ void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility *u

void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *dialog)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

disconnect(ui->applicationLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
disconnect(ui->winClassLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
disconnect(ui->winNameLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
Expand Down Expand Up @@ -410,8 +362,6 @@ void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *di

void AddEditAutoProfileDialog::checkForDefaultStatus()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

bool status = ui->applicationLineEdit->text().length() > 0;
status = status ? status : (ui->winClassLineEdit->text().length() > 0);
status = status ? status : (ui->winNameLineEdit->text().length() > 0);
Expand All @@ -431,8 +381,6 @@ void AddEditAutoProfileDialog::checkForDefaultStatus()
*/
void AddEditAutoProfileDialog::accept()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

bool validForm = true;
bool propertyFound = false;
QString errorString = QString();
Expand Down
Loading