diff options
Diffstat (limited to 'src-qt5/core-utils/lumina-xconfig')
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 18 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.h | 12 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.ui | 13 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/lumina-xconfig.pro | 6 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/main.cpp | 16 |
5 files changed, 34 insertions, 31 deletions
diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp index f4aa1c49..2aed4d30 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -54,6 +54,7 @@ QStringList MainUI::currentOpts(){ for(int i=0; i<SCREENS.length(); i++){ if(SCREENS[i].order <0){ continue; } //skip this screen - non-active opts << "--output" << SCREENS[i].ID << "--mode" << QString::number(SCREENS[i].geom.width())+"x"+QString::number(SCREENS[i].geom.height()); + if(SCREENS[i].isprimary){ opts << "--primary"; } if(SCREENS[i].order > 0){ //Get the ID of the previous screen QString id; @@ -79,8 +80,8 @@ ScreenInfo MainUI::currentScreenInfo(){ void MainUI::UpdateScreens(){ //First probe the server for current screens - SCREENS.clear(); - QStringList info = LUtils::getCmdOutput("xrandr -q"); + SCREENS = RRSettings::CurrentScreens(); + /*QStringList info = LUtils::getCmdOutput("xrandr -q"); ScreenInfo cscreen; for(int i=0; i<info.length(); i++){ if(info[i].contains("connected") ){ @@ -105,6 +106,7 @@ void MainUI::UpdateScreens(){ UpdateScreens(); return; }else if( !devres.isEmpty() ){ + cscreen.isprimary = info[i].contains(" primary "); //Device that is connected and attached (has a resolution) qDebug() << "Create new Screen entry:" << dev << devres; cscreen.ID = dev; @@ -121,9 +123,9 @@ void MainUI::UpdateScreens(){ //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 @@ -138,7 +140,7 @@ void MainUI::UpdateScreens(){ else if(SCREENS[i].geom.x()==xoffset){ 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 currrent order to it + SCREENS[i].order = cnum; //assign the current order to it cnum++; //get ready for the next one QListWidgetItem *it = new QListWidgetItem(); it->setTextAlignment(Qt::AlignCenter); @@ -170,6 +172,7 @@ void MainUI::UpdateScreens(){ } if(ui->list_screens->currentItem()==0){ ui->list_screens->setCurrentRow(0); } ScreenSelected(); //update buttons + RRSettings::SaveScreens(SCREENS); } void MainUI::ScreenSelected(){ @@ -196,6 +199,7 @@ void MainUI::ScreenSelected(){ else{ui->combo_resolution->addItem(res, res); } if(cur.resList[i].contains(cres)){ ui->combo_resolution->setCurrentIndex(i); } } + ui->check_primary->setChecked( cur.isprimary ); } } @@ -282,14 +286,16 @@ void MainUI::ApplyChanges(){ 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(); for(int i=0; i<SCREENS.length(); i++){ if(SCREENS[i].ID == it->whatsThis()){ 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(); } } //Now run the command QStringList opts = currentOpts(); LUtils::runCmd("xrandr", opts); QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); -}
\ No newline at end of file +} diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.h b/src-qt5/core-utils/lumina-xconfig/MainUI.h index 0563c4ca..b8be8701 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.h +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.h @@ -12,17 +12,7 @@ #include <QString> #include <QList> -class ScreenInfo{ - public: - QString ID; - QRect geom; //screen geometry - int order; //left to right - QStringList resList; - ScreenInfo(){ - order = -1; //initial value is invalid - } - ~ScreenInfo(){} -}; +#include "ScreenSettings.h" namespace Ui{ class MainUI; diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.ui b/src-qt5/core-utils/lumina-xconfig/MainUI.ui index c1c4b614..de1cc18d 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.ui +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>408</width> - <height>316</height> + <height>321</height> </rect> </property> <property name="windowTitle"> @@ -142,7 +142,7 @@ </item> </layout> </item> - <item row="1" column="1"> + <item row="2" column="1"> <spacer name="verticalSpacer_3"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -155,7 +155,7 @@ </property> </spacer> </item> - <item row="2" column="1"> + <item row="3" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <spacer name="horizontalSpacer_2"> @@ -182,6 +182,13 @@ </item> </layout> </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="check_primary"> + <property name="text"> + <string>Primary Screen</string> + </property> + </widget> + </item> </layout> </widget> <widget class="QWidget" name="tab_new"> diff --git a/src-qt5/core-utils/lumina-xconfig/lumina-xconfig.pro b/src-qt5/core-utils/lumina-xconfig/lumina-xconfig.pro index 676f237c..2661c19b 100644 --- a/src-qt5/core-utils/lumina-xconfig/lumina-xconfig.pro +++ b/src-qt5/core-utils/lumina-xconfig/lumina-xconfig.pro @@ -9,9 +9,11 @@ target.path = $${L_BINDIR} TEMPLATE = app SOURCES += main.cpp \ - mainUI.cpp + mainUI.cpp \ + ScreenSettings.cpp -HEADERS += mainUI.h +HEADERS += mainUI.h \ + ScreenSettings.h FORMS += mainUI.ui diff --git a/src-qt5/core-utils/lumina-xconfig/main.cpp b/src-qt5/core-utils/lumina-xconfig/main.cpp index 699665fb..f30486f4 100644 --- a/src-qt5/core-utils/lumina-xconfig/main.cpp +++ b/src-qt5/core-utils/lumina-xconfig/main.cpp @@ -9,20 +9,18 @@ #include <LuminaUtils.h> #include <LuminaSingleApplication.h> +#include "ScreenSettings.h" int main(int argc, char ** argv) { - /*QStringList in; + bool CLIdone = false; for(int i=1; i<argc; i++){ //skip the first arg (app binary) - QString path = argv[i]; - if(path=="."){ - //Insert the current working directory - in << QDir::currentPath(); - }else{ - if(!path.startsWith("/")){ path.prepend(QDir::currentPath()+"/"); } - in << path; + if(QString(argv[i]) == "--reset-monitors"){ + RRSettings::ApplyPrevious(); + CLIdone = true; + break; } } - if(in.isEmpty()){ in << QDir::homePath(); }*/ + if(CLIdone){ return 0; } LTHEME::LoadCustomEnvSettings(); LSingleApplication a(argc, argv, "lumina-xconfig"); //loads translations inside constructor if( !a.isPrimaryProcess()){ return 0; } |