From 88502b4dffafadd765e93bcda930e2e1be253796 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 17 Aug 2017 13:14:16 -0400 Subject: Fix up some tiling issues in lumina-xconfig. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 50 ++++++++++++++++++---------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'src-qt5/core-utils/lumina-xconfig/MainUI.cpp') diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp index 030b96be..1a3662fe 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -80,7 +80,7 @@ ScreenInfo MainUI::currentScreenInfo(){ } void MainUI::AddScreenToWidget(ScreenInfo screen){ - qDebug() << "Add Screen To Widget:" << screen.ID << screen.geom; + //qDebug() << "Add Screen To Widget:" << screen.ID << screen.geom; QLabel *lab = new QLabel(this); lab->setAlignment(Qt::AlignCenter); QMdiSubWindow *it = ui->mdiArea->addSubWindow(lab, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint); @@ -90,7 +90,7 @@ void MainUI::AddScreenToWidget(ScreenInfo screen){ it->setWhatsThis(screen.ID); QRect scaled( screen.geom.topLeft()*scaleFactor, screen.geom.size()*scaleFactor); - qDebug() << " - Scaled:" << scaled; + //qDebug() << " - Scaled:" << scaled; it->show(); it->setGeometry(scaled); //scale it down for the display it->setFixedSize(scaled.size()); @@ -117,9 +117,9 @@ void MainUI::SyncBackend(){ //Find the window associated with this screen for(int s=0; swhatsThis()==SCREENS[i].ID){ - qDebug() << "Adjust geom of window:" << SCREENS[i].geom; + //qDebug() << "Adjust geom of window:" << SCREENS[i].geom; SCREENS[i].geom.moveTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); - qDebug() << " - New Geom:" << SCREENS[i].geom; + //qDebug() << " - New Geom:" << SCREENS[i].geom; if(SCREENS[i].applyChange<1){ SCREENS[i].applyChange = (windows[s]->widget()->isEnabled() ? 0 : 1); } //disabled window is one that will be removed } } @@ -244,14 +244,23 @@ void MainUI::tileScreensY(bool activeonly){ while(overlap){ QRegion tmp(cur->pos().x(), newy, cur->width(), cur->height()); QRegion diff = tmp.subtracted(total); - overlap = (diff.boundingRect()!=tmp.boundingRect()); + overlap = (diff.boundingRect()!=tmp.boundingRect() || diff.rects().length()>1); //qDebug() << "Check Y Overlap:" << newy << overlap << tmp.boundingRect() << diff.boundingRect(); if(overlap){ + QVector rects = diff.rects(); QRect bound = diff.boundingRect(); - if(bound.isNull()){ newy+=cur->height(); } - else if(newy!=bound.top()){ newy = bound.top(); } - else if(newy!=bound.bottom()){ newy = bound.bottom() + 1; } - else{ newy++; } //make sure it always changes - no infinite loops!! + //qDebug() << " - got Y overlap:" << bound << rects; + if( bound.isNull() || rects.isEmpty() ){ newy+=cur->height(); } + else{ + int orig = newy; + newy = bound.top(); + for(int i=0; iheight(); + if(rects[i].height()==cur->height()){ continue; } //skip this one - just the same height + if(rects[i].top()>newy || newy==bound.bottom()){ newy=rects[i].top(); } + } + if(orig==newy){ newy = bound.bottom()+1; } //make sure it always changes - no infinite loops!! + } } } if(!activeonly || cur==active){ cur->move(cur->pos().x(), newy); } @@ -292,16 +301,23 @@ void MainUI::tileScreensX(bool activeonly){ while(overlap){ QRegion tmp(newx, cur->pos().y(), cur->width(), cur->height()); QRegion diff = tmp.subtracted(total); - overlap = (diff.boundingRect()!=tmp.boundingRect()); - //qDebug() << "Check X Overlap:" << newx << overlap << tmp.boundingRect() << diff.boundingRect(); + overlap = (diff.boundingRect()!=tmp.boundingRect() || diff.rects().length()>1); + //qDebug() << "Check X Overlap:" << newx << overlap << total.rects() << tmp.boundingRect() << diff.boundingRect(); if(overlap){ + QVector rects = diff.rects(); QRect bound = diff.boundingRect(); - if(bound.isNull()){ newx+=cur->width(); } - else if(newx!=bound.left()){ newx = bound.left(); } - else if(newx!=bound.right()){ newx = bound.right() + 1; } - else{ newx++; }//make sure it always changes - no infinite loops!! - }else{ - qDebug() << "Found Area:" << tmp << diff << newx; + //qDebug() << " - got X overlap:" << bound << rects; + if( bound.isNull() || rects.isEmpty() ){ newx+=cur->width(); } + else{ + int orig = newx; + newx = bound.left(); + for(int i=0; iwidth(); + if(rects[i].width()==cur->width()){ continue; } //skip this one - just the same width + if(rects[i].left()>newx || newx==bound.right()){ newx=rects[i].left(); } + } + if(orig==newx){ newx = bound.right()+1; } //make sure it always changes - no infinite loops!! + } } } if(!activeonly || cur==active){ cur->move(newx, cur->pos().y()); } -- cgit From ca225b7bd525ea961bf5aec2fa3f8c05e8307e4e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 22 Aug 2017 13:35:07 -0400 Subject: Get 90% of the work for adding profiles to lumina-xconfig finished. Still need to work out a few small issues when loading a profile into the preview pane. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 62 +++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'src-qt5/core-utils/lumina-xconfig/MainUI.cpp') diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp index 1a3662fe..aecc5122 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); @@ -28,6 +30,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ singleTileMenu->addAction(tr("Align Horizontal then Vertical"))->setWhatsThis("XY"); singleTileMenu->addAction(tr("Align Vertical then Horizontal"))->setWhatsThis("YX"); ui->mdiArea->setContextMenuPolicy(Qt::CustomContextMenu); + + profilesMenu = new QMenu(this); + ui->tool_save->setMenu(profilesMenu); + connect(ui->mdiArea, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu()) ); connect(singleTileMenu, SIGNAL(triggered(QAction*)), this, SLOT(tileSingleScreen(QAction*)) ); @@ -43,6 +49,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->tool_tileY, SIGNAL(clicked()), this, SLOT(tileScreensY()) ); connect(ui->tool_tile, SIGNAL(clicked()), this, SLOT(tileScreens()) ); connect(ui->combo_availscreens, SIGNAL(currentIndexChanged(int)), this, SLOT(updateNewScreenResolutions()) ); + + connect(ui->tool_profile_load, SIGNAL(clicked()), this, SLOT(loadProfile()) ); + connect(ui->tool_profile_remove, SIGNAL(clicked()), this, SLOT(removeProfile()) ); + connect(profilesMenu, SIGNAL(triggered(QAction*)), this, SLOT(saveAsProfile(QAction*)) ); + + updateProfiles(); QTimer::singleShot(0, this, SLOT(UpdateScreens()) ); } @@ -126,9 +138,11 @@ void MainUI::SyncBackend(){ } } -void MainUI::UpdateScreens(){ +void MainUI::UpdateScreens(QString profile){ //First probe the server for current screens - SCREENS = RRSettings::CurrentScreens(); + if(profile.isEmpty()){ SCREENS = RRSettings::CurrentScreens(); } + else{ SCREENS = RRSettings::PreviousSettings(profile); } + //Determine the scale factor for putting these into the UI QRegion tot; for(int i=0; icombo_profiles->currentText(); + RRSettings::removeProfile(cur); + updateProfiles(); +} + +void MainUI::updateProfiles(){ + QStringList profiles = RRSettings::savedProfiles(); + ui->combo_profiles->clear(); + profiles.sort(); + ui->combo_profiles->addItems(profiles); + //Update the profiles menu as needed + profilesMenu->clear(); + for(int i=0; iaddAction(profiles[i])->setWhatsThis(profiles[i]); + } + if(!profiles.isEmpty()){ profilesMenu->addSeparator(); } + profilesMenu->addAction(tr("New Profile") ); + + //Now update the tab as needed + ui->tabWidget->setTabEnabled(2,!profiles.isEmpty()); + if(ui->tabWidget->currentIndex()==2){ ui->tabWidget->setCurrentIndex(0); } +} + +void MainUI::loadProfile(){ + QString cur = ui->combo_profiles->currentText(); + UpdateScreens(cur); +} + +void MainUI::saveAsProfile(QAction *act){ + QString profile = act->whatsThis(); + if(profile.isEmpty()){ + //Need to prompt for a profile name + QStringList known = RRSettings::savedProfiles(); + while(known.contains(profile) || profile.isEmpty()){ + bool ok = false; + profile = QInputDialog::getText(this, tr("Create Screen Profile"), profile.isEmpty() ? tr("Profile Name") : tr("Profile exists - different name:"), QLineEdit::Normal, profile, &ok); + if(!ok || profile.isEmpty()){ return; } //cancelled + } + } + RRSettings::SaveScreens(SCREENS, profile); + updateProfiles(); +} -- cgit