[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Pager Configuration Dialog
From:       "Ignat Semenov" <ragnarokk91 () gmail ! com>
Date:       2010-05-23 10:22:26
Message-ID: op.vc5lrobxybqwlo () localhost ! localdomain
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi all,

I'm currently trying to improve the Pager Configuration Dialog. Actually,  
it's not the only one that should be improved IMHO, but well, that's a  
different story, now I'm fighting the Pager plasmoid. So far so good. I've  
decided to do this :

- Change radiobuttons to comboboxes, as any other config dialog in KDE  
uses that if there are three o more options available, and I remember some  
article about that on the Planet.

- Lay the buttons out nicely

- Use a QFormLayout (do it right TM)

- Center the button, one more layout

-  Use a top-level layout : as the dialog is resizable, if the user resize  
it, it's not going to look so nice, so a layout is needed.

But there is a problem. It uses KConfigDialog, and passes a widget that is  
created from the .ui file. It appears that setupUi() doesn't honor any  
top-level layouts, so to create one, you must do it by hand! In code, I  
mean. Finally, I get this when I try to build the configuration dialog  
with the new .ui file:

http://imagebin.ca/view/Fh1QOPS.html

The .ui file is attached, as well as a patch for the source files  
(radiobuttons -> comboboxes) and the .ui file (in case you prefer a patch).

Now the question is this:

1) What's that bad clipping

2) What should I do about the top-level layout (kinda the same question)

In the meantime I'm going to fight the other ones.



Looking forward to your answer

Regards,

Ignat
[Attachment #5 (multipart/related)]

[Attachment #7 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD></HEAD>
<BODY style="font-family:'DejaVu Sans Mono'; font-size:12px"><P>Hi all,</P><P>I'm \
currently trying to improve the Pager Configuration Dialog. Actually, it's not the \
only one that should be improved IMHO, but well, that's a different story, now I'm \
fighting the Pager plasmoid. So far so good. I've decided to do this :</P><P>- Change \
radiobuttons to comboboxes, as any other config dialog in KDE uses that if there are \
three o more options available, and I remember some article about that on the \
Planet.</P><P>- Lay the buttons out nicely</P><P>- Use a QFormLayout (do it right \
TM)</P><P>- Center the button, one more layout</P><P>-   Use a top-level layout : as \
the dialog is resizable, if the user resize it, it's not going to look so nice, so a \
layout is needed.</P><P>But there is a problem. It uses KConfigDialog, and passes a \
widget that is created from the .ui file. It appears that setupUi() doesn't honor any \
top-level layouts, so to create one, you must do it by hand! In code, I mean. \
Finally, I get this when I try to build the configuration dialog with the new .ui \
file:</P><P>http://imagebin.ca/view/Fh1QOPS.html</P><P>The .ui file is attached, as \
well as a patch for the source files (radiobuttons -&gt; comboboxes) and the .ui file \
(in case you prefer a patch).</P><P>Now the question is this:</P><P>1) What's that \
bad clipping</P><P>2) What should I do about the top-level layout (kinda the same \
question)</P><P>In the meantime I'm going to fight the other \
ones.</P><P><BR></P><P>Looking forward to your \
answer</P><P>Regards,</P><P>Ignat</P></BODY></HTML>


["pagerConfig.ui" (pagerConfig.ui)]

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>pagerConfig</class>
 <widget class="QWidget" name="pagerConfig">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>342</width>
    <height>276</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Configure Pager</string>
  </property>
  <widget class="QWidget" name="">
   <property name="geometry">
    <rect>
     <x>1</x>
     <y>0</y>
     <width>341</width>
     <height>276</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
       </size>
      </property>
     </spacer>
    </item>
    <item>
     <layout class="QFormLayout" name="formLayout">
      <property name="formAlignment">
       <set>Qt::AlignHCenter|Qt::AlignTop</set>
      </property>
      <item row="0" column="0">
       <widget class="QLabel" name="displayLabel">
        <property name="text">
         <string>Display text:</string>
        </property>
        <property name="alignment">
         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
        </property>
       </widget>
      </item>
      <item row="0" column="1">
       <widget class="QComboBox" name="displayTextComboBox">
        <item>
         <property name="text">
          <string>Desktop name</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>Desktop number</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>No text</string>
         </property>
        </item>
       </widget>
      </item>
      <item row="1" column="0">
       <widget class="QLabel" name="label">
        <property name="text">
         <string>Display icons:</string>
        </property>
        <property name="alignment">
         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
        </property>
        <property name="buddy">
         <cstring>showWindowIconsCheckBox</cstring>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
       <widget class="QCheckBox" name="showWindowIconsCheckBox">
        <property name="text">
         <string/>
        </property>
       </widget>
      </item>
      <item row="2" column="0">
       <widget class="QLabel" name="currentLabel">
        <property name="text">
         <string>Selecting current desktop:</string>
        </property>
        <property name="alignment">
         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
        </property>
       </widget>
      </item>
      <item row="2" column="1">
       <widget class="QComboBox" name="selectDesktopComboBox">
        <item>
         <property name="text">
          <string>Does nothing</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>Shows desktop</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>Shows the dashboard</string>
         </property>
        </item>
       </widget>
      </item>
      <item row="3" column="0">
       <widget class="QLabel" name="labelRows">
        <property name="text">
         <string>Number of rows:</string>
        </property>
        <property name="alignment">
         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
        </property>
       </widget>
      </item>
      <item row="3" column="1">
       <widget class="KIntSpinBox" name="spinRows"/>
      </item>
     </layout>
    </item>
    <item>
     <spacer name="verticalSpacer_2">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
       </size>
      </property>
     </spacer>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <spacer name="horizontalSpacer">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
       <widget class="QPushButton" name="configureDesktopsButton">
        <property name="text">
         <string>Configure Desktops...</string>
        </property>
       </widget>
      </item>
      <item>
       <spacer name="horizontalSpacer_2">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
     </layout>
    </item>
    <item>
     <spacer name="verticalSpacer_3">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
       </size>
      </property>
     </spacer>
    </item>
   </layout>
  </widget>
 </widget>
 <customwidgets>
  <customwidget>
   <class>KIntSpinBox</class>
   <extends>QSpinBox</extends>
   <header>knuminput.h</header>
  </customwidget>
 </customwidgets>
 <tabstops>
  <tabstop>configureDesktopsButton</tabstop>
 </tabstops>
 <resources/>
 <connections/>
</ui>

["new.patch" (new.patch)]

Index: pager.h
===================================================================
--- pager.h	(revision 1129541)
+++ pager.h	(working copy)
@@ -123,8 +123,9 @@
         Ui::pagerConfig ui;
         enum DisplayedText
         {
+
+            Name,
             Number,
-            Name,
             None
         };
 
Index: pager.cpp
===================================================================
--- pager.cpp	(revision 1129541)
+++ pager.cpp	(working copy)
@@ -291,20 +291,8 @@
     connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
     connect(ui.configureDesktopsButton, SIGNAL(clicked()), SLOT(slotConfigureDesktop()));
 
-    switch (m_displayedText){
-        case Number:
-            ui. desktopNumberRadioButton->setChecked(true);
-            break;
+    ui.displayTextComboBox->setCurrentIndex((int)m_displayedText);
 
-        case Name:
-            ui.desktopNameRadioButton->setChecked(true);
-            break;
-
-        case None:
-            ui.displayNoneRadioButton->setChecked(true);
-            break;
-    }
-
     ui.showWindowIconsCheckBox->setChecked(m_showWindowIcons);
     if (formFactor() == Plasma::Vertical) {
         ui.labelRows->setText(i18n("Number of columns:"));
@@ -314,19 +302,8 @@
     }
     ui.spinRows->setMaximum(m_desktopCount);
 
-    switch (m_currentDesktopSelected){
-        case DoNothing:
-            ui.doNothingRadioButton->setChecked(true);
-            break;
+    ui.selectDesktopComboBox->setCurrentIndex((int)m_currentDesktopSelected);
 
-        case ShowDesktop:
-            ui.showDesktopRadioButton->setChecked(true);
-            break;
-
-        case ShowDashboard:
-            ui.showDashboardRadioButton->setChecked(true);
-            break;
-    }
 }
 
 void Pager::recalculateGeometry()
@@ -556,15 +533,8 @@
 
     DisplayedText displayedText;
 
-    if (ui.desktopNumberRadioButton->isChecked()) {
-        displayedText = Number;
+    displayedText = (DisplayedText)ui.displayTextComboBox->currentIndex();
 
-    } else if (ui.desktopNameRadioButton->isChecked()) {
-        displayedText = Name;
-    } else {
-        displayedText = None;
-    }
-
     if ((int)m_displayedText != (int)displayedText) {
         m_displayedText = displayedText;
         cg.writeEntry("displayedText", (int)m_displayedText);
@@ -579,13 +549,7 @@
 
     CurrentDesktopSelected currentDesktopSelected;
 
-    if (ui.doNothingRadioButton->isChecked()) {
-        currentDesktopSelected = DoNothing;
-    } else if (ui.showDesktopRadioButton->isChecked()) {
-        currentDesktopSelected = ShowDesktop;
-    } else {
-        currentDesktopSelected = ShowDashboard;
-    }
+    currentDesktopSelected = (CurrentDesktopSelected)ui.selectDesktopComboBox->currentIndex();
 
     if ((int)m_currentDesktopSelected != (int)currentDesktopSelected) {
         m_currentDesktopSelected = currentDesktopSelected;
Index: pagerConfig.ui
===================================================================
--- pagerConfig.ui	(revision 1129541)
+++ pagerConfig.ui	(working copy)
@@ -13,28 +13,34 @@
   <property name="windowTitle">
    <string>Configure Pager</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2">
-   <property name="margin">
-    <number>0</number>
+  <widget class="QWidget" name="">
+   <property name="geometry">
+    <rect>
+     <x>1</x>
+     <y>0</y>
+     <width>341</width>
+     <height>276</height>
+    </rect>
    </property>
-   <property name="spacing">
-    <number>0</number>
-   </property>
-   <item row="0" column="0">
-    <widget class="QGroupBox" name="appearenceGroupBox">
-     <property name="title">
-      <string/>
-     </property>
-     <property name="flat">
-      <bool>true</bool>
-     </property>
-     <property name="checkable">
-      <bool>false</bool>
-     </property>
-     <layout class="QGridLayout" name="gridLayout">
-      <property name="margin">
-       <number>0</number>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
       </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>40</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <layout class="QFormLayout" name="formLayout">
+      <property name="formAlignment">
+       <set>Qt::AlignHCenter|Qt::AlignTop</set>
+      </property>
       <item row="0" column="0">
        <widget class="QLabel" name="displayLabel">
         <property name="text">
@@ -45,37 +51,26 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1" colspan="2">
-       <widget class="QRadioButton" name="desktopNumberRadioButton">
-        <property name="text">
-         <string>Desktop number</string>
-        </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupText</string>
-        </attribute>
+      <item row="0" column="1">
+       <widget class="QComboBox" name="displayTextComboBox">
+        <item>
+         <property name="text">
+          <string>Desktop name</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Desktop number</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>No text</string>
+         </property>
+        </item>
        </widget>
       </item>
-      <item row="1" column="1" colspan="2">
-       <widget class="QRadioButton" name="desktopNameRadioButton">
-        <property name="text">
-         <string>Desktop name</string>
-        </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupText</string>
-        </attribute>
-       </widget>
-      </item>
-      <item row="2" column="1" colspan="2">
-       <widget class="QRadioButton" name="displayNoneRadioButton">
-        <property name="text">
-         <string>No text</string>
-        </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupText</string>
-        </attribute>
-       </widget>
-      </item>
-      <item row="3" column="0">
+      <item row="1" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
          <string>Display icons:</string>
@@ -88,168 +83,122 @@
         </property>
        </widget>
       </item>
-      <item row="3" column="1" colspan="2">
+      <item row="1" column="1">
        <widget class="QCheckBox" name="showWindowIconsCheckBox">
         <property name="text">
          <string/>
         </property>
        </widget>
       </item>
-      <item row="4" column="0">
-       <widget class="QLabel" name="labelRows">
+      <item row="2" column="0">
+       <widget class="QLabel" name="currentLabel">
         <property name="text">
-         <string>Number of rows:</string>
+         <string>Selecting current desktop:</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
         </property>
-        <property name="buddy">
-         <cstring>spinRows</cstring>
-        </property>
        </widget>
       </item>
-      <item row="4" column="1">
-       <widget class="KIntSpinBox" name="spinRows">
-        <property name="toolTip">
-         <string>Change the number of rows</string>
+      <item row="2" column="1">
+       <widget class="QComboBox" name="selectDesktopComboBox">
+        <item>
+         <property name="text">
+          <string>Does nothing</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Shows desktop</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Shows the dashboard</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <widget class="QLabel" name="labelRows">
+        <property name="text">
+         <string>Number of rows:</string>
         </property>
-        <property name="whatsThis">
-         <string>Change the number of rows</string>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
         </property>
-        <property name="minimum">
-         <number>1</number>
-        </property>
-        <property name="maximum">
-         <number>20</number>
-        </property>
        </widget>
       </item>
-      <item row="4" column="2">
-       <spacer name="horizontalSpacer_3">
+      <item row="3" column="1">
+       <widget class="KIntSpinBox" name="spinRows"/>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <spacer name="verticalSpacer_2">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>40</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <spacer name="horizontalSpacer">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
         <property name="sizeHint" stdset="0">
          <size>
-          <width>64</width>
+          <width>40</width>
           <height>20</height>
          </size>
         </property>
        </spacer>
       </item>
-      <item row="5" column="0">
-       <widget class="QLabel" name="currentLabel">
+      <item>
+       <widget class="QPushButton" name="configureDesktopsButton">
         <property name="text">
-         <string>Selecting current desktop:</string>
+         <string>Configure Desktops...</string>
         </property>
-        <property name="alignment">
-         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-        </property>
-        <property name="buddy">
-         <cstring>spinRows</cstring>
-        </property>
        </widget>
       </item>
-      <item row="5" column="1" colspan="2">
-       <widget class="QRadioButton" name="doNothingRadioButton">
-        <property name="text">
-         <string>Does nothing</string>
+      <item>
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
         </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupAction</string>
-        </attribute>
-       </widget>
-      </item>
-      <item row="6" column="1" colspan="2">
-       <widget class="QRadioButton" name="showDesktopRadioButton">
-        <property name="text">
-         <string>Shows desktop</string>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
         </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupAction</string>
-        </attribute>
-       </widget>
+       </spacer>
       </item>
-      <item row="7" column="1" colspan="2">
-       <widget class="QRadioButton" name="showDashboardRadioButton">
-        <property name="text">
-         <string>Shows the dashboard</string>
-        </property>
-        <attribute name="buttonGroup">
-         <string comment="KDE::DoNotExtract">buttonGroupAction</string>
-        </attribute>
-       </widget>
-      </item>
      </layout>
-    </widget>
-   </item>
-   <item row="0" column="1">
-    <spacer name="horizontalSpacer">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>4</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="1" column="0">
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType">
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>15</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="2" column="0" colspan="2">
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QPushButton" name="configureDesktopsButton">
-       <property name="text">
-        <string>Configure Desktops...</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>333</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item row="3" column="0">
-    <spacer name="verticalSpacer_4">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>47</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-  </layout>
+    </item>
+    <item>
+     <spacer name="verticalSpacer_3">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>40</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+   </layout>
+  </widget>
  </widget>
  <customwidgets>
   <customwidget>
@@ -259,17 +208,8 @@
   </customwidget>
  </customwidgets>
  <tabstops>
-  <tabstop>desktopNumberRadioButton</tabstop>
-  <tabstop>desktopNameRadioButton</tabstop>
-  <tabstop>displayNoneRadioButton</tabstop>
-  <tabstop>showWindowIconsCheckBox</tabstop>
-  <tabstop>spinRows</tabstop>
   <tabstop>configureDesktopsButton</tabstop>
  </tabstops>
  <resources/>
  <connections/>
- <buttongroups>
-  <buttongroup name="buttonGroupText"/>
-  <buttongroup name="buttonGroupAction"/>
- </buttongroups>
 </ui>


_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic