summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbarbutton.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/ktoolbarbutton.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbarbutton.cpp106
1 files changed, 60 insertions, 46 deletions
diff --git a/microkde/kdeui/ktoolbarbutton.cpp b/microkde/kdeui/ktoolbarbutton.cpp
index 1d5d0e5..7b98b32 100644
--- a/microkde/kdeui/ktoolbarbutton.cpp
+++ b/microkde/kdeui/ktoolbarbutton.cpp
@@ -34,8 +34,12 @@
#include <qtooltip.h>
#include <qbitmap.h>
-#include <qpopupmenu.h>
+#include <q3popupmenu.h>
#include <qcursor.h>
#include <qpainter.h>
#include <qlayout.h>
+//Added by qt3to4:
+#include <QPixmap>
+#include <QMouseEvent>
+#include <QEvent>
#include <kapplication.h>
@@ -49,5 +53,5 @@
#include <kmainwindow.h>
-template class QIntDict<KToolBarButton>;
+template class Q3IntDict<KToolBarButton>;
class KToolBarButtonPrivate
@@ -116,5 +120,5 @@ KToolBarButton::KToolBarButton( const QString& _icon, int _id,
//US d->m_instance = _instance;
- setFocusPolicy( NoFocus );
+ setFocusPolicy( Qt::NoFocus );
// connect all of our slots and start trapping events
@@ -147,5 +151,5 @@ KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id,
QToolButton::setTextLabel(txt);
- setFocusPolicy( NoFocus );
+ setFocusPolicy( Qt::NoFocus );
// connect all of our slots and start trapping events
@@ -162,5 +166,5 @@ KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id,
// set our pixmap and do our initial setup
- setIconSet( QIconSet( pixmap ));
+ setIconSet( QIcon( pixmap ));
modeChange();
}
@@ -293,5 +297,5 @@ void KToolBarButton::setIcon( const QString &icon )
}
-void KToolBarButton::setIconSet( const QIconSet &iconset )
+void KToolBarButton::setIconSet( const QIcon &iconset )
{
QToolButton::setIconSet( iconset );
@@ -306,6 +310,6 @@ void KToolBarButton::setPixmap( const QPixmap &pixmap )
return;
}
- QIconSet set = iconSet();
- set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Active );
+ QIcon set = iconSet();
+ set.setPixmap( pixmap, QIcon::Automatic, QIcon::Active );
QToolButton::setIconSet( set );
}
@@ -313,6 +317,6 @@ void KToolBarButton::setPixmap( const QPixmap &pixmap )
void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap )
{
- QIconSet set = iconSet();
- set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Normal );
+ QIcon set = iconSet();
+ set.setPixmap( pixmap, QIcon::Automatic, QIcon::Normal );
QToolButton::setIconSet( set );
}
@@ -320,6 +324,6 @@ void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap )
void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap )
{
- QIconSet set = iconSet();
- set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Disabled );
+ QIcon set = iconSet();
+ set.setPixmap( pixmap, QIcon::Automatic, QIcon::Disabled );
QToolButton::setIconSet( set );
}
@@ -327,5 +331,5 @@ void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap )
void KToolBarButton::setDefaultIcon( const QString& icon )
{
- QIconSet set = iconSet();
+ QIcon set = iconSet();
QPixmap pm;
if (!strcmp(d->m_parent->name(), "mainToolBar"))
@@ -335,5 +339,5 @@ void KToolBarButton::setDefaultIcon( const QString& icon )
pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
d->m_iconSize );
- set.setPixmap( pm, QIconSet::Automatic, QIconSet::Normal );
+ set.setPixmap( pm, QIcon::Automatic, QIcon::Normal );
QToolButton::setIconSet( set );
}
@@ -341,5 +345,5 @@ void KToolBarButton::setDefaultIcon( const QString& icon )
void KToolBarButton::setDisabledIcon( const QString& icon )
{
- QIconSet set = iconSet();
+ QIcon set = iconSet();
QPixmap pm;
if (!strcmp(d->m_parent->name(), "mainToolBar"))
@@ -349,9 +353,9 @@ void KToolBarButton::setDisabledIcon( const QString& icon )
pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
d->m_iconSize );
- set.setPixmap( pm, QIconSet::Automatic, QIconSet::Disabled );
+ set.setPixmap( pm, QIcon::Automatic, QIcon::Disabled );
QToolButton::setIconSet( set );
}
-QPopupMenu *KToolBarButton::popup()
+QMenu *KToolBarButton::popup()
{
// obsolete
@@ -360,5 +364,5 @@ QPopupMenu *KToolBarButton::popup()
}
-void KToolBarButton::setPopup(QPopupMenu *p, bool)
+void KToolBarButton::setPopup(Q3PopupMenu *p, bool)
{
QToolButton::setPopup(p);
@@ -367,5 +371,5 @@ void KToolBarButton::setPopup(QPopupMenu *p, bool)
-void KToolBarButton::setDelayedPopup (QPopupMenu *p, bool)
+void KToolBarButton::setDelayedPopup (Q3PopupMenu *p, bool)
{
QToolButton::setPopup(p);
@@ -452,19 +456,25 @@ void KToolBarButton::drawButton( QPainter *_painter )
{
#ifdef DESKTOP_VERSION
- QStyle::SFlags flags = QStyle::Style_Default;
- QStyle::SCFlags active = QStyle::SC_None;
+ QStyle::State flags = QStyle::State_None;
+ QStyle::SubControls active = QStyle::SC_None;
if (isDown()) {
- flags |= QStyle::Style_Down;
+ flags |= QStyle::State_DownArrow;
active |= QStyle::SC_ToolButton;
}
- if (isEnabled()) flags |= QStyle::Style_Enabled;
- if (isOn()) flags |= QStyle::Style_On;
- if (isEnabled() && d->m_isRaised) flags |= QStyle::Style_Raised;
- if (hasFocus()) flags |= QStyle::Style_HasFocus;
+ if (isEnabled()) flags |= QStyle::State_Enabled;
+ if (isOn()) flags |= QStyle::State_On;
+ if (isEnabled() && d->m_isRaised) flags |= QStyle::State_Raised;
+ if (hasFocus()) flags |= QStyle::State_HasFocus;
+
+ QStyleOptionToolButton qsotb;
+ qsotb.initFrom(this);
+ qsotb.state = flags;
+ qsotb.activeSubControls = active;
+ qsotb.rect = rect();
+ qsotb.palette = palette();
// Draw a styled toolbutton
- style().drawComplexControl(QStyle::CC_ToolButton, _painter, this, rect(),
- colorGroup(), flags, QStyle::SC_ToolButton, active, QStyleOption());
+ style()->drawComplexControl(QStyle::CC_ToolButton, &qsotb, _painter, this);
#else
@@ -485,7 +495,7 @@ void KToolBarButton::drawButton( QPainter *_painter )
isOn() ? QIconSet::On : QIconSet::Off );
*/
- QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
- isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
- QIconSet::Disabled);
+ QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
+ isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
+ QIcon::Disabled);
if( !pixmap.isNull())
@@ -509,7 +519,7 @@ void KToolBarButton::drawButton( QPainter *_painter )
isOn() ? QIconSet::On : QIconSet::Off );
*/
- QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
- isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
- QIconSet::Disabled);
+ QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
+ isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
+ QIcon::Disabled);
if( !pixmap.isNull())
@@ -527,5 +537,5 @@ void KToolBarButton::drawButton( QPainter *_painter )
if (!textLabel().isNull())
{
- textFlags = AlignVCenter|AlignLeft;
+ textFlags = Qt::AlignVCenter|Qt::AlignLeft;
if (!pixmap.isNull())
dx = 4 + pixmap.width() + 2;
@@ -545,5 +555,5 @@ void KToolBarButton::drawButton( QPainter *_painter )
if (!textLabel().isNull())
{
- textFlags = AlignVCenter|AlignLeft;
+ textFlags = Qt::AlignVCenter|Qt::AlignLeft;
dx = (width() - fm.width(textLabel())) / 2;
dy = (height() - fm.lineSpacing()) / 2;
@@ -564,7 +574,7 @@ void KToolBarButton::drawButton( QPainter *_painter )
isOn() ? QIconSet::On : QIconSet::Off );
*/
- QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
- isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
- QIconSet::Disabled);
+ QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
+ isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
+ QIcon::Disabled);
if( !pixmap.isNull())
@@ -582,5 +592,5 @@ void KToolBarButton::drawButton( QPainter *_painter )
if (!textLabel().isNull())
{
- textFlags = AlignBottom|AlignHCenter;
+ textFlags = Qt::AlignBottom|Qt::AlignHCenter;
dx = (width() - fm.width(textLabel())) / 2;
dy = height() - fm.lineSpacing() - 4;
@@ -611,12 +621,16 @@ void KToolBarButton::drawButton( QPainter *_painter )
{
#ifdef DESKTOP_VERSION
- QStyle::SFlags arrowFlags = QStyle::Style_Default;
+ QStyle::State arrowFlags = QStyle::State_None;
+
+ if (isDown()) arrowFlags |= QStyle::State_DownArrow;
+ if (isEnabled()) arrowFlags |= QStyle::State_Enabled;
- if (isDown()) arrowFlags |= QStyle::Style_Down;
- if (isEnabled()) arrowFlags |= QStyle::Style_Enabled;
+ QStyleOption qso;
+ qso.initFrom(this);
+ qso.state = arrowFlags;
+ qso.rect = QRect(width()-7, height()-7, 7, 7);
+ qso.palette = palette();
- style().drawPrimitive(QStyle::PE_ArrowDown, _painter,
- QRect(width()-7, height()-7, 7, 7), colorGroup(),
- arrowFlags, QStyleOption() );
+ style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &qso, _painter);
#else
style().drawArrow(_painter, Qt::DownArrow, isDown(),