aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnar Mar Sig <antab@antab.is>2017-02-03 00:10:34 +0000
committerArnar Mar Sig <antab@antab.is>2017-02-03 00:10:34 +0000
commitf4b89e8c1331efb29c65808cf7f5e273108ef3fa (patch)
tree42dfe96f207c3e5d26692687bec5da3d24175f86
parentAdd missing call to this->setText(). (diff)
downloadlumina-f4b89e8c1331efb29c65808cf7f5e273108ef3fa.tar.gz
lumina-f4b89e8c1331efb29c65808cf7f5e273108ef3fa.tar.bz2
lumina-f4b89e8c1331efb29c65808cf7f5e273108ef3fa.zip
* Initialize PanelWidget layout in the constructor.
* Instead of removing all PanelWidgets in LoadSettings, remove any extra panels and add more if needed.
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp35
1 files changed, 22 insertions, 13 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
index 827061af..3c355aa7 100644
--- a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp
+++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp
@@ -21,6 +21,13 @@ page_interface_panels::page_interface_panels(QWidget *parent) : PageWidget(paren
connect(ui->tool_panels_add, SIGNAL(clicked()), this, SLOT(newPanel()) );
updateIcons();
setupProfiles();
+
+ //Create panels container
+ QHBoxLayout *panels_layout = new QHBoxLayout();
+ panels_layout->setContentsMargins(0,0,0,0);
+ panels_layout->setAlignment(Qt::AlignLeft);
+ panels_layout->addStretch();
+ ui->scroll_panels->widget()->setLayout(panels_layout);
}
page_interface_panels::~page_interface_panels(){
@@ -53,28 +60,30 @@ void page_interface_panels::LoadSettings(int screennum){
QString screenID = QApplication::screens().at(cscreen)->name();
QString DPrefix = "desktop-"+screenID+"/";
int panelnumber = settings->value(DPrefix+"panels",-1).toInt();
+ QBoxLayout *panels_layout = static_cast<QHBoxLayout*>(ui->scroll_panels->widget()->layout());
-//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);
+ //Remove extra panels (if any)
+ for(int i=panelnumber; i<PANELS.length(); i++){
+ PanelWidget *tmp = PANELS.takeAt(i);
+ delete tmp;
+ i--;
}
- 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);
+
+ int current_count = panels_layout->count()-1;
+
+ //Update current panels
+ for(int i=0; i<current_count; i++) {
+ PANELS[i]->LoadSettings(settings, cscreen, i);
}
- for(int i=0; i<panelnumber; i++){
+ //Create new panels
+ for(int i=current_count; 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);
+ panels_layout->insertWidget(panels_layout->count()-1, tmp);
}
- static_cast<QHBoxLayout*>(ui->scroll_panels->widget()->layout())->addStretch();
QApplication::processEvents();
loading = false;
bgstack15