26 #include <QtGui/QPainter>
27 #include <QtGui/QKeyEvent>
28 #include <QtGui/QApplication>
37 connect(
this, SIGNAL(toggled(
bool)),
38 this, SLOT(updateToolTip()));
39 connect(
this, SIGNAL(clicked(
bool)),
40 this, SLOT(updateCursor()));
41 m_pixmap =
KIcon(
"dialog-ok").pixmap(
QSize(22, 22).expandedTo(iconSize()));
51 QSize size = KUrlNavigatorButtonBase::sizeHint();
52 size.setWidth(m_pixmap.width() + 4);
65 setCursor(Qt::ArrowCursor);
70 QPainter painter(
this);
71 painter.setClipRect(event->rect());
73 const int buttonWidth = width();
74 const int buttonHeight = height();
77 const int x = (buttonWidth - m_pixmap.width()) / 2;
78 const int y = (buttonHeight - m_pixmap.height()) / 2;
79 painter.drawPixmap(
QRect(x, y, m_pixmap.width(), m_pixmap.height()), m_pixmap);
81 painter.setPen(Qt::NoPen);
82 painter.setBrush(palette().color(foregroundRole()));
84 const int verticalGap = 4;
85 const int caretWidth = 2;
86 const int x = (layoutDirection() == Qt::LeftToRight) ? 0 : width() - caretWidth;
87 painter.drawRect(x, verticalGap, caretWidth, buttonHeight - 2 * verticalGap);
91 void KUrlNavigatorToggleButton::updateToolTip()
94 setToolTip(
i18n(
"Click for Location Navigation"));
96 setToolTip(
i18n(
"Click to Edit Location"));
100 void KUrlNavigatorToggleButton::updateCursor()
102 setCursor(isChecked() ? Qt::ArrowCursor : Qt::IBeamCursor);
107 #include "kurlnavigatortogglebutton_p.moc"
QString i18n(const char *text)