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

Plasma

spinbox.cpp

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

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