start "hide league client" feature
This commit is contained in:
parent
90c328aa4b
commit
16e1813f95
|
@ -16,6 +16,7 @@ class QMessageBox;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
class LoadingWindow;
|
class LoadingWindow;
|
||||||
|
class X11Helper;
|
||||||
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
|
@ -37,6 +38,8 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void loadingStatus(float);
|
void loadingStatus(float);
|
||||||
|
|
||||||
|
void toggleLeagueVisibility();
|
||||||
|
|
||||||
void toggleMainswitch(bool);
|
void toggleMainswitch(bool);
|
||||||
void aatoggled(bool);
|
void aatoggled(bool);
|
||||||
void smitewarntoggled(bool);
|
void smitewarntoggled(bool);
|
||||||
|
@ -63,6 +66,7 @@ private:
|
||||||
LolAutoAccept lolaa;
|
LolAutoAccept lolaa;
|
||||||
LoadingWindow* lwin;
|
LoadingWindow* lwin;
|
||||||
QMessageBox* dodgeQuestion;
|
QMessageBox* dodgeQuestion;
|
||||||
|
X11Helper* x11Helper;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef X11HELPER_H
|
||||||
|
#define X11HELPER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
using Window = unsigned long;
|
||||||
|
struct _XDisplay;
|
||||||
|
using Display = struct _XDisplay;
|
||||||
|
|
||||||
|
class X11Helper : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static Window InvalidWindow;
|
||||||
|
|
||||||
|
explicit X11Helper(QObject* parent = nullptr);
|
||||||
|
virtual ~X11Helper();
|
||||||
|
|
||||||
|
Window findWindow(const QString& name);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void map(Window win);
|
||||||
|
void unmap(Window win);
|
||||||
|
void setMap(Window win, bool b);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Window searchWindows(Window top, const QString& search);
|
||||||
|
|
||||||
|
Display* disp;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // X11HELPER_H
|
|
@ -66,6 +66,7 @@ SOURCES += \
|
||||||
src/runepagelist.cpp \
|
src/runepagelist.cpp \
|
||||||
src/settingstab.cpp \
|
src/settingstab.cpp \
|
||||||
src/stagesettings.cpp \
|
src/stagesettings.cpp \
|
||||||
|
src/x11helper.cpp \
|
||||||
thirdparty/Log/Log.cpp
|
thirdparty/Log/Log.cpp
|
||||||
|
|
||||||
# platform specific implementations
|
# platform specific implementations
|
||||||
|
@ -101,6 +102,7 @@ HEADERS += \
|
||||||
include/runepagelist.h \
|
include/runepagelist.h \
|
||||||
include/settingstab.h \
|
include/settingstab.h \
|
||||||
include/stagesettings.h \
|
include/stagesettings.h \
|
||||||
|
include/x11helper.h \
|
||||||
thirdparty/Log/Log.h
|
thirdparty/Log/Log.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
@ -130,6 +132,9 @@ QMAKE_EXTRA_TARGETS += updatelang
|
||||||
|
|
||||||
# build AppImage
|
# build AppImage
|
||||||
unix {
|
unix {
|
||||||
|
DEFINES += X11SUPPORT=1
|
||||||
|
LIBS += -lX11
|
||||||
|
|
||||||
linuxdeploy-x86_64.AppImage.commands = wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod u+x linuxdeploy-x86_64.AppImage
|
linuxdeploy-x86_64.AppImage.commands = wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod u+x linuxdeploy-x86_64.AppImage
|
||||||
|
|
||||||
resources/lolautoaccept.png.depends = resources/lolautoaccept.svg
|
resources/lolautoaccept.png.depends = resources/lolautoaccept.svg
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
#include <Log.h>
|
#include <Log.h>
|
||||||
|
|
||||||
#include "loadingwindow.h"
|
#include "loadingwindow.h"
|
||||||
|
#include "x11helper.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
||||||
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)),
|
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)),
|
||||||
dodgeQuestion(new QMessageBox(QMessageBox::Icon::Warning, MainWindow::tr("Dodge?"), MainWindow::tr("Are you sure you want to dodge?"), QMessageBox::Cancel | QMessageBox::Yes, this)) {
|
dodgeQuestion(new QMessageBox(QMessageBox::Icon::Warning, MainWindow::tr("Dodge?"), MainWindow::tr("Are you sure you want to dodge?"), QMessageBox::Cancel | QMessageBox::Yes, this)),
|
||||||
|
x11Helper(new X11Helper(this)) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
||||||
|
@ -27,6 +29,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui
|
||||||
QObject::connect(&lolaa, &LolAutoAccept::statusChanged, this, &MainWindow::lolaaStatusChanged);
|
QObject::connect(&lolaa, &LolAutoAccept::statusChanged, this, &MainWindow::lolaaStatusChanged);
|
||||||
QObject::connect(&lolaa, &LolAutoAccept::positionChanged, this, &MainWindow::onPosChange);
|
QObject::connect(&lolaa, &LolAutoAccept::positionChanged, this, &MainWindow::onPosChange);
|
||||||
|
|
||||||
|
QObject::connect(ui->hideLeague, &QCheckBox::stateChanged, this, &MainWindow::toggleLeagueVisibility);
|
||||||
|
|
||||||
saveTimer->setInterval(std::chrono::minutes(1));
|
saveTimer->setInterval(std::chrono::minutes(1));
|
||||||
saveTimer->setSingleShot(true);
|
saveTimer->setSingleShot(true);
|
||||||
QObject::connect(saveTimer, &QTimer::timeout, this, &MainWindow::saveConfig);
|
QObject::connect(saveTimer, &QTimer::timeout, this, &MainWindow::saveConfig);
|
||||||
|
@ -97,6 +101,20 @@ void MainWindow::loadingStatus(float f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::toggleLeagueVisibility() {
|
||||||
|
if(x11Helper) {
|
||||||
|
const bool shouldBeHidden = ui->hideLeague->isChecked();
|
||||||
|
Window win = x11Helper->findWindow("League of Legends");
|
||||||
|
qInfo() << "LeagueClient win id:" << win;
|
||||||
|
if(win != 0) {
|
||||||
|
x11Helper->setMap(win, shouldBeHidden);
|
||||||
|
} else {
|
||||||
|
// TODO: show error in status bar?
|
||||||
|
// TODO: reset checkbox to unchecked?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::toggleMainswitch(bool state) {
|
void MainWindow::toggleMainswitch(bool state) {
|
||||||
qDebug() << "mainswitch toggled: " << state;
|
qDebug() << "mainswitch toggled: " << state;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "x11helper.h"
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
X11Helper::X11Helper(QObject *parent) : QObject(parent), disp(XOpenDisplay(nullptr)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
X11Helper::~X11Helper() {
|
||||||
|
XCloseDisplay(this->disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Window X11Helper::findWindow(const QString& name) {
|
||||||
|
return searchWindows(DefaultRootWindow(disp), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Window X11Helper::searchWindows(Window top, const QString& search) {
|
||||||
|
{
|
||||||
|
char* window_name;
|
||||||
|
if (XFetchName(disp, top, &window_name)) {
|
||||||
|
QString winName(window_name);
|
||||||
|
XFree(window_name);
|
||||||
|
if (search == winName) {
|
||||||
|
return top; // dont look for kids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window* children = nullptr;
|
||||||
|
Window dummy;
|
||||||
|
unsigned int nchildren;
|
||||||
|
if (!XQueryTree(disp, top, &dummy, &dummy, &children, &nchildren)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < nchildren; i++) {
|
||||||
|
Window res = searchWindows(children[i], search);
|
||||||
|
if(res != 0) {
|
||||||
|
XFree((char*) children);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (children) {
|
||||||
|
XFree((char*) children);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::map(Window win) {
|
||||||
|
XMapRaised(disp, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::unmap(Window win) {
|
||||||
|
XUnmapWindow(disp, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::setMap(Window win, bool b) {
|
||||||
|
if(b) {
|
||||||
|
map(win);
|
||||||
|
} else {
|
||||||
|
unmap(win);
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,6 +62,30 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QCheckBox" name="enableAutoWrite">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Write a Text as soon as you are in a champ select lobby.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto Write</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="dodgeBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Dodge without closing the client.
|
||||||
|
You will still be punished.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Dodge</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="enableSmiteWarning">
|
<widget class="QCheckBox" name="enableSmiteWarning">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -75,7 +99,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" rowspan="6">
|
<item row="0" column="1" rowspan="7">
|
||||||
<widget class="QLabel" name="copyrightlabel">
|
<widget class="QLabel" name="copyrightlabel">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
@ -97,7 +121,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
<item row="9" column="0" colspan="2">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
|
@ -190,17 +214,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="enableAutoWrite">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Write a Text as soon as you are in a champ select lobby.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto Write</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0" colspan="2">
|
|
||||||
<widget class="QTextEdit" name="autoWriteText">
|
<widget class="QTextEdit" name="autoWriteText">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -237,6 +251,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" rowspan="2">
|
||||||
|
<widget class="QCheckBox" name="enableAll">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable LoL-Auto-Accept</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="mainswitch">
|
<widget class="QCheckBox" name="mainswitch">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -247,24 +268,15 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" rowspan="2">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="enableAll">
|
<widget class="QCheckBox" name="hideLeague">
|
||||||
<property name="text">
|
|
||||||
<string>Enable LoL-Auto-Accept</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="2">
|
|
||||||
<widget class="QPushButton" name="dodgeBtn">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Dodge without closing the client.
|
<string>This hides the League Client.
|
||||||
You will still be punished.</string>
|
It will not anoy you anymore.
|
||||||
|
Only available on Linux with X11.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Dodge</string>
|
<string>Hide League Client</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue