AntiMicroX
autoprofilewatcher.h
Go to the documentation of this file.
1 /* antimicrox Gamepad to KB+M event mapper
2  * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
3  * Copyright (C) 2020 Jagoda Górska <juliagoda.pl@protonmail>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef AUTOPROFILEWATCHER_H
20 #define AUTOPROFILEWATCHER_H
21 
22 #include <QHash>
23 #include <QSet>
24 #include <QTimer>
25 
26 class AntiMicroSettings;
27 class AutoProfileInfo;
28 class QSettings;
29 
35 class AutoProfileWatcher : public QObject
36 {
37  Q_OBJECT
38 
39  public:
40  explicit AutoProfileWatcher(AntiMicroSettings *settings, QObject *parent = nullptr);
42 
43  void startTimer();
44  void stopTimer();
45  static void disconnectWindowTimer();
47  QList<AutoProfileInfo *> *getCustomDefaults();
49  // bool isGUIDLocked(QString guid);
50  bool isUniqueIDLocked(QString uniqueID);
51  QHash<QString, QList<AutoProfileInfo *>> const &getAppProfileAssignments();
52  QHash<QString, QList<AutoProfileInfo *>> const &getWindowClassProfileAssignments();
53  QHash<QString, QList<AutoProfileInfo *>> const &getWindowNameProfileAssignments();
54  QHash<QString, AutoProfileInfo *> const &getDefaultProfileAssignments();
55 
56  static const int CHECKTIME = 500; // time in ms
57 
58  protected:
59  QString findAppLocation();
61  void convToUniqueIDAutoProfGroupSett(QSettings *sett, QString guidAutoProfSett, QString uniqueAutoProfSett);
62 
63  signals:
65 
66  public slots:
67  void syncProfileAssignment();
68 
69  private slots:
70  void runAppCheck();
71 
72  private:
73  // QSet<QString>& getGuidSetLocal();
74  QSet<QString> &getUniqeIDSetLocal();
75 
77  static QTimer checkWindowTimer;
79  QHash<QString, QList<AutoProfileInfo *>> appProfileAssignments;
80  QHash<QString, QList<AutoProfileInfo *>> windowClassProfileAssignments;
81  QHash<QString, QList<AutoProfileInfo *>> windowNameProfileAssignments;
82  QHash<QString, AutoProfileInfo *> defaultProfileAssignments;
86  // QSet<QString> guidSet;
87  QSet<QString> uniqueIDSet;
88 };
89 
90 #endif // AUTOPROFILEWATCHER_H
x11extras.h
AutoProfileWatcher::clearProfileAssignments
void clearProfileAssignments()
Definition: autoprofilewatcher.cpp:510
AutoProfileWatcher::_instance
static AutoProfileWatcher * _instance
Definition: autoprofilewatcher.h:76
AutoProfileWatcher::isUniqueIDLocked
bool isUniqueIDLocked(QString uniqueID)
Definition: autoprofilewatcher.cpp:607
X11Extras::getWindowClass
QString getWindowClass(Window window)
Definition: x11extras.cpp:536
AutoProfileWatcher::windowClassProfileAssignments
QHash< QString, QList< AutoProfileInfo * > > windowClassProfileAssignments
Definition: autoprofilewatcher.h:80
AutoProfileWatcher::findAppLocation
QString findAppLocation()
Definition: autoprofilewatcher.cpp:570
AutoProfileInfo::setWindowClass
void setWindowClass(QString windowClass)
Definition: autoprofileinfo.cpp:99
AutoProfileWatcher::getUniqeIDSetLocal
QSet< QString > & getUniqeIDSetLocal()
Definition: autoprofilewatcher.cpp:629
AutoProfileInfo::setWindowName
void setWindowName(QString winName)
Definition: autoprofileinfo.cpp:103
AutoProfileInfo::setPartialState
void setPartialState(bool value)
Definition: autoprofileinfo.cpp:129
X11Extras::getApplicationLocation
QString getApplicationLocation(int pid)
Find the application file location for a given PID.
Definition: x11extras.cpp:336
WinExtras::getCurrentWindowText
static QString getCurrentWindowText()
Get the window text of the window currently in focus.
Definition: winextras.cpp:458
AutoProfileWatcher::AutoProfileWatcher
AutoProfileWatcher(AntiMicroSettings *settings, QObject *parent=nullptr)
Definition: autoprofilewatcher.cpp:41
AntiMicroSettings::getLock
QMutex * getLock()
Definition: antimicrosettings.cpp:95
AutoProfileWatcher::disconnectWindowTimer
static void disconnectWindowTimer()
Definition: autoprofilewatcher.cpp:67
AutoProfileWatcher::convToUniqueIDAutoProfGroupSett
void convToUniqueIDAutoProfGroupSett(QSettings *sett, QString guidAutoProfSett, QString uniqueAutoProfSett)
Definition: autoprofilewatcher.cpp:631
AutoProfileInfo::setExe
void setExe(QString exe)
Definition: autoprofileinfo.cpp:75
winextras.h
AntiMicroSettings
Definition: antimicrosettings.h:26
X11Extras::findParentClient
Window findParentClient(Window window)
Definition: x11extras.cpp:170
autoprofilewatcher.h
AutoProfileWatcher::runAppCheck
void runAppCheck()
Definition: autoprofilewatcher.cpp:77
AutoProfileWatcher::uniqueIDSet
QSet< QString > uniqueIDSet
Definition: autoprofilewatcher.h:87
AutoProfileWatcher::getWindowNameProfileAssignments
const QHash< QString, QList< AutoProfileInfo * > > & getWindowNameProfileAssignments()
Definition: autoprofilewatcher.cpp:619
AutoProfileWatcher::foundApplicableProfile
void foundApplicableProfile(AutoProfileInfo *info)
AutoProfileInfo::setDefaultState
void setDefaultState(bool value)
Definition: autoprofileinfo.cpp:111
AutoProfileWatcher::stopTimer
void stopTimer()
Definition: autoprofilewatcher.cpp:75
AutoProfileWatcher::~AutoProfileWatcher
~AutoProfileWatcher()
Definition: autoprofilewatcher.cpp:54
AutoProfileWatcher::syncProfileAssignment
void syncProfileAssignment()
Definition: autoprofilewatcher.cpp:336
AutoProfileWatcher::getCustomDefaults
QList< AutoProfileInfo * > * getCustomDefaults()
Definition: autoprofilewatcher.cpp:591
X11Extras::getWindowInFocus
unsigned long getWindowInFocus()
Definition: x11extras.cpp:574
WinExtras::getForegroundWindowExePath
static QString getForegroundWindowExePath()
Check foreground window (window in focus) and obtain the corresponding exe file path.
Definition: winextras.cpp:248
AutoProfileWatcher::getWindowClassProfileAssignments
const QHash< QString, QList< AutoProfileInfo * > > & getWindowClassProfileAssignments()
Definition: autoprofilewatcher.cpp:614
AutoProfileWatcher::windowNameProfileAssignments
QHash< QString, QList< AutoProfileInfo * > > windowNameProfileAssignments
Definition: autoprofilewatcher.h:81
AutoProfileWatcher::settings
AntiMicroSettings * settings
Definition: autoprofilewatcher.h:78
AutoProfileWatcher::getAppProfileAssignments
const QHash< QString, QList< AutoProfileInfo * > > & getAppProfileAssignments()
Definition: autoprofilewatcher.cpp:609
AutoProfileWatcher::currentApplication
QString currentApplication
Definition: autoprofilewatcher.h:84
AutoProfileWatcher::currentAppWindowTitle
QString currentAppWindowTitle
Definition: autoprofilewatcher.h:85
AutoProfileWatcher::CHECKTIME
static const int CHECKTIME
Definition: autoprofilewatcher.h:56
AutoProfileInfo::isActive
bool isActive()
Definition: autoprofileinfo.cpp:109
AutoProfileWatcher::getDefaultProfileAssignments
const QHash< QString, AutoProfileInfo * > & getDefaultProfileAssignments()
Definition: autoprofilewatcher.cpp:624
AutoProfileWatcher::getAutoProfileWatcherInstance
static AutoProfileWatcher * getAutoProfileWatcherInstance()
Definition: autoprofilewatcher.cpp:65
AutoProfileWatcher::defaultProfileAssignments
QHash< QString, AutoProfileInfo * > defaultProfileAssignments
Definition: autoprofilewatcher.h:82
X11Extras::getInstance
static X11Extras * getInstance()
Definition: x11extras.cpp:73
AutoProfileWatcher::startTimer
void startTimer()
Definition: autoprofilewatcher.cpp:73
autoprofileinfo.h
AutoProfileWatcher::getDefaultAllProfile
AutoProfileInfo * getDefaultAllProfile()
Definition: autoprofilewatcher.cpp:605
AutoProfileWatcher::allDefaultInfo
AutoProfileInfo * allDefaultInfo
Definition: autoprofilewatcher.h:83
X11Extras::getApplicationPid
int getApplicationPid(Window window)
Check window and any parents for the window property "_NET_WM_PID".
Definition: x11extras.cpp:243
AutoProfileInfo
Links information about targeted application with recommended profile.
Definition: autoprofileinfo.h:29
number
it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted the original copyright holder who places the Library under this License may add an geographical distribution limitation excluding those so that distribution is permitted only in or among countries not thus excluded In such this License incorporates the limitation as if written in the body of this License The Free Software Foundation may publish revised and or new versions of the Lesser General Public License from time to time Such new versions will be similar in spirit to the present but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number
Definition: lgpl-2.1.txt:423
AutoProfileWatcher::appProfileAssignments
QHash< QString, QList< AutoProfileInfo * > > appProfileAssignments
Definition: autoprofilewatcher.h:79
AutoProfileWatcher
Manages auto profile functionality. Allows for profiles to be associated with specific applications.
Definition: autoprofilewatcher.h:35
antimicrosettings.h
X11Extras::getWindowTitle
QString getWindowTitle(Window window)
Definition: x11extras.cpp:486
AutoProfileWatcher::checkWindowTimer
static QTimer checkWindowTimer
Definition: autoprofilewatcher.h:77