diff options
author | Ken Moore <moorekou@gmail.com> | 2016-06-27 23:09:43 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-06-27 23:09:43 -0400 |
commit | 43b41a4a7fa570408045f5d7de4207312d941ecd (patch) | |
tree | 3f9e2af039f964d4e0126fd37c5a3d4cacd49923 /src-qt5 | |
parent | Get the panel interface page all converted over to the new UI. (diff) | |
download | lumina-43b41a4a7fa570408045f5d7de4207312d941ecd.tar.gz lumina-43b41a4a7fa570408045f5d7de4207312d941ecd.tar.bz2 lumina-43b41a4a7fa570408045f5d7de4207312d941ecd.zip |
Get the new menu interface page converted over.
Diffstat (limited to 'src-qt5')
5 files changed, 213 insertions, 8 deletions
diff --git a/src-qt5/core-utils/lumina-config/pages/getPage.h b/src-qt5/core-utils/lumina-config/pages/getPage.h index ad0fea08..90358edf 100644 --- a/src-qt5/core-utils/lumina-config/pages/getPage.h +++ b/src-qt5/core-utils/lumina-config/pages/getPage.h @@ -48,7 +48,7 @@ static QList<PAGEINFO> KnownPages(){ #include "page_fluxbox_settings.h" #include "page_interface_desktop.h" #include "page_interface_panels.h" -//#include "page_interface_menu.h" +#include "page_interface_menu.h" static PageWidget* GetNewPage(QString id, QWidget *parent){ //Find the page that matches this "id" @@ -60,7 +60,7 @@ static PageWidget* GetNewPage(QString id, QWidget *parent){ else if(id=="fluxbox-settings"){ return new page_fluxbox_settings(parent); } else if(id=="interface-desktop"){ return new page_interface_desktop(parent); } else if(id=="interface-panel"){ return new page_interface_panels(parent); } -// else if(id=="interface-menu"){ return new page_interface_menu(parent); } + else if(id=="interface-menu"){ return new page_interface_menu(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_interface_menu.cpp b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp new file mode 100644 index 00000000..742c5728 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp @@ -0,0 +1,164 @@ +//=========================================== +// 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_interface_menu.h" +#include "ui_page_interface_menu.h" +#include "getPage.h" +#include "../AppDialog.h" +#include "../GetPluginDialog.h" + +//========== +// PUBLIC +//========== +page_interface_menu::page_interface_menu(QWidget *parent) : PageWidget(parent), ui(new Ui::page_interface_menu()){ + ui->setupUi(this); + PINFO = new LPlugins(); + connect(ui->tool_menu_add, SIGNAL(clicked()), this, SLOT(addmenuplugin()) ); + connect(ui->tool_menu_rm, SIGNAL(clicked()), this, SLOT(rmmenuplugin()) ); + connect(ui->tool_menu_up, SIGNAL(clicked()), this, SLOT(upmenuplugin()) ); + connect(ui->tool_menu_dn, SIGNAL(clicked()), this, SLOT(downmenuplugin()) ); + connect(ui->list_menu, SIGNAL(currentRowChanged(int)), this, SLOT(checkmenuicons()) ); + + updateIcons(); +} + +page_interface_menu::~page_interface_menu(){ + delete PINFO; +} + +//================ +// PUBLIC SLOTS +//================ +void page_interface_menu::SaveSettings(){ + QSettings settings("lumina-desktop","desktopsettings"); + QStringList items; + for(int i=0; i<ui->list_menu->count(); i++){ + items << ui->list_menu->item(i)->whatsThis(); + } + settings.setValue("menu/itemlist", items); + emit HasPendingChanges(false); +} + +void page_interface_menu::LoadSettings(int){ + emit HasPendingChanges(false); + emit ChangePageTitle( tr("Desktop Settings") ); + QSettings settings("lumina-desktop","desktopsettings"); + +QStringList items = settings.value("menu/itemlist", QStringList() ).toStringList(); + if(items.isEmpty()){ items << "terminal" << "filemanager" << "applications" << "line" << "settings"; } + //qDebug() << "Menu Items:" << items; + ui->list_menu->clear(); + for(int i=0; i<items.length(); i++){ + LPI info = PINFO->menuPluginInfo(items[i]); + if(items[i].startsWith("app::::")){ + bool ok = false; + XDGDesktop desk = LXDG::loadDesktopFile(items[i].section("::::",1,1), ok); + if(!ok){ continue; } //invalid application file (no longer installed?) + QListWidgetItem *item = new QListWidgetItem(); + item->setWhatsThis( items[i] ); + item->setIcon( LXDG::findIcon(desk.icon) ); + item->setText( desk.name ); + item->setToolTip( desk.comment ); + ui->list_menu->addItem(item); + continue; //now go to the next item + } + if(info.ID.isEmpty()){ continue; } //invalid plugin + //qDebug() << "Add Menu Item:" << info.ID; + QListWidgetItem *item = new QListWidgetItem(); + item->setWhatsThis( info.ID ); + item->setIcon( LXDG::findIcon(info.icon,"") ); + item->setText( info.name ); + item->setToolTip( info.description ); + ui->list_menu->addItem(item); + } + checkmenuicons(); //update buttons +} + +void page_interface_menu::updateIcons(){ + ui->tool_menu_add->setIcon( LXDG::findIcon("list-add","") ); + ui->tool_menu_rm->setIcon( LXDG::findIcon("list-remove","") ); + ui->tool_menu_up->setIcon( LXDG::findIcon("go-up","") ); + ui->tool_menu_dn->setIcon( LXDG::findIcon("go-down","") ); +} + +//================= +// PRIVATE +//================= +XDGDesktop page_interface_menu::getSysApp(bool allowreset){ + AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); + dlg.allowReset(allowreset); + dlg.exec(); + XDGDesktop desk; + if(dlg.appreset && allowreset){ + desk.filePath = "reset"; //special internal flag + }else{ + desk = dlg.appselected; + } + return desk; +} + +//================= +// PRIVATE SLOTS +//================= +void page_interface_menu::addmenuplugin(){ + GetPluginDialog dlg(this); + dlg.LoadPlugins("menu", PINFO); + dlg.exec(); + if(!dlg.selected){ return; } //cancelled + QString plug = dlg.plugID; + //Now add the item to the list + LPI info = PINFO->menuPluginInfo(plug); + QListWidgetItem *it; + if(info.ID=="app"){ + //Need to prompt for the exact application to add to the menu + // Note: whatsThis() format: "app::::< *.desktop file path >" + XDGDesktop desk = getSysApp(); + if(desk.filePath.isEmpty()){ return; }//nothing selected + //Create the item for the list + it = new QListWidgetItem(LXDG::findIcon(desk.icon,""), desk.name ); + it->setWhatsThis(info.ID+"::::"+desk.filePath); + it->setToolTip( desk.comment ); + }else{ + it = new QListWidgetItem( LXDG::findIcon(info.icon,""), info.name ); + it->setWhatsThis(info.ID); + it->setToolTip( info.description ); + } + ui->list_menu->addItem(it); + ui->list_menu->setCurrentRow(ui->list_menu->count()-1); //make sure it is auto-selected + settingChanged(); +} + +void page_interface_menu::rmmenuplugin(){ + if(ui->list_menu->currentRow() < 0){ return; } //no selection + delete ui->list_menu->takeItem( ui->list_menu->currentRow() ); + settingChanged(); +} + +void page_interface_menu::upmenuplugin(){ + int row = ui->list_menu->currentRow(); + if(row <= 0){ return; } + ui->list_menu->insertItem(row-1, ui->list_menu->takeItem(row)); + ui->list_menu->setCurrentRow(row-1); + + checkmenuicons(); + settingChanged(); +} + +void page_interface_menu::downmenuplugin(){ + int row = ui->list_menu->currentRow(); + if(row < 0 || row >= (ui->list_menu->count()-1) ){ return; } + ui->list_menu->insertItem(row+1, ui->list_menu->takeItem(row)); + ui->list_menu->setCurrentRow(row+1); + + checkmenuicons(); + settingChanged(); +} + +void page_interface_menu::checkmenuicons(){ + ui->tool_menu_up->setEnabled( ui->list_menu->currentRow() > 0 ); + ui->tool_menu_dn->setEnabled( ui->list_menu->currentRow() < (ui->list_menu->count()-1) ); + ui->tool_menu_rm->setEnabled( ui->list_menu->currentRow() >=0 ); +} diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h new file mode 100644 index 00000000..f2a53007 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h @@ -0,0 +1,41 @@ +//=========================================== +// 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_INTERFACE_MENU_H +#define _LUMINA_CONFIG_PAGE_INTERFACE_MENU_H +#include "../globals.h" +#include "PageWidget.h" +#include "../LPlugins.h" + +namespace Ui{ + class page_interface_menu; +}; + +class page_interface_menu : public PageWidget{ + Q_OBJECT +public: + page_interface_menu(QWidget *parent); + ~page_interface_menu(); + +public slots: + void SaveSettings(); + void LoadSettings(int screennum); + void updateIcons(); + +private: + Ui::page_interface_menu *ui; + LPlugins *PINFO; + //Get an application on the system + XDGDesktop getSysApp(bool allowreset = false); + +private slots: + void addmenuplugin(); + void rmmenuplugin(); + void upmenuplugin(); + void downmenuplugin(); + void checkmenuicons(); +}; +#endif diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.ui b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.ui index 1d230494..4579ef54 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.ui +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.ui @@ -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="QLabel" name="label_10"> diff --git a/src-qt5/core-utils/lumina-config/pages/pages.pri b/src-qt5/core-utils/lumina-config/pages/pages.pri index ebf6f892..ab97e07d 100644 --- a/src-qt5/core-utils/lumina-config/pages/pages.pri +++ b/src-qt5/core-utils/lumina-config/pages/pages.pri @@ -9,7 +9,7 @@ HEADERS += $${PWD}/getPage.h \ $${PWD}/page_fluxbox_keys.h \ $${PWD}/page_fluxbox_settings.h \ $${PWD}/page_interface_desktop.h \ -# $${PWD}/page_interface_menu.h \ + $${PWD}/page_interface_menu.h \ $${PWD}/page_interface_panels.h # $${PWD}/page_session_locale.h \ # $${PWD}/page_session_options.h \ @@ -23,7 +23,7 @@ SOURCES += $${PWD}/page_main.cpp \ $${PWD}/page_fluxbox_keys.cpp \ $${PWD}/page_fluxbox_settings.cpp \ $${PWD}/page_interface_desktop.cpp \ -# $${PWD}/page_interface_menu.cpp \ + $${PWD}/page_interface_menu.cpp \ $${PWD}/page_interface_panels.cpp # $${PWD}/page_session_locale.cpp \ # $${PWD}/page_session_options.cpp \ |