summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Koller <[email protected]>2017-01-29 15:44:24 +0100
committerMartin Koller <[email protected]>2017-01-29 15:44:24 +0100
commit1d05792ad782ce4cd41e31c1ab6eef3026b5218b (patch)
tree5d74e1d3d214ae8afcf939517d729cabc3051a10
parentfc7211ec3192ee29d651ab17fbc859269721d557 (diff)
Fix some bugs (mem leak, layout, preview not showing colors)
1) memory leak when opening SchemeEditorDialog (is never deleted) 2) The color preview widget can be reduced in height to nearly zero, which makes no sense 3) The scheme editor does not reflect any color change in the preview widget 4) triple-redundant widgets in the scmeditorcolors.ui file 5) user unfriendly current tab when opening the SchemeEditorDialog (I want to change a color, so the color tab shall be active) 6) Unneeded and incorrect tab index enum (enum values were not corresponding to the index the tab was inserted) 7) The SchemeEditorDialog did not just only expand the color table when enlarging the dialogs height BUG: 372309 BUG: 372407 REVIEW: 129902
-rw-r--r--kcms/colors/colorscm.cpp1
-rw-r--r--kcms/colors/colorsettings.ui6
-rw-r--r--kcms/colors/preview.ui36
-rw-r--r--kcms/colors/scmeditorcolors.cpp1
-rw-r--r--kcms/colors/scmeditorcolors.ui146
-rw-r--r--kcms/colors/scmeditordialog.cpp11
-rw-r--r--kcms/colors/scmeditordialog.h7
-rw-r--r--kcms/colors/scmeditordialog.ui12
8 files changed, 31 insertions, 189 deletions
diff --git a/kcms/colors/colorscm.cpp b/kcms/colors/colorscm.cpp
index de5b04d..105843c 100644
--- a/kcms/colors/colorscm.cpp
+++ b/kcms/colors/colorscm.cpp
@@ -428,6 +428,7 @@ void KColorCm::on_schemeEditButton_clicked()
return;
}
SchemeEditorDialog* dialog = new SchemeEditorDialog(path, this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose); // avoid mem-leak
dialog->setModal(true);
dialog->show();
connect(dialog, &SchemeEditorDialog::accepted, [=](){ this->populateSchemeList(); });
diff --git a/kcms/colors/colorsettings.ui b/kcms/colors/colorsettings.ui
index e81752b..bd7af54 100644
--- a/kcms/colors/colorsettings.ui
+++ b/kcms/colors/colorsettings.ui
@@ -101,12 +101,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>10</height>
- </size>
- </property>
</widget>
</item>
<item row="5" column="1">
diff --git a/kcms/colors/preview.ui b/kcms/colors/preview.ui
index 0eef1ca..72910e2 100644
--- a/kcms/colors/preview.ui
+++ b/kcms/colors/preview.ui
@@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>467</width>
- <height>106</height>
+ <height>116</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -43,22 +43,6 @@
</property>
</widget>
</item>
- <item row="2" column="1">
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="0" column="3">
<spacer>
<property name="orientation">
@@ -353,6 +337,22 @@
</layout>
</widget>
</item>
+ <item row="2" column="1">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<resources/>
diff --git a/kcms/colors/scmeditorcolors.cpp b/kcms/colors/scmeditorcolors.cpp
index a975aea..457602d 100644
--- a/kcms/colors/scmeditorcolors.cpp
+++ b/kcms/colors/scmeditorcolors.cpp
@@ -63,6 +63,7 @@ void SchemeEditorColors::updateValues()
{
const int currentSet = colorSet->currentIndex() - 1;
setPreview->setPalette(m_config, (KColorScheme::ColorSet)currentSet);
+ colorPreview->setPalette(m_config);
}
void SchemeEditorColors::setupColorTable()
diff --git a/kcms/colors/scmeditorcolors.ui b/kcms/colors/scmeditorcolors.ui
index 87a7244..923e783 100644
--- a/kcms/colors/scmeditorcolors.ui
+++ b/kcms/colors/scmeditorcolors.ui
@@ -423,148 +423,12 @@
</item>
<item row="0" column="0" colspan="2">
<widget class="QStackedWidget" name="stackPreview">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="pageCommonPreview">
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="PreviewWidget" name="colorPreview" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>10</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="pageSetPreview">
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="SetPreviewWidget" name="setPreview" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>10</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
- <widget class="QStackedWidget" name="stackPreview">
- <property name="currentIndex">
- <number>0</number>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <widget class="QWidget" name="pageCommonPreview">
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="PreviewWidget" name="colorPreview" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>10</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="pageSetPreview">
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="SetPreviewWidget" name="setPreview" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>10</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
- <widget class="QStackedWidget" name="stackPreview">
<property name="currentIndex">
<number>0</number>
</property>
diff --git a/kcms/colors/scmeditordialog.cpp b/kcms/colors/scmeditordialog.cpp
index 83ab53d..9c6da63 100644
--- a/kcms/colors/scmeditordialog.cpp
+++ b/kcms/colors/scmeditordialog.cpp
@@ -52,9 +52,10 @@ SchemeEditorDialog::SchemeEditorDialog(const QString &path, QWidget *parent)
m_colorTab = new SchemeEditorColors(m_config);
m_disabledTab = new SchemeEditorEffects(m_config, QPalette::Disabled);
m_inactiveTab = new SchemeEditorEffects(m_config, QPalette::Inactive);
- tabWidget->insertTab(OptionTab, m_optionTab, i18n("Options"));
- tabWidget->insertTab(ColorTab, m_colorTab, i18n("Colors"));
- tabWidget->insertTab(DisabledTab, m_disabledTab, i18n("Disabled"));
+ tabWidget->addTab(m_optionTab, i18n("Options"));
+ tabWidget->addTab(m_colorTab, i18n("Colors"));
+ tabWidget->addTab(m_disabledTab, i18n("Disabled"));
+ tabWidget->setCurrentWidget(m_colorTab);
connect(m_optionTab, &SchemeEditorOptions::changed, this, &SchemeEditorDialog::updateTabs);
connect(m_colorTab, &SchemeEditorColors::changed, this, &SchemeEditorDialog::updateTabs);
@@ -205,11 +206,11 @@ void SchemeEditorDialog::updateTabs(bool madeByUser)
bool hideInactiveTab = group.readEntry("Enable", QVariant(true)).toBool();
if ( hideInactiveTab )
{
- tabWidget->insertTab(InactiveTab, m_inactiveTab, i18n("Inactive"));
+ tabWidget->addTab(m_inactiveTab, i18n("Inactive"));
}
else
{
- tabWidget->removeTab(InactiveTab);
+ tabWidget->removeTab(tabWidget->indexOf(m_inactiveTab));
}
m_optionTab->updateValues();
diff --git a/kcms/colors/scmeditordialog.h b/kcms/colors/scmeditordialog.h
index a49052e..52b6433 100644
--- a/kcms/colors/scmeditordialog.h
+++ b/kcms/colors/scmeditordialog.h
@@ -53,13 +53,6 @@ private Q_SLOTS:
void updateTabs(bool byUser=false);
private:
-
- enum IndexTabs {
- OptionTab = 0,
- ColorTab,
- DisabledTab,
- InactiveTab
- };
/** save the current scheme */
void saveScheme();
void setUnsavedChanges(bool changes);
diff --git a/kcms/colors/scmeditordialog.ui b/kcms/colors/scmeditordialog.ui
index 91fca6d..5ecda7a 100644
--- a/kcms/colors/scmeditordialog.ui
+++ b/kcms/colors/scmeditordialog.ui
@@ -11,18 +11,6 @@
</rect>
</property>
<layout class="QVBoxLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">