KFile
kurlnavigatordropdownbutton.cpp
Go to the documentation of this file.
00001 /***************************************************************************** 00002 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> * 00003 * * 00004 * This library is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU Library General Public * 00006 * License as published by the Free Software Foundation; either * 00007 * version 2 of the License, or (at your option) any later version. * 00008 * * 00009 * This library 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 GNU * 00012 * Library General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU Library General Public License * 00015 * along with this library; see the file COPYING.LIB. If not, write to * 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00017 * Boston, MA 02110-1301, USA. * 00018 *****************************************************************************/ 00019 00020 #include "kurlnavigatordropdownbutton_p.h" 00021 #include "kurlnavigator.h" 00022 00023 #include <kglobalsettings.h> 00024 00025 #include <QtGui/QKeyEvent> 00026 #include <QtGui/QPainter> 00027 #include <QtGui/QStyleOption> 00028 00029 KUrlNavigatorDropDownButton::KUrlNavigatorDropDownButton(QWidget* parent) : 00030 KUrlNavigatorButtonBase(parent) 00031 { 00032 } 00033 00034 KUrlNavigatorDropDownButton::~KUrlNavigatorDropDownButton() 00035 { 00036 } 00037 00038 QSize KUrlNavigatorDropDownButton::sizeHint() const 00039 { 00040 QSize size = KUrlNavigatorButtonBase::sizeHint(); 00041 size.setWidth(size.height() / 2); 00042 return size; 00043 } 00044 00045 void KUrlNavigatorDropDownButton::paintEvent(QPaintEvent* event) 00046 { 00047 Q_UNUSED(event); 00048 00049 QPainter painter(this); 00050 drawHoverBackground(&painter); 00051 00052 const QColor fgColor = foregroundColor(); 00053 00054 QStyleOption option; 00055 option.initFrom(this); 00056 option.rect = QRect(0, 0, width(), height()); 00057 option.palette = palette(); 00058 option.palette.setColor(QPalette::Text, fgColor); 00059 option.palette.setColor(QPalette::WindowText, fgColor); 00060 option.palette.setColor(QPalette::ButtonText, fgColor); 00061 00062 if (layoutDirection() == Qt::LeftToRight) { 00063 style()->drawPrimitive(QStyle::PE_IndicatorArrowRight, &option, &painter, this); 00064 } else { 00065 style()->drawPrimitive(QStyle::PE_IndicatorArrowLeft, &option, &painter, this); 00066 } 00067 00068 } 00069 00070 #include "kurlnavigatordropdownbutton_p.moc"
KDE 4.6 API Reference