From 9c6e1c1118f68debadb9507349da3f4f4538410b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 15 Aug 2017 14:25:22 -0400 Subject: Get most of lumina-xconfig updated so screens can be moved around on a canvas, rather than forcing a horizontal arrangement. Not quite finished yet - almost though. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 160 ++++++++++++--------------- 1 file changed, 72 insertions(+), 88 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 6553bb37..90f09104 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -15,6 +15,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); loadIcons(); + scaleFactor = 1/20.0; //Fill the location list with the valid entries ui->combo_location->clear(); ui->combo_location->addItem(tr("Right Of"), "--right-of"); @@ -24,10 +25,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->push_rescan, SIGNAL(clicked()), this, SLOT(UpdateScreens()) ); connect(ui->push_activate, SIGNAL(clicked()), this, SLOT(ActivateScreen()) ); connect(ui->tool_deactivate, SIGNAL(clicked()), this, SLOT(DeactivateScreen()) ); - connect(ui->tool_moveleft, SIGNAL(clicked()), this, SLOT(MoveScreenLeft()) ); - connect(ui->tool_moveright, SIGNAL(clicked()), this, SLOT(MoveScreenRight()) ); + //connect(ui->tool_moveleft, SIGNAL(clicked()), this, SLOT(MoveScreenLeft()) ); + //connect(ui->tool_moveright, SIGNAL(clicked()), this, SLOT(MoveScreenRight()) ); connect(ui->tool_applyconfig, SIGNAL(clicked()), this, SLOT(ApplyChanges()) ); - connect(ui->list_screens, SIGNAL(itemSelectionChanged()),this, SLOT(ScreenSelected()) ); + connect(ui->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(ScreenSelected()) ); + connect(ui->tool_tile, SIGNAL(clicked()), ui->mdiArea, SLOT(tileSubWindows()) ); QTimer::singleShot(0, this, SLOT(UpdateScreens()) ); } @@ -38,8 +40,8 @@ MainUI::~MainUI(){ void MainUI::loadIcons(){ this->setWindowIcon( LXDG::findIcon("preferences-system-windows-actions","") ); ui->tool_deactivate->setIcon( LXDG::findIcon("list-remove","") ); - ui->tool_moveleft->setIcon( LXDG::findIcon("arrow-left","") ); - ui->tool_moveright->setIcon( LXDG::findIcon("arrow-right","") ); + //ui->tool_moveleft->setIcon( LXDG::findIcon("arrow-left","") ); + //ui->tool_moveright->setIcon( LXDG::findIcon("arrow-right","") ); ui->push_activate->setIcon( LXDG::findIcon("list-add","") ); ui->push_rescan->setIcon( LXDG::findIcon("view-refresh","") ); ui->push_close->setIcon( LXDG::findIcon("window-close","") ); @@ -67,11 +69,17 @@ QStringList MainUI::currentOpts(){ return opts; } +QString MainUI::currentSelection(){ + QMdiSubWindow *tmp = ui->mdiArea->activeSubWindow(); + if(tmp!=0){ return tmp->whatsThis(); } + else{ return ""; } +} + ScreenInfo MainUI::currentScreenInfo(){ - QListWidgetItem *item = ui->list_screens->currentItem(); + QString item = currentSelection(); if(item!=0){ for(int i=0; iwhatsThis()){ return SCREENS[i]; } + if(SCREENS[i].ID==item){ return SCREENS[i]; } } } //Fallback when nothing found/selected @@ -79,68 +87,43 @@ ScreenInfo MainUI::currentScreenInfo(){ } void MainUI::AddScreenToWidget(ScreenInfo screen){ - QListWidgetItem *it = new QListWidgetItem(); + //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); + it->setWindowTitle(screen.ID); + lab->setText(QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())); + + /*QListWidgetItem *it = new QListWidgetItem(); it->setTextAlignment(Qt::AlignCenter); - it->setText( screen.ID+"\n\n ("+QString::number(screen.geom.x())+", "+QString::number(screen.geom.y())+")\n ("+QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())+") " ); + it->setText( screen.ID+"\n\n ("+QString::number(screen.geom.x())+", "+QString::number(screen.geom.y())+")\n ("+QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())+") " );*/ it->setWhatsThis(screen.ID); - ui->list_screens->addItem(it); + //ui->list_screens->addItem(it); + QRect scaled( screen.geom.topLeft()*scaleFactor, screen.geom.size()*scaleFactor); + qDebug() << " - Scaled:" << scaled; + it->show(); + //QApplication::processEvents(); + it->setGeometry(scaled); //scale it down for the display + it->setFixedSize(scaled.size()); + } void MainUI::UpdateScreens(){ //First probe the server for current screens SCREENS = RRSettings::CurrentScreens(); - /*QStringList info = LUtils::getCmdOutput("xrandr -q"); - ScreenInfo cscreen; - for(int i=0; ix++" - cscreen.geom.setRect( devres.section("+",-2,-2).toInt(), devres.section("+",-1,-1).toInt(), devres.section("x",0,0).toInt(), devres.section("+",0,0).section("x",1,1).toInt() ); - - }else if(info[i].contains(" connected")){ - //Device that is connected, but not attached - qDebug() << "Create new Screen entry:" << dev << "none"; - cscreen.ID = dev; - cscreen.order = -2; //flag this right now as a non-active screen - } - }else if( !cscreen.ID.isEmpty() && info[i].section("\t",0,0,QString::SectionSkipEmpty).contains("x")){ - //available resolution for a device - cscreen.resList << info[i].section("\t",0,0,QString::SectionSkipEmpty); - } - } //end loop over info lines - if(!cscreen.ID.isEmpty()){ SCREENS << cscreen; } //make sure to add the last screen to the array - */ //Now go through the screens and arrange them in order from left->right in the UI bool found = true; int xoffset = 0; //start at 0 int cnum = 0; - QString csel = ""; - if(ui->list_screens->currentItem()!=0){ csel = ui->list_screens->currentItem()->whatsThis(); } - ui->list_screens->clear(); + QString csel = currentSelection(); + //Clear all the current widgets + while(ui->mdiArea->currentSubWindow()!=0 ){ + QMdiSubWindow *tmp = ui->mdiArea->currentSubWindow(); + tmp->widget()->deleteLater(); + ui->mdiArea->removeSubWindow(tmp); + tmp->deleteLater(); + } + while(found){ found = false; //make sure to break out if a screen is not found for(int i=0; isetTextAlignment(Qt::AlignCenter); - it->setText( SCREENS[i].ID+"\n ("+QString::number(SCREENS[i].geom.x())+", "+QString::number(SCREENS[i].geom.y())+")\n("+QString::number(SCREENS[i].geom.width())+"x"+QString::number(SCREENS[i].geom.height())+") " ); - it->setWhatsThis(SCREENS[i].ID); - ui->list_screens->addItem(it);*/ - //if(SCREENS[i].ID==csel){ ui->list_screens->setCurrentItem(it); } }else if(SCREENS[i].geom.x() < xoffset || SCREENS[i].geom.x() > xoffset){ //Screen not aligned with previous screen edge qDebug() << "Found mis-aligned screen:" << i << SCREENS[i].ID; @@ -187,24 +164,25 @@ void MainUI::UpdateScreens(){ ui->group_avail->setVisible(true); ui->tabWidget->setTabEnabled(1,true); } - if(ui->list_screens->currentItem()==0){ ui->list_screens->setCurrentRow(0); } + //if(ui->list_screens->currentItem()==0){ ui->list_screens->setCurrentRow(0); } ScreenSelected(); //update buttons RRSettings::SaveScreens(SCREENS); } void MainUI::ScreenSelected(){ - QListWidgetItem *item = ui->list_screens->currentItem(); - if(item==0){ + QString item = currentSelection(); + //QListWidgetItem *item = ui->list_screens->currentItem(); + if(item.isEmpty()){ //nothing selected - ui->tool_deactivate->setEnabled(false); - ui->tool_moveleft->setEnabled(false); - ui->tool_moveright->setEnabled(false); + //ui->tool_deactivate->setEnabled(false); + //ui->tool_moveleft->setEnabled(false); + //ui->tool_moveright->setEnabled(false); ui->tab_config->setEnabled(false); }else{ //Item selected - ui->tool_deactivate->setEnabled(ui->list_screens->count()>1); - ui->tool_moveleft->setEnabled(ui->list_screens->row(item) > 0); - ui->tool_moveright->setEnabled(ui->list_screens->row(item) < (ui->list_screens->count()-1)); + //ui->tool_deactivate->setEnabled(ui->list_screens->count()>1); + //ui->tool_moveleft->setEnabled(ui->list_screens->row(item) > 0); + //ui->tool_moveright->setEnabled(ui->list_screens->row(item) < (ui->list_screens->count()-1)); ui->tab_config->setEnabled(true); //Update the info available on the config tab ScreenInfo cur = currentScreenInfo(); @@ -220,7 +198,7 @@ void MainUI::ScreenSelected(){ } } -void MainUI::MoveScreenLeft(){ +/*void MainUI::MoveScreenLeft(){ QListWidgetItem *item = ui->list_screens->currentItem(); if(item==0){ return; } //no selection //Get the current ID @@ -240,9 +218,9 @@ void MainUI::MoveScreenLeft(){ //Now run the command //LUtils::runCmd("xrandr", QStringList() << "--output" << CID << "--left-of" << LID); QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); -} +}*/ -void MainUI::MoveScreenRight(){ +/*void MainUI::MoveScreenRight(){ QListWidgetItem *item = ui->list_screens->currentItem(); if(item==0){ return; } //no selection //Get the current ID @@ -260,16 +238,10 @@ void MainUI::MoveScreenRight(){ QStringList opts = currentOpts(); LUtils::runCmd("xrandr", opts); QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); -} +}*/ void MainUI::DeactivateScreen(QString device){ - if(device.isEmpty()){ - //Get the currently selected device - QListWidgetItem *item = ui->list_screens->currentItem(); - if(item==0){ return; } //no selection - //Get the current ID - device = item->whatsThis(); - } + if(device.isEmpty()){ device = currentSelection(); } if(device.isEmpty()){ return; } //nothing found //Remove the screen from the settings for(int i=0; ilist_screens->currentItem(); - if(it==0){ return; } //nothing to do + QString item = currentSelection(); + if(item.isEmpty()){ return; } //nothing to do QString newres = ui->combo_resolution->currentData().toString(); if(newres.isEmpty()){ return; } //nothing to do //qDebug() << "Apply Screen Changes" << it->whatsThis() << "->" << newres; //Adjust the order of the two screens bool setprimary = ui->check_primary->isChecked(); + QList windows = ui->mdiArea->subWindowList(); for(int i=0; iwhatsThis()){ + if(SCREENS[i].ID == item){ SCREENS[i].geom.setWidth(newres.section("x",0,0).toInt()); SCREENS[i].geom.setHeight(newres.section("x",1,1).toInt()); } - if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==it->whatsThis(); } + if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==item; } + //Find the window associated with this screen + for(int s=0; swhatsThis()==SCREENS[i].ID){ + SCREENS[i].geom.setTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); + } + } } //Now run the command QStringList opts = currentOpts(); LUtils::runCmd("xrandr", opts); QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); + QTimer::singleShot(1000, this, SLOT(RestartFluxbox()) ); +} + +void MainUI::RestartFluxbox(){ + QProcess::startDetached("killall fluxbox"); } -- cgit From 3b6e8b8ee6e05e3d05e3d69b64b2afe5bc8c0d22 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 15 Aug 2017 19:19:54 -0400 Subject: Get the lumina-xconfig monitor settings all up and working again. 1) Add 2D placement options for screens 2) Add Rotation options for screens 3) Add Fluxbox restart fix for session changes. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 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 90f09104..9ef2bca8 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -20,6 +20,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->combo_location->clear(); ui->combo_location->addItem(tr("Right Of"), "--right-of"); ui->combo_location->addItem(tr("Left Of"), "--left-of"); + ui->combo_rotation->clear(); + ui->combo_rotation->addItem(tr("None"), 0); + ui->combo_rotation->addItem(tr("Left"), -90); + ui->combo_rotation->addItem(tr("Right"), 90); + ui->combo_rotation->addItem(tr("Inverted"), 180); connect(ui->push_close, SIGNAL(clicked()), this, SLOT(close()) ); connect(ui->push_rescan, SIGNAL(clicked()), this, SLOT(UpdateScreens()) ); @@ -174,15 +179,11 @@ void MainUI::ScreenSelected(){ //QListWidgetItem *item = ui->list_screens->currentItem(); if(item.isEmpty()){ //nothing selected - //ui->tool_deactivate->setEnabled(false); - //ui->tool_moveleft->setEnabled(false); - //ui->tool_moveright->setEnabled(false); + ui->tool_deactivate->setEnabled(false); ui->tab_config->setEnabled(false); }else{ //Item selected - //ui->tool_deactivate->setEnabled(ui->list_screens->count()>1); - //ui->tool_moveleft->setEnabled(ui->list_screens->row(item) > 0); - //ui->tool_moveright->setEnabled(ui->list_screens->row(item) < (ui->list_screens->count()-1)); + ui->tool_deactivate->setEnabled(true); ui->tab_config->setEnabled(true); //Update the info available on the config tab ScreenInfo cur = currentScreenInfo(); @@ -195,6 +196,9 @@ void MainUI::ScreenSelected(){ if(cur.resList[i].contains(cres)){ ui->combo_resolution->setCurrentIndex(i); } } ui->check_primary->setChecked( cur.isprimary ); + int index = ui->combo_rotation->findData( cur.rotation ); + if(index<0){ index = 0; } + ui->combo_rotation->setCurrentIndex(index); } } @@ -268,7 +272,6 @@ void MainUI::ActivateScreen(){ } void MainUI::ApplyChanges(){ - //NOTE: need to re-specifiy the QString item = currentSelection(); if(item.isEmpty()){ return; } //nothing to do QString newres = ui->combo_resolution->currentData().toString(); @@ -281,6 +284,7 @@ void MainUI::ApplyChanges(){ if(SCREENS[i].ID == item){ SCREENS[i].geom.setWidth(newres.section("x",0,0).toInt()); SCREENS[i].geom.setHeight(newres.section("x",1,1).toInt()); + SCREENS[i].rotation = ui->combo_rotation->currentData().toInt(); } if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==item; } //Find the window associated with this screen @@ -291,8 +295,8 @@ void MainUI::ApplyChanges(){ } } //Now run the command - QStringList opts = currentOpts(); - LUtils::runCmd("xrandr", opts); + RRSettings::Apply(SCREENS); + //And update the UI and WM in a moment QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); QTimer::singleShot(1000, this, SLOT(RestartFluxbox()) ); } -- cgit From 816f8131c8dd6fba426c9db936e0fa8aaa73dcb7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 15 Aug 2017 19:30:16 -0400 Subject: Add the option to save settings as the user's defaults. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 54 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 22 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 9ef2bca8..3afa4308 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -32,6 +32,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->tool_deactivate, SIGNAL(clicked()), this, SLOT(DeactivateScreen()) ); //connect(ui->tool_moveleft, SIGNAL(clicked()), this, SLOT(MoveScreenLeft()) ); //connect(ui->tool_moveright, SIGNAL(clicked()), this, SLOT(MoveScreenRight()) ); + connect(ui->tool_save, SIGNAL(clicked()), this, SLOT(SaveSettings()) ); connect(ui->tool_applyconfig, SIGNAL(clicked()), this, SLOT(ApplyChanges()) ); connect(ui->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(ScreenSelected()) ); connect(ui->tool_tile, SIGNAL(clicked()), ui->mdiArea, SLOT(tileSubWindows()) ); @@ -113,6 +114,31 @@ void MainUI::AddScreenToWidget(ScreenInfo screen){ } +void MainUI::SyncBackend(){ + QString item = currentSelection(); + if(item.isEmpty()){ return; } //nothing to do + QString newres = ui->combo_resolution->currentData().toString(); + if(newres.isEmpty()){ return; } //nothing to do + //qDebug() << "Apply Screen Changes" << it->whatsThis() << "->" << newres; + //Adjust the order of the two screens + bool setprimary = ui->check_primary->isChecked(); + QList windows = ui->mdiArea->subWindowList(); + for(int i=0; icombo_rotation->currentData().toInt(); + } + if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==item; } + //Find the window associated with this screen + for(int s=0; swhatsThis()==SCREENS[i].ID){ + SCREENS[i].geom.setTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); + } + } + } +} + void MainUI::UpdateScreens(){ //First probe the server for current screens SCREENS = RRSettings::CurrentScreens(); @@ -272,28 +298,7 @@ void MainUI::ActivateScreen(){ } void MainUI::ApplyChanges(){ - QString item = currentSelection(); - if(item.isEmpty()){ return; } //nothing to do - QString newres = ui->combo_resolution->currentData().toString(); - if(newres.isEmpty()){ return; } //nothing to do - //qDebug() << "Apply Screen Changes" << it->whatsThis() << "->" << newres; - //Adjust the order of the two screens - bool setprimary = ui->check_primary->isChecked(); - QList windows = ui->mdiArea->subWindowList(); - for(int i=0; icombo_rotation->currentData().toInt(); - } - if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==item; } - //Find the window associated with this screen - for(int s=0; swhatsThis()==SCREENS[i].ID){ - SCREENS[i].geom.setTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); - } - } - } + SyncBackend(); //Now run the command RRSettings::Apply(SCREENS); //And update the UI and WM in a moment @@ -301,6 +306,11 @@ void MainUI::ApplyChanges(){ QTimer::singleShot(1000, this, SLOT(RestartFluxbox()) ); } +void MainUI::SaveSettings(){ + SyncBackend(); + RRSettings::SaveScreens(SCREENS); +} + void MainUI::RestartFluxbox(){ QProcess::startDetached("killall fluxbox"); } -- cgit From da9c5fa59b4f90b0041548962c61877379654a89 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 16 Aug 2017 12:55:34 -0400 Subject: More updates for lumina-xconfig: 1) Unify the enable/disable routines. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 54 +++++++++++++++------------- 1 file changed, 30 insertions(+), 24 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 3afa4308..9c110126 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -15,7 +15,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); loadIcons(); - scaleFactor = 1/20.0; + scaleFactor = 1/15.0; //simple default value //Fill the location list with the valid entries ui->combo_location->clear(); ui->combo_location->addItem(tr("Right Of"), "--right-of"); @@ -56,7 +56,7 @@ void MainUI::loadIcons(){ ui->tool_applyconfig->setIcon( LXDG::findIcon("dialog-ok-apply","") ); } -QStringList MainUI::currentOpts(){ +/*QStringList MainUI::currentOpts(){ //Read all the settings and create the xrandr options to maintain these settings QStringList opts; for(int i=0; imdiArea->activeSubWindow(); @@ -134,6 +134,7 @@ void MainUI::SyncBackend(){ for(int s=0; swhatsThis()==SCREENS[i].ID){ SCREENS[i].geom.setTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); + SCREENS[i].applyChange = (windows[s]->isEnabled() ? 0 : 1); //disabled window is one that will be removed } } } @@ -143,9 +144,9 @@ void MainUI::UpdateScreens(){ //First probe the server for current screens SCREENS = RRSettings::CurrentScreens(); //Now go through the screens and arrange them in order from left->right in the UI - bool found = true; - int xoffset = 0; //start at 0 - int cnum = 0; + //bool found = true; + //int xoffset = 0; //start at 0 + //int cnum = 0; QString csel = currentSelection(); //Clear all the current widgets while(ui->mdiArea->currentSubWindow()!=0 ){ @@ -154,8 +155,11 @@ void MainUI::UpdateScreens(){ ui->mdiArea->removeSubWindow(tmp); tmp->deleteLater(); } - - while(found){ + //Now add all the active screens to the display + for(int i=0; icombo_availscreens->clear(); ui->combo_cscreens->clear(); for(int i=0; icombo_availscreens->addItem(SCREENS[i].ID); - }else{ + }else if(SCREENS[i].isactive){ ui->combo_cscreens->addItem(SCREENS[i].ID); } } @@ -271,30 +275,32 @@ void MainUI::ScreenSelected(){ }*/ void MainUI::DeactivateScreen(QString device){ - if(device.isEmpty()){ device = currentSelection(); } - if(device.isEmpty()){ return; } //nothing found - //Remove the screen from the settings - for(int i=0; imdiArea->currentSubWindow(); + if(cur==0){ return; } + cur->setEnabled( !cur->isEnabled() ); //toggle it between enabled/disabled } void MainUI::ActivateScreen(){ //Assemble the command; QString ID = ui->combo_availscreens->currentText(); - QString DID = ui->combo_cscreens->currentText(); + //Find the screen infor associated with this ID + for(int i=0; icombo_cscreens->currentText(); QString loc = ui->combo_location->currentData().toString(); if(ID.isEmpty() || DID.isEmpty() || loc.isEmpty()){ return; } //invalid inputs QStringList opts = currentOpts(); opts << "--output" << ID << loc << DID <<"--auto"; //qDebug() << "Activate Options:" << opts; LUtils::runCmd("xrandr", opts ); - QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); + QTimer::singleShot(500, this, SLOT(UpdateScreens()) );*/ } void MainUI::ApplyChanges(){ -- cgit From 4473c070989a9e3835ad032e03e952cf2cb6b0fa Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 16 Aug 2017 15:23:22 -0400 Subject: Fix up a bit more of the new lumina-xconfig. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 156 +++++++++------------------ 1 file changed, 48 insertions(+), 108 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 9c110126..246fba62 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -16,10 +16,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); loadIcons(); scaleFactor = 1/15.0; //simple default value - //Fill the location list with the valid entries - ui->combo_location->clear(); - ui->combo_location->addItem(tr("Right Of"), "--right-of"); - ui->combo_location->addItem(tr("Left Of"), "--left-of"); ui->combo_rotation->clear(); ui->combo_rotation->addItem(tr("None"), 0); ui->combo_rotation->addItem(tr("Left"), -90); @@ -35,7 +31,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->tool_save, SIGNAL(clicked()), this, SLOT(SaveSettings()) ); connect(ui->tool_applyconfig, SIGNAL(clicked()), this, SLOT(ApplyChanges()) ); connect(ui->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(ScreenSelected()) ); - connect(ui->tool_tile, SIGNAL(clicked()), ui->mdiArea, SLOT(tileSubWindows()) ); + connect(ui->tool_tile, SIGNAL(clicked()), this, SLOT(tileScreens()) ); + connect(ui->combo_availscreens, SIGNAL(currentIndexChanged(int)), this, SLOT(updateNewScreenResolutions()) ); QTimer::singleShot(0, this, SLOT(UpdateScreens()) ); } @@ -56,25 +53,6 @@ void MainUI::loadIcons(){ ui->tool_applyconfig->setIcon( LXDG::findIcon("dialog-ok-apply","") ); } -/*QStringList MainUI::currentOpts(){ - //Read all the settings and create the xrandr options to maintain these settings - QStringList opts; - for(int i=0; i 0){ - //Get the ID of the previous screen - QString id; - for(int j=0; jmdiArea->activeSubWindow(); if(tmp!=0){ return tmp->whatsThis(); } @@ -93,22 +71,17 @@ 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); it->setWindowTitle(screen.ID); lab->setText(QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())); - /*QListWidgetItem *it = new QListWidgetItem(); - it->setTextAlignment(Qt::AlignCenter); - it->setText( screen.ID+"\n\n ("+QString::number(screen.geom.x())+", "+QString::number(screen.geom.y())+")\n ("+QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())+") " );*/ it->setWhatsThis(screen.ID); - //ui->list_screens->addItem(it); QRect scaled( screen.geom.topLeft()*scaleFactor, screen.geom.size()*scaleFactor); qDebug() << " - Scaled:" << scaled; it->show(); - //QApplication::processEvents(); it->setGeometry(scaled); //scale it down for the display it->setFixedSize(scaled.size()); @@ -117,9 +90,9 @@ void MainUI::AddScreenToWidget(ScreenInfo screen){ void MainUI::SyncBackend(){ QString item = currentSelection(); if(item.isEmpty()){ return; } //nothing to do - QString newres = ui->combo_resolution->currentData().toString(); + QString newres = ui->combo_resolution->currentData().toString().section("(",0,0).simplified(); if(newres.isEmpty()){ return; } //nothing to do - //qDebug() << "Apply Screen Changes" << it->whatsThis() << "->" << newres; + //qDebug() << "Apply Screen Changes" << item << "->" << newres; //Adjust the order of the two screens bool setprimary = ui->check_primary->isChecked(); QList windows = ui->mdiArea->subWindowList(); @@ -127,14 +100,15 @@ void MainUI::SyncBackend(){ if(SCREENS[i].ID == item){ SCREENS[i].geom.setWidth(newres.section("x",0,0).toInt()); SCREENS[i].geom.setHeight(newres.section("x",1,1).toInt()); + //qDebug() << " - New Geom:" << SCREENS[i].geom; SCREENS[i].rotation = ui->combo_rotation->currentData().toInt(); } - if(setprimary){ SCREENS[i].isprimary = SCREENS[i].ID==item; } + if(setprimary){ SCREENS[i].isprimary = (SCREENS[i].ID==item); } //Find the window associated with this screen for(int s=0; swhatsThis()==SCREENS[i].ID){ - SCREENS[i].geom.setTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); - SCREENS[i].applyChange = (windows[s]->isEnabled() ? 0 : 1); //disabled window is one that will be removed + SCREENS[i].geom.moveTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); + if(SCREENS[i].applyChange<1){ SCREENS[i].applyChange = (windows[s]->widget()->isEnabled() ? 0 : 1); } //disabled window is one that will be removed } } } @@ -159,36 +133,12 @@ void MainUI::UpdateScreens(){ for(int i=0; i xoffset){ - //Screen not aligned with previous screen edge - qDebug() << "Found mis-aligned screen:" << i << SCREENS[i].ID; - found = true; //make sure to look for the next one - xoffset = xoffset+SCREENS[i].geom.width(); //next number to look for - SCREENS[i].order = cnum; //assign the current order to it - cnum++; //get ready for the next one - AddScreenToWidget(SCREENS[i]); - } - } - }*/ //Now update the available/current screens in the UI ui->combo_availscreens->clear(); - ui->combo_cscreens->clear(); for(int i=0; icombo_availscreens->addItem(SCREENS[i].ID); - }else if(SCREENS[i].isactive){ - ui->combo_cscreens->addItem(SCREENS[i].ID); } } if(ui->combo_availscreens->count()<1){ @@ -201,7 +151,7 @@ void MainUI::UpdateScreens(){ } //if(ui->list_screens->currentItem()==0){ ui->list_screens->setCurrentRow(0); } ScreenSelected(); //update buttons - RRSettings::SaveScreens(SCREENS); + updateNewScreenResolutions(); } void MainUI::ScreenSelected(){ @@ -232,75 +182,65 @@ void MainUI::ScreenSelected(){ } } -/*void MainUI::MoveScreenLeft(){ - QListWidgetItem *item = ui->list_screens->currentItem(); - if(item==0){ return; } //no selection - //Get the current ID - QString CID = item->whatsThis(); - //Now get the ID of the one on the left - item = ui->list_screens->item( ui->list_screens->row(item)-1 ); - if(item == 0){ return; } //no item on the left (can't go left) - QString LID = item->whatsThis(); //left ID - //Adjust the order of the two screens +void MainUI::updateNewScreenResolutions(){ + QString id = ui->combo_availscreens->currentText(); for(int i=0; icombo_resolutions->clear(); + for(int r=0; rcombo_resolutions->addItem(SCREENS[i].resList[r].section(" ",0,0, QString::SectionSkipEmpty)); + if(SCREENS[i].resList[r].contains("+")){ ui->combo_resolutions->setCurrentIndex(r); } //preferred resolution + } + break; + } } - //Now run the command - QStringList opts = currentOpts(); - LUtils::runCmd("xrandr", opts); - //Now run the command - //LUtils::runCmd("xrandr", QStringList() << "--output" << CID << "--left-of" << LID); - QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); -}*/ +} -/*void MainUI::MoveScreenRight(){ - QListWidgetItem *item = ui->list_screens->currentItem(); - if(item==0){ return; } //no selection - //Get the current ID - QString CID = item->whatsThis(); - //Now get the ID of the one on the left - item = ui->list_screens->item( ui->list_screens->row(item)+1 ); - if(item == 0){ return; } //no item on the right (can't go right) - QString RID = item->whatsThis(); //right ID - //Adjust the order of the two screens - for(int i=0; i wins = ui->mdiArea->subWindowList(); + QRegion total; + int xpos, ypos; + xpos = ypos = 0; + QMdiSubWindow *cur = 0; + float diff; + while(!wins.isEmpty()){ + cur=0; + diff = -1; + //Scan for the window closest to the current X value + for(x=0; xgeometry().y()geometry().y() && wins[y]->geometry().y()>ypos){ cur = wins[y]; } + } + } + if(cur!=0){ + + } } - //Now run the command - QStringList opts = currentOpts(); - LUtils::runCmd("xrandr", opts); - QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); -}*/ +} -void MainUI::DeactivateScreen(QString device){ +void MainUI::DeactivateScreen(){ QMdiSubWindow *cur = ui->mdiArea->currentSubWindow(); if(cur==0){ return; } - cur->setEnabled( !cur->isEnabled() ); //toggle it between enabled/disabled + cur->widget()->setEnabled( !cur->widget()->isEnabled() ); //toggle it between enabled/disabled } void MainUI::ActivateScreen(){ //Assemble the command; QString ID = ui->combo_availscreens->currentText(); + QStringList res = ui->combo_resolutions->currentText().split("x"); //Find the screen infor associated with this ID for(int i=0; icombo_cscreens->currentText(); - QString loc = ui->combo_location->currentData().toString(); - if(ID.isEmpty() || DID.isEmpty() || loc.isEmpty()){ return; } //invalid inputs - QStringList opts = currentOpts(); - opts << "--output" << ID << loc << DID <<"--auto"; - //qDebug() << "Activate Options:" << opts; - LUtils::runCmd("xrandr", opts ); - QTimer::singleShot(500, this, SLOT(UpdateScreens()) );*/ } void MainUI::ApplyChanges(){ -- cgit From 671c2e8a4d65648e0c6747799a5a5ff0c0846cee Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 16 Aug 2017 16:06:01 -0400 Subject: Get rudimentary y-dimension tiling working. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 44 ++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 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 246fba62..b97d1b3b 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -197,26 +197,46 @@ void MainUI::updateNewScreenResolutions(){ } void MainUI::tileScreens(bool activeonly){ + qDebug() << "Tile Windows in Y Dimension"; QList wins = ui->mdiArea->subWindowList(); QRegion total; int xpos, ypos; xpos = ypos = 0; QMdiSubWindow *cur = 0; - float diff; while(!wins.isEmpty()){ cur=0; - diff = -1; - //Scan for the window closest to the current X value - for(x=0; xgeometry().y()geometry().y() && wins[y]->geometry().y()>ypos){ cur = wins[y]; } - } + for(int i=0; ipos().y() < cur->pos().y()){ cur = wins[i]; } } - if(cur!=0){ - + if(cur==0){ + //Note: This should **never** happen + qDebug() << "No windows found below y=:" << ypos; + //need to move the reference point + QRect bounding = total.boundingRect(); + ypos+= (bounding.height()/2); + }else{ + if(total.isNull()){ + //First window handled + cur->move(cur->pos().x(), ypos); + }else{ + int newy = ypos; + bool overlap = true; + while(overlap){ + QRegion tmp(cur->pos().x(), newy, cur->width(), cur->height()); + QRegion diff = tmp.subtracted(total); + overlap = (diff.boundingRect()!=tmp.boundingRect()); + qDebug() << "Check Overlap:" << newy << overlap << tmp.boundingRect() << diff.boundingRect(); + if(overlap){ + QRect bound = diff.boundingRect(); + if(newy!=bound.top()){ newy = bound.top(); } + else{ newy = bound.bottom(); } + } + } + cur->move(cur->pos().x(), newy); + } + total = total.united(cur->geometry()); + wins.removeAll(cur); } } } -- cgit From 3fd9d7521213e42f223ada18765f775791ca157b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 17 Aug 2017 09:15:06 -0400 Subject: Get the tiling options all working for lumina-xconfig. All good to go now. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 104 +++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 12 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 b97d1b3b..77d0a7ce 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -22,15 +22,25 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->combo_rotation->addItem(tr("Right"), 90); ui->combo_rotation->addItem(tr("Inverted"), 180); + singleTileMenu = new QMenu(this); + singleTileMenu->addAction(tr("Align Horizontally"))->setWhatsThis("X"); + singleTileMenu->addAction(tr("Align Vertically"))->setWhatsThis("Y"); + singleTileMenu->addAction(tr("Align Horizontal then Vertical"))->setWhatsThis("XY"); + singleTileMenu->addAction(tr("Align Vertical then Horizontal"))->setWhatsThis("YX"); + ui->mdiArea->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->mdiArea, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) ); + + connect(singleTileMenu, SIGNAL(triggered(QAction*)), this, SLOT(tileSingleScreen(QAction*)) ); connect(ui->push_close, SIGNAL(clicked()), this, SLOT(close()) ); connect(ui->push_rescan, SIGNAL(clicked()), this, SLOT(UpdateScreens()) ); connect(ui->push_activate, SIGNAL(clicked()), this, SLOT(ActivateScreen()) ); connect(ui->tool_deactivate, SIGNAL(clicked()), this, SLOT(DeactivateScreen()) ); - //connect(ui->tool_moveleft, SIGNAL(clicked()), this, SLOT(MoveScreenLeft()) ); - //connect(ui->tool_moveright, SIGNAL(clicked()), this, SLOT(MoveScreenRight()) ); + connect(ui->tool_save, SIGNAL(clicked()), this, SLOT(SaveSettings()) ); connect(ui->tool_applyconfig, SIGNAL(clicked()), this, SLOT(ApplyChanges()) ); connect(ui->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(ScreenSelected()) ); + connect(ui->tool_tileX, SIGNAL(clicked()), this, SLOT(tileScreensX()) ); + 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()) ); QTimer::singleShot(0, this, SLOT(UpdateScreens()) ); @@ -43,8 +53,7 @@ MainUI::~MainUI(){ void MainUI::loadIcons(){ this->setWindowIcon( LXDG::findIcon("preferences-system-windows-actions","") ); ui->tool_deactivate->setIcon( LXDG::findIcon("list-remove","") ); - //ui->tool_moveleft->setIcon( LXDG::findIcon("arrow-left","") ); - //ui->tool_moveright->setIcon( LXDG::findIcon("arrow-right","") ); + ui->push_activate->setIcon( LXDG::findIcon("list-add","") ); ui->push_rescan->setIcon( LXDG::findIcon("view-refresh","") ); ui->push_close->setIcon( LXDG::findIcon("window-close","") ); @@ -75,6 +84,7 @@ void MainUI::AddScreenToWidget(ScreenInfo screen){ QLabel *lab = new QLabel(this); lab->setAlignment(Qt::AlignCenter); QMdiSubWindow *it = ui->mdiArea->addSubWindow(lab, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint); + it->setSystemMenu(0); it->setWindowTitle(screen.ID); lab->setText(QString::number(screen.geom.width())+"x"+QString::number(screen.geom.height())); @@ -107,7 +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; SCREENS[i].geom.moveTopLeft( windows[s]->geometry().topLeft()/scaleFactor ); + 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 } } @@ -196,12 +208,12 @@ void MainUI::updateNewScreenResolutions(){ } } -void MainUI::tileScreens(bool activeonly){ +void MainUI::tileScreensY(bool activeonly){ qDebug() << "Tile Windows in Y Dimension"; QList wins = ui->mdiArea->subWindowList(); + QMdiSubWindow *active = ui->mdiArea->currentSubWindow(); QRegion total; - int xpos, ypos; - xpos = ypos = 0; + int ypos = 0; QMdiSubWindow *cur = 0; while(!wins.isEmpty()){ cur=0; @@ -218,7 +230,7 @@ void MainUI::tileScreens(bool activeonly){ }else{ if(total.isNull()){ //First window handled - cur->move(cur->pos().x(), ypos); + if(!activeonly || cur==active){ cur->move(cur->pos().x(), ypos); } }else{ int newy = ypos; bool overlap = true; @@ -226,14 +238,16 @@ void MainUI::tileScreens(bool activeonly){ QRegion tmp(cur->pos().x(), newy, cur->width(), cur->height()); QRegion diff = tmp.subtracted(total); overlap = (diff.boundingRect()!=tmp.boundingRect()); - qDebug() << "Check Overlap:" << newy << overlap << tmp.boundingRect() << diff.boundingRect(); + //qDebug() << "Check Y Overlap:" << newy << overlap << tmp.boundingRect() << diff.boundingRect(); if(overlap){ QRect bound = diff.boundingRect(); - if(newy!=bound.top()){ newy = bound.top(); } - else{ newy = bound.bottom(); } + if(bound.isNull()){ newy+=cur->height(); } + else if(newy!=bound.top()){ newy = bound.top() + 1; } + else if(newy!=bound.bottom()){ newy = bound.bottom() + 1; } + else{ newy++; } //make sure it always changes - no infinite loops!! } } - cur->move(cur->pos().x(), newy); + if(!activeonly || cur==active){ cur->move(cur->pos().x(), newy); } } total = total.united(cur->geometry()); wins.removeAll(cur); @@ -241,6 +255,72 @@ void MainUI::tileScreens(bool activeonly){ } } +void MainUI::tileScreensX(bool activeonly){ + qDebug() << "Tile Windows in X Dimension"; + QList wins = ui->mdiArea->subWindowList(); + QMdiSubWindow *active = ui->mdiArea->currentSubWindow(); + QRegion total; + int xpos = 0; + QMdiSubWindow *cur = 0; + while(!wins.isEmpty()){ + cur=0; + for(int i=0; ipos().x() < cur->pos().x()){ cur = wins[i]; } + } + if(cur==0){ + //Note: This should **never** happen + qDebug() << "No windows found left of x=:" << xpos; + //need to move the reference point + QRect bounding = total.boundingRect(); + xpos+= (bounding.width()/2); + }else{ + if(total.isNull()){ + //First window handled + if(!activeonly || cur==active){ cur->move(xpos, cur->pos().y()); } + }else{ + int newx = xpos; + bool overlap = true; + 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(); + if(overlap){ + QRect bound = diff.boundingRect(); + if(bound.isNull()){ newx+=cur->width(); } + else if(newx!=bound.left()){ newx = bound.left() + 1; } + else if(newx!=bound.right()){ newx = bound.right() + 1; } + else{ newx++; }//make sure it always changes - no infinite loops!! + } + } + if(!activeonly || cur==active){ cur->move(newx, cur->pos().y()); } + } + total = total.united(cur->geometry()); + wins.removeAll(cur); + } + } +} + +void MainUI::tileScreens(){ + tileScreensY(); + tileScreensX(); +} + +void MainUI::tileSingleScreen(QAction* act){ + if(act->whatsThis()=="X"){ + tileScreensX(true); + }else if(act->whatsThis()=="Y"){ + tileScreensY(true); + }else if(act->whatsThis()=="XY"){ + tileScreensX(true); + tileScreensY(true); + }else if(act->whatsThis()=="YX"){ + tileScreensY(true); + tileScreensX(true); + } +} + void MainUI::DeactivateScreen(){ QMdiSubWindow *cur = ui->mdiArea->currentSubWindow(); if(cur==0){ return; } -- cgit From 6bb4e2830d3460fa8aa07b53ca70e2f3670aa279 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 17 Aug 2017 10:12:28 -0400 Subject: Clean up more of the lumina-xconfig tiling options. much nicer now. --- src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 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 77d0a7ce..030b96be 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -28,7 +28,7 @@ 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); - connect(ui->mdiArea, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) ); + connect(ui->mdiArea, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu()) ); connect(singleTileMenu, SIGNAL(triggered(QAction*)), this, SLOT(tileSingleScreen(QAction*)) ); connect(ui->push_close, SIGNAL(clicked()), this, SLOT(close()) ); @@ -129,6 +129,13 @@ void MainUI::SyncBackend(){ void MainUI::UpdateScreens(){ //First probe the server for current screens SCREENS = RRSettings::CurrentScreens(); + //Determine the scale factor for putting these into the UI + QRegion tot; + for(int i=0; imdiArea->width())/wid; //Now go through the screens and arrange them in order from left->right in the UI //bool found = true; //int xoffset = 0; //start at 0 @@ -161,7 +168,6 @@ void MainUI::UpdateScreens(){ ui->group_avail->setVisible(true); ui->tabWidget->setTabEnabled(1,true); } - //if(ui->list_screens->currentItem()==0){ ui->list_screens->setCurrentRow(0); } ScreenSelected(); //update buttons updateNewScreenResolutions(); } @@ -209,7 +215,7 @@ void MainUI::updateNewScreenResolutions(){ } void MainUI::tileScreensY(bool activeonly){ - qDebug() << "Tile Windows in Y Dimension"; + //qDebug() << "Tile Windows in Y Dimension"; QList wins = ui->mdiArea->subWindowList(); QMdiSubWindow *active = ui->mdiArea->currentSubWindow(); QRegion total; @@ -218,6 +224,7 @@ void MainUI::tileScreensY(bool activeonly){ while(!wins.isEmpty()){ cur=0; for(int i=0; i1){ continue; } //ensure active window is last if(cur==0){ cur = wins[i]; } //first one else if(wins[i]->pos().y() < cur->pos().y()){ cur = wins[i]; } } @@ -242,7 +249,7 @@ void MainUI::tileScreensY(bool activeonly){ if(overlap){ QRect bound = diff.boundingRect(); if(bound.isNull()){ newy+=cur->height(); } - else if(newy!=bound.top()){ newy = bound.top() + 1; } + 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!! } @@ -256,7 +263,7 @@ void MainUI::tileScreensY(bool activeonly){ } void MainUI::tileScreensX(bool activeonly){ - qDebug() << "Tile Windows in X Dimension"; + //qDebug() << "Tile Windows in X Dimension"; QList wins = ui->mdiArea->subWindowList(); QMdiSubWindow *active = ui->mdiArea->currentSubWindow(); QRegion total; @@ -265,6 +272,7 @@ void MainUI::tileScreensX(bool activeonly){ while(!wins.isEmpty()){ cur=0; for(int i=0; i1){ continue; } //ensure active window is last if(cur==0){ cur = wins[i]; } //first one else if(wins[i]->pos().x() < cur->pos().x()){ cur = wins[i]; } } @@ -289,9 +297,11 @@ void MainUI::tileScreensX(bool activeonly){ if(overlap){ QRect bound = diff.boundingRect(); if(bound.isNull()){ newx+=cur->width(); } - else if(newx!=bound.left()){ newx = bound.left() + 1; } + 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; } } if(!activeonly || cur==active){ cur->move(newx, cur->pos().y()); } @@ -341,6 +351,17 @@ void MainUI::ActivateScreen(){ break; } } + tileScreensX(true); + //Now remove that option from the "new" list + ui->combo_availscreens->removeItem(ui->combo_availscreens->currentIndex()); + if(ui->combo_availscreens->count()<1){ + ui->group_avail->setVisible(false); + ui->tabWidget->setCurrentIndex(0); + ui->tabWidget->setTabEnabled(1,false); + }else{ + ui->group_avail->setVisible(true); + ui->tabWidget->setTabEnabled(1,true); + } } void MainUI::ApplyChanges(){ -- cgit