You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libcutefish/screen/confighandler.h

102 lines
3.0 KiB
C

4 years ago
/********************************************************************
Copyright © 2019 Roman Gilg <subdiff@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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/>.
*********************************************************************/
#ifndef CONFIGHANDLER_H
#define CONFIGHANDLER_H
4 years ago
#include "./common/control.h"
#include <kscreen/config.h>
#include <memory>
class OutputModel;
class ConfigHandler : public QObject
{
Q_OBJECT
public:
4 years ago
explicit ConfigHandler(QObject *parent = nullptr);
4 years ago
~ConfigHandler() override = default;
void setConfig(KScreen::ConfigPtr config);
void updateInitialData();
4 years ago
OutputModel *outputModel() const
{
4 years ago
return m_outputs;
}
QSize normalizeScreen();
4 years ago
KScreen::ConfigPtr config() const
{
4 years ago
return m_config;
}
4 years ago
KScreen::ConfigPtr initialConfig() const
{
4 years ago
return m_initialConfig;
}
int retention() const;
void setRetention(int retention);
qreal scale(const KScreen::OutputPtr &output) const;
void setScale(KScreen::OutputPtr &output, qreal scale);
KScreen::OutputPtr replicationSource(const KScreen::OutputPtr &output) const;
void setReplicationSource(KScreen::OutputPtr &output, const KScreen::OutputPtr &source);
bool autoRotate(const KScreen::OutputPtr &output) const;
void setAutoRotate(KScreen::OutputPtr &output, bool autoRotate);
bool autoRotateOnlyInTabletMode(const KScreen::OutputPtr &output) const;
void setAutoRotateOnlyInTabletMode(KScreen::OutputPtr &output, bool value);
void writeControl();
void checkNeedsSave();
Q_SIGNALS:
void outputModelChanged();
void changed();
void screenNormalizationUpdate(bool normalized);
void needsSaveChecked(bool need);
void retentionChanged();
void outputConnect(bool connected);
private:
void checkScreenNormalization();
QSize screenSize() const;
Control::OutputRetention getRetention() const;
void primaryOutputSelected(int index);
void primaryOutputChanged(const KScreen::OutputPtr &output);
void initOutput(const KScreen::OutputPtr &output);
void resetScale(const KScreen::OutputPtr &output);
KScreen::ConfigPtr m_config = nullptr;
KScreen::ConfigPtr m_initialConfig;
OutputModel *m_outputs = nullptr;
std::unique_ptr<ControlConfig> m_control;
std::unique_ptr<ControlConfig> m_initialControl;
4 years ago
Control::OutputRetention m_initialRetention = Control::OutputRetention::Undefined;
4 years ago
QSize m_lastNormalizedScreenSize;
};
4 years ago
#endif