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

List:       kde-core-devel
Subject:    KPropertiesDialog needs a fix
From:       Rafael =?utf-8?q?Fern=C3=A1ndez_L=C3=B3pez?= <ereslibre () kde ! org>
Date:       2007-12-22 4:23:30
Message-ID: 200712220523.34309.ereslibre () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi all,

Tonight I've been trying to fix KPropertiesDialog. Reminding:

http://media.ereslibre.es/2007/10/propertiesdialog.png

This is just unacceptable. This will be a very used dialog and it just looks 
inconsistent, broken. My attempt to fix it has been:

http://media.ereslibre.es/2007/12/propsdialog1.png
http://media.ereslibre.es/2007/12/propsdialog2.png

As you can see, the top right is not painted correctly, and I would like to 
know if someone could give a hand here. I would be pleased to see this fixed.

Attached the patch I've been working on.

Now, there are some problems. For example, when running "kcmshell4 style", you 
get:

http://media.ereslibre.es/2007/12/styledialog1.png

What looks actually strange to me. Look at the border coming from the title 
that shouldn't be drawn. I wonder why from the title we are creating a tabbar 
just for one widget (the one being shown).

So now, there are some possibilities:

- Some really good and incredible person (:P) could take a look at my patch 
and how to make the rest of the widget be drawn correctly.

- We could consider using QTabWidget instead of QTabBar for the 
KPropertiesDialog (that is created after all the stuff on 
kdelibs/kdeui/paged/kpageview_p.cpp).

- We could fix the modules in where we add a widget that should be used for 
tabbing and there is only one widget being added.


So, that's all for now folks, 
Rafael Fernández López

GPG Fingerprint: B9F4 4730 43F8 FFDD CC5E BA8E 724E 406E 3F01 D070

["kdelibs.diff" (text/x-diff)]

Index: kdeui/paged/kpageview_p.cpp
===================================================================
--- kdeui/paged/kpageview_p.cpp	(revisión: 751398)
+++ kdeui/paged/kpageview_p.cpp	(copia de trabajo)
@@ -198,15 +198,16 @@ KPageTabbedView::KPageTabbedView( QWidge
 
   setFrameShape( NoFrame );
 
-  QGridLayout *layout = new QGridLayout( this );
+  QHBoxLayout *layout = new QHBoxLayout( this );
   layout->setMargin( 0 );
   layout->setSpacing( 0 );
 
   mTabBar = new QTabBar( this );
+  mTabBar->setDrawBase(false);
   connect( mTabBar, SIGNAL( currentChanged( int ) ), this, SLOT( currentPageChanged( \
int ) ) );  
-  layout->addWidget( mTabBar, 0, 0, Qt::AlignBottom );
-  layout->setColumnStretch( 1, 1 );
+  layout->addWidget( mTabBar );
+  layout->addStretch( 1 );
 }
 
 void KPageTabbedView::setModel( QAbstractItemModel *model )
Index: kdeui/paged/kpagewidgetmodel.cpp
===================================================================
--- kdeui/paged/kpagewidgetmodel.cpp	(revisión: 751398)
+++ kdeui/paged/kpagewidgetmodel.cpp	(copia de trabajo)
@@ -21,9 +21,14 @@
 
 #include "kpagewidgetmodel.h"
 #include "kpagewidgetmodel_p.h"
+#include "kdialog.h"
 
+#include <QPainter>
+#include <QStyleOption>
 #include <QPointer>
 #include <QWidget>
+#include <QBoxLayout>
+#include <QApplication>
 
 #include <kicon.h>
 
@@ -50,10 +55,53 @@ class KPageWidgetItem::Private
     bool enabled : 1;
 };
 
+
+class SpecialWidget
+    : public QWidget
+{
+public:
+    SpecialWidget(QWidget *innerWidget, QWidget *parent = 0)
+        : QWidget(parent)
+    {
+        QStyleOptionTabWidgetFrame opt;
+        opt.initFrom(this);
+
+        QVBoxLayout *layout = new QVBoxLayout(this);
+        layout->setMargin(KDialog::marginHint() + \
QApplication::style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt)); +        \
layout->setSpacing(KDialog::spacingHint()); +        setLayout(layout);
+        layout->addWidget(innerWidget);
+    }
+
+    virtual ~SpecialWidget()
+    {
+    }
+
+protected:
+    void paintEvent(QPaintEvent *event)
+    {
+        QWidget::paintEvent(event);
+
+        QPainter p(this);
+        QStyleOptionTabWidgetFrame opt;
+        opt.initFrom(this);
+
+        QRect rect = opt.rect;
+        int overlap = \
QApplication::style()->pixelMetric(QStyle::PM_TabBarTabOverlap, &opt) + +             \
QApplication::style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &opt); +        \
opt.rect = opt.rect.adjusted(0, -overlap, 0, 0); +
+        QApplication::style()->drawPrimitive(QStyle::PE_FrameTabWidget, &opt, &p);
+
+        p.end();
+    }
+};
+
 KPageWidgetItem::KPageWidgetItem( QWidget *widget )
   : QObject( 0 ), d( new Private )
 {
-  d->widget = widget;
+  QWidget *parent = dynamic_cast<QWidget*>(widget->parent());
+  d->widget = new SpecialWidget(widget, parent);
 
   /**
    * Hide the widget, otherwise when the widget has this KPageView as
@@ -67,7 +115,8 @@ KPageWidgetItem::KPageWidgetItem( QWidge
 KPageWidgetItem::KPageWidgetItem( QWidget *widget, const QString &name )
   : QObject( 0 ), d( new Private )
 {
-  d->widget = widget;
+  QWidget *parent = dynamic_cast<QWidget*>(widget->parent());
+  d->widget = new SpecialWidget(widget, parent);
   d->name = name;
 
   /**
Index: kdeui/paged/kpageview.cpp
===================================================================
--- kdeui/paged/kpageview.cpp	(revisión: 751398)
+++ kdeui/paged/kpageview.cpp	(copia de trabajo)
@@ -49,6 +49,8 @@ void KPageViewPrivate::_k_rebuildGui()
 
   Q_ASSERT( view );
 
+  view->setAutoFillBackground(false);
+
   view->setSelectionBehavior( QAbstractItemView::SelectItems );
   view->setSelectionMode( QAbstractItemView::SingleSelection );
 
@@ -67,6 +69,9 @@ void KPageViewPrivate::_k_rebuildGui()
 
     titleWidget->setVisible(q->showPageHeader());
 
+    layout->setSpacing(0);
+    layout->setMargin(0);
+
     Qt::Alignment alignment = q->viewPosition();
   if ( alignment & Qt::AlignTop )
     layout->addWidget( view, 0, 1 );


["signature.asc" (application/pgp-signature)]

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

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