diff options
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 54 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.h | 2 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/ScreenSettings.cpp | 31 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/ScreenSettings.h | 5 |
4 files changed, 46 insertions, 46 deletions
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; i<SCREENS.length(); i++){ @@ -73,7 +73,7 @@ QStringList MainUI::currentOpts(){ } } return opts; -} +}*/ QString MainUI::currentSelection(){ QMdiSubWindow *tmp = ui->mdiArea->activeSubWindow(); @@ -134,6 +134,7 @@ void MainUI::SyncBackend(){ for(int s=0; s<windows.length(); s++){ if(windows[s]->whatsThis()==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; i<SCREENS.length(); i++){ + if(SCREENS[i].isactive){ AddScreenToWidget(SCREENS[i]); } + } + /*while(found){ found = false; //make sure to break out if a screen is not found for(int i=0; i<SCREENS.length(); i++){ if(SCREENS[i].order != -1){qDebug() << "Skip Screen:" << i << SCREENS[i].order; } //already evaluated - skip it @@ -175,15 +179,15 @@ void MainUI::UpdateScreens(){ AddScreenToWidget(SCREENS[i]); } } - } + }*/ //Now update the available/current screens in the UI ui->combo_availscreens->clear(); ui->combo_cscreens->clear(); for(int i=0; i<SCREENS.length(); i++){ - if(SCREENS[i].order<0){ + if(!SCREENS[i].isactive && SCREENS[i].isavailable){ ui->combo_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; i<SCREENS.length(); i++){ - if(SCREENS[i].ID==device){ SCREENS.removeAt(i); break; } - } - //Now run the command - QStringList opts = currentOpts(); - opts << "--output" << device << "--off"; - LUtils::runCmd("xrandr", opts); - QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); + QMdiSubWindow *cur = ui->mdiArea->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; i<SCREENS.length(); i++){ + if(SCREENS[i].ID==ID){ + SCREENS[i].isactive = true; + QStringList res = SCREENS[i].resList.first().split("x"); + SCREENS[i].geom.setSize( QSize(res[0].toInt(), res[1].toInt()) ); + AddScreenToWidget(SCREENS[i]); + break; + } + } + /*QString DID = ui->combo_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(){ diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.h b/src-qt5/core-utils/lumina-xconfig/MainUI.h index e47dc321..3a6c9f3f 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.h +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.h @@ -39,7 +39,7 @@ private: double scaleFactor; ScreenInfo currentScreenInfo(); - QStringList currentOpts(); + //QStringList currentOpts(); QString currentSelection(); void AddScreenToWidget(ScreenInfo); diff --git a/src-qt5/core-utils/lumina-xconfig/ScreenSettings.cpp b/src-qt5/core-utils/lumina-xconfig/ScreenSettings.cpp index 13ed86f4..9bad91db 100644 --- a/src-qt5/core-utils/lumina-xconfig/ScreenSettings.cpp +++ b/src-qt5/core-utils/lumina-xconfig/ScreenSettings.cpp @@ -21,34 +21,26 @@ void RRSettings::ApplyPrevious(){ QString primary; QStringList avail; for(int i=0; i<screens.length(); i++){ - //if(screens[i].order>=0){screens[i].order = -1; } //reset all screen orders (need to re-check all) if(devs.contains(screens[i].ID) && screens[i].isavailable){ //only load settings for monitors which are currently attached set.beginGroup(screens[i].ID); screens[i].geom = set.value("geometry", QRect()).toRect(); screens[i].isprimary = set.value("isprimary", false).toBool(); if(screens[i].isprimary){ primary = screens[i].ID; } - screens[i].isactive = lastactive.contains(screens[i].ID); - screens[i].order = (screens[i].isactive ? -1 : -3); //check/ignore + screens[i].applyChange = (screens[i].isactive && !lastactive.contains(screens[i].ID) ? 1 : 0); //disable/ignore screens[i].rotation = set.value("rotation",0).toInt(); set.endGroup(); - }else if(screens[i].isavailable){ - screens[i].order = -2; //needs activation/placement - }else{ - screens[i].order = -3; //ignored + }else if(screens[i].isactive){ + screens[i].applyChange = 1; //disable monitor - not enabled in the default settings } - //Now clean up the list as needed - if(screens[i].order < -2){ screens.removeAt(i); i--; } //just remove it (less to loop through later) - else{ avail << screens[i].ID; } //needed for some checks later - make it simple } - //NOTE ABOUT orders: -1: check geom, -2: auto-add to end, -3: ignored //Quick checks for simple systems - just use current X config as-is if(devs.isEmpty() && (avail.filter("LVDS").isEmpty() || screens.length()==1) ){ return; } //Typical ID's: LVDS-[], DVI-I-[], DP-[], HDMI-[], VGA-[] - //"LVDS" is the built-in laptop display normally + //"LVDS" or "eDP" is the built-in laptop display normally if(primary.isEmpty()){ - QStringList priority; priority << "LVDS" << "DP" << "HDMI" << "DVI" << "VGA"; + QStringList priority; priority << "LVDS" << "eDP" << "DP" << "HDMI" << "DVI" << "VGA"; for(int i=0; i<priority.length() && primary.isEmpty(); i++){ QStringList filter = avail.filter(priority[i]); if(!filter.isEmpty()){ filter.sort(); primary = filter.first(); } @@ -58,10 +50,10 @@ void RRSettings::ApplyPrevious(){ //Ensure only one monitor is primary, and reset a few flags for(int i=0; i<screens.length(); i++){ if(screens[i].ID!=primary){ screens[i].isprimary = false; } - screens[i].isactive = true; //we want all these monitors to be active eventually + //screens[i].isactive = true; //we want all these monitors to be active eventually } // Handle all the available monitors - int handled = 0; + /*int handled = 0; int cx = 0; //current x point while(handled<screens.length()){ //Go through horizontally and place monitors (TO-DO: Vertical placement not handled yet) @@ -94,7 +86,7 @@ void RRSettings::ApplyPrevious(){ qDebug() << "Unhandled Monitors:" << screens.length()-handled; break; } - } + }*/ //Now reset the display with xrandr RRSettings::Apply(screens); } @@ -144,7 +136,7 @@ QList<ScreenInfo> RRSettings::CurrentScreens(){ //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 + //cscreen.order = -2; //flag this right now as a non-active screen cscreen.isavailable = true; cscreen.isactive = false; } @@ -188,8 +180,9 @@ void RRSettings::Apply(QList<ScreenInfo> screens){ QStringList opts; //qDebug() << "Apply:" << screens.length(); for(int i=0; i<screens.length(); i++){ - qDebug() << " -- Screen:" << i << screens[i].ID << screens[i].isactive << screens[i].order; - if(screens[i].order <0 || !screens[i].isactive){ continue; } //skip this screen - non-active + qDebug() << " -- Screen:" << i << screens[i].ID << screens[i].isactive; + if(screens[i].applyChange <=0 || !screens[i].isactive){ continue; } //skip this screen - non-active + else if(screens[i].applyChange==1){ opts << "--output" << screens[i].ID << "--off"; continue; } //deactivate a screen opts << "--output" << screens[i].ID << "--mode" << QString::number(screens[i].geom.width())+"x"+QString::number(screens[i].geom.height()); opts << "--pos" << QString::number(screens[i].geom.x())+"x"+QString::number(screens[i].geom.y()); if(screens[i].rotation==-90){ opts << "--rotate" << "left"; } diff --git a/src-qt5/core-utils/lumina-xconfig/ScreenSettings.h b/src-qt5/core-utils/lumina-xconfig/ScreenSettings.h index 0532cf72..9371e361 100644 --- a/src-qt5/core-utils/lumina-xconfig/ScreenSettings.h +++ b/src-qt5/core-utils/lumina-xconfig/ScreenSettings.h @@ -19,13 +19,14 @@ class ScreenInfo{ bool isprimary; bool isactive; bool isavailable; - int order; //left to right + int applyChange; //[<=0: do nothing, 1: deactivate] QStringList resList; int rotation; //possible values: [-90, 0, 90, 180] + //Initial Defaults ScreenInfo(){ - order = -1; //initial value is invalid + applyChange = -1; //initial value is invalid isprimary = false; isactive = false; isavailable = false; |