diff options
| author | 2010-01-10 16:10:35 +0000 | |
|---|---|---|
| committer | 2010-01-10 16:10:35 +0000 | |
| commit | 8c0d79d49bb878eb3b731f338a2dc3d1c902143c (patch) | |
| tree | d0374bf049de0d50f6cbc9de794c818bbf5ce5ba /src | |
| parent | small fix to previous commit (diff) | |
| download | KVIrc-8c0d79d49bb878eb3b731f338a2dc3d1c902143c.tar.gz KVIrc-8c0d79d49bb878eb3b731f338a2dc3d1c902143c.tar.bz2 KVIrc-8c0d79d49bb878eb3b731f338a2dc3d1c902143c.zip | |
more stylish: themed combo box, used by kviconsole
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3828 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_console.cpp | 4 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_console.h | 4 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedcombobox.cpp | 126 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedcombobox.h | 45 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedlabel.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedlabel.h | 1 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedlineedit.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_themedlineedit.h | 1 |
9 files changed, 178 insertions, 9 deletions
diff --git a/src/kvirc/CMakeLists.txt b/src/kvirc/CMakeLists.txt index 29d6b6085..37c8cb2b9 100644 --- a/src/kvirc/CMakeLists.txt +++ b/src/kvirc/CMakeLists.txt @@ -52,6 +52,7 @@ SET(kvirc_MOC_HDRS ui/kvi_statusbar.h ui/kvi_statusbarapplet.h ui/kvi_texticonwin.h + ui/kvi_themedcombobox.h ui/kvi_themedlabel.h ui/kvi_themedlineedit.h ui/kvi_toolbar.h @@ -134,6 +135,7 @@ SET(kvirc_SRCS ui/kvi_statusbar.cpp ui/kvi_statusbarapplet.cpp ui/kvi_texticonwin.cpp + ui/kvi_themedcombobox.cpp ui/kvi_themedlabel.cpp ui/kvi_themedlineedit.cpp ui/kvi_toolbar.cpp diff --git a/src/kvirc/ui/kvi_console.cpp b/src/kvirc/ui/kvi_console.cpp index 5a73158b4..28d64324e 100644 --- a/src/kvirc/ui/kvi_console.cpp +++ b/src/kvirc/ui/kvi_console.cpp @@ -112,14 +112,12 @@ KviConsole::KviConsole(KviFrame * lpFrm,int iFlags) m_pButtonBox->setSpacing(0); m_pButtonBox->setMargin(0); new QLabel(__tr2qs("Address:"),m_pButtonBox); - m_pAddressEdit = new QComboBox(m_pButtonBox); - m_pAddressEdit->setObjectName("url_editor"); + m_pAddressEdit = new KviThemedComboBox(m_pButtonBox, "url_editor"); m_pAddressEdit->setAutoCompletion(true); m_pAddressEdit->setDuplicatesEnabled(false); m_pAddressEdit->setEditable(true); m_pAddressEdit->addItem(QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_URL))),""); recentUrlsChanged(); - //m_pAddressEdit->setCurrentText(""); m_pAddressEdit->setInsertPolicy(QComboBox::NoInsert); m_pAddressEdit->setMinimumHeight(24); //icon is 16px, + margins m_pButtonBox->setStretchFactor(m_pAddressEdit,1); diff --git a/src/kvirc/ui/kvi_console.h b/src/kvirc/ui/kvi_console.h index 5768a085d..082e7151e 100644 --- a/src/kvirc/ui/kvi_console.h +++ b/src/kvirc/ui/kvi_console.h @@ -34,10 +34,10 @@ #include "kvi_irccontext.h" #include "kvi_pointerlist.h" #include "kvi_userlistview.h" +#include "kvi_themedcombobox.h" #include <time.h> -#include <QComboBox> #include <QToolButton> class QToolBar; @@ -91,7 +91,7 @@ protected: // UI KviUserListView * m_pNotifyListView; KviWindowToolPageButton * m_pNotifyViewButton; - QComboBox * m_pAddressEdit; + KviThemedComboBox * m_pAddressEdit; QString m_szStatusString; // nick (flags) on server | not connected QString m_szOwnSmartColor; QStringList * m_pTmpHighLightedChannels; diff --git a/src/kvirc/ui/kvi_themedcombobox.cpp b/src/kvirc/ui/kvi_themedcombobox.cpp new file mode 100644 index 000000000..9f2a232c3 --- /dev/null +++ b/src/kvirc/ui/kvi_themedcombobox.cpp @@ -0,0 +1,126 @@ +//============================================================================= +// +// File : kvi_themedlineedit.cpp +// Creation date : Sun Jan 10 2010 12:17:00 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) 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 "kvi_themedcombobox.h" +#include "kvi_options.h" +#include "kvi_settings.h" +#include "kvi_app.h" +#include "kvi_window.h" + +#include <QPainter> +#include <QLineEdit> +#include <QStyleOptionFrameV2> + +#ifdef COMPILE_PSEUDO_TRANSPARENCY + extern QPixmap * g_pShadedChildGlobalDesktopBackground; +#endif + +KviThemedComboBox::KviThemedComboBox(QWidget * par,const char * name) +: QComboBox(par) +{ + setObjectName(name); + setAutoFillBackground(false); + + QPalette pal = palette(); + pal.setBrush(QPalette::Active, QPalette::Base, Qt::transparent); + pal.setBrush(QPalette::Inactive, QPalette::Base, Qt::transparent); + pal.setBrush(QPalette::Disabled, QPalette::Base, Qt::transparent); + + setPalette(pal); + + applyOptions(); +} + +KviThemedComboBox::~KviThemedComboBox() +{ +} + +void KviThemedComboBox::applyOptions() +{ + setFont(KVI_OPTION_FONT(KviOption_fontLabel)); + update(); +} + +void KviThemedComboBox::paintEvent ( QPaintEvent * event ) +{ + QPainter p(this); + QLineEdit *le = lineEdit(); + if(le) + { + QRect r = rect(); + QPalette pal = palette(); + QStyleOptionFrameV2 option; + + option.initFrom(this); + option.rect = contentsRect(); + option.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, le); + option.midLineWidth = 0; + option.state |= QStyle::State_Sunken; + if(le->isReadOnly()) + option.state |= QStyle::State_ReadOnly; + option.features = QStyleOptionFrameV2::None; + + r = style()->subElementRect(QStyle::SE_LineEditContents, &option, le); + int left, right, top, bottom; + le->getTextMargins(&left, &top, &right, &bottom); + r.setX(r.x() + left); + r.setY(r.y() + top); + r.setRight(r.right() - right); + r.setBottom(r.bottom() - bottom); + p.setClipRect(r); + } // else not editable + +#ifdef COMPILE_PSEUDO_TRANSPARENCY + if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing()) + { + p.save(); + p.setCompositionMode(QPainter::CompositionMode_Source); + QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade); + col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); + p.fillRect(contentsRect(), col); + p.restore(); + } else if(g_pShadedChildGlobalDesktopBackground) + { + QPoint pnt = mapToGlobal(contentsRect().topLeft()); + p.drawTiledPixmap(contentsRect(),*g_pShadedChildGlobalDesktopBackground,pnt); + } else { +#endif + + if(KVI_OPTION_PIXMAP(KviOption_pixmapLabelBackground).pixmap()) + { + p.drawTiledPixmap(contentsRect(),*(KVI_OPTION_PIXMAP(KviOption_pixmapLabelBackground).pixmap())); + } else { + p.fillRect(contentsRect(),KVI_OPTION_COLOR(KviOption_colorLabelBackground)); + } + +#ifdef COMPILE_PSEUDO_TRANSPARENCY + } +#endif + + QComboBox::paintEvent(event); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES +#include "kvi_themedcombobox.moc" +#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvirc/ui/kvi_themedcombobox.h b/src/kvirc/ui/kvi_themedcombobox.h new file mode 100644 index 000000000..6739a43c6 --- /dev/null +++ b/src/kvirc/ui/kvi_themedcombobox.h @@ -0,0 +1,45 @@ +#ifndef _KVI_THEMEDCOMBOBOX_H_ +#define _KVI_THEMEDCOMBOBOX_H_ +//============================================================================= +// +// File : kvi_themedcombobox.h +// Creation date : Sun Jan 10 2010 12:17:00 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) 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 "kvi_settings.h" + +#include <QComboBox> + +class KVIRC_API KviThemedComboBox : public QComboBox +{ + Q_OBJECT + Q_PROPERTY(int TransparencyCapable READ dummyRead) +public: + KviThemedComboBox(QWidget * par,const char * name); + ~KviThemedComboBox(); +protected: + virtual void paintEvent ( QPaintEvent * event ); +public: + int dummyRead() const { return 0; }; + void applyOptions(); +}; + +#endif //_KVI_THEMEDCOMBOBOX_H_ diff --git a/src/kvirc/ui/kvi_themedlabel.cpp b/src/kvirc/ui/kvi_themedlabel.cpp index 52bab1b25..bf87f6022 100644 --- a/src/kvirc/ui/kvi_themedlabel.cpp +++ b/src/kvirc/ui/kvi_themedlabel.cpp @@ -75,7 +75,7 @@ void KviThemedLabel::applyOptions() update(); } -void KviThemedLabel::paintEvent ( QPaintEvent * event ) +void KviThemedLabel::paintEvent(QPaintEvent *) { QPainter p(this); #ifdef COMPILE_PSEUDO_TRANSPARENCY diff --git a/src/kvirc/ui/kvi_themedlabel.h b/src/kvirc/ui/kvi_themedlabel.h index 3a2996823..6a63b3a4e 100644 --- a/src/kvirc/ui/kvi_themedlabel.h +++ b/src/kvirc/ui/kvi_themedlabel.h @@ -25,7 +25,6 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_string.h" #include <QFrame> diff --git a/src/kvirc/ui/kvi_themedlineedit.cpp b/src/kvirc/ui/kvi_themedlineedit.cpp index 77e08cf74..b5db4bbc3 100644 --- a/src/kvirc/ui/kvi_themedlineedit.cpp +++ b/src/kvirc/ui/kvi_themedlineedit.cpp @@ -117,5 +117,5 @@ void KviThemedLineEdit::paintEvent ( QPaintEvent * event ) } #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES -#include "kvi_themedlabel.moc" +#include "kvi_themedlineedit.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvirc/ui/kvi_themedlineedit.h b/src/kvirc/ui/kvi_themedlineedit.h index 530a861b8..b0c9890fd 100644 --- a/src/kvirc/ui/kvi_themedlineedit.h +++ b/src/kvirc/ui/kvi_themedlineedit.h @@ -25,7 +25,6 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_string.h" #include <QLineEdit> |
