Changeset View
Changeset View
Standalone View
Standalone View
kcm/src/widget.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
43 | #include <kscreen/configmonitor.h> | 43 | #include <kscreen/configmonitor.h> | ||
44 | 44 | | |||
45 | #include <QtCore/QDir> | 45 | #include <QtCore/QDir> | ||
46 | #include <QStandardPaths> | 46 | #include <QStandardPaths> | ||
47 | #include <KLocalizedString> | 47 | #include <KLocalizedString> | ||
48 | #include <QComboBox> | 48 | #include <QComboBox> | ||
49 | #include <QPushButton> | 49 | #include <QPushButton> | ||
50 | #include <QQuickView> | 50 | #include <QQuickView> | ||
51 | #include <kconfig.h> | ||||
52 | #include <KConfigGroup> | ||||
51 | 53 | | |||
52 | #define QML_PATH "kcm_kscreen/qml/" | 54 | #define QML_PATH "kcm_kscreen/qml/" | ||
55 | Q_DECLARE_METATYPE(Widget::DisplaySwitchAction) | ||||
53 | 56 | | |||
54 | Widget::Widget(QWidget *parent): | 57 | Widget::Widget(QWidget *parent): | ||
55 | QWidget(parent), | 58 | QWidget(parent), | ||
56 | mScreen(nullptr), | 59 | mScreen(nullptr), | ||
57 | mConfig(nullptr), | 60 | mConfig(nullptr), | ||
58 | mPrevConfig(nullptr) | 61 | mPrevConfig(nullptr) | ||
59 | { | 62 | { | ||
60 | qRegisterMetaType<QQuickView*>(); | 63 | qRegisterMetaType<QQuickView*>(); | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 127 | [this] { | |||
125 | QPointer<ScalingConfig> dialog = new ScalingConfig(mConfig->outputs(), this); | 128 | QPointer<ScalingConfig> dialog = new ScalingConfig(mConfig->outputs(), this); | ||
126 | dialog->exec(); | 129 | dialog->exec(); | ||
127 | delete dialog; | 130 | delete dialog; | ||
128 | }); | 131 | }); | ||
129 | 132 | | |||
130 | vbox->addWidget(mScaleAllOutputsButton); | 133 | vbox->addWidget(mScaleAllOutputsButton); | ||
131 | 134 | | |||
132 | 135 | | |||
136 | QHBoxLayout *unknownMonitorActionLayout = new QHBoxLayout; | ||||
137 | unknownMonitorActionLayout->setMargin(0); | ||||
138 | vbox->addLayout(unknownMonitorActionLayout); | ||||
139 | | ||||
140 | QLabel *unknownMonitorActionLabel = new QLabel(i18n("Default Action:"), this); | ||||
141 | unknownMonitorActionLabel->setObjectName(QStringLiteral("unknownMonitorActionLabel")); | ||||
142 | unknownMonitorActionLayout->addWidget(unknownMonitorActionLabel); | ||||
143 | | ||||
144 | mDefaultActionWhenUnknownMonitorPlugged = new QComboBox(this); | ||||
145 | mDefaultActionWhenUnknownMonitorPlugged->setObjectName(QStringLiteral("defaultactioncombobox")); | ||||
146 | connect(mDefaultActionWhenUnknownMonitorPlugged, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||||
147 | this, &Widget::changed); | ||||
148 | | ||||
149 | unknownMonitorActionLayout->addWidget(mDefaultActionWhenUnknownMonitorPlugged); | ||||
150 | | ||||
151 | mDefaultActionWhenUnknownMonitorPlugged->addItem(i18n("None"), DisplaySwitchAction::None); | ||||
152 | mDefaultActionWhenUnknownMonitorPlugged->addItem(i18n("Clone"), DisplaySwitchAction::Clone); | ||||
153 | mDefaultActionWhenUnknownMonitorPlugged->addItem(i18n("Extend to Right"), DisplaySwitchAction::ExtendToRight); | ||||
154 | mDefaultActionWhenUnknownMonitorPlugged->addItem(i18n("Extend to Left"), DisplaySwitchAction::ExtendToLeft); | ||||
155 | | ||||
133 | mOutputTimer = new QTimer(this); | 156 | mOutputTimer = new QTimer(this); | ||
134 | connect(mOutputTimer, &QTimer::timeout, | 157 | connect(mOutputTimer, &QTimer::timeout, | ||
135 | this, &Widget::clearOutputIdentifiers); | 158 | this, &Widget::clearOutputIdentifiers); | ||
136 | 159 | | |||
137 | loadQml(); | 160 | loadQml(); | ||
161 | load(); | ||||
138 | } | 162 | } | ||
139 | 163 | | |||
140 | Widget::~Widget() | 164 | Widget::~Widget() | ||
141 | { | 165 | { | ||
142 | clearOutputIdentifiers(); | 166 | clearOutputIdentifiers(); | ||
143 | } | 167 | } | ||
144 | 168 | | |||
145 | bool Widget::eventFilter(QObject* object, QEvent* event) | 169 | bool Widget::eventFilter(QObject* object, QEvent* event) | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 187 | { | |||
198 | slotOutputEnabledChanged(); | 222 | slotOutputEnabledChanged(); | ||
199 | } | 223 | } | ||
200 | 224 | | |||
201 | KScreen::ConfigPtr Widget::currentConfig() const | 225 | KScreen::ConfigPtr Widget::currentConfig() const | ||
202 | { | 226 | { | ||
203 | return mConfig; | 227 | return mConfig; | ||
204 | } | 228 | } | ||
205 | 229 | | |||
230 | void Widget::load() | ||||
231 | { | ||||
232 | KConfig config(QStringLiteral("kscreenrc")); | ||||
233 | KConfigGroup group = config.group("General"); | ||||
234 | | ||||
235 | const DisplaySwitchAction act = static_cast<DisplaySwitchAction>(group.readEntry("DisplayUnknownScreenAction", (int)ExtendToRight)); | ||||
236 | const int index = mDefaultActionWhenUnknownMonitorPlugged->findData(act); | ||||
237 | if (index != -1) { | ||||
238 | mDefaultActionWhenUnknownMonitorPlugged->setCurrentIndex(index); | ||||
239 | } else { | ||||
240 | mDefaultActionWhenUnknownMonitorPlugged->setCurrentIndex(2); | ||||
241 | } | ||||
242 | } | ||||
243 | | ||||
244 | void Widget::save() | ||||
245 | { | ||||
246 | KConfig config(QStringLiteral("kscreenrc")); | ||||
247 | KConfigGroup group = config.group("General"); | ||||
248 | | ||||
249 | group.writeEntry("DisplayUnknownScreenAction", (int)mDefaultActionWhenUnknownMonitorPlugged->currentData().value<DisplaySwitchAction>()); | ||||
250 | } | ||||
251 | | ||||
206 | void Widget::loadQml() | 252 | void Widget::loadQml() | ||
207 | { | 253 | { | ||
208 | qmlRegisterType<QMLOutput>("org.kde.kscreen", 1, 0, "QMLOutput"); | 254 | qmlRegisterType<QMLOutput>("org.kde.kscreen", 1, 0, "QMLOutput"); | ||
209 | qmlRegisterType<QMLScreen>("org.kde.kscreen", 1, 0, "QMLScreen"); | 255 | qmlRegisterType<QMLScreen>("org.kde.kscreen", 1, 0, "QMLScreen"); | ||
210 | 256 | | |||
211 | qmlRegisterType<KScreen::Output>("org.kde.kscreen", 1, 0, "KScreenOutput"); | 257 | qmlRegisterType<KScreen::Output>("org.kde.kscreen", 1, 0, "KScreenOutput"); | ||
212 | qmlRegisterType<KScreen::Edid>("org.kde.kscreen", 1, 0, "KScreenEdid"); | 258 | qmlRegisterType<KScreen::Edid>("org.kde.kscreen", 1, 0, "KScreenEdid"); | ||
213 | qmlRegisterType<KScreen::Mode>("org.kde.kscreen", 1, 0, "KScreenMode"); | 259 | qmlRegisterType<KScreen::Mode>("org.kde.kscreen", 1, 0, "KScreenMode"); | ||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |