diff options
Diffstat (limited to 'lumina-config')
-rw-r--r-- | lumina-config/PanelWidget.cpp | 199 | ||||
-rw-r--r-- | lumina-config/PanelWidget.h | 63 | ||||
-rw-r--r-- | lumina-config/PanelWidget.ui | 123 | ||||
-rw-r--r-- | lumina-config/lumina-config.pro | 9 | ||||
-rw-r--r-- | lumina-config/mainUI.cpp | 115 | ||||
-rw-r--r-- | lumina-config/mainUI.h | 24 | ||||
-rw-r--r-- | lumina-config/mainUI.ui | 550 |
7 files changed, 481 insertions, 602 deletions
diff --git a/lumina-config/PanelWidget.cpp b/lumina-config/PanelWidget.cpp new file mode 100644 index 00000000..e8398bae --- /dev/null +++ b/lumina-config/PanelWidget.cpp @@ -0,0 +1,199 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "PanelWidget.h" +#include "ui_PanelWidget.h" + +#include "LPlugins.h" +#include "GetPluginDialog.h" +#include "mainUI.h" +#include <LuminaXDG.h> + +#include <QSettings> +#include <QStringList> + + +PanelWidget::PanelWidget(QWidget *parent, QWidget *Main, LPlugins *Pinfo) : QWidget(parent), ui(new Ui::PanelWidget){ + ui->setupUi(this); + mainui = Main; + PINFO = Pinfo; + //Fill up the menu's with the valid entries + ui->combo_align->addItem(tr("Top/Left"), "left"); + ui->combo_align->addItem(tr("Center"), "center"); + ui->combo_align->addItem(tr("Bottom/Right"), "right"); + ui->combo_edge->addItem(tr("Top"), "top"); + ui->combo_edge->addItem(tr("Bottom"), "bottom"); + ui->combo_edge->addItem(tr("Left"), "left"); + ui->combo_edge->addItem(tr("Right"), "right"); + + LoadIcons(); + //Now connect any other signals/slots + connect(ui->combo_edge, SIGNAL(currentIndexChanged(int)), this, SLOT(ItemChanged()) ); + connect(ui->combo_align, SIGNAL(currentIndexChanged(int)), this, SLOT(ItemChanged()) ); + connect(ui->spin_plength, SIGNAL(valueChanged(int)), this, SLOT(ItemChanged()) ); + connect(ui->spin_pxthick, SIGNAL(valueChanged(int)), this, SLOT(ItemChanged()) ); + connect(ui->check_autohide, SIGNAL(stateChanged(int)), this, SLOT(ItemChanged()) ); + connect(ui->group_customcolor, SIGNAL(toggled(bool)), this, SLOT(ItemChanged()) ); + +} + +PanelWidget::~PanelWidget(){ + +} + +void PanelWidget::LoadSettings(QSettings *settings, int Dnum, int Pnum){ + pnum = Pnum; dnum = Dnum; //save these for later + ui->label->setText( QString(tr("Panel %1")).arg(QString::number(Pnum+1) ) ); + QString prefix = "panel"+QString::number(Dnum)+"."+QString::number(Pnum)+"/"; + qDebug() << "Loading Panel Settings:" << prefix; + //Now load the settings into the GUI + int tmp = ui->combo_align->findData( settings->value(prefix+"pinLocation","center").toString().toLower() ); + if(tmp>=0){ ui->combo_align->setCurrentIndex( tmp ); } + tmp = ui->combo_edge->findData( settings->value(prefix+"location","top").toString().toLower() ); + if(tmp>=0){ ui->combo_edge->setCurrentIndex( tmp ); } + ui->spin_plength->setValue( settings->value( prefix+"lengthPercent",100).toInt() ); + ui->spin_pxthick->setValue( settings->value( prefix+"height",30).toInt() ); + ui->check_autohide->setChecked( settings->value(prefix+"hidepanel", false).toBool() ); + ui->group_customcolor->setChecked( settings->value(prefix+"customcolor",false).toBool() ); + ui->label_color_sample->setWhatsThis( settings->value(prefix+"color","rgba(255,255,255,160)").toString()); + ui->list_plugins->clear(); + QStringList plugs = settings->value(prefix+"pluginlist",QStringList()).toStringList(); + for(int i=0; i<plugs.length(); i++){ + QString pid = plugs[i].section("---",0,0); + if(pid.startsWith("applauncher")){ + bool ok = false; + XDGDesktop desk = LXDG::loadDesktopFile(pid.section("::",1,1),ok); + if(ok){ + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(desk.icon,""), desk.name ); + it->setWhatsThis(plugs[i]); //make sure to preserve the entire plugin ID (is the unique version) + ui->list_plugins->addItem(it); + } + }else{ + LPI info = PINFO->panelPluginInfo(pid); + if(!info.ID.isEmpty()){ + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(info.icon,""), info.name ); + it->setWhatsThis(plugs[i]); //make sure to preserve the entire plugin ID (is the unique version) + ui->list_plugins->addItem(it); + } + } + } + reloadColorSample(); +} + +void PanelWidget::SaveSettings(QSettings *settings){//save the current settings + QString prefix = "panel"+QString::number(dnum)+"."+QString::number(pnum)+"/"; + qDebug() << "Saving panel settings:" << prefix; + settings->setValue(prefix+"location", ui->combo_edge->currentData().toString() ); + settings->setValue(prefix+"pinLocation", ui->combo_align->currentData().toString() ); + settings->setValue(prefix+"lengthPercent", ui->spin_plength->value() ); + settings->setValue(prefix+"height", ui->spin_pxthick->value() ); + settings->setValue(prefix+"hidepanel", ui->check_autohide->isChecked() ); + settings->setValue(prefix+"customColor", ui->group_customcolor->isChecked() ); + settings->setValue(prefix+"color", ui->label_color_sample->whatsThis() ); + QStringList plugs; + for(int i=0; i<ui->list_plugins->count(); i++){ + plugs << ui->list_plugins->item(i)->whatsThis(); + } + settings->setValue(prefix+"pluginlist", plugs ); + +} + +int PanelWidget::PanelNumber(){ + return pnum; +} + +void PanelWidget::ChangePanelNumber(int newnum){ + ui->label->setText( QString(tr("Panel %1")).arg(QString::number(newnum+1) ) ); + pnum = newnum; //So we can retain the current settings, but will save them with a different number +} + +void PanelWidget::LoadIcons(){ + ui->tool_rm->setIcon( LXDG::findIcon("list-remove","") ); + ui->tool_remplugin->setIcon( LXDG::findIcon("list-remove","") ); + ui->tool_addplugin->setIcon( LXDG::findIcon("list-add","") ); + ui->tool_upplugin->setIcon( LXDG::findIcon("go-up","") ); + ui->tool_downplugin->setIcon( LXDG::findIcon("go-down","") ); + ui->tool_selectcolor->setIcon( LXDG::findIcon("preferences-desktop-color","") ); + ui->toolBox->setItemIcon(0,LXDG::findIcon("transform-move","")); + ui->toolBox->setItemIcon(1,LXDG::findIcon("preferences-desktop-display","")); + ui->toolBox->setItemIcon(2,LXDG::findIcon("preferences-plugin","")); +} + +void PanelWidget::reloadColorSample(){ + ui->label_color_sample->setStyleSheet("background: "+ui->label_color_sample->whatsThis()); +} + +void PanelWidget::on_tool_rm_clicked(){ + emit PanelRemoved(pnum); +} + +void PanelWidget::ItemChanged(){ + emit PanelChanged(); +} + +void PanelWidget::UseColorChanged(){ + + emit PanelChanged(); +} + +void PanelWidget::on_tool_selectcolor_clicked(){ + QString color = static_cast<MainUI*>(mainui)->getColorStyle(ui->label_color_sample->whatsThis()); + if( color.isEmpty()){ return; } + ui->label_color_sample->setWhatsThis(color); + reloadColorSample(); + emit PanelChanged(); +} + +void PanelWidget::on_tool_addplugin_clicked(){ + GetPluginDialog dlg(mainui); + dlg.LoadPlugins("panel", PINFO); + dlg.exec(); + if(!dlg.selected){ return; } //cancelled + QString pan = dlg.plugID; //getNewPanelPlugin(); + if(pan == "applauncher"){ + //Prompt for the application to add + XDGDesktop app = static_cast<MainUI*>(mainui)->getSysApp(); + if(app.filePath.isEmpty()){ return; } //cancelled + pan.append("::"+app.filePath); + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(app.icon,""), app.name); + it->setWhatsThis(pan); + ui->list_plugins->addItem(it); + ui->list_plugins->setCurrentItem(it); + ui->list_plugins->scrollToItem(it); + }else{ + if(pan.isEmpty()){ return; } //nothing selected + //Add the new plugin to the list + LPI info = PINFO->panelPluginInfo(pan); + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(info.icon,""), info.name); + it->setWhatsThis(info.ID); + ui->list_plugins->addItem(it); + ui->list_plugins->setCurrentItem(it); + ui->list_plugins->scrollToItem(it); + } + emit PanelChanged(); +} + +void PanelWidget::on_tool_remplugin_clicked(){ + if(ui->list_plugins->currentRow() < 0){ return; } + delete ui->list_plugins->takeItem( ui->list_plugins->currentRow() ); + emit PanelChanged(); +} + +void PanelWidget::on_tool_upplugin_clicked(){ + int row = ui->list_plugins->currentRow(); + if( row <= 0){ return; } + ui->list_plugins->insertItem(row-1, ui->list_plugins->takeItem(row)); + ui->list_plugins->setCurrentRow(row-1); + emit PanelChanged(); +} + +void PanelWidget::on_tool_downplugin_clicked(){ + int row = ui->list_plugins->currentRow(); + if( row < 0 || row >= (ui->list_plugins->count()-1) ){ return; } + ui->list_plugins->insertItem(row+1, ui->list_plugins->takeItem(row)); + ui->list_plugins->setCurrentRow(row+1); + emit PanelChanged(); +} diff --git a/lumina-config/PanelWidget.h b/lumina-config/PanelWidget.h new file mode 100644 index 00000000..e407391e --- /dev/null +++ b/lumina-config/PanelWidget.h @@ -0,0 +1,63 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_CONFIG_PANEL_WIDGET_H +#define _LUMINA_CONFIG_PANEL_WIDGET_H + +#include <QWidget> +#include <QObject> +#include <QSettings> + +//#include "mainUI.h" +#include "LPlugins.h" + +//namespace for using the *.ui file +namespace Ui{ + class PanelWidget; +}; + +class PanelWidget : public QWidget{ + Q_OBJECT +public: + PanelWidget(QWidget *parent, QWidget *Main, LPlugins *Pinfo); + ~PanelWidget(); + + void LoadSettings(QSettings *settings, int Dnum, int Pnum); + void SaveSettings(QSettings *settings); //save the current settings + + int PanelNumber(); + void ChangePanelNumber(int newnum); + +public slots: + void LoadIcons(); + +private: + Ui::PanelWidget *ui; + QWidget *mainui; + LPlugins *PINFO; + + int dnum, pnum; + + void reloadColorSample(); + +private slots: + void on_tool_rm_clicked(); + void ItemChanged(); + void UseColorChanged(); + void on_tool_selectcolor_clicked(); + void on_tool_addplugin_clicked(); + void on_tool_remplugin_clicked(); + void on_tool_upplugin_clicked(); + void on_tool_downplugin_clicked(); + +signals: + void PanelChanged(); + void PanelRemoved(int); + +}; + +#endif + diff --git a/lumina-config/PanelWidget.ui b/lumina-config/PanelWidget.ui index a2452d17..9cf4ffdb 100644 --- a/lumina-config/PanelWidget.ui +++ b/lumina-config/PanelWidget.ui @@ -6,10 +6,28 @@ <rect> <x>0</x> <y>0</y> - <width>264</width> - <height>280</height> + <width>245</width> + <height>246</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>245</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>245</width> + <height>16777215</height> + </size> + </property> <property name="windowTitle"> <string>Form</string> </property> @@ -47,7 +65,7 @@ </font> </property> <property name="text"> - <string notr="true">TextLabel</string> + <string notr="true">Panel Number</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -58,6 +76,9 @@ </item> <item> <widget class="QToolBox" name="toolBox"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> <property name="currentIndex"> <number>0</number> </property> @@ -66,14 +87,29 @@ <rect> <x>0</x> <y>0</y> - <width>262</width> - <height>169</height> + <width>241</width> + <height>133</height> </rect> </property> <attribute name="label"> - <string>Geometry</string> + <string>Location</string> </attribute> <layout class="QFormLayout" name="formLayout"> + <property name="labelAlignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <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 row="0" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> @@ -82,7 +118,7 @@ </widget> </item> <item row="0" column="1"> - <widget class="QComboBox" name="comboBox"/> + <widget class="QComboBox" name="combo_edge"/> </item> <item row="2" column="0"> <widget class="QLabel" name="label_3"> @@ -92,23 +128,32 @@ </widget> </item> <item row="2" column="1"> - <widget class="QSpinBox" name="spinBox"> + <widget class="QSpinBox" name="spin_pxthick"> <property name="suffix"> - <string> pixels thick</string> + <string> pixel(s) thick</string> </property> <property name="minimum"> - <number>1</number> + <number>5</number> </property> <property name="maximum"> <number>30000</number> </property> + <property name="singleStep"> + <number>5</number> + </property> </widget> </item> <item row="3" column="1"> - <widget class="QSpinBox" name="spinBox_2"> + <widget class="QSpinBox" name="spin_plength"> <property name="suffix"> <string>% length</string> </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>100</number> + </property> </widget> </item> <item row="5" column="0"> @@ -132,15 +177,35 @@ </widget> </item> <item row="1" column="1"> - <widget class="QComboBox" name="comboBox_2"/> + <widget class="QComboBox" name="combo_align"/> </item> </layout> </widget> <widget class="QWidget" name="page_3"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>241</width> + <height>133</height> + </rect> + </property> <attribute name="label"> <string>Appearance</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout_2"> + <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="QCheckBox" name="check_autohide"> <property name="text"> @@ -209,30 +274,42 @@ <rect> <x>0</x> <y>0</y> - <width>262</width> - <height>169</height> + <width>241</width> + <height>133</height> </rect> </property> <attribute name="label"> <string>Plugins</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout_3"> + <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="QListWidget" name="listWidget"/> + <widget class="QListWidget" name="list_plugins"/> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> - <widget class="QToolButton" name="toolButton_2"> + <widget class="QToolButton" name="tool_remplugin"> <property name="text"> - <string>...</string> + <string notr="true">rem</string> </property> </widget> </item> <item> - <widget class="QToolButton" name="toolButton_4"> + <widget class="QToolButton" name="tool_addplugin"> <property name="text"> - <string>...</string> + <string notr="true">add</string> </property> </widget> </item> @@ -250,16 +327,16 @@ </spacer> </item> <item> - <widget class="QToolButton" name="toolButton_3"> + <widget class="QToolButton" name="tool_upplugin"> <property name="text"> - <string>...</string> + <string notr="true">up</string> </property> </widget> </item> <item> - <widget class="QToolButton" name="toolButton"> + <widget class="QToolButton" name="tool_downplugin"> <property name="text"> - <string>...</string> + <string notr="true">dn</string> </property> </widget> </item> diff --git a/lumina-config/lumina-config.pro b/lumina-config/lumina-config.pro index 472b2182..284cd0a4 100644 --- a/lumina-config/lumina-config.pro +++ b/lumina-config/lumina-config.pro @@ -19,7 +19,8 @@ SOURCES += main.cpp \ LPlugins.cpp \ ColorDialog.cpp \ ThemeDialog.cpp \ - GetPluginDialog.cpp + GetPluginDialog.cpp \ + PanelWidget.cpp HEADERS += mainUI.h \ LPlugins.h \ @@ -27,14 +28,16 @@ HEADERS += mainUI.h \ AppDialog.h \ ColorDialog.h \ ThemeDialog.h \ - GetPluginDialog.h + GetPluginDialog.h \ + PanelWidget.h FORMS += mainUI.ui \ KeyCatch.ui \ AppDialog.ui \ ColorDialog.ui \ ThemeDialog.ui \ - GetPluginDialog.ui + GetPluginDialog.ui \ + PanelWidget.ui # RESOURCES+= lumina-config.qrc diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp index dac7f4f0..2a98545a 100644 --- a/lumina-config/mainUI.cpp +++ b/lumina-config/mainUI.cpp @@ -88,7 +88,8 @@ void MainUI::setupIcons(){ ui->tabWidget_desktop->setTabIcon( ui->tabWidget_desktop->indexOf(ui->tab_themes), LXDG::findIcon("preferences-desktop-theme","") ); //Panels Page - ui->tool_panel1_add->setIcon( LXDG::findIcon("list-add","") ); + ui->tool_panels_add->setIcon( LXDG::findIcon("list-add","") ); + /*ui->tool_panel1_add->setIcon( LXDG::findIcon("list-add","") ); ui->tool_panel1_rm->setIcon( LXDG::findIcon("list-remove","") ); ui->tool_panel1_addplugin->setIcon( LXDG::findIcon("list-add","") ); ui->tool_panel1_rmplugin->setIcon( LXDG::findIcon("list-remove","") ); @@ -108,6 +109,7 @@ void MainUI::setupIcons(){ ui->toolBox_panel2->setItemIcon(1,LXDG::findIcon("preferences-plugin","")); ui->tabWidget_panels->setTabIcon( ui->tabWidget_panels->indexOf(ui->tab_panels), LXDG::findIcon("configure-toolbars","") ); ui->tabWidget_panels->setTabIcon( ui->tabWidget_panels->indexOf(ui->tab_desktopInterface), LXDG::findIcon("preferences-plugin","") ); + */ //Menu Page ui->tool_menu_add->setIcon( LXDG::findIcon("list-add","") ); @@ -164,7 +166,8 @@ void MainUI::setupConnections(){ connect(ui->check_desktop_autolaunchers, SIGNAL(clicked()), this, SLOT(desktimechanged()) ); //just need to poke the save routines //Panels Page - connect(ui->tool_panel1_add,SIGNAL(clicked()), this, SLOT(addpanel1()) ); + connect(ui->tool_panels_add, SIGNAL(clicked()), this, SLOT(newPanel()) ); + /*connect(ui->tool_panel1_add,SIGNAL(clicked()), this, SLOT(addpanel1()) ); connect(ui->tool_panel2_add,SIGNAL(clicked()), this, SLOT(addpanel2()) ); connect(ui->tool_panel1_rm,SIGNAL(clicked()), this, SLOT(rmpanel1()) ); connect(ui->tool_panel2_rm,SIGNAL(clicked()), this, SLOT(rmpanel2()) ); @@ -192,7 +195,7 @@ void MainUI::setupConnections(){ connect(ui->tool_panel2_rmplugin, SIGNAL(clicked()), this, SLOT(rmpanel2plugin()) ); connect(ui->tool_panel2_upplug, SIGNAL(clicked()), this, SLOT(uppanel2plugin()) ); connect(ui->tool_panel2_dnplug, SIGNAL(clicked()), this, SLOT(dnpanel2plugin()) ); - + */ //Menu Page connect(ui->tool_menu_add, SIGNAL(clicked()), this, SLOT(addmenuplugin()) ); connect(ui->tool_menu_rm, SIGNAL(clicked()), this, SLOT(rmmenuplugin()) ); @@ -261,7 +264,7 @@ void MainUI::setupMenus(){ */ //Panel locations - ui->combo_panel1_loc->clear(); + /*ui->combo_panel1_loc->clear(); ui->combo_panel2_loc->clear(); QStringList loc; loc << tr("Top") << tr("Bottom") << tr("Left") << tr("Right"); ui->combo_panel1_loc->addItems(loc); @@ -270,7 +273,7 @@ void MainUI::setupMenus(){ ui->combo_panel1_align->addItem(tr("Center"),"center"); ui->combo_panel2_align->addItem(tr("Center"),"center"); ui->combo_panel1_align->addItem(tr("Top/Left"),"left"); ui->combo_panel2_align->addItem(tr("Top/Left"),"left"); ui->combo_panel1_align->addItem(tr("Bottom/Right"),"right"); ui->combo_panel2_align->addItem(tr("Bottom/Right"),"right"); - + */ //Session window manager settings ui->combo_session_wfocus->clear(); @@ -469,7 +472,7 @@ void MainUI::slotChangePage(bool enabled){ //Hide the save button for particular pages //ui->push_save->setVisible(!ui->actionDefaults->isChecked() || moddesk || modpan || modmenu || modshort || moddef || modses); //hide on the default page if nothing waiting to be saved //Special functions for particular pages - if(ui->page_panels->isVisible()){ checkpanels(); } + //if(ui->page_panels->isVisible()){ checkpanels(); } } @@ -523,7 +526,8 @@ void MainUI::loadCurrentSettings(bool screenonly){ int panels = settings->value(DPrefix+"panels",-1).toInt(); if(panels==-1 && primary){ panels=1; } panelnumber = panels; - if(panels >= 1){ + loadPanels(); + /*if(panels >= 1){ //Load the panel 1 information QString PPrefix = "panel"+QString::number(cdesk)+".0/"; ui->toolBox_panel1->setVisible(true); @@ -631,6 +635,7 @@ void MainUI::loadCurrentSettings(bool screenonly){ ui->label_panel2_sample->setStyleSheet("background: rgba(255,255,255,160)"); } checkpanels(); //make sure buttons are updated + */ if(!screenonly){ @@ -705,8 +710,11 @@ void MainUI::saveCurrentSettings(bool screenonly){ } // Panels Page - if(modpan){ - settings->setValue(DPrefix+"panels", panelnumber); + if(modpan){ + settings->setValue(DPrefix+"panels", PANELS.length()); + savePanels(); + } + /*settings->setValue(DPrefix+"panels", panelnumber); if(panelnumber>=1){ QString PPrefix = "panel"+QString::number(currentDesktop())+".0/"; settings->setValue(PPrefix+"color", ui->label_panel1_sample->whatsThis()); @@ -754,7 +762,7 @@ void MainUI::saveCurrentSettings(bool screenonly){ QStringList keys = settings->allKeys().filter("panel"+QString::number(currentDesktop())+".1/"); for(int i=0; i<keys.length(); i++){ settings->remove(keys[i]); } } - } + }*/ // Menu Page if(modmenu && !screenonly){ @@ -923,7 +931,59 @@ void MainUI::panelValChanged(){ if(!loading){ ui->push_save->setEnabled(true); modpan = true; } } -void MainUI::addpanel1(){ +void MainUI::newPanel(){ + panelnumber++; + //Now create a new Panel widget with this number + PanelWidget *tmp = new PanelWidget(ui->scroll_panels->widget(), this, PINFO); + tmp->LoadSettings(settings, currentDesktop(), panelnumber-1); + 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); +} + +void MainUI::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(); +} + +void MainUI::loadPanels(){ + //First clean any current panels + for(int i=0; i<PANELS.length(); i++){ delete PANELS.takeAt(i); i--; } + //Now create new panels + int dnum = currentDesktop(); + if(ui->scroll_panels->widget()->layout()==0){ ui->scroll_panels->widget()->setLayout( new QHBoxLayout() ); } + for(int i=0; i<panelnumber; i++){ + PanelWidget *tmp = new PanelWidget(ui->scroll_panels->widget(), this, PINFO); + tmp->LoadSettings(settings, dnum, 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); + } +} + +void MainUI::savePanels(){ + for(int i=0; i<PANELS.length(); i++){ + PANELS[i]->SaveSettings(settings); + } +} + +/*void MainUI::addpanel1(){ ui->toolBox_panel1->setVisible(true); panelnumber = 1; checkpanels(); @@ -989,21 +1049,6 @@ void MainUI::adjustpanel1(){ panadjust = false; return; //} - /*int newindex=0; - switch(ui->combo_panel2_loc->currentIndex()){ - case 0: - newindex = 1; break; - case 1: - newindex = 0; break; - case 2: - newindex = 3; break; - case 3: - newindex = 2; break; - } - if(newindex != ui->combo_panel1_loc->currentIndex()){ - valchanged = true; - ui->combo_panel1_loc->setCurrentIndex(newindex); - }*/ //panadjust = false; //if(!loading && valchanged){ ui->push_save->setEnabled(true); modpan = true; } } @@ -1020,22 +1065,6 @@ void MainUI::adjustpanel2(){ panadjust = false; return; //} - - /*int newindex=0; - switch(ui->combo_panel1_loc->currentIndex()){ - case 0: - newindex = 1; break; - case 1: - newindex = 0; break; - case 2: - newindex = 3; break; - case 3: - newindex = 2; break; - } - if(newindex != ui->combo_panel2_loc->currentIndex()){ - valchanged = true; - ui->combo_panel2_loc->setCurrentIndex(newindex); - }*/ //panadjust = false; //if(!loading && valchanged){ ui->push_save->setEnabled(true); modpan = true; } } @@ -1161,7 +1190,7 @@ void MainUI::dnpanel2plugin(){ ui->list_panel2_plugins->insertItem(row+1, ui->list_panel2_plugins->takeItem(row)); ui->list_panel2_plugins->setCurrentRow(row+1); if(!loading){ ui->push_save->setEnabled(true); modpan = true; } -} +}*/ //============ diff --git a/lumina-config/mainUI.h b/lumina-config/mainUI.h index 47588a0c..04c6253c 100644 --- a/lumina-config/mainUI.h +++ b/lumina-config/mainUI.h @@ -36,6 +36,7 @@ #include "ColorDialog.h" #include "ThemeDialog.h" #include "GetPluginDialog.h" +#include "PanelWidget.h" //namespace for using the *.ui file namespace Ui{ @@ -48,6 +49,12 @@ public: MainUI(); ~MainUI(); + //Panels Page simplifications + QString getColorStyle(QString current, bool allowTransparency = true); + + //Get an application on the system + XDGDesktop getSysApp(bool allowreset = false); + private: Ui::MainUI *ui; //the *.ui file access QSettings *settings, *appsettings, *sessionsettings; @@ -61,6 +68,7 @@ private: bool loading, panadjust; bool moddesk, modpan, modmenu, modshort, moddef, modses; //page modified flags int panelnumber; + QList<PanelWidget*> PANELS; //General purpose functions (not connected to buttons) void setupMenus(); //called during initialization @@ -68,13 +76,6 @@ private: int currentDesktop(); //the number for the current desktop - //Panels Page simplifications - QString getColorStyle(QString current, bool allowTransparency = true); - //QString getNewPanelPlugin(); - - //Get an application on the system - XDGDesktop getSysApp(bool allowreset = false); - //Convert to/from fluxbox keyboard shortcuts QString dispToFluxKeys(QString); QString fluxToDispKeys(QString); @@ -110,7 +111,12 @@ private slots: //Panels Page void panelValChanged(); - void addpanel1(); + void newPanel(); + void removePanel(int); //connected to a signal from the panel widget + void loadPanels(); + void savePanels(); + + /*void addpanel1(); void addpanel2(); void rmpanel1(); void rmpanel2(); @@ -128,7 +134,7 @@ private slots: void uppanel1plugin(); void uppanel2plugin(); void dnpanel1plugin(); - void dnpanel2plugin(); + void dnpanel2plugin();*/ //Menu Page/Tab void addmenuplugin(); diff --git a/lumina-config/mainUI.ui b/lumina-config/mainUI.ui index 4be021d8..5625d0a8 100644 --- a/lumina-config/mainUI.ui +++ b/lumina-config/mainUI.ui @@ -381,7 +381,7 @@ <item> <widget class="QTabWidget" name="tabWidget_panels"> <property name="currentIndex"> - <number>0</number> + <number>1</number> </property> <widget class="QWidget" name="tab_desktopInterface"> <attribute name="title"> @@ -550,552 +550,54 @@ <attribute name="title"> <string>Panels</string> </attribute> - <layout class="QGridLayout" name="gridLayout_panels" rowstretch="0,1" columnstretch="0,0"> - <item row="0" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_9"> + <layout class="QGridLayout" name="gridLayout_panels" rowstretch="0" columnstretch="0,0"> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_5"> <item> - <widget class="QToolButton" name="tool_panel2_add"> + <widget class="QToolButton" name="tool_panels_add"> <property name="text"> <string notr="true">add</string> </property> </widget> </item> <item> - <widget class="QToolButton" name="tool_panel2_rm"> - <property name="text"> - <string notr="true">rem</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_panel2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Panel #2</string> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> </property> - </widget> + </spacer> </item> </layout> </item> - <item row="1" column="0"> - <widget class="QToolBox" name="toolBox_panel1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="midLineWidth"> - <number>2</number> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="page_panel1_appearance"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>249</width> - <height>215</height> - </rect> - </property> - <attribute name="label"> - <string>Geometry</string> - </attribute> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Location:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="combo_panel1_loc"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Custom Color:</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_panel1_sample"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="text"> - <string>Sample</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel1_getcolor"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="check_panel1_hidepanel"> - <property name="text"> - <string>Auto-hide Panel </string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QCheckBox" name="check_panel1_usetheme"> - <property name="text"> - <string>Follow Theme</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="1"> - <layout class="QVBoxLayout" name="verticalLayout_11"> - <item> - <widget class="QSpinBox" name="spin_panel1_size"> - <property name="suffix"> - <string> pixels thick</string> - </property> - <property name="maximum"> - <number>500</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spin_panel1_length"> - <property name="suffix"> - <string>% length</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Size:</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_30"> - <property name="text"> - <string>Alignment:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QComboBox" name="combo_panel1_align"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_panel1_plugins"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>197</width> - <height>117</height> - </rect> - </property> - <attribute name="label"> - <string>Plugins</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QListWidget" name="list_panel1_plugins"> - <property name="iconSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QToolButton" name="tool_panel1_addplugin"> - <property name="text"> - <string notr="true">add</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel1_rmplugin"> - <property name="text"> - <string notr="true">rem</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="tool_panel1_upplug"> - <property name="text"> - <string notr="true">up</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel1_dnplug"> - <property name="text"> - <string notr="true">dn</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - <item row="1" column="1"> - <widget class="QToolBox" name="toolBox_panel2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="lineWidth"> - <number>1</number> + <item row="0" column="1"> + <widget class="QScrollArea" name="scroll_panels"> + <property name="sizeAdjustPolicy"> + <enum>QAbstractScrollArea::AdjustToContents</enum> </property> - <property name="midLineWidth"> - <number>2</number> + <property name="widgetResizable"> + <bool>true</bool> </property> - <property name="currentIndex"> - <number>0</number> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </property> - <widget class="QWidget" name="page_panel2_appearance"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>249</width> - <height>209</height> - </rect> - </property> - <attribute name="label"> - <string>Geometry</string> - </attribute> - <layout class="QFormLayout" name="formLayout_2"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Location:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="combo_panel2_loc"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Custom Color:</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <item> - <widget class="QLabel" name="label_panel2_sample"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="text"> - <string>Sample</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel2_getcolor"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="3" column="1"> - <widget class="QCheckBox" name="check_panel2_hidepanel"> - <property name="text"> - <string>Auto-hide Panel </string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="check_panel2_usetheme"> - <property name="text"> - <string>Follow Theme</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QVBoxLayout" name="verticalLayout_20"> - <item> - <widget class="QSpinBox" name="spin_panel2_size"> - <property name="suffix"> - <string> pixels thick</string> - </property> - <property name="maximum"> - <number>500</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spin_panel2_length"> - <property name="suffix"> - <string>% length</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Size:</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_31"> - <property name="text"> - <string>Alignment:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="combo_panel2_align"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_panel2_plugins"> + <widget class="QWidget" name="scrollAreaWidgetContents_2"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>197</width> - <height>117</height> + <width>487</width> + <height>263</height> </rect> </property> - <attribute name="label"> - <string>Plugins</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_7"> - <item> - <widget class="QListWidget" name="list_panel2_plugins"> - <property name="iconSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <item> - <widget class="QToolButton" name="tool_panel2_addplugin"> - <property name="text"> - <string notr="true">add</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel2_rmplugin"> - <property name="text"> - <string notr="true">rem</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="tool_panel2_upplug"> - <property name="text"> - <string notr="true">up</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel2_dnplug"> - <property name="text"> - <string notr="true">dn</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> </widget> </widget> </item> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QToolButton" name="tool_panel1_add"> - <property name="text"> - <string notr="true">add</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_panel1_rm"> - <property name="text"> - <string notr="true">rem</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_panel1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Panel #1</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </item> </layout> </widget> </widget> @@ -1883,7 +1385,7 @@ <x>0</x> <y>0</y> <width>129</width> - <height>16</height> + <height>28</height> </rect> </property> <property name="sizePolicy"> |