diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.cpp | 47 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-xconfig/MainUI.h | 2 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp index 169302ca..6553bb37 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.cpp +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.cpp @@ -32,7 +32,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ } MainUI::~MainUI(){ - + } void MainUI::loadIcons(){ @@ -55,10 +55,10 @@ QStringList MainUI::currentOpts(){ 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){ + if(SCREENS[i].order > 0){ //Get the ID of the previous screen - QString id; - for(int j=0; j<SCREENS.length(); j++){ + QString id; + for(int j=0; j<SCREENS.length(); j++){ if(SCREENS[j].order == SCREENS[i].order-1){ id = SCREENS[j].ID; break;} } if(!id.isEmpty()){ opts << "--right-of" << id; } @@ -78,6 +78,14 @@ ScreenInfo MainUI::currentScreenInfo(){ return ScreenInfo(); } +void MainUI::AddScreenToWidget(ScreenInfo screen){ + 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); +} + void MainUI::UpdateScreens(){ //First probe the server for current screens SCREENS = RRSettings::CurrentScreens(); @@ -86,10 +94,10 @@ void MainUI::UpdateScreens(){ for(int i=0; i<info.length(); i++){ if(info[i].contains("connected") ){ //qDebug() << "xrandr info:" << info[i]; - if(!cscreen.ID.isEmpty()){ + if(!cscreen.ID.isEmpty()){ SCREENS << cscreen; //current screen finished - save it into the array - cscreen = ScreenInfo(); //Now create a new structure - } + cscreen = ScreenInfo(); //Now create a new structure + } //qDebug() << "Line:" << info[i]; QString dev = info[i].section(" ",0,0); //device ID //The device resolution can be either the 3rd or 4th output - check both @@ -112,7 +120,7 @@ void MainUI::UpdateScreens(){ cscreen.ID = dev; //Note: devres format: "<width>x<height>+<xoffset>+<yoffset>" 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"; @@ -136,22 +144,31 @@ void MainUI::UpdateScreens(){ 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){} //already evaluated - skip it + if(SCREENS[i].order != -1){qDebug() << "Skip Screen:" << i << SCREENS[i].order; } //already evaluated - skip it 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 current order to it cnum++; //get ready for the next one - QListWidgetItem *it = new QListWidgetItem(); + AddScreenToWidget(SCREENS[i]); + /*QListWidgetItem *it = new QListWidgetItem(); it->setTextAlignment(Qt::AlignCenter); - it->setText( SCREENS[i].ID+"\n ("+QString::number(SCREENS[i].geom.width())+"x"+QString::number(SCREENS[i].geom.height())+") " ); + 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); } + 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; + 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(); @@ -219,7 +236,7 @@ void MainUI::MoveScreenLeft(){ } //Now run the command QStringList opts = currentOpts(); - LUtils::runCmd("xrandr", opts); + LUtils::runCmd("xrandr", opts); //Now run the command //LUtils::runCmd("xrandr", QStringList() << "--output" << CID << "--left-of" << LID); QTimer::singleShot(500, this, SLOT(UpdateScreens()) ); diff --git a/src-qt5/core-utils/lumina-xconfig/MainUI.h b/src-qt5/core-utils/lumina-xconfig/MainUI.h index b8be8701..5a1a62cc 100644 --- a/src-qt5/core-utils/lumina-xconfig/MainUI.h +++ b/src-qt5/core-utils/lumina-xconfig/MainUI.h @@ -38,6 +38,8 @@ private: QStringList currentOpts(); + void AddScreenToWidget(ScreenInfo); + private slots: void UpdateScreens(); void ScreenSelected(); |