[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Statusbar icons of Konqueror and KHTML Part do not look nice
From:       Aurélien_Gâteau <aurelien.gateau () free ! fr>
Date:       2009-05-17 13:45:35
Message-ID: 4A1014FF.2020608 () free ! fr
[Download RAW message or body]

Hi,

Some Qt styles, like Plastique or Polyester, can draw a border around
statusbar items. In this case, Konqueror checkbox and KHTML Part icons
do not look nice because their borders aren't aligned with the other
status bar items.

Attached patches fix this.

This screenshot http://www.imagebam.com/image/b8d4c336021771 shows
before/after (before is top left, after is bottom right). Note that to
get a border around Konqueror checkbox, you also need the attached
QStatusBar patch (submitted to Qt Software as N253704)

Is it ok to commit?

Aurélien

["khtmlpart-statusbar-icons.diff" (text/x-diff)]

diff --git khtml/khtml_part.cpp khtml/khtml_part.cpp
index 53edddf..491e2b7 100644
--- khtml/khtml_part.cpp  (revision 966843)
+++ khtml/khtml_part.cpp  (working copy)
@@ -729,8 +729,7 @@ bool KHTMLPart::openUrl( const KUrl &url )
     if (userAgent != KProtocolManager::userAgentForHost(QString())) {
       if (!d->m_statusBarUALabel) {
         d->m_statusBarUALabel = new KUrlLabel(d->m_statusBarExtension->statusBar());
-        d->m_statusBarUALabel->setFixedHeight(KHTMLGlobal::iconLoader()->currentSize(KIconLoader::Small));
                
-        d->m_statusBarUALabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Fixed)); +        \
d->m_statusBarUALabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Minimum));  d->m_statusBarUALabel->setUseCursor(false);
         d->m_statusBarExtension->addStatusBarItem(d->m_statusBarUALabel, 0, false);
         d->m_statusBarUALabel->setPixmap(SmallIcon("preferences-web-browser-identification"));
 @@ -1242,8 +1241,7 @@ KJSErrorDlg *KHTMLPart::jsErrorExtension() {
 
   if (!d->m_statusBarJSErrorLabel) {
     d->m_statusBarJSErrorLabel = new \
                KUrlLabel(d->m_statusBarExtension->statusBar());
-    d->m_statusBarJSErrorLabel->setFixedHeight(KIconLoader::global()->currentSize(KIconLoader::Small));
                
-    d->m_statusBarJSErrorLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Fixed)); +    \
d->m_statusBarJSErrorLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Minimum));  d->m_statusBarJSErrorLabel->setUseCursor(false);
     d->m_statusBarExtension->addStatusBarItem(d->m_statusBarJSErrorLabel, 0, false);
     d->m_statusBarJSErrorLabel->setToolTip(i18n("This web page contains coding \
errors.")); @@ -6973,8 +6971,7 @@ void KHTMLPart::walletOpened(KWallet::Wallet \
*wallet) {  d->m_walletForms.clear();
   if (!d->m_statusBarWalletLabel) {
     d->m_statusBarWalletLabel = new KUrlLabel(d->m_statusBarExtension->statusBar());
-    d->m_statusBarWalletLabel->setFixedHeight(KHTMLGlobal::iconLoader()->currentSize(KIconLoader::Small));
                
-    d->m_statusBarWalletLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Fixed)); +    \
d->m_statusBarWalletLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Minimum));  d->m_statusBarWalletLabel->setUseCursor(false);
     d->m_statusBarExtension->addStatusBarItem(d->m_statusBarWalletLabel, 0, false);
     d->m_statusBarWalletLabel->setPixmap(SmallIcon("wallet-open"));
@@ -7181,8 +7178,7 @@ void KHTMLPart::setSuppressedPopupIndicator( bool enable, \
KHTMLPart *originPart  
     if ( enable && !d->m_statusBarPopupLabel ) {
         d->m_statusBarPopupLabel = new KUrlLabel( \
                d->m_statusBarExtension->statusBar() );
-        d->m_statusBarPopupLabel->setFixedHeight( \
                KHTMLGlobal::iconLoader()->currentSize( KIconLoader::Small) );
-        d->m_statusBarPopupLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, \
QSizePolicy::Fixed )); +        d->m_statusBarPopupLabel->setSizePolicy( QSizePolicy( \
QSizePolicy::Fixed, QSizePolicy::Minimum ));  d->m_statusBarPopupLabel->setUseCursor( \
                false );
         d->m_statusBarExtension->addStatusBarItem( d->m_statusBarPopupLabel, 0, \
                false );
         d->m_statusBarPopupLabel->setPixmap( SmallIcon( "window-suppressed") );


["konqueror-statusbar-checkbox.diff" (text/x-diff)]

Index: apps/konqueror/src/konqframestatusbar.cpp
===================================================================
--- apps/konqueror/src/konqframestatusbar.cpp	(revision 966798)
+++ apps/konqueror/src/konqframestatusbar.cpp	(working copy)
@@ -44,22 +44,42 @@
       : QCheckBox( parent ) {}
 protected:
     void paintEvent( QPaintEvent * );
+
+    QSize sizeHint() const
+    {
+        QSize size = connectPixmap().size();
+        // Add some room around the pixmap. Makes it a bit easier to click and
+        // ensure it does not look crowded with styles which draw a frame
+        // around statusbar items.
+        size.rwidth() += 4;
+        return size;
+    }
+
+private:
+    const QPixmap& connectPixmap() const
+    {
+        static QPixmap indicator_connect( UserIcon( "indicator_connect" ) );
+        return indicator_connect;
+    }
+
+    const QPixmap& noConnectPixmap() const
+    {
+        static QPixmap indicator_noconnect( UserIcon( "indicator_noconnect" ) );
+        return indicator_noconnect;
+    }
 };
 
 #define DEFAULT_HEADER_HEIGHT 13
 
 void KonqCheckBox::paintEvent( QPaintEvent * )
 {
-    //static QPixmap indicator_anchor( UserIcon( "indicator_anchor" ) );
-    static QPixmap indicator_connect( UserIcon( "indicator_connect" ) );
-    static QPixmap indicator_noconnect( UserIcon( "indicator_noconnect" ) );
+    QPainter p(this);
 
-   QPainter p(this);
-
-   if (isChecked() || isDown())
-      p.drawPixmap(0,0,indicator_connect);
-   else
-      p.drawPixmap(0,0,indicator_noconnect);
+    const QPixmap &pixmap = (isChecked() || isDown()) ? connectPixmap() : \
noConnectPixmap(); +    p.drawPixmap(
+        (width() - pixmap.width()) / 2,
+        (height() - pixmap.height()) / 2,
+        pixmap);
 }
 
 KonqFrameStatusBar::KonqFrameStatusBar( KonqFrame *_parent )
@@ -83,7 +103,7 @@
     m_pLinkedViewCheckBox = new KonqCheckBox( this );
     m_pLinkedViewCheckBox->setObjectName( "m_pLinkedViewCheckBox" );
     m_pLinkedViewCheckBox->setFocusPolicy(Qt::NoFocus);
-    m_pLinkedViewCheckBox->setSizePolicy(QSizePolicy( QSizePolicy::Fixed, \
QSizePolicy::Fixed )); +    m_pLinkedViewCheckBox->setSizePolicy(QSizePolicy( \
                QSizePolicy::Fixed, QSizePolicy::Minimum ));
     m_pLinkedViewCheckBox->setWhatsThis( i18n("Checking this box on at least two \
                views sets those views as 'linked'. "
                           "Then, when you change directories in one view, the other \
                views "
                           "linked with it will automatically update to show the \
current directory. "


["qstatusbar-draw-border-around-last-item.diff" (text/x-diff)]

From 21c900d2ae38ed8605de06ce5c364dd3bd525f76 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Aurélien Gâteau?= <agateau@kde.org>
Date: Thu, 14 May 2009 23:13:07 +0200
Subject: [PATCH] Make sure the frame of the last item of a statusbar is painted

---
 src/gui/widgets/qstatusbar.cpp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gui/widgets/qstatusbar.cpp b/src/gui/widgets/qstatusbar.cpp
index 65d3c05..833e9e8 100644
--- a/src/gui/widgets/qstatusbar.cpp
+++ b/src/gui/widgets/qstatusbar.cpp
@@ -564,6 +564,7 @@ void QStatusBar::reformat()
         int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight());
         maxH = qMax(maxH, itemH);
     }
+    l->addSpacing(2);
 #ifndef QT_NO_SIZEGRIP
     if (d->resizer) {
         maxH = qMax(maxH, d->resizer->sizeHint().height());
@@ -728,7 +729,7 @@ void QStatusBar::paintEvent(QPaintEvent *event)
         QStatusBarPrivate::SBItem* item = d->items.at(i);
         if (item && item->w->isVisible() && (!haveMessage || item->p)) {
             QRect ir = item->w->geometry().adjusted(-2, -1, 2, 1);
-            if (event->rect().contains(ir)) {
+            if (event->rect().intersects(ir)) {
                 QStyleOption opt(0);
                 opt.rect = ir;
                 opt.palette = palette();
--
1.6.0.4



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic