From e630667a18729e9b4f37c83fbbc4afc2fdd562dd Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 27 Jun 2016 20:53:48 -0400 Subject: Get the new fluxbox-keys page all converted over to the new UI. --- src-qt5/core-utils/lumina-config/main.cpp | 4 +- src-qt5/core-utils/lumina-config/pages/getPage.h | 6 + .../lumina-config/pages/page_fluxbox_keys.cpp | 200 +++++++++++++++++++++ .../lumina-config/pages/page_fluxbox_keys.h | 44 +++++ .../lumina-config/pages/page_fluxbox_keys.ui | 12 +- .../lumina-config/pages/page_fluxbox_settings.ui | 16 +- src-qt5/core-utils/lumina-config/pages/pages.pri | 12 +- 7 files changed, 278 insertions(+), 16 deletions(-) create mode 100644 src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.cpp create mode 100644 src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h diff --git a/src-qt5/core-utils/lumina-config/main.cpp b/src-qt5/core-utils/lumina-config/main.cpp index a63e0fbe..20d517b2 100644 --- a/src-qt5/core-utils/lumina-config/main.cpp +++ b/src-qt5/core-utils/lumina-config/main.cpp @@ -19,8 +19,8 @@ int main(int argc, char ** argv) LuminaThemeEngine theme(&a); - MainUI w; - //mainWindow w; + //MainUI w; + mainWindow w; QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &w, SLOT(slotSingleInstance()) ); QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.show(); diff --git a/src-qt5/core-utils/lumina-config/pages/getPage.h b/src-qt5/core-utils/lumina-config/pages/getPage.h index 959cd4a2..5add9e78 100644 --- a/src-qt5/core-utils/lumina-config/pages/getPage.h +++ b/src-qt5/core-utils/lumina-config/pages/getPage.h @@ -30,6 +30,8 @@ static QList KnownPages(){ list << PageInfo("theme", QObject::tr("Change Desktop Theme"), QObject::tr("Theme Settings"), "preferences-desktop-theme",QObject::tr("Change interface fonts and colors"), "appearance", QStringList(), QStringList() << "background" << "interface" << "color" << "theme" << "plugins"); list << PageInfo("autostart", QObject::tr("Startup Services and Applications"), QObject::tr("Startup Settings"), "preferences-system-session-services",QObject::tr("Automatically start applications or services"), "session", QStringList(), QStringList() << "apps" << "autostart" << "services" << "xdg" << "startup" << "session"); list << PageInfo("defaultapps", QObject::tr("Default Applications for File Type"), QObject::tr("Mimetype Settings"), "preferences-desktop-filetype-association",QObject::tr("Change default applications"), "session", QStringList(), QStringList() << "apps" << "default" << "services" << "xdg" << "session"); + list << PageInfo("fluxbox-keys", QObject::tr("Keyboard Shortcuts"), QObject::tr("Keyboard Shortcuts"), "preferences-desktop-keyboard",QObject::tr("Change keyboard shortcuts"), "session", QStringList(), QStringList() << "apps" << "fluxbox" << "keys" << "keyboard" << "session" << "launch"); + list << PageInfo("fluxbox-settings", QObject::tr("Window Manager"), QObject::tr("Window Settings"), "preferences-system-windows",QObject::tr("Change window settings and appearances"), "appearance", QStringList(), QStringList() << "window" << "frame" << "border" << "workspace" << "theme" << "fluxbox" << "session"); return list; } @@ -39,6 +41,8 @@ static QList KnownPages(){ #include "page_theme.h" #include "page_autostart.h" #include "page_defaultapps.h" +#include "page_fluxbox_keys.h" +//#include "page_fluxbox_settings.h" static PageWidget* GetNewPage(QString id, QWidget *parent){ //Find the page that matches this "id" @@ -46,6 +50,8 @@ static PageWidget* GetNewPage(QString id, QWidget *parent){ else if(id=="theme"){ return new page_theme(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); } //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_keys.cpp b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.cpp new file mode 100644 index 00000000..ed382bb8 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.cpp @@ -0,0 +1,200 @@ +//=========================================== +// 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_keys.h" +#include "ui_page_fluxbox_keys.h" +#include "getPage.h" + +//========== +// PUBLIC +//========== +page_fluxbox_keys::page_fluxbox_keys(QWidget *parent) : PageWidget(parent), ui(new Ui::page_fluxbox_keys()){ + ui->setupUi(this); + + connect(ui->tool_shortcut_clear, SIGNAL(clicked()), this, SLOT(clearKeyBinding()) ); + connect(ui->tool_shortcut_set, SIGNAL(clicked()), this, SLOT(applyKeyBinding()) ); + connect(ui->tree_shortcut, SIGNAL(itemSelectionChanged()), this, SLOT(updateKeyConfig()) ); + updateIcons(); +} + +page_fluxbox_keys::~page_fluxbox_keys(){ + +} + +//================ +// PUBLIC SLOTS +//================ +void page_fluxbox_keys::SaveSettings(){ +QStringList current; + for(int i=0; itree_shortcut->topLevelItemCount(); i++){ + QTreeWidgetItem *it = ui->tree_shortcut->topLevelItem(i); + current << it->whatsThis(1)+" :"+it->whatsThis(0); //Full Fluxbox command line + } + + QStringList info = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-keys"); + for(int i=0; i 0){ + //Found Item to be replaced/removed + QString it = current.filter(info[i].section(":",1,10)).join("\n").section("\n",0,0); //ensure only the first match + if(it.section(" :",0,0).isEmpty()){ info.removeAt(i); i--; } //remove this entry + else{ info[i] = it; } //replace this entry + current.removeAll(it); //already taken care of - remove it from the current list + } + } + //Now save the new contents + for(int i=0; itree_shortcut->clear(); + QStringList info = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-keys"); + //First take care of the special Lumina options + QStringList special; + special << "Exec lumina-open -volumeup::::"+tr("Audio Volume Up") \ + << "Exec lumina-open -volumedown::::"+tr("Audio Volume Down") \ + << "Exec lumina-open -brightnessup::::"+tr("Screen Brightness Up") \ + << "Exec lumina-open -brightnessdown::::"+tr("Screen Brightness Down") \ + << "Exec lumina-screenshot::::"+tr("Take Screenshot") \ + << "Exec xscreensaver-command -lock::::"+tr("Lock Screen"); + for(int i=0; isetText(0, special[i].section("::::",1,1)); + it->setWhatsThis(0, special[i].section("::::",0,0)); + if(!spec.isEmpty()){ + info.removeAll(spec); //this line has been dealt with - remove it + it->setText(1, fluxToDispKeys(spec.section(":",0,0)) ); //need to make this easier to read later + it->setWhatsThis(1, spec.section(":",0,0) ); + } + ui->tree_shortcut->addTopLevelItem(it); + } + //Now add support for all the other fluxbox shortcuts + for(int i=0; isetText(0, showexec.simplified() ); + it->setWhatsThis(0, exec); + it->setText(1, fluxToDispKeys(info[i].section(":",0,0)) ); //need to make this easier to read later + it->setWhatsThis(1, info[i].section(":",0,0) ); + ui->tree_shortcut->addTopLevelItem(it); + } + +} + +void page_fluxbox_keys::updateIcons(){ + ui->tool_shortcut_set->setIcon( LXDG::findIcon("input-keyboard","") ); + ui->tool_shortcut_clear->setIcon( LXDG::findIcon("edit-clear","") ); +} + +//================= +// PRIVATE +//================= +//Convert to/from fluxbox key codes +QString page_fluxbox_keys::dispToFluxKeys(QString in){ + in.replace("Ctrl", "Control"); + in.replace("Shift", "Shift"); + in.replace("Alt", "Mod1"); + in.replace("Meta", "Mod4"); + in.replace("PgUp", "Prior"); + in.replace("PgDown", "Next"); + in.replace("Del", "Delete"); + in.replace("Backspace", "BackSpace"); + in.replace("Ins","Insert"); + in.replace("Volume Up", "XF86AudioRaiseVolume"); //multimedia key + in.replace("Volume Down", "XF86AudioLowerVolume"); //multimedia key + in.replace("+"," "); + return in; +} + +QString page_fluxbox_keys::fluxToDispKeys(QString in){ + in.replace("Control", "Ctrl"); + in.replace("Shift", "Shift"); + in.replace("Mod1", "Alt"); + in.replace("Mod4", "Meta"); + in.replace("Prior", "PgUp"); + in.replace("Next", "PgDown"); + //in.replace("Delete", "Del"); //the "Delete" is better looking + in.replace("BackSpace", "Backspace"); + //in.replace("Insert", "Ins"); //the "Insert" is better looking + in.replace("XF86AudioRaiseVolume", "Volume Up"); //multimedia key + in.replace("XF86AudioLowerVolume", "Volume Down"); //multimedia key + return in; +} + +//Read/overwrite a text file +QStringList page_fluxbox_keys::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_keys::overwriteFile(QString path, QStringList contents){ + QFile file(path); + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){ + QTextStream txt(&file); + for(int i=0; itree_shortcut->currentItem()==0){ return; } + ui->tree_shortcut->currentItem()->setText(1,""); + ui->tree_shortcut->currentItem()->setWhatsThis(1,""); + settingChanged(); +} + +void page_fluxbox_keys::applyKeyBinding(){ + QKeySequence seq = ui->keyEdit_shortcut->keySequence(); + qDebug() << "New Key Sequence:" << seq.toString(QKeySequence::NativeText) << seq.toString(QKeySequence::PortableText); + if(seq.isEmpty()){ + //Verify removal of the action first + + //Now remove the action + delete ui->tree_shortcut->currentItem(); + }else{ + QTreeWidgetItem *it = ui->tree_shortcut->currentItem(); + it->setText(1,seq.toString(QKeySequence::NativeText)); + it->setWhatsThis(1,dispToFluxKeys(seq.toString(QKeySequence::PortableText))); + qDebug() << " - Flux Sequence:" << it->whatsThis(1); + } + ui->keyEdit_shortcut->clear(); + settingChanged(); +} + +void page_fluxbox_keys::updateKeyConfig(){ + ui->group_shortcut_modify->setEnabled(ui->tree_shortcut->currentItem()!=0); + ui->keyEdit_shortcut->clear(); +} diff --git a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h new file mode 100644 index 00000000..7fc143ff --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h @@ -0,0 +1,44 @@ +//=========================================== +// 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_KEYS_H +#define _LUMINA_CONFIG_PAGE_FLUXBOX_KEYS_H +#include "../globals.h" +#include "PageWidget.h" + +namespace Ui{ + class page_fluxbox_keys; +}; + +class page_fluxbox_keys : public PageWidget{ + Q_OBJECT +public: + page_fluxbox_keys(QWidget *parent); + ~page_fluxbox_keys(); + +public slots: + void SaveSettings(); + void LoadSettings(int screennum); + void updateIcons(); + +private: + Ui::page_fluxbox_keys *ui; + + //Convert to/from fluxbox keyboard shortcuts + QString dispToFluxKeys(QString); + QString fluxToDispKeys(QString); + + //Read/overwrite a text file + QStringList readFile(QString path); + bool overwriteFile(QString path, QStringList contents); + +private slots: + void clearKeyBinding(); + void applyKeyBinding(); + void updateKeyConfig(); + +}; +#endif diff --git a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.ui b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.ui index 0c950672..2ded896e 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.ui +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.ui @@ -1,7 +1,7 @@ - Form - + page_fluxbox_keys + 0 @@ -15,16 +15,16 @@ - 0 + 6 - 0 + 6 - 0 + 6 - 0 + 6 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 e15f1dd9..677eac62 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 @@ -14,6 +14,18 @@ Form + + 6 + + + 6 + + + 6 + + + 6 + @@ -87,8 +99,8 @@ 0 0 - 356 - 109 + 362 + 115 diff --git a/src-qt5/core-utils/lumina-config/pages/pages.pri b/src-qt5/core-utils/lumina-config/pages/pages.pri index 7c0f6538..4e433725 100644 --- a/src-qt5/core-utils/lumina-config/pages/pages.pri +++ b/src-qt5/core-utils/lumina-config/pages/pages.pri @@ -5,8 +5,8 @@ HEADERS += $${PWD}/getPage.h \ $${PWD}/page_wallpaper.h \ $${PWD}/page_theme.h \ $${PWD}/page_autostart.h \ - $${PWD}/page_defaultapps.h -# $${PWD}/page_fluxbox_keys.h \ + $${PWD}/page_defaultapps.h \ + $${PWD}/page_fluxbox_keys.h # $${PWD}/page_fluxbox_settings.h \ # $${PWD}/page_interface_desktop.h \ # $${PWD}/page_interface_menu.h \ @@ -19,8 +19,8 @@ SOURCES += $${PWD}/page_main.cpp \ $${PWD}/page_wallpaper.cpp \ $${PWD}/page_theme.cpp \ $${PWD}/page_autostart.cpp \ - $${PWD}/page_defaultapps.cpp -# $${PWD}/page_fluxbox_keys.cpp \ + $${PWD}/page_defaultapps.cpp \ + $${PWD}/page_fluxbox_keys.cpp # $${PWD}/page_fluxbox_settings.cpp \ # $${PWD}/page_interface_desktop.cpp \ # $${PWD}/page_interface_menu.cpp \ @@ -33,8 +33,8 @@ FORMS += $${PWD}/page_main.ui \ $${PWD}/page_wallpaper.ui \ $${PWD}/page_theme.ui \ $${PWD}/page_autostart.ui \ - $${PWD}/page_defaultapps.ui -# $${PWD}/page_fluxbox_keys.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 \ -- cgit