From e0772a5488241714a50f713a0081dbc14d03ec2e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 5 Jul 2016 08:19:27 -0400 Subject: Add a full fluxbox init file editor to lumina-config as an "advanced" editor mode. --- .../lumina-config/pages/page_fluxbox_settings.cpp | 169 +++++++------ .../lumina-config/pages/page_fluxbox_settings.h | 1 + .../lumina-config/pages/page_fluxbox_settings.ui | 271 +++++++++++++-------- 3 files changed, 262 insertions(+), 179 deletions(-) (limited to 'src-qt5') 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 index 8f075488..20dc4a22 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.cpp @@ -14,10 +14,14 @@ page_fluxbox_settings::page_fluxbox_settings(QWidget *parent) : PageWidget(parent), ui(new Ui::page_fluxbox_settings()){ ui->setupUi(this); loading= false; + ui->radio_simple->setChecked(true); + ui->radio_advanced->setChecked(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()) ); + connect(ui->text_file, SIGNAL(textChanged()), this, SLOT(settingChanged()) ); + connect(ui->radio_simple, SIGNAL(toggled(bool)), this, SLOT(switchEditor()) ); updateIcons(); } @@ -29,28 +33,33 @@ 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 - + QStringList FB; + if(ui->radio_simple->isChecked()){ + 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 + }else{ + //advanced editor + FB = ui->text_file->toPlainText().split("\n"); + } //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"; } @@ -61,61 +70,67 @@ 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; icombo_session_wtheme->count()>0){ ui->combo_session_wtheme->insertSeparator(ui->combo_session_wtheme->count()); } + if(ui->radio_simple->isChecked()){ + ui->stackedWidget->setCurrentWidget(ui->page_simple); //ensure the proper page is visible + 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; icombo_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()); } - 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()); } - + 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()); } + }else{ + //Advanced editor + ui->stackedWidget->setCurrentWidget(ui->page_advanced); //ensure the proper page is visible + ui->text_file->setPlainText( readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init").join("\n") ); + } QApplication::processEvents(); loading = false; } @@ -168,3 +183,7 @@ void page_fluxbox_settings::sessionthemechanged(){ } settingChanged(); } + +void page_fluxbox_settings::switchEditor(){ + LoadSettings(-1); +} 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 index b78b204b..46b923b4 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.h @@ -39,5 +39,6 @@ private slots: } void sessionthemechanged(); + void switchEditor(); }; #endif diff --git a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.ui b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.ui index 677eac62..13d27cf9 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.ui +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_settings.ui @@ -27,134 +27,197 @@ 6 - - - + + + - Number of Workspaces + Simple Editor - - - - - - 1 - - - 10 - - - - - - - New Window Placement - - - - - - - - - - Focus Policy + + true - - - - - + + - Window Theme + Advanced Editor - - - - - - - 0 - 0 - + + + 0 - - Window Theme Preview - - - - - - true - - - - - 0 - 0 - 362 - 115 - - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Number of Workspaces + + + + + + + 1 + + + 10 + + + + + + + New Window Placement + + + + + + + + + + Focus Policy + + + + + + + + + + Window Theme + + + + + + + + + + - + 0 0 - - - 1 - - - 1 - - - 1 - - - 1 - + + Window Theme Preview + + - - - - 0 - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Sunken - - - No Preview Available - - - false - - - Qt::AlignCenter + + + true + + + + 0 + 0 + 362 + 78 + + + + + 0 + 0 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 0 + 0 + + + + + + + QFrame::NoFrame + + + QFrame::Sunken + + + No Preview Available + + + false + + + Qt::AlignCenter + + + + + - - - + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + -- cgit