parent
afb7f24ec7
commit
540ad34d97
@ -0,0 +1 @@
|
||||
build
|
@ -1,4 +1,4 @@
|
||||
lxqt-config-monitor
|
||||
===================
|
||||
|
||||
This tool lets you change monitor settings. It is based on lxrandr-qt.
|
||||
This tool lets you change monitor settings. It was based on lxrandr-qt but now uses libkscreen.
|
||||
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
@ -1,34 +0,0 @@
|
||||
Info for developers
|
||||
==============
|
||||
|
||||
lxqt-config-monitor has 3 important modules:
|
||||
|
||||
- Monitor (monitor.h and monitor.cpp)
|
||||
- MonitorSettingsDialog (monitorsettingsdialog.h and monitorsettingsdialog.cpp)
|
||||
- XRandR (xrandr.h and xrandr.cpp)
|
||||
|
||||
MonitorSettingsDialog module contains all code related to GUI.
|
||||
|
||||
XRandR module contains code related to get or set settings from XRandR X11 driver. XRandR doesn't need MonitorSettingsDialog to work.
|
||||
|
||||
Monitor module is a glue between MonitorSettingsDialog and XRandR.
|
||||
|
||||
Indeep, XRandR module can be replaced and other modules won't need changes. Example, Wayland or Mir can use other tool for monitor settings. Other module can be added to work with that tool.
|
||||
|
||||
|
||||
Module XRandR
|
||||
============
|
||||
|
||||
Contains an implementation of class Backend. This class has got two methods in order to get or set configs.
|
||||
|
||||
This is only a simple implementation. It reads info from a pipe to a xrandr command.
|
||||
|
||||
Module Monitor
|
||||
============
|
||||
|
||||
Contains 4 classes:
|
||||
|
||||
- Backend: It is an abstract class. It has to be implemented by monitor drivers. In X11 this driver is XRandR
|
||||
- MonitorInfo: This class contains all information about one monitor. It is obtained from Backend::getMonitorsInfo method.
|
||||
- MonitorSettings: This class is used by Backend::setMonitorsSettings method. This class contains settings for one monitor.
|
||||
- Monitor: This class is used by MonitorSettingsDialog in order to store monitor settings.
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (C) 2015 P.L. Lucas <selairi@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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "loadsettings.h"
|
||||
#include <KScreen/Output>
|
||||
#include <KScreen/Config>
|
||||
#include <KScreen/GetConfigOperation>
|
||||
#include <KScreen/SetConfigOperation>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QSettings>
|
||||
#include <QJsonDocument>
|
||||
#include <KScreen/EDID>
|
||||
|
||||
|
||||
|
||||
|
||||
LoadSettings::LoadSettings(QObject *parent):QObject(parent)
|
||||
{
|
||||
KScreen::GetConfigOperation *operation = new KScreen::GetConfigOperation();
|
||||
connect(operation, &KScreen::GetConfigOperation::finished, [this, operation] (KScreen::ConfigOperation *op) {
|
||||
KScreen::GetConfigOperation *configOp = qobject_cast<KScreen::GetConfigOperation *>(op);
|
||||
if (configOp)
|
||||
{
|
||||
loadConfiguration(configOp->config());
|
||||
operation->deleteLater();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void LoadSettings::loadConfiguration(KScreen::ConfigPtr config)
|
||||
{
|
||||
QSettings settings("LXQt", "lxqt-config-monitor");
|
||||
QJsonDocument document = QJsonDocument::fromJson( settings.value("currentConfig").toByteArray() );
|
||||
QJsonObject json = document.object();
|
||||
QJsonArray array = json["outputs"].toArray();
|
||||
KScreen::OutputList outputs = config->outputs();
|
||||
for (const KScreen::OutputPtr &output : outputs)
|
||||
{
|
||||
qDebug() << "Output: " << output->name();
|
||||
for(int i=0;i<array.size();i++)
|
||||
{
|
||||
QJsonObject monitorSettings = array[i].toObject();
|
||||
if( monitorSettings["name"] == output->name() )
|
||||
{
|
||||
KScreen::Edid* edid = output->edid();
|
||||
if (edid && edid->isValid())
|
||||
if( monitorSettings["hash"].toString() != edid->hash() )
|
||||
{
|
||||
qDebug() << "Hash: " << monitorSettings["hash"].toString() << "==" << edid->hash();
|
||||
return exit(1); // Saved settings are from other monitor
|
||||
}
|
||||
if( monitorSettings["connected"].toBool() != output->isConnected() )
|
||||
return exit(2); // Saved settings are from other monitor
|
||||
if( !output->isConnected() )
|
||||
continue;
|
||||
output->setEnabled( monitorSettings["enabled"].toBool() );
|
||||
output->setPrimary( monitorSettings["primary"].toBool() );
|
||||
output->setPos( QPoint(monitorSettings["xPos"].toInt(),monitorSettings["yPos"].toInt()) );
|
||||
output->setCurrentModeId( monitorSettings["currentMode"].toString() );
|
||||
output->setRotation( (KScreen::Output::Rotation)(monitorSettings["rotation"].toInt()) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (KScreen::Config::canBeApplied(config))
|
||||
KScreen::SetConfigOperation(config).exec();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MonitorSettingsDialog</class>
|
||||
<widget class="QDialog" name="MonitorSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>527</width>
|
||||
<height>362</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Monitor Settings</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset theme="preferences-desktop-display">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QListWidget" name="monitorList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="unify">
|
||||
<property name="text">
|
||||
<string>Unify all monitors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="positionPushButton">
|
||||
<property name="text">
|
||||
<string>Monitor Position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="primaryLabel">
|
||||
<property name="text">
|
||||
<string>Primary monitor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="primaryCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>monitorList</sender>
|
||||
<signal>currentRowChanged(int)</signal>
|
||||
<receiver>stackedWidget</receiver>
|
||||
<slot>setCurrentIndex(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>146</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>394</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MonitorSettingsDialog</class>
|
||||
<widget class="QDialog" name="MonitorSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>510</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Monitor Settings</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset theme="preferences-desktop-display">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QListWidget" name="monitorList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="settingsButton">
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="preferences-system"/>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>monitorList</sender>
|
||||
<signal>currentRowChanged(int)</signal>
|
||||
<receiver>stackedWidget</receiver>
|
||||
<slot>setCurrentIndex(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>126</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MonitorSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>338</x>
|
||||
<y>439</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue