[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-04-25 13:43:46
Message-ID: 1209131026.588513.13308.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 801024 by sebas:

    More porting to WoC. It basically seems to work now,
    but I cannot get the background color of the widget
    to be transparant. It's got the widget's grey background
    now. Will have to investigate further.


 M  +62 -52    notes.cpp  
 M  +20 -21    notes.h  


--- trunk/extragear/plasma/applets/notes/notes.cpp #801023:801024
@@ -1,21 +1,22 @@
-/*
-    Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> 
-                                                                          
-    This program is free software; you can redistribute it and/or modify  
-    it under the terms of the GNU General Public License as published by  
-    the Free Software Foundation; either version 2 of the License, or     
-    (at your option) any later version.                                   
-                                                                          
-    This program is distributed in the hope that it will be useful,       
-    but WITHOUT ANY WARRANTY; without even the implied warranty of        
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
-    GNU General Public License for more details.                          
-                                                                          
-    You should have received a copy of the GNU General Public License     
-    along with this program; if not, write to the                         
-    Free Software Foundation, Inc.,                                       
-    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        
- */
+/***************************************************************************
+ *   Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net>         *
+ *   Copyright (C) 2008 Sebastian Kügler <sebas@kde.org>                   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
+ ***************************************************************************/
 
 #include "notes.h"
 
@@ -38,6 +39,7 @@
     setAcceptsHoverEvents(true);
     setDrawStandardBackground(false);
     resize(256, 256);
+    m_textEdit = new QTextEdit();
 }
 
 void Notes::init()
@@ -45,57 +47,64 @@
 
     m_notes_theme.setContainsMultipleImages(false);
 
-    m_textEdit = new QTextEdit();
 
-    m_layout = new QGraphicsLinearLayout();
-    m_layout->setContentsMargins(0,0,0,0);
-    m_layout->setSpacing(0);
-    m_proxy = new QGraphicsProxyWidget(this);
-    m_proxy->setWidget(m_textEdit);
-    m_proxy->show();
-    m_layout->addItem(m_proxy);
-    setLayout(m_layout);
+    m_textEdit->setLineWrapMode(QTextEdit::WidgetWidth);
 
+
     KConfigGroup cg = config();
 
-    updateTextGeometry();
-// //m_textArea->setDefaultText(i18n("Welcome to Notes Plasmoid! Type your notes \
here...")); +    //m_textEdit->setDefaultText(i18n("Welcome to Notes Plasmoid! Type \
your notes here..."));  QString text = cg.readEntry("autoSave",QString());
     if (! text.isEmpty()) {
-//     //m_textArea->setPlainText(text);
+        m_textEdit->setPlainText(text);
     }
- //m_textArea->setStyled(false);
     //FIXME this has no effect right now. try setTextInteractionFlags
-    //m_textArea->setOpenExternalLinks(true);
+    //m_textEdit->setOpenExternalLinks(true);
     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 ... +    
+    m_textEdit->setFont(font);
+    m_textEdit->setTextColor(textColor);
+    m_textEdit->setTextBackgroundColor(QColor(0,0,0,0));
+    m_textEdit->viewport()->setAutoFillBackground(false);
+    m_textEdit->setAutoFillBackground(false);
+    m_textEdit->setStyleSheet("background: none");
+
+    m_proxy = new QGraphicsProxyWidget(this);
+    m_proxy->setWidget(m_textEdit);
+    m_proxy->show();
+
+    m_layout = new QGraphicsLinearLayout();
+    m_layout->setContentsMargins(0,0,0,0);
+    m_layout->setSpacing(0);
+    setLayout(m_layout);
+    m_layout->addItem(m_proxy);
+    connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(saveNote())); 
+    //updateTextGeometry();
 }
 
 void Notes::constraintsUpdated(Plasma::Constraints constraints)
 {
     //XXX why does everything break so horribly if I remove this line?
     setDrawStandardBackground(false);
-    if (constraints & Plasma::SizeConstraint) {
-        updateTextGeometry();
-    }
+    //if (constraints & Plasma::SizeConstraint) {
+    //    updateTextGeometry();
+    //}
 }
 
+/*
 void Notes::updateTextGeometry()
 {
     //note: we're using a custom bg so we have no 'border': using boundingrect here \
is ok  //FIXME there's no way to force the height on a qgraphicstextitem :(
-    const qreal xpad = boundingRect().width() / 10;
-    const qreal ypad = boundingRect().height() / 10;
- //m_textArea->setGeometry(QRectF(xpad, ypad, boundingRect().width() - 2 * xpad, \
boundingRect().height() - 2 * ypad)); +    //const qreal xpad = \
boundingRect().width() / 10; +    //const qreal ypad = boundingRect().height() / 10;
+    //m_textEdit->setGeometry(QRectF(xpad, ypad, boundingRect().width() - 2 * xpad, \
boundingRect().height() - 2 * ypad)); +    m_textEdit->setGeometry(geometry());
 }
-
+*/
 void Notes::saveNote()
 {
-    KConfigGroup cg = config();
-    //cg.writeEntry("autoSave", m_textArea->toPlainText());
     emit configNeedsSaving();
 }
 
@@ -112,6 +121,7 @@
                            const QRect &contentsRect)
 {
     Q_UNUSED(option);
+    kDebug() << "painting";
 
     m_notes_theme.resize((int)contentsRect.width(),
                          (int)contentsRect.height());
@@ -128,8 +138,8 @@
     parent->addPage(widget, parent->windowTitle(), "battery");
     connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
     connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
-    //ui.textColorButton->setColor(m_textArea->defaultTextColor());
-    //ui.textFontButton->setFont(m_textArea->font());
+    ui.textColorButton->setColor(m_textEdit->textColor());
+    ui.textFontButton->setFont(m_textEdit->font());
 }
 
 void Notes::configAccepted()
@@ -141,18 +151,18 @@
     bool changed = false;
 
     QFont newFont = ui.textFontButton->font();
-    //if (m_textArea->font() != newFont) {
+    if (m_textEdit->font() != newFont) {
         changed = true;
         cg.writeEntry("font", newFont);
-        //m_textArea->setFont(newFont);
-    //}
+        m_textEdit->setFont(newFont);
+    }
 
     QColor newColor = ui.textColorButton->color();
-    //if (m_textArea->defaultTextColor() != newColor) {
+    if (m_textEdit->textColor() != newColor) {
         changed = true;
         cg.writeEntry("textcolor", newColor);
-        //m_textArea->setDefaultTextColor(newColor);
-    //}
+        m_textEdit->setTextColor(newColor);
+    }
 
     if (changed) {
         emit configNeedsSaving();
--- trunk/extragear/plasma/applets/notes/notes.h #801023:801024
@@ -1,21 +1,22 @@
-/*
-    Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> 
-                                                                          
-    This program is free software; you can redistribute it and/or modify  
-    it under the terms of the GNU General Public License as published by  
-    the Free Software Foundation; either version 2 of the License, or     
-    (at your option) any later version.                                   
-                                                                          
-    This program is distributed in the hope that it will be useful,       
-    but WITHOUT ANY WARRANTY; without even the implied warranty of        
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
-    GNU General Public License for more details.                          
-                                                                          
-    You should have received a copy of the GNU General Public License     
-    along with this program; if not, write to the                         
-    Free Software Foundation, Inc.,                                       
-    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        
- */
+/***************************************************************************
+ *   Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net>         *
+ *   Copyright (C) 2008 Sebastian Kügler <sebas@kde.org>                   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
+ ***************************************************************************/
 
 #ifndef NOTES_HEADER
 #define NOTES_HEADER
@@ -52,14 +53,12 @@
         void saveNote();
 
     private:
-        void updateTextGeometry();
+        //void updateTextGeometry();
         Plasma::Svg m_notes_theme;
         QGraphicsLinearLayout *m_layout;
         QGraphicsProxyWidget *m_proxy;
         QTextEdit *m_textEdit;
         Ui::config ui;
-        //KDialog *m_dialog;
-
         QSizeF m_size;
 };
 


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

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