aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core-utils/lumina-config/pages/PageWidget.h2
-rw-r--r--src-qt5/core-utils/lumina-config/pages/getPage.h4
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp170
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h43
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_sample.cpp1
-rw-r--r--src-qt5/core-utils/lumina-config/pages/pages.pri22
6 files changed, 228 insertions, 14 deletions
diff --git a/src-qt5/core-utils/lumina-config/pages/PageWidget.h b/src-qt5/core-utils/lumina-config/pages/PageWidget.h
index bee27d24..66fce36a 100644
--- a/src-qt5/core-utils/lumina-config/pages/PageWidget.h
+++ b/src-qt5/core-utils/lumina-config/pages/PageWidget.h
@@ -50,7 +50,7 @@ public slots:
virtual void updateIcons(){}
//Simplification function for widget connections
- void settingChanged(){
+ virtual void settingChanged(){
emit HasPendingChanges(true);
}
};
diff --git a/src-qt5/core-utils/lumina-config/pages/getPage.h b/src-qt5/core-utils/lumina-config/pages/getPage.h
index 5add9e78..6844a8e6 100644
--- a/src-qt5/core-utils/lumina-config/pages/getPage.h
+++ b/src-qt5/core-utils/lumina-config/pages/getPage.h
@@ -42,7 +42,7 @@ static QList<PAGEINFO> KnownPages(){
#include "page_autostart.h"
#include "page_defaultapps.h"
#include "page_fluxbox_keys.h"
-//#include "page_fluxbox_settings.h"
+#include "page_fluxbox_settings.h"
static PageWidget* GetNewPage(QString id, QWidget *parent){
//Find the page that matches this "id"
@@ -51,7 +51,7 @@ static PageWidget* GetNewPage(QString id, QWidget *parent){
else if(id=="autostart"){ return new page_autostart(parent); }
else if(id=="defaultapps"){ return new page_defaultapps(parent); }
else if(id=="fluxbox-keys"){ return new page_fluxbox_keys(parent); }
-// else if(id=="fluxbox-session"){ return new page_fluxbox_settings(parent); }
+ else if(id=="fluxbox-settings"){ return new page_fluxbox_settings(parent); }
//Return the main control_panel page as the fallback/default
return new page_main(parent);
}
diff --git a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp
new file mode 100644
index 00000000..8f075488
--- /dev/null
+++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp
@@ -0,0 +1,170 @@
+//===========================================
+// Lumina Desktop Source Code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "page_fluxbox_settings.h"
+#include "ui_page_fluxbox_settings.h"
+#include "getPage.h"
+
+//==========
+// PUBLIC
+//==========
+page_fluxbox_settings::page_fluxbox_settings(QWidget *parent) : PageWidget(parent), ui(new Ui::page_fluxbox_settings()){
+ ui->setupUi(this);
+ loading= false;
+ connect(ui->combo_session_wfocus, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
+ connect(ui->combo_session_wloc, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
+ connect(ui->combo_session_wtheme, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionthemechanged()) );
+ connect(ui->spin_session_wkspaces, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()) );
+ updateIcons();
+}
+
+page_fluxbox_settings::~page_fluxbox_settings(){
+
+}
+
+//================
+// PUBLIC SLOTS
+//================
+void page_fluxbox_settings::SaveSettings(){
+ QStringList FB = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init");
+ // - window placement
+ int index = FB.indexOf( FB.filter("session.screen0.windowPlacement:").join("") );
+ QString line = "session.screen0.windowPlacement:\t"+ui->combo_session_wloc->itemData( ui->combo_session_wloc->currentIndex() ).toString();
+ if(index < 0){ FB << line; } //add line to the end of the file
+ else{ FB[index] = line; } //replace the current setting with the new one
+ // - window focus
+ index = FB.indexOf( FB.filter("session.screen0.focusModel:").join("") );
+ line = "session.screen0.focusModel:\t"+ui->combo_session_wfocus->itemData( ui->combo_session_wfocus->currentIndex() ).toString();
+ if(index < 0){ FB << line; } //add line to the end of the file
+ else{ FB[index] = line; } //replace the current setting with the new one
+ // - window theme
+ index = FB.indexOf( FB.filter("session.styleFile:").join("") );
+ line = "session.styleFile:\t"+ui->combo_session_wtheme->itemData( ui->combo_session_wtheme->currentIndex() ).toString();
+ if(index < 0){ FB << line; } //add line to the end of the file
+ else{ FB[index] = line; } //replace the current setting with the new one
+ // - workspace number
+ index = FB.indexOf( FB.filter("session.screen0.workspaces:").join("") );
+ line = "session.screen0.workspaces:\t"+QString::number(ui->spin_session_wkspaces->value());
+ if(index < 0){ FB << line; } //add line to the end of the file
+ else{ FB[index] = line; } //replace the current setting with the new one
+
+ //Save the fluxbox settings
+ bool ok = overwriteFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init", FB);
+ if(!ok){ qDebug() << "Warning: Could not save fluxbox-init"; }
+ emit HasPendingChanges(false);
+}
+
+void page_fluxbox_settings::LoadSettings(int){
+ emit HasPendingChanges(false);
+ emit ChangePageTitle( tr("Window Manager Settings") );
+ loading = true;
+ ui->combo_session_wfocus->clear();
+ ui->combo_session_wfocus->addItem( tr("Click To Focus"), "ClickToFocus");
+ ui->combo_session_wfocus->addItem( tr("Active Mouse Focus"), "MouseFocus");
+ ui->combo_session_wfocus->addItem( tr("Strict Mouse Focus"), "StrictMouseFocus");
+
+ ui->combo_session_wloc->clear();
+ ui->combo_session_wloc->addItem( tr("Align in a Row"), "RowSmartPlacement");
+ ui->combo_session_wloc->addItem( tr("Align in a Column"), "ColSmartPlacement");
+ ui->combo_session_wloc->addItem( tr("Cascade"), "CascadePlacement");
+ ui->combo_session_wloc->addItem( tr("Underneath Mouse"), "UnderMousePlacement");
+
+ ui->combo_session_wtheme->clear();
+ QStringList dirs; dirs << LOS::AppPrefix()+"share/fluxbox/styles" << QDir::homePath()+"/.fluxbox/styles";
+ QFileInfoList fbstyles;
+ for(int i=0; i<dirs.length(); i++){
+ QDir fbdir(dirs[i]);
+ fbstyles << fbdir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
+ }
+ QString lastdir;
+ for(int i=0; i<fbstyles.length(); i++){
+ if(lastdir!=fbstyles[i].absolutePath()){
+ lastdir = fbstyles[i].absolutePath(); //save for checking later
+ if(ui->combo_session_wtheme->count()>0){ ui->combo_session_wtheme->insertSeparator(ui->combo_session_wtheme->count()); }
+ }
+ ui->combo_session_wtheme->addItem(fbstyles[i].fileName(), fbstyles[i].absoluteFilePath());
+ }
+
+ QStringList FB = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init");
+ QString val;
+ //Do the window placement
+ val = FB.filter("session.screen0.windowPlacement:").join("").section(":",1,1).simplified();
+ //qDebug() << "Window Placement:" << val;
+ int index = ui->combo_session_wloc->findData(val);
+ if(index<0){ index = 0;} //use the default
+ ui->combo_session_wloc->setCurrentIndex(index);
+
+ //Do the window focus
+ val = FB.filter("session.screen0.focusModel:").join("").section(":",1,1).simplified();
+ //qDebug() << "Window Focus:" << val;
+ index = ui->combo_session_wfocus->findData(val);
+ if(index<0){ index = 0;} //use the default
+ ui->combo_session_wfocus->setCurrentIndex(index);
+
+ //Do the window theme
+ val = FB.filter("session.styleFile:").join("").section(":",1,1).simplified();
+ //qDebug() << "Window Theme:" << val;
+ index = ui->combo_session_wtheme->findData(val);
+ if(index<0){ index = 0;} //use the default
+ ui->combo_session_wtheme->setCurrentIndex(index);
+
+ //Now the number of workspaces
+ val = FB.filter("session.screen0.workspaces:").join("").section(":",1,1).simplified();
+ //qDebug() << "Number of Workspaces:" << val;
+ if(!val.isEmpty()){ ui->spin_session_wkspaces->setValue(val.toInt()); }
+
+ QApplication::processEvents();
+ loading = false;
+}
+
+void page_fluxbox_settings::updateIcons(){
+
+}
+
+//=================
+// PRIVATE
+//=================
+//Read/overwrite a text file
+QStringList page_fluxbox_settings::readFile(QString path){
+ QStringList out;
+ QFile file(path);
+ if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
+ QTextStream txt(&file);
+ while(!txt.atEnd()){
+ out << txt.readLine();
+ }
+ file.close();
+ }
+ return out;
+}
+
+bool page_fluxbox_settings::overwriteFile(QString path, QStringList contents){
+ QFile file(path);
+ if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
+ QTextStream txt(&file);
+ for(int i=0; i<contents.length(); i++){
+ txt << contents[i]+"\n";
+ }
+ file.close();
+ return true;
+ }
+ return false;
+}
+
+//=================
+// PRIVATE SLOTS
+//=================
+void page_fluxbox_settings::sessionthemechanged(){
+ //Update the Fluxbox Theme preview
+ QString previewfile = ui->combo_session_wtheme->itemData( ui->combo_session_wtheme->currentIndex() ).toString();
+ previewfile.append( (previewfile.endsWith("/") ? "preview.jpg": "/preview.jpg") );
+ if(QFile::exists(previewfile)){
+ ui->label_session_wpreview->setPixmap(QPixmap(previewfile));
+ }else{
+ ui->label_session_wpreview->setText(tr("No Preview Available"));
+ }
+ settingChanged();
+}
diff --git a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h
new file mode 100644
index 00000000..b78b204b
--- /dev/null
+++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h
@@ -0,0 +1,43 @@
+//===========================================
+// Lumina Desktop Source Code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_CONFIG_PAGE_FLUXBOX_SETTINGS_H
+#define _LUMINA_CONFIG_PAGE_FLUXBOX_SETTINGS_H
+#include "../globals.h"
+#include "PageWidget.h"
+
+namespace Ui{
+ class page_fluxbox_settings;
+};
+
+class page_fluxbox_settings : public PageWidget{
+ Q_OBJECT
+public:
+ page_fluxbox_settings(QWidget *parent);
+ ~page_fluxbox_settings();
+
+public slots:
+ void SaveSettings();
+ void LoadSettings(int screennum);
+ void updateIcons();
+
+private:
+ Ui::page_fluxbox_settings *ui;
+ bool loading;
+
+ //Read/overwrite a text file
+ QStringList readFile(QString path);
+ bool overwriteFile(QString path, QStringList contents);
+
+private slots:
+ //Simplification function for widget connections
+ void settingChanged(){
+ if(!loading){ emit HasPendingChanges(true); }
+ }
+
+ void sessionthemechanged();
+};
+#endif
diff --git a/src-qt5/core-utils/lumina-config/pages/page_sample.cpp b/src-qt5/core-utils/lumina-config/pages/page_sample.cpp
index 5273b14b..32742873 100644
--- a/src-qt5/core-utils/lumina-config/pages/page_sample.cpp
+++ b/src-qt5/core-utils/lumina-config/pages/page_sample.cpp
@@ -25,6 +25,7 @@ page_sample::~page_sample(){
//================
void page_sample::SaveSettings(){
+ emit HasPendingChanged(false);
}
void page_sample::LoadSettings(int){
diff --git a/src-qt5/core-utils/lumina-config/pages/pages.pri b/src-qt5/core-utils/lumina-config/pages/pages.pri
index 4e433725..742063c8 100644
--- a/src-qt5/core-utils/lumina-config/pages/pages.pri
+++ b/src-qt5/core-utils/lumina-config/pages/pages.pri
@@ -6,8 +6,8 @@ HEADERS += $${PWD}/getPage.h \
$${PWD}/page_theme.h \
$${PWD}/page_autostart.h \
$${PWD}/page_defaultapps.h \
- $${PWD}/page_fluxbox_keys.h
-# $${PWD}/page_fluxbox_settings.h \
+ $${PWD}/page_fluxbox_keys.h \
+ $${PWD}/page_fluxbox_settings.h
# $${PWD}/page_interface_desktop.h \
# $${PWD}/page_interface_menu.h \
# $${PWD}/page_interface_panels.h \
@@ -20,8 +20,8 @@ SOURCES += $${PWD}/page_main.cpp \
$${PWD}/page_theme.cpp \
$${PWD}/page_autostart.cpp \
$${PWD}/page_defaultapps.cpp \
- $${PWD}/page_fluxbox_keys.cpp
-# $${PWD}/page_fluxbox_settings.cpp \
+ $${PWD}/page_fluxbox_keys.cpp \
+ $${PWD}/page_fluxbox_settings.cpp
# $${PWD}/page_interface_desktop.cpp \
# $${PWD}/page_interface_menu.cpp \
# $${PWD}/page_interface_panels.cpp \
@@ -34,10 +34,10 @@ FORMS += $${PWD}/page_main.ui \
$${PWD}/page_theme.ui \
$${PWD}/page_autostart.ui \
$${PWD}/page_defaultapps.ui \
- $${PWD}/page_fluxbox_keys.ui
-# $${PWD}/page_fluxbox_settings.ui \
-# $${PWD}/page_interface_desktop.ui \
-# $${PWD}/page_interface_menu.ui \
-# $${PWD}/page_interface_panels.ui \
-# $${PWD}/page_session_locale.ui \
-# $${PWD}/page_session_options.ui \
+ $${PWD}/page_fluxbox_keys.ui \
+ $${PWD}/page_fluxbox_settings.ui \
+ $${PWD}/page_interface_desktop.ui \
+ $${PWD}/page_interface_menu.ui \
+ $${PWD}/page_interface_panels.ui \
+ $${PWD}/page_session_locale.ui \
+ $${PWD}/page_session_options.ui
bgstack15