diff options
author | Ken Moore <ken@ixsystems.com> | 2017-02-06 10:58:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-06 10:58:50 -0500 |
commit | d4d21d474829d6cf9aba1c761974b3419c9ba959 (patch) | |
tree | 49c79676a6081d36f1271c7b32f1bcffdfdf71b0 /src-qt5/core-utils/lumina-config | |
parent | Commit my work-in-progress on a new NativeWindowSystem class. (diff) | |
parent | * Initialize PanelWidget layout in the constructor. (diff) | |
download | lumina-d4d21d474829d6cf9aba1c761974b3419c9ba959.tar.gz lumina-d4d21d474829d6cf9aba1c761974b3419c9ba959.tar.bz2 lumina-d4d21d474829d6cf9aba1c761974b3419c9ba959.zip |
Merge pull request #369 from antab/issue-363
Fix for #363
Diffstat (limited to 'src-qt5/core-utils/lumina-config')
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp | 35 |
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; |