• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

lineedit.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2008 Aaron Seigo <aseigo@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include "lineedit.h"
00021 
00022 #include <QPainter>
00023 
00024 #include <klineedit.h>
00025 #include <kmimetype.h>
00026 
00027 #include <plasma/private/style_p.h>
00028 
00029 #include "theme.h"
00030 #include "svg.h"
00031 
00032 namespace Plasma
00033 {
00034 
00035 class LineEditPrivate
00036 {
00037 public:
00038     LineEditPrivate(LineEdit *lineEdit)
00039         :q(lineEdit)
00040     {
00041     }
00042 
00043     ~LineEditPrivate()
00044     {
00045     }
00046 
00047     void setPalette()
00048     {
00049         KLineEdit *native = q->nativeWidget();
00050         QColor color = Theme::defaultTheme()->color(Theme::TextColor);
00051         QPalette p = native->palette();
00052 
00053         p.setColor(QPalette::Normal, QPalette::Text, color);
00054         p.setColor(QPalette::Inactive, QPalette::Text, color);
00055         native->setPalette(p);
00056         native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
00057     }
00058 
00059     LineEdit *q;
00060     Plasma::Style::Ptr style;
00061 };
00062 
00063 LineEdit::LineEdit(QGraphicsWidget *parent)
00064     : QGraphicsProxyWidget(parent),
00065       d(new LineEditPrivate(this))
00066 {
00067     KLineEdit *native = new KLineEdit;
00068     connect(native, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
00069     connect(native, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
00070     connect(native, SIGNAL(textEdited(const QString&)), this, SIGNAL(textEdited(const QString&)));
00071     setWidget(native);
00072     native->setAttribute(Qt::WA_NoSystemBackground);
00073     d->style = Plasma::Style::sharedStyle();
00074     native->setStyle(d->style.data());
00075 
00076     d->setPalette();
00077     connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(setPalette()));
00078 }
00079 
00080 LineEdit::~LineEdit()
00081 {
00082     delete d;
00083     Plasma::Style::doneWithSharedStyle();
00084 }
00085 
00086 void LineEdit::setText(const QString &text)
00087 {
00088     static_cast<KLineEdit*>(widget())->setText(text);
00089 }
00090 
00091 QString LineEdit::text() const
00092 {
00093     return static_cast<KLineEdit*>(widget())->text();
00094 }
00095 
00096 void LineEdit::setClearButtonShown(bool show)
00097 {
00098     nativeWidget()->setClearButtonShown(show);
00099 }
00100 
00101 bool LineEdit::isClearButtonShown() const
00102 {
00103     return nativeWidget()->isClearButtonShown();
00104 }
00105 
00106 void LineEdit::setStyleSheet(const QString &stylesheet)
00107 {
00108     widget()->setStyleSheet(stylesheet);
00109 }
00110 
00111 QString LineEdit::styleSheet()
00112 {
00113     return widget()->styleSheet();
00114 }
00115 
00116 KLineEdit *LineEdit::nativeWidget() const
00117 {
00118     return static_cast<KLineEdit*>(widget());
00119 }
00120 
00121 } // namespace Plasma
00122 
00123 #include <lineedit.moc>
00124 

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal