[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KPropertiesDialog needs a fix
From: Aurélien Gâteau <aurelien.gateau () free ! fr>
Date: 2007-12-24 0:09:58
Message-ID: fkmtcl$f3$1 () ger ! gmane ! org
[Download RAW message or body]
Rafael Fernández López wrote:
> Hi all,
>
> Tonight I've been trying to fix KPropertiesDialog. Reminding:
>
> http://media.ereslibre.es/2007/10/propertiesdialog.png
[snip]
> So now, there are some possibilities:
[snip]
> - 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).
Attached patch does this: it makes KPropertiesDialog inherits from KDialog
instead of KPageDialog and set a QTabWidget as the main widget.
What do you think about this?
Aurélien
["kio_kpropertiesdialog_qtabwidget.diff" (text/x-diff)]
Index: kfile/kpropertiesdialog.h
===================================================================
--- kfile/kpropertiesdialog.h (révision 751500)
+++ kfile/kpropertiesdialog.h (copie de travail)
@@ -54,7 +54,7 @@
* If you are looking for more flexibility, see KFileMetaInfo and
* KFileMetaInfoWidget.
*/
-class KIO_EXPORT KPropertiesDialog : public KPageDialog
+class KIO_EXPORT KPropertiesDialog : public KDialog
{
Q_OBJECT
@@ -285,6 +285,8 @@
*/
void setFileNameReadOnly( bool ro );
+ void addPage(QWidget* page, const QString& caption);
+
public Q_SLOTS:
/**
* Called when the user presses 'Ok'.
@@ -350,8 +352,7 @@
public:
/**
* Constructor
- * To insert tabs into the properties dialog, use the add methods provided by
- * KPageDialog (the properties dialog is a KPageDialog).
+ * To insert tabs into the properties dialog, use KPropertiesDialog::addPage().
*/
KPropertiesDialogPlugin( KPropertiesDialog *_props );
virtual ~KPropertiesDialogPlugin();
Index: kfile/kpropertiesdialog.cpp
===================================================================
--- kfile/kpropertiesdialog.cpp (révision 751500)
+++ kfile/kpropertiesdialog.cpp (copie de travail)
@@ -184,7 +184,13 @@
KPropertiesDialog *q;
bool m_aborted:1;
QWidget* fileSharePage;
+
/**
+ * The tab widget holding our pages
+ */
+ QTabWidget* m_tabWidget;
+
+ /**
* The URL of the props dialog (when shown for only one file)
*/
KUrl m_singleUrl;
@@ -205,7 +211,7 @@
KPropertiesDialog::KPropertiesDialog (const KFileItem& item,
QWidget* parent)
- : KPageDialog(parent), d(new KPropertiesDialogPrivate(this))
+ : KDialog(parent), d(new KPropertiesDialogPrivate(this))
{
setCaption( i18n( "Properties for %1" , KIO::decodeFileName(item.url().fileName())) );
@@ -220,7 +226,7 @@
KPropertiesDialog::KPropertiesDialog (const QString& title,
QWidget* parent)
- : KPageDialog(parent), d(new KPropertiesDialogPrivate(this))
+ : KDialog(parent), d(new KPropertiesDialogPrivate(this))
{
setCaption( i18n( "Properties for %1", title ) );
@@ -229,7 +235,7 @@
KPropertiesDialog::KPropertiesDialog(const KFileItemList& _items,
QWidget* parent)
- : KPageDialog(parent), d(new KPropertiesDialogPrivate(this))
+ : KDialog(parent), d(new KPropertiesDialogPrivate(this))
{
if ( _items.count() > 1 )
setCaption( i18np( "Properties for 1 item", "Properties for %1 Selected Items", _items.count() ) );
@@ -247,7 +253,7 @@
KPropertiesDialog::KPropertiesDialog (const KUrl& _url,
QWidget* parent)
- : KPageDialog(parent), d(new KPropertiesDialogPrivate(this))
+ : KDialog(parent), d(new KPropertiesDialogPrivate(this))
{
setCaption( i18n( "Properties for %1" , KIO::decodeFileName(_url.fileName())) );
@@ -263,7 +269,7 @@
KPropertiesDialog::KPropertiesDialog (const KUrl& _tempUrl, const KUrl& _currentDir,
const QString& _defaultName,
QWidget* parent)
- : KPageDialog(parent), d(new KPropertiesDialogPrivate(this))
+ : KDialog(parent), d(new KPropertiesDialogPrivate(this))
{
setCaption( i18n( "Properties for %1" , KIO::decodeFileName(_tempUrl.fileName())) );
@@ -336,7 +342,8 @@
void KPropertiesDialog::KPropertiesDialogPrivate::init()
{
- q->setFaceType(KPageDialog::Tabbed);
+ m_tabWidget = new QTabWidget();
+ q->setMainWidget(m_tabWidget);
q->setButtons(KDialog::Ok | KDialog::Cancel);
q->setDefaultButton(KDialog::Ok);
@@ -382,6 +389,19 @@
saveDialogSize(group, KConfigBase::Persistent);
}
+void KPropertiesDialog::addPage(QWidget* page, const QString& caption)
+{
+ // Insert the page inside an intermediate widget to ensure we have the
+ // correct margin inside the tab.
+ QWidget* container = new QWidget();
+ QVBoxLayout* layout = new QVBoxLayout(container);
+ layout->setMargin(KDialog::marginHint());
+ page->setParent(container);
+ layout->addWidget(page);
+
+ d->m_tabWidget->addTab(container, caption);
+}
+
void KPropertiesDialog::insertPlugin (KPropertiesDialogPlugin* plugin)
{
connect (plugin, SIGNAL (changed ()),
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic