deskflow/src/lib/gui/config/Screen.h

114 lines
3.9 KiB
C
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Symless Ltd.
2012-06-10 16:50:54 +00:00
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
2012-06-10 16:50:54 +00:00
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
2012-06-10 16:50:54 +00:00
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
#pragma once
2012-06-10 16:50:54 +00:00
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
#include "ScreenConfig.h"
2012-06-10 16:50:54 +00:00
#include "gui/proxy/QSettingsProxy.h"
#include <QList>
2012-06-10 16:50:54 +00:00
#include <QPixmap>
#include <QString>
#include <QStringList>
class QSettings;
class QTextStream;
class ScreenSettingsDialog;
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
class Screen : public ScreenConfig {
using QSettingsProxy = synergy::gui::proxy::QSettingsProxy;
friend class ScreenSettingsDialog;
friend class ScreenSetupModel;
friend class ScreenSetupView;
friend QDataStream &operator<<(QDataStream &outStream, const Screen &screen) {
return outStream << screen.name() << screen.switchCornerSize()
<< screen.aliases() << screen.modifiers()
<< screen.switchCorners() << screen.fixes()
<< screen.isServer();
}
friend QDataStream &operator>>(QDataStream &inStream, Screen &screen) {
return inStream >> screen.m_Name >> screen.m_SwitchCornerSize >>
screen.m_Aliases >> screen.m_Modifiers >> screen.m_SwitchCorners >>
screen.m_Fixes >> screen.m_isServer;
}
public:
explicit Screen();
explicit Screen(const QString &name);
const QPixmap &pixmap() const { return m_Pixmap; }
const QString &name() const { return m_Name; }
const QStringList &aliases() const { return m_Aliases; }
bool isNull() const { return m_Name.isEmpty(); }
int modifier(int m) const {
return m_Modifiers[m] ==
static_cast<int>(ScreenConfig::Modifier::DefaultMod)
? m
: m_Modifiers[m];
}
const QList<int> &modifiers() const { return m_Modifiers; }
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
const QList<bool> &switchCorners() const { return m_SwitchCorners; }
int switchCornerSize() const { return m_SwitchCornerSize; }
bool fix(Fix f) const { return m_Fixes[static_cast<int>(f)]; }
const QList<bool> &fixes() const { return m_Fixes; }
void loadSettings(QSettingsProxy &settings);
void saveSettings(QSettingsProxy &settings) const;
QTextStream &writeScreensSection(QTextStream &outStream) const;
QTextStream &writeAliasesSection(QTextStream &outStream) const;
bool swapped() const { return m_Swapped; }
QString &name() { return m_Name; }
void setName(const QString &name) { m_Name = name; }
bool isServer() const { return m_isServer; }
void markAsServer() { m_isServer = true; }
bool operator==(const Screen &screen) const;
protected:
void init();
QStringList &aliases() { return m_Aliases; }
void setModifier(int m, int n) { m_Modifiers[m] = n; }
QList<int> &modifiers() { return m_Modifiers; }
void addAlias(const QString &alias) { m_Aliases.append(alias); }
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
QList<bool> &switchCorners() { return m_SwitchCorners; }
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
void setFix(int f, bool on) { m_Fixes[f] = on; }
QList<bool> &fixes() { return m_Fixes; }
void setSwapped(bool on) { m_Swapped = on; }
private:
QPixmap m_Pixmap = QPixmap(":res/icons/64x64/video-display.png");
QString m_Name;
QStringList m_Aliases;
QList<int> m_Modifiers;
QList<bool> m_SwitchCorners;
int m_SwitchCornerSize;
QList<bool> m_Fixes;
bool m_Swapped = false;
bool m_isServer = false;
2012-06-10 16:50:54 +00:00
};