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

List:       kde-commits
Subject:    extragear/plasma/applets/notes
From:       Sebastian Kügler <sebas () kde ! nl>
Date:       2008-05-12 1:57:52
Message-ID: 1210557472.835504.20185.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 806679 by sebas:

* slotes -> Q_SLOTS
* defaultText is member now, so we can have some disabled hint
  ... which is not there yet.


 M  +17 -1     notes.cpp  
 M  +5 -2      notes.h  


--- trunk/extragear/plasma/applets/notes/notes.cpp #806678:806679
@@ -41,10 +41,12 @@
     setBackgroundHints(Plasma::Applet::NoBackground);
     resize(256, 256);
 
+    m_defaultText = i18n("Welcome to the Notes Plasmoid! Type your notes here...");
     m_textEdit = new KTextEdit();
     m_layout = new QGraphicsLinearLayout();
     m_proxy = new QGraphicsProxyWidget(this);
     m_autoFont = false;
+
     updateTextGeometry();
 }
 
@@ -63,10 +65,11 @@
 
     KConfigGroup cg = config();
 
-    m_textEdit->setPlainText(i18n("Welcome to the Notes Plasmoid! Type your notes here..."));
     QString text = cg.readEntry("autoSave", QString());
     if (! text.isEmpty()) {
         m_textEdit->setPlainText(text);
+    } else {
+        m_textEdit->setPlainText(m_defaultText);
     }
     m_font = cg.readEntry("font", KGlobalSettings::generalFont());
     m_autoFont = cg.readEntry("autoFont", true);
@@ -78,6 +81,8 @@
     setLayout(m_layout);
     updateTextGeometry();
     connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(saveNote()));
+    connect(this, SIGNAL(clicked()), this, SLOT(focusNote()));
+    focusNote();
 }
 
 void Notes::constraintsEvent(Plasma::Constraints constraints)
@@ -117,6 +122,17 @@
     emit configNeedsSaving();
 }
 
+void Notes::focusNote()
+{
+    if (m_textEdit->toPlainText() == m_defaultText) {
+        m_textEdit->setEnabled(false);
+        kDebug() << "enabled: false";
+    } else {
+        m_textEdit->setEnabled(true);
+        kDebug() << "enabled: true";
+    }
+}
+
 Notes::~Notes()
 {
     //FIXME is it really ok to save from here?
--- trunk/extragear/plasma/applets/notes/notes.h #806678:806679
@@ -48,14 +48,16 @@
                             const QStyleOptionGraphicsItem *option,
                             const QRect& contentsRect);
 
-    public slots:
+    public Q_SLOTS:
         void configAccepted();
-        void saveNote();
 
     protected:
         void constraintsEvent(Plasma::Constraints constraints);
         void createConfigurationInterface(KConfigDialog *parent);
 
+    private Q_SLOTS:
+        void saveNote();
+        void focusNote();
     private:
         int fontSize();
         int m_autoFontPercent;
@@ -68,6 +70,7 @@
         QGraphicsLinearLayout *m_layout;
         QGraphicsProxyWidget *m_proxy;
         KTextEdit *m_textEdit;
+        QString m_defaultText;
         Ui::config ui;
 
         QSizeF m_size;
[prev in list] [next in list] [prev in thread] [next in thread] 

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