aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-05-18 15:46:10 -0400
committerKen Moore <ken@ixsystems.com>2017-05-18 15:46:10 -0400
commit73e9d69e1ce4f68ab541c63f0a0d756cc44642cc (patch)
tree76e761ebd1ace2a456c8a9b2bee1928155340991 /src-qt5
parentFinal fox for the x11/lumina metaport "run_depends". (diff)
downloadlumina-73e9d69e1ce4f68ab541c63f0a0d756cc44642cc.tar.gz
lumina-73e9d69e1ce4f68ab541c63f0a0d756cc44642cc.tar.bz2
lumina-73e9d69e1ce4f68ab541c63f0a0d756cc44642cc.zip
Add the ability to scan/migrate desktop/panel settings from one monitor ID to another on the first start of the desktop, and enable that migration for single-monitor arrangements.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/LDesktopUtils.cpp17
-rw-r--r--src-qt5/core/libLumina/LDesktopUtils.h5
-rw-r--r--src-qt5/core/lumina-desktop/LSession.cpp25
3 files changed, 45 insertions, 2 deletions
diff --git a/src-qt5/core/libLumina/LDesktopUtils.cpp b/src-qt5/core/libLumina/LDesktopUtils.cpp
index a46f03d0..d76c68e9 100644
--- a/src-qt5/core/libLumina/LDesktopUtils.cpp
+++ b/src-qt5/core/libLumina/LDesktopUtils.cpp
@@ -9,6 +9,7 @@
#include <QDesktopWidget>
#include <QApplication>
#include <QScreen>
+#include <QSettings>
#include "LuminaThemes.h"
@@ -526,3 +527,19 @@ int LDesktopUtils::VersionStringToNumber(QString version){
//NOTE: This format allows numbers to be anywhere from 0->999 without conflict
return (maj*1000000 + mid*1000 + min);
}
+
+void LDesktopUtils::MigrateDesktopSettings(QSettings *settings, QString fromID, QString toID){
+ //desktop-ID
+ QStringList keys = settings->allKeys();
+ QStringList filter = keys.filter("desktop-"+fromID+"/");
+ for(int i=0; i<filter.length(); i++){
+ settings->setValue("desktop-"+toID+"/"+filter[i].section("/",1,-1), settings->value(filter[i]));
+ settings->remove(filter[i]);
+ }
+ //panel_ID.[number]
+ filter = keys.filter("panel_"+fromID+".");
+ for(int i=0; i<filter.length(); i++){
+ settings->setValue("panel_"+toID+"."+ filter[i].section("/",0,0).section(".",-1)+"/"+filter[i].section("/",1,-1), settings->value(filter[i]));
+ settings->remove(filter[i]);
+ }
+}
diff --git a/src-qt5/core/libLumina/LDesktopUtils.h b/src-qt5/core/libLumina/LDesktopUtils.h
index dbad8757..b21bc78a 100644
--- a/src-qt5/core/libLumina/LDesktopUtils.h
+++ b/src-qt5/core/libLumina/LDesktopUtils.h
@@ -12,6 +12,7 @@
#include <QFile>
#include <QDir>
#include <QDateTime>
+#include <QSettings>
//Other classes needed
#include <LUtils.h>
@@ -44,6 +45,10 @@ public:
static void LoadSystemDefaults(bool skipOS = false);
static bool checkUserFiles(QString lastversion); //returns true if something changed
static int VersionStringToNumber(QString version); //convert the lumina version string to a number for comparisons
+
+ //Migrating desktop settings from one ID to another
+ static void MigrateDesktopSettings(QSettings *settings, QString fromID, QString toID);
+
};
#endif
diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp
index 735390aa..8932ac36 100644
--- a/src-qt5/core/lumina-desktop/LSession.cpp
+++ b/src-qt5/core/lumina-desktop/LSession.cpp
@@ -403,6 +403,25 @@ void LSession::updateDesktops(){
bool firstrun = (DESKTOPS.length()==0);
bool numchange = DESKTOPS.length()!=sC;
+ QSettings dset("lumina-desktop", "desktopsettings");
+ if(firstrun && sC==1){
+ //Sanity check - ensure the monitor ID did not change between sessions for single-monitor setups
+ QString name = QApplication::screens().at(0)->name();
+ if(!dset.contains("desktop-"+name+"/screen/lastHeight")){
+ //Empty Screen - find the previous one and migrate the settings over
+ QStringList old = dset.allKeys().filter("desktop-").filter("/screen/lastHeight");
+ QStringList lastused = dset.value("last_used_screens").toStringList();
+ QString oldname;
+ for(int i=0; i<old.length(); i++){
+ QString tmp = old[i].section("/",0,0).section("-",1,-1); //old desktop ID
+ if(tmp=="default"){ continue; } //always skip this one
+ else if(lastused.contains(tmp)){
+ oldname = tmp; break; //use the first screen that was last used
+ }
+ }
+ if(!oldname.isEmpty()){ LDesktopUtils::MigrateDesktopSettings(&dset, oldname, name); }
+ }
+ }
// If the screen count is changing on us
if ( sC != DW->screenCount() ) {
@@ -431,7 +450,10 @@ void LSession::updateDesktops(){
}
//Now add any new desktops
+ QStringList allNames;
+ QList<QScreen*> scrns = QApplication::screens();
for(int i=0; i<sC; i++){
+ allNames << scrns.at(i)->name();
if(!dnums.contains(i) && !geoms.contains(DW->screenGeometry(i)) ){
//Start the desktop on this screen
qDebug() << " - Start desktop on screen:" << i;
@@ -439,7 +461,7 @@ void LSession::updateDesktops(){
geoms << DW->screenGeometry(i);
}
}
-
+ dset.setValue("last_used_screens", allNames);
//Make sure fluxbox also gets prompted to re-load screen config if the number of screens changes in the middle of a session
if(numchange && !firstrun) {
qDebug() << "Update WM";
@@ -449,7 +471,6 @@ void LSession::updateDesktops(){
//Make sure all the background windows are registered on the system as virtual roots
QTimer::singleShot(100,this, SLOT(registerDesktopWindows()));
//Determine if any High-DPI screens are available and enable auto-scaling as needed
- QList<QScreen*> scrns = QApplication::screens();
for(int i=0; i<scrns.length(); i++){
qDebug() << "Check Screen DPI:" << scrns[i]->name();
qDebug() << " -- Physical DPI:" << scrns[i]->physicalDotsPerInchX() << "x" << scrns[i]->physicalDotsPerInchY();
bgstack15