diff options
Diffstat (limited to 'src-qt5')
7 files changed, 278 insertions, 16 deletions
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<PAGEINFO> 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<PAGEINFO> 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; i<ui->tree_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<info.length(); i++){ + if(info[i].isEmpty() || info[i].startsWith("#") || info[i].startsWith("!")){ continue; } + if(current.filter(info[i].section(":",1,-1)).length() > 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; i<current.length(); i++){ + if(!current[i].section(" :",0,0).isEmpty()){ info << current[i]; } + } + bool ok = overwriteFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-keys", info); + if(!ok){ qDebug() << "Warning: Could not save fluxbox-keys"; } + emit HasPendingChanges(false); +} + +void page_fluxbox_keys::LoadSettings(int){ + emit HasPendingChanges(false); + emit ChangePageTitle( tr("Keyboard Shortcuts") ); + +ui->tree_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; i<special.length(); i++){ + QString spec = info.filter(":"+special[i].section("::::",0,0)).join("").simplified(); + QTreeWidgetItem *it = new QTreeWidgetItem(); + it->setText(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; i<info.length(); i++){ + //skip empty/invalid lines, as well as non-global shortcuts (OnMenu, OnWindow, etc..) + if(info[i].isEmpty() || info[i].startsWith("#") || info[i].startsWith("!") || info[i].startsWith("On")){ continue; } + QString exec = info[i].section(":",1,100); + QString showexec = exec; + if(showexec.startsWith("If {Matches")){ showexec = showexec.section("{",2,2).section("}",0,0); } + if(showexec.startsWith("Exec ")){ showexec.replace("Exec ","Run "); } + else{ showexec = showexec.section("(",0,0).section("{",0,0); } //built-in command - remove the extra commands on some of them + QTreeWidgetItem *it = new QTreeWidgetItem(); + it->setText(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; i<contents.length(); i++){ + txt << contents[i]+"\n"; + } + file.close(); + return true; + } + return false; +} + +//================= +// PRIVATE SLOTS +//================= +void page_fluxbox_keys::clearKeyBinding(){ + if(ui->tree_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 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> + <class>page_fluxbox_keys</class> + <widget class="QWidget" name="page_fluxbox_keys"> <property name="geometry"> <rect> <x>0</x> @@ -15,16 +15,16 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <property name="leftMargin"> - <number>0</number> + <number>6</number> </property> <property name="topMargin"> - <number>0</number> + <number>6</number> </property> <property name="rightMargin"> - <number>0</number> + <number>6</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>6</number> </property> <item> <widget class="QTreeWidget" name="tree_shortcut"> 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 @@ <string>Form</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="topMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>6</number> + </property> <item> <layout class="QFormLayout" name="formLayout_4"> <item row="0" column="0"> @@ -87,8 +99,8 @@ <rect> <x>0</x> <y>0</y> - <width>356</width> - <height>109</height> + <width>362</width> + <height>115</height> </rect> </property> <property name="sizePolicy"> 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 \ |