diff options
Diffstat (limited to 'src-qt5')
4 files changed, 318 insertions, 162 deletions
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 index ed382bb8..18bc09e6 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.cpp @@ -13,10 +13,15 @@ //========== page_fluxbox_keys::page_fluxbox_keys(QWidget *parent) : PageWidget(parent), ui(new Ui::page_fluxbox_keys()){ ui->setupUi(this); - + loading = false; + ui->radio_simple->setChecked(true); + ui->radio_advanced->setChecked(false); 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()) ); + connect(ui->text_file, SIGNAL(textChanged()), this, SLOT(settingChanged()) ); + connect(ui->radio_simple, SIGNAL(toggled(bool)), this, SLOT(switchEditor()) ); + connect(ui->group_keys, SIGNAL(toggled(bool)), this, SLOT(togglesyntaxgroup()) ); updateIcons(); } @@ -28,26 +33,33 @@ 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; + if(ui->radio_simple->isChecked()){ + //Basic Editor + 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 + 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]; } + //Now save the new contents + for(int i=0; i<current.length(); i++){ + if(!current[i].section(" :",0,0).isEmpty()){ info << current[i]; } + } + }else{ + //advanced editor + info = ui->text_file->toPlainText().split("\n"); } bool ok = overwriteFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-keys", info); if(!ok){ qDebug() << "Warning: Could not save fluxbox-keys"; } @@ -57,46 +69,54 @@ QStringList current; void page_fluxbox_keys::LoadSettings(int){ emit HasPendingChanges(false); emit ChangePageTitle( tr("Keyboard Shortcuts") ); - -ui->tree_shortcut->clear(); + loading = true; 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") \ + if(ui->radio_simple->isChecked()){ + ui->stackedWidget->setCurrentWidget(ui->page_simple); //ensure the proper page is visible + //First take care of the special Lumina options + ui->tree_shortcut->clear(); + 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) ); + 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); } - 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); + //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); + } + }else{ + //Advanced Editor + ui->stackedWidget->setCurrentWidget(ui->page_advanced); + ui->text_file->setPlainText( info.join("\n") ); } - + QApplication::processEvents(); + loading = false; } void page_fluxbox_keys::updateIcons(){ @@ -198,3 +218,11 @@ void page_fluxbox_keys::updateKeyConfig(){ ui->group_shortcut_modify->setEnabled(ui->tree_shortcut->currentItem()!=0); ui->keyEdit_shortcut->clear(); } + +void page_fluxbox_keys::switchEditor(){ + LoadSettings(-1); +} + +void page_fluxbox_keys::togglesyntaxgroup(){ + ui->plainTextEdit->setVisible(ui->group_keys->isChecked()); +} 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 index 7fc143ff..1b0d63d6 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h +++ b/src-qt5/core-utils/lumina-config/pages/page_fluxbox_keys.h @@ -24,8 +24,14 @@ public slots: void LoadSettings(int screennum); void updateIcons(); + //Simplification function for widget connections + virtual void settingChanged(){ + if(!loading){ emit HasPendingChanges(true); } + } + private: Ui::page_fluxbox_keys *ui; + bool loading; //Convert to/from fluxbox keyboard shortcuts QString dispToFluxKeys(QString); @@ -39,6 +45,7 @@ private slots: void clearKeyBinding(); void applyKeyBinding(); void updateKeyConfig(); - + void switchEditor(); + void togglesyntaxgroup(); }; #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 2ded896e..4c4d2aeb 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 @@ -27,121 +27,231 @@ <number>6</number> </property> <item> - <widget class="QTreeWidget" name="tree_shortcut"> - <property name="indentation"> - <number>0</number> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="itemsExpandable"> - <bool>false</bool> - </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> - <property name="expandsOnDoubleClick"> - <bool>false</bool> - </property> - <attribute name="headerDefaultSectionSize"> - <number>200</number> - </attribute> - <attribute name="headerHighlightSections"> - <bool>true</bool> - </attribute> - <attribute name="headerMinimumSectionSize"> - <number>200</number> - </attribute> - <attribute name="headerShowSortIndicator" stdset="0"> - <bool>true</bool> - </attribute> - <column> - <property name="text"> - <string>Action</string> - </property> - </column> - <column> - <property name="text"> - <string>Keyboard Shortcut</string> - </property> - </column> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QRadioButton" name="radio_simple"> + <property name="text"> + <string>Basic Editor</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="radio_advanced"> + <property name="text"> + <string>Advanced Editor</string> + </property> + </widget> + </item> + </layout> </item> <item> - <widget class="QGroupBox" name="group_shortcut_modify"> - <property name="title"> - <string>Modify Shortcut</string> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <layout class="QGridLayout" name="gridLayout_4"> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="topMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>3</number> - </property> - <property name="bottomMargin"> - <number>3</number> - </property> - <item row="0" column="3"> - <widget class="QKeySequenceEdit" name="keyEdit_shortcut"/> - </item> - <item row="0" column="0"> - <widget class="QToolButton" name="tool_shortcut_clear"> - <property name="text"> - <string>Clear Shortcut</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QToolButton" name="tool_shortcut_set"> - <property name="text"> - <string>Apply Change</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_32"> - <property name="text"> - <string>Change Key Binding:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_10"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> </widget> </item> <item> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Note: Current key bindings need to be cleared and saved before they can be re-used.</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>true</bool> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="currentIndex"> + <number>1</number> </property> + <widget class="QWidget" name="page_simple"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QTreeWidget" name="tree_shortcut"> + <property name="indentation"> + <number>0</number> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + <property name="expandsOnDoubleClick"> + <bool>false</bool> + </property> + <attribute name="headerDefaultSectionSize"> + <number>200</number> + </attribute> + <attribute name="headerHighlightSections"> + <bool>true</bool> + </attribute> + <attribute name="headerMinimumSectionSize"> + <number>200</number> + </attribute> + <attribute name="headerShowSortIndicator" stdset="0"> + <bool>true</bool> + </attribute> + <column> + <property name="text"> + <string>Action</string> + </property> + </column> + <column> + <property name="text"> + <string>Keyboard Shortcut</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="QGroupBox" name="group_shortcut_modify"> + <property name="title"> + <string>Modify Shortcut</string> + </property> + <layout class="QGridLayout" name="gridLayout_4"> + <property name="leftMargin"> + <number>3</number> + </property> + <property name="topMargin"> + <number>3</number> + </property> + <property name="rightMargin"> + <number>3</number> + </property> + <property name="bottomMargin"> + <number>3</number> + </property> + <item row="0" column="3"> + <widget class="QKeySequenceEdit" name="keyEdit_shortcut"/> + </item> + <item row="0" column="0"> + <widget class="QToolButton" name="tool_shortcut_clear"> + <property name="text"> + <string>Clear Shortcut</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QToolButton" name="tool_shortcut_set"> + <property name="text"> + <string>Apply Change</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_32"> + <property name="text"> + <string>Change Key Binding:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_10"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Note: Current key bindings need to be cleared and saved before they can be re-used.</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_advanced"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QPlainTextEdit" name="text_file"> + <property name="lineWrapMode"> + <enum>QPlainTextEdit::NoWrap</enum> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="group_keys"> + <property name="title"> + <string>View Syntax Codes</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <widget class="QPlainTextEdit" name="plainTextEdit"> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="plainText"> + <string>"Mod1": Alt key +"Mod4": Windows/Mac key +"Control": Ctrl key</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> 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 13d27cf9..0fc33dfb 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 @@ -48,6 +48,13 @@ </layout> </item> <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> <number>0</number> @@ -140,7 +147,7 @@ <x>0</x> <y>0</y> <width>362</width> - <height>78</height> + <height>69</height> </rect> </property> <property name="sizePolicy"> @@ -214,7 +221,11 @@ <number>0</number> </property> <item> - <widget class="QPlainTextEdit" name="text_file"/> + <widget class="QPlainTextEdit" name="text_file"> + <property name="lineWrapMode"> + <enum>QPlainTextEdit::NoWrap</enum> + </property> + </widget> </item> </layout> </widget> |