diff options
author | Ken Moore <moorekou@gmail.com> | 2016-06-28 06:54:09 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-06-28 06:54:09 -0400 |
commit | e44b85bd20abbd174523de548d5167a03d80b4d3 (patch) | |
tree | 3f2ceb07d2f397b6f8513d889d803abe6c30c23c /src-qt5/core-utils/lumina-config | |
parent | Re-enable the old UI - only 2 more pages left to convert before switching to ... (diff) | |
download | lumina-e44b85bd20abbd174523de548d5167a03d80b4d3.tar.gz lumina-e44b85bd20abbd174523de548d5167a03d80b4d3.tar.bz2 lumina-e44b85bd20abbd174523de548d5167a03d80b4d3.zip |
Oops - forgot to add the page_interface_panels files to git.
Diffstat (limited to 'src-qt5/core-utils/lumina-config')
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp | 143 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_interface_panels.h | 48 |
2 files changed, 191 insertions, 0 deletions
diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp new file mode 100644 index 00000000..9d940033 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp @@ -0,0 +1,143 @@ +//=========================================== +// 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_panels.h" +#include "ui_page_interface_panels.h" +#include "getPage.h" +#include "../GetPluginDialog.h" +#include "../AppDialog.h" + +//========== +// PUBLIC +//========== +page_interface_panels::page_interface_panels(QWidget *parent) : PageWidget(parent), ui(new Ui::page_interface_panels()){ + ui->setupUi(this); + loading = false; + PINFO = new LPlugins(); + settings = new QSettings("lumina-desktop","desktopsettings"); + connect(ui->tool_panels_add, SIGNAL(clicked()), this, SLOT(newPanel()) ); + updateIcons(); +} + +page_interface_panels::~page_interface_panels(){ + delete PINFO; +} + +//================ +// PUBLIC SLOTS +//================ +void page_interface_panels::SaveSettings(){ + QString DPrefix = "desktop-"+QString::number(cscreen)+"/"; + settings->setValue(DPrefix+"panels", PANELS.length()); + for(int i=0; i<PANELS.length(); i++){ + PANELS[i]->SaveSettings(settings); + } + //The plugin ID's will be changed to unique ID's by the desktop - reload in a moment + emit HasPendingChanges(false); + settings->sync(); //save to disk right now + QTimer::singleShot(1000, this, SLOT(LoadSettings()) ); +} + +void page_interface_panels::LoadSettings(int screennum){ + if(screennum>=0){ + cscreen = screennum; + } + loading = true; + emit HasPendingChanges(false); + emit ChangePageTitle( tr("Desktop Settings") ); + QString DPrefix = "desktop-"+QString::number(cscreen)+"/"; + int panelnumber = settings->value(DPrefix+"panels",-1).toInt(); + +//First clean any current panels + for(int i=0; i<PANELS.length(); i++){ delete PANELS.takeAt(i); i--; } + //Now create new panels + if(ui->scroll_panels->widget()->layout()==0){ + ui->scroll_panels->widget()->setLayout( new QHBoxLayout() ); + ui->scroll_panels->widget()->layout()->setContentsMargins(0,0,0,0); + } + ui->scroll_panels->widget()->layout()->setAlignment(Qt::AlignLeft); + //Clear anything left over in the layout + for(int i=0; i<ui->scroll_panels->widget()->layout()->count(); i++){ + delete ui->scroll_panels->widget()->layout()->takeAt(i); + } + for(int i=0; i<panelnumber; i++){ + PanelWidget *tmp = new PanelWidget(ui->scroll_panels->widget(), this, PINFO); + tmp->LoadSettings(settings, cscreen, i); + PANELS << tmp; + connect(tmp, SIGNAL(PanelChanged()), this, SLOT(panelValChanged()) ); + connect(tmp, SIGNAL(PanelRemoved(int)), this, SLOT(removePanel(int)) ); + ui->scroll_panels->widget()->layout()->addWidget(tmp); + } + static_cast<QHBoxLayout*>(ui->scroll_panels->widget()->layout())->addStretch(); + + QApplication::processEvents(); + loading = false; +} + +void page_interface_panels::updateIcons(){ + ui->tool_panels_add->setIcon( LXDG::findIcon("list-add","") ); +} + +//================= +// PRIVATE +//================= +/*XDGDesktop page_interface_panels::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_panels::panelValChanged(){ + ui->tool_panels_add->setEnabled(panelnumber < 12); + if(!loading){ settingChanged(); } +} + +void page_interface_panels::newPanel(){ + if(panelnumber<0){ panelnumber=0; } //just in case + panelnumber++; + //Now create a new Panel widget with this number + PanelWidget *tmp = new PanelWidget(ui->scroll_panels->widget(), this, PINFO); + tmp->LoadSettings(settings, cscreen, panelnumber-1); + PANELS << tmp; + connect(tmp, SIGNAL(PanelChanged()), this, SLOT(panelValChanged()) ); + connect(tmp, SIGNAL(PanelRemoved(int)), this, SLOT(removePanel(int)) ); + static_cast<QBoxLayout*>(ui->scroll_panels->widget()->layout())->insertWidget(PANELS.length()-1, tmp); + //update the widget first (2 necessary for scroll below to work) + ui->scroll_panels->update(); + QApplication::processEvents(); + QApplication::processEvents(); + ui->scroll_panels->ensureWidgetVisible(tmp); + panelValChanged(); +} + +void page_interface_panels::removePanel(int pan){ + //connected to a signal from the panel widget + bool changed = false; + for(int i=0; i<PANELS.length(); i++){ + int num = PANELS[i]->PanelNumber(); + if(num==pan){ + delete PANELS.takeAt(i); + i--; + changed = true; + }else if(num > pan){ + PANELS[i]->ChangePanelNumber(num-1); + changed = true; + } + } + if(!changed){ return; } //nothing done + panelnumber--; + panelValChanged(); +} diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h new file mode 100644 index 00000000..308bbd9a --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h @@ -0,0 +1,48 @@ +//=========================================== +// 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_PANELS_H +#define _LUMINA_CONFIG_PAGE_INTERFACE_PANELS_H +#include "../globals.h" +#include "PageWidget.h" +#include "../LPlugins.h" +#include "../PanelWidget.h" + +namespace Ui{ + class page_interface_panels; +}; + +class page_interface_panels : public PageWidget{ + Q_OBJECT +public: + page_interface_panels(QWidget *parent); + ~page_interface_panels(); + + bool needsScreenSelector(){ return true; } + +public slots: + void SaveSettings(); + void LoadSettings(int screennum = -1); + void updateIcons(); + +private: + Ui::page_interface_panels *ui; + bool loading; + int cscreen; //current monitor/screen number + int panelnumber; //current number of panels + QSettings *settings; + LPlugins *PINFO; + QList<PanelWidget*> PANELS; + + //Get an application on the system + //XDGDesktop getSysApp(bool allowreset = false); + +private slots: + void panelValChanged(); + void newPanel(); + void removePanel(int); //connected to a signal from the panel widget +}; +#endif |