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

List:       kde-commits
Subject:    extragear/plasma/applets/notes
From:       Chani Armitage <chanika () gmail ! com>
Date:       2008-03-25 1:40:16
Message-ID: 1206409216.684482.23928.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 789733 by chani:

better config dialog
patch from David Benjamin
BUG: 159713


 M  +22 -11    config.ui  
 M  +25 -23    notes.cpp  
 M  +0 -4      notes.h  


--- trunk/extragear/plasma/applets/notes/config.ui #789732:789733
@@ -5,33 +5,44 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>167</width>
-    <height>72</height>
+    <width>316</width>
+    <height>65</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" >
-   <item>
-    <widget class="KPushButton" name="fontSelectButton" >
+  <layout class="QGridLayout" >
+   <item row="0" column="0" >
+    <widget class="QLabel" name="textFontLabel" >
      <property name="text" >
-      <string>Select Font...</string>
+      <string>Font:</string>
      </property>
     </widget>
    </item>
-   <item>
-    <widget class="KPushButton" name="colorSelectButton" >
+   <item row="0" column="1" >
+    <widget class="KFontRequester" name="textFontButton" />
+   </item>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="textColorLabel" >
      <property name="text" >
-      <string>Select Text Color...</string>
+      <string>Text Color:</string>
      </property>
     </widget>
    </item>
+   <item row="1" column="1" >
+    <widget class="KColorButton" name="textColorButton" />
+   </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>KPushButton</class>
+   <class>KColorButton</class>
    <extends>QPushButton</extends>
-   <header>kpushbutton.h</header>
+   <header>kcolorbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>KFontRequester</class>
+   <extends>QWidget</extends>
+   <header>kfontrequester.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
--- trunk/extragear/plasma/applets/notes/notes.cpp #789732:789733
@@ -55,10 +55,10 @@
     m_textArea->setStyled(false);
     //FIXME this has no effect right now. try setTextInteractionFlags
     m_textArea->setOpenExternalLinks(true);
-    m_font = cg.readEntry("font", QFont());
-    m_textArea->setFont(m_font);
-    m_textColor = cg.readEntry("textcolor", QColor());
-    m_textArea->setDefaultTextColor(m_textColor);
+    QFont font = cg.readEntry("font", QFont());
+    m_textArea->setFont(font);
+    QColor textColor = cg.readEntry("textcolor", QColor(Qt::black));
+    m_textArea->setDefaultTextColor(textColor);
     connect(m_textArea, SIGNAL(editingFinished()), this, SLOT(saveNote())); // \
FIXME: Doesn't work? This could make the following unnecessary ...  }
 
@@ -120,36 +120,38 @@
         m_dialog->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
         connect( m_dialog, SIGNAL(applyClicked()), this, SLOT(configAccepted()) );
         connect( m_dialog, SIGNAL(okClicked()), this, SLOT(configAccepted()) );
-        connect( ui.fontSelectButton, SIGNAL(clicked()), this, \
                SLOT(showFontSelectDlg()) );
-        connect( ui.colorSelectButton, SIGNAL(clicked()), this, \
SLOT(showColorSelectDlg()));  }
 
+    ui.textColorButton->setColor(m_textArea->defaultTextColor());
+    ui.textFontButton->setFont(m_textArea->font());
     m_dialog->show();
 }
 
-//FIXME those two dialogs give the cancel button issues.
-void Notes::showFontSelectDlg()
-{
-    KFontDialog::getFont(m_font);
-}
-
-void Notes::showColorSelectDlg()
-{
-    KColorDialog::getColor(m_textColor);
-}
-
 void Notes::configAccepted()
 {
     prepareGeometryChange();
 
     KConfigGroup cg = config();
-    //TODO only write if changed. but how do we know if that happened?
-    cg.writeEntry("font", m_font);
-    cg.writeEntry("textcolor", m_textColor);
-    emit configNeedsSaving();
 
-    m_textArea->setFont(m_font);
-    m_textArea->setDefaultTextColor(m_textColor);
+    bool changed = false;
+
+    QFont newFont = ui.textFontButton->font();
+    if (m_textArea->font() != newFont) {
+        changed = true;
+        cg.writeEntry("font", newFont);
+        m_textArea->setFont(newFont);
+    }
+
+    QColor newColor = ui.textColorButton->color();
+    if (m_textArea->defaultTextColor() != newColor) {
+        changed = true;
+        cg.writeEntry("textcolor", newColor);
+        m_textArea->setDefaultTextColor(newColor);
+    }
+
+    if (changed) {
+        emit configNeedsSaving();
+    }
 }
 
 #include "notes.moc"
--- trunk/extragear/plasma/applets/notes/notes.h #789732:789733
@@ -46,8 +46,6 @@
     public slots:
         void showConfigurationInterface();
         void configAccepted();
-        void showFontSelectDlg();
-        void showColorSelectDlg();
         void saveNote();
 
     private:
@@ -58,8 +56,6 @@
         Ui::config ui;
         KDialog *m_dialog;
 
-        QFont m_font;
-        QColor m_textColor;
         QSizeF m_size;
 };
 


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

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