From 2f75f2bddb395dd708729b6a701c1802129e5884 Mon Sep 17 00:00:00 2001 From: reionwong Date: Thu, 16 Sep 2021 15:09:39 +0800 Subject: [PATCH] Update --- CMakeLists.txt | 2 + debian/changelog | 6 +-- debian/control | 4 +- debian/copyright | 4 +- src/cscreenmanager.cpp | 60 ++++++++++++++++++++++++++ src/cscreenmanager.h | 29 +++++++++++++ src/cscreenoutput.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++ src/cscreenoutput.h | 69 ++++++++++++++++++++++++++++++ src/qml/About/Main.qml | 2 +- 9 files changed, 263 insertions(+), 8 deletions(-) create mode 100644 src/cscreenmanager.cpp create mode 100644 src/cscreenmanager.h create mode 100644 src/cscreenoutput.cpp create mode 100644 src/cscreenoutput.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ecc59..86f0c70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ pkg_search_module(ICU REQUIRED icu-i18n) include_directories(${ICU_INCLUDE_DIRS}) set(SRCS + src/cscreenmanager.cpp + src/cscreenoutput.cpp src/application.cpp src/main.cpp src/appearance.cpp diff --git a/debian/changelog b/debian/changelog index 8c549ab..56c7301 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -cutefish-settings (0.1) UNRELEASED; urgency=low +cutefish-settings (0.5) UNRELEASED; urgency=high - * Initial release (CutefishOS) + * Initial release CutefishOS - -- CutefishOS Thu, 16 Oct 2014 17:22:15 +0200 + -- CutefishOS Thu, 16 Sep 2021 03:52:45 +0800 \ No newline at end of file diff --git a/debian/control b/debian/control index b425c03..3350a48 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: cutefish-settings Section: devel Priority: optional -Maintainer: CutefishOS +Maintainer: CutefishOS Build-Depends: cmake, debhelper (>= 9), extra-cmake-modules, @@ -21,7 +21,7 @@ Build-Depends: cmake, qttools5-dev, qttools5-dev-tools Standards-Version: 4.5.0 -Homepage: https://github.com/cutefishos/terminal +Homepage: https://cutefishos.com Package: cutefish-settings Architecture: any diff --git a/debian/copyright b/debian/copyright index 716fe64..f639407 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,3 +1,3 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: calamares -Source: +Upstream-Name: cutefish-settings +Source: cutefishos.com diff --git a/src/cscreenmanager.cpp b/src/cscreenmanager.cpp new file mode 100644 index 0000000..b6b6e7a --- /dev/null +++ b/src/cscreenmanager.cpp @@ -0,0 +1,60 @@ +#include "cscreenmanager.h" + +#include +#include + +CScreenManager::CScreenManager(QObject *parent) + : QObject(parent) + , m_lastOutputId(-1) +{ + for (const QScreen *qscreen : QGuiApplication::screens()) { + screenAdded(qscreen); + } + + connect(qApp, &QGuiApplication::screenAdded, this, &CScreenManager::screenAdded); + connect(qApp, &QGuiApplication::screenRemoved, this, &CScreenManager::screenRemoved); +} + +QMap CScreenManager::outputMap() const +{ + return m_outputMap; +} + +int CScreenManager::outputId(const QScreen *qscreen) +{ + QList ids; + for (auto output : qAsConst(m_outputMap)) { + if (qscreen == output->qscreen()) { + return output->id(); + } + } + m_lastOutputId++; + return m_lastOutputId; +} + +void CScreenManager::screenAdded(const QScreen *qscreen) +{ + CScreenOutput *output = new CScreenOutput; + output->setId(outputId(qscreen)); + output->setName(qscreen->name()); + m_outputMap.insert(output->id(), output); + +// if (!m_blockSignals) { +// Q_EMIT configChanged(toKScreenConfig()); +// } +} + +void CScreenManager::screenRemoved(QScreen *qscreen) +{ + int removedOutputId = -1; + + for (auto output : m_outputMap) { + if (output->qscreen() == qscreen) { + removedOutputId = output->id(); + m_outputMap.remove(removedOutputId); + delete output; + } + } + + // Q_EMIT configChanged(toKScreenConfig()); +} diff --git a/src/cscreenmanager.h b/src/cscreenmanager.h new file mode 100644 index 0000000..2a2b8d1 --- /dev/null +++ b/src/cscreenmanager.h @@ -0,0 +1,29 @@ +#ifndef CSCREENMANAGER_H +#define CSCREENMANAGER_H + +#include +#include +#include + +#include "cscreenoutput.h" + +class CScreenManager : public QObject +{ + Q_OBJECT + +public: + explicit CScreenManager(QObject *parent = nullptr); + + QMap outputMap() const; + int outputId(const QScreen *qscreen); + +private slots: + void screenAdded(const QScreen *qscreen); + void screenRemoved(QScreen *qscreen); + +private: + QMap m_outputMap; + int m_lastOutputId; +}; + +#endif // CSCREENMANAGER_H diff --git a/src/cscreenoutput.cpp b/src/cscreenoutput.cpp new file mode 100644 index 0000000..586da84 --- /dev/null +++ b/src/cscreenoutput.cpp @@ -0,0 +1,95 @@ +#include "cscreenoutput.h" + +CScreenOutput::CScreenOutput(QObject *parent) + : QObject(parent) +{ + +} + +int CScreenOutput::id() const +{ + return m_id; +} + +void CScreenOutput::setId(int id) +{ + if (id != m_id) { + m_id = id; + emit outputChanged(); + } +} + +QString CScreenOutput::name() const +{ + return m_name; +} + +void CScreenOutput::setName(QString name) +{ + if (name != m_name) { + m_name = name; + emit outputChanged(); + } +} + +QString CScreenOutput::hash() const +{ + +} + +CScreenOutput::Rotation CScreenOutput::rotation() const +{ + return m_rotation; +} + +void CScreenOutput::setRotation(const Rotation &rotation) +{ + if (rotation != m_rotation) { + m_rotation = rotation; + emit rotationChanged(); + } +} + +bool CScreenOutput::connected() const +{ + return m_connected; +} + +void CScreenOutput::setConnected(bool connected) +{ + if (connected != m_connected) { + m_connected = connected; + emit connectedChanged(); + } +} + +bool CScreenOutput::primary() const +{ + return m_primary; +} + +void CScreenOutput::setPrimary(bool primary) +{ + if (primary != m_primary) { + m_primary = primary; + emit primaryChanged(); + } +} + +bool CScreenOutput::enabled() const +{ + return m_enabled; +} + +void CScreenOutput::setEnabled(bool enabled) +{ + if (enabled != m_enabled) { + m_enabled = enabled; + emit enabledChanged(); + } +} + +const QScreen *CScreenOutput::qscreen() const +{ + return m_qscreen; +} diff --git a/src/cscreenoutput.h b/src/cscreenoutput.h new file mode 100644 index 0000000..8abfa48 --- /dev/null +++ b/src/cscreenoutput.h @@ -0,0 +1,69 @@ +#ifndef CSCREENOUTPUT_H +#define CSCREENOUTPUT_H + +#include +#include + +class CScreenOutput : public QObject +{ + Q_OBJECT + Q_PROPERTY(int id READ id CONSTANT) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY outputChanged) + Q_PROPERTY(Rotation rotation READ rotation WRITE setRotation NOTIFY rotationChanged) + Q_PROPERTY(bool connected READ connected WRITE setConnected NOTIFY connectedChanged) + Q_PROPERTY(bool primary READ primary WRITE setPrimary NOTIFY primaryChanged) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + +public: + enum Rotation { + None = 1, + Left = 2, + Inverted = 4, + Right = 8, + }; + Q_ENUM(Rotation); + + explicit CScreenOutput(QObject *parent = nullptr); + + int id() const; + void setId(int id); + + QString name() const; + void setName(QString name); + + QString hash() const; + + Rotation rotation() const; + void setRotation(const Rotation &rotation); + + bool connected() const; + void setConnected(bool connected); + + bool primary() const; + void setPrimary(bool primary); + + bool enabled() const; + void setEnabled(bool enabled); + + const QScreen *qscreen() const; + +signals: + void outputChanged(); + void rotationChanged(); + void primaryChanged(); + void enabledChanged(); + void connectedChanged(); + +private: + int m_id; + QString m_name; + QString m_hash; + Rotation m_rotation; + bool m_connected; + bool m_primary; + bool m_enabled; + + QScreen *m_qscreen; +}; + +#endif // CSCREENOUTPUT_H diff --git a/src/qml/About/Main.qml b/src/qml/About/Main.qml index d383c59..40061c2 100644 --- a/src/qml/About/Main.qml +++ b/src/qml/About/Main.qml @@ -74,7 +74,7 @@ ItemPage { RoundedItem { StandardItem { key: qsTr("System Version") - value: "0.4" + value: "0.5" } StandardItem {