//=========================================== // Lumina-DE source code // Copyright (c) 2016, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "ScreenSettings.h" #include #include #include //Reset current screen config to match previously-saved settings void RRSettings::ApplyPrevious(){ QList screens; QSettings set("lumina-desktop","lumina-xconfig"); if(set.allKeys().isEmpty()){ return; } QString profile = set.value("default_profile","").toString(); if(profile.isEmpty() || !savedProfiles().contains(profile) ){ screens = PreviousSettings(); } else{ screens = PreviousSettings(profile); } //Now reset the display with xrandr RRSettings::Apply(screens); } void RRSettings::MirrorAll(){ QList screens; //Now find the highest resolution supported by all connected monitors //Setup one monitor with that resolution, and mirror the rest of them //Now reset the display with xrandr RRSettings::Apply(screens); } //Read the current screen config from xrandr QList RRSettings::CurrentScreens(){ QList SCREENS; 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() ); cscreen.isavailable = true; cscreen.isactive = true; if(devrotate=="left"){ cscreen.rotation = -90; } else if(devrotate=="right"){ cscreen.rotation = 90; } else if(devrotate=="inverted"){ cscreen.rotation = 180; } else{ cscreen.rotation = 0; } }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 cscreen.isavailable = true; cscreen.isactive = false; } }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 primary info lines if(!cscreen.ID.isEmpty()){ SCREENS << cscreen; } //make sure to add the last screen to the array return SCREENS; } QList RRSettings::PreviousSettings(QString profile){ QSettings set("lumina-desktop","lumina-xconfig"); if(profile.isEmpty()){ set.beginGroup("MonitorSettings"); } else{ set.beginGroup("MonitorProfiles/"+profile); } //Setup a couple lists QStringList devs = set.childGroups(); //known/saved devices QList screens = RRSettings::CurrentScreens(); QStringList lastactive = set.value("lastActive",QStringList()).toStringList(); //Now go through all the saved settings and put that info into the array QString primary; QStringList avail; for(int i=0; i screens, QString profile){ QSettings set("lumina-desktop","lumina-xconfig"); if(profile.isEmpty()){ set.beginGroup("MonitorSettings"); } else{ set.beginGroup("MonitorProfiles/"+profile); } //Setup a couple lists QStringList olddevs = set.childGroups(); QStringList active; //Now go through all the current screens and save that info for(int i=0; i screens){ //Verify that there is at least 1 active/enabled monitor first bool foundactive = false; for(int i=0; i