mirror of https://github.com/cutefishos/settings
Update
parent
1fa908d411
commit
2f75f2bddb
@ -1,5 +1,5 @@
|
||||
cutefish-settings (0.1) UNRELEASED; urgency=low
|
||||
cutefish-settings (0.5) UNRELEASED; urgency=high
|
||||
|
||||
* Initial release (CutefishOS) <cutefishos@foxmail.com>
|
||||
* Initial release CutefishOS <support@cutefishos.com>
|
||||
|
||||
-- CutefishOS <cutefishos@foxmail.com> Thu, 16 Oct 2014 17:22:15 +0200
|
||||
-- CutefishOS <support@cutefishos.com> Thu, 16 Sep 2021 03:52:45 +0800
|
||||
@ -1,3 +1,3 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: calamares
|
||||
Source: <url://example.com>
|
||||
Upstream-Name: cutefish-settings
|
||||
Source: cutefishos.com
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
#include "cscreenmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
|
||||
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<int, CScreenOutput *> CScreenManager::outputMap() const
|
||||
{
|
||||
return m_outputMap;
|
||||
}
|
||||
|
||||
int CScreenManager::outputId(const QScreen *qscreen)
|
||||
{
|
||||
QList<int> 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());
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
#ifndef CSCREENMANAGER_H
|
||||
#define CSCREENMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QScreen>
|
||||
#include <QMap>
|
||||
|
||||
#include "cscreenoutput.h"
|
||||
|
||||
class CScreenManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CScreenManager(QObject *parent = nullptr);
|
||||
|
||||
QMap<int, CScreenOutput *> outputMap() const;
|
||||
int outputId(const QScreen *qscreen);
|
||||
|
||||
private slots:
|
||||
void screenAdded(const QScreen *qscreen);
|
||||
void screenRemoved(QScreen *qscreen);
|
||||
|
||||
private:
|
||||
QMap<int, CScreenOutput *> m_outputMap;
|
||||
int m_lastOutputId;
|
||||
};
|
||||
|
||||
#endif // CSCREENMANAGER_H
|
||||
@ -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;
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
#ifndef CSCREENOUTPUT_H
|
||||
#define CSCREENOUTPUT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QScreen>
|
||||
|
||||
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
|
||||
Loading…
Reference in New Issue