summaryrefslogtreecommitdiffstats
path: root/src/widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index fba46a7..069e8db 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -139,10 +139,12 @@ Widget::Widget(QWidget *parent) :
if (currentCount == _lastScreenCount) {
// Nothing seems to have changed. This might happen when another tool changes the screen config. Let's not interfere.
} else if (currentCount > _lastScreenCount) { // Screen count increased - auto setup
+ _lastScreenCount = currentCount;
ScreenSetup::inst()->initModes();
- ScreenSetup::inst()->setDefaultMode(CommandLine::testMode());
- if (!keepResolution()) {
- ScreenSetup::inst()->revertChanges();
+ ScreenMode mode;
+ auto ret = ScreenSetup::inst()->setDefaultMode(CommandLine::testMode(), mode);
+ if (!ret.ok() || !keepResolution()) {
+ ret.revert();
}
} else { // Screen count decreased - pop up GUI and don't just deconfig the screen
this->show();
@@ -569,8 +571,7 @@ bool Widget::keepResolution()
//______________________________________________________________________________
void Widget::connectButtons() {
-
- // Swap dualscreen
+ // Swap dualscreen
connect(_ui->btnDualSwap, &QPushButton::clicked, [=](bool) {
_ui->dualContainer->addItem(_ui->dualContainer->takeAt(1));
_ui->dualContainer->addItem(_ui->dualContainer->takeAt(0));
@@ -578,9 +579,10 @@ void Widget::connectButtons() {
// Apply CLONE
connect(_ui->btnCloneApply, &QPushButton::clicked, [=](bool) {
- if (!ScreenSetup::inst()->setClone(_ui->cboCloneResolution->currentData().toSize()) || !keepResolution()) {
+ auto ret = ScreenSetup::inst()->setClone(_ui->cboCloneResolution->currentData().toSize());
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting clone";
- ScreenSetup::inst()->revertChanges();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();
@@ -593,9 +595,10 @@ void Widget::connectButtons() {
if (_ui->btnDualSwap->isChecked()) {
qSwap(left, right);
}
- if (!ScreenSetup::inst()->setCustom({left, right}) || !keepResolution()) {
+ auto ret = ScreenSetup::inst()->setCustom({left, right});
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting dualhead";
- ScreenSetup::inst()->revertChanges();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();
@@ -613,9 +616,10 @@ void Widget::connectButtons() {
continue;
list[index].second.append(e->info.output);
}
- if (!ScreenSetup::inst()->setCustom(list) || !keepResolution()) {
+ auto ret = ScreenSetup::inst()->setCustom(list);
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting custom";
- ScreenSetup::inst()->revertChanges();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();