1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Merge pull request #109 from teo/master

Settings Dialog UX changes
This commit is contained in:
Christian Muehlhaeuser
2012-08-02 12:23:27 -07:00
11 changed files with 126 additions and 247 deletions

View File

@@ -70,7 +70,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
AudioControls.cpp AudioControls.cpp
SettingsDialog.cpp SettingsDialog.cpp
DiagnosticsDialog.cpp DiagnosticsDialog.cpp
SettingsListDelegate.cpp
TomahawkWindow.cpp TomahawkWindow.cpp
LoadXSPFDialog.cpp LoadXSPFDialog.cpp
SocialWidget.cpp SocialWidget.cpp

View File

@@ -3,6 +3,7 @@
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -28,6 +29,7 @@
#include <QtNetwork/QNetworkProxy> #include <QtNetwork/QNetworkProxy>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QSizeGrip> #include <QtGui/QSizeGrip>
#include <QtGui/QToolBar>
#include "AtticaManager.h" #include "AtticaManager.h"
#include "AclRegistry.h" #include "AclRegistry.h"
@@ -39,7 +41,6 @@
#include "ExternalResolverGui.h" #include "ExternalResolverGui.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#include "utils/GuiHelpers.h" #include "utils/GuiHelpers.h"
#include "SettingsListDelegate.h"
#include "accounts/AccountDelegate.h" #include "accounts/AccountDelegate.h"
#include "database/Database.h" #include "database/Database.h"
#include "network/Servent.h" #include "network/Servent.h"
@@ -72,11 +73,23 @@ SettingsDialog::SettingsDialog( QWidget *parent )
TomahawkSettings* s = TomahawkSettings::instance(); TomahawkSettings* s = TomahawkSettings::instance();
TomahawkUtils::unmarginLayout( layout() ); TomahawkUtils::unmarginLayout( layout() );
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
#ifdef Q_WS_X11
ui->stackedWidget->setContentsMargins( 4, 4, 4, 4 );
#else
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
#endif
ui->checkBoxReporter->setChecked( s->crashReporterEnabled() ); ui->checkBoxReporter->setChecked( s->crashReporterEnabled() );
ui->checkBoxHttp->setChecked( s->httpEnabled() ); ui->checkBoxHttp->setChecked( s->httpEnabled() );
QFrame *sepLine = new QFrame( this );
sepLine->setFrameShape( QFrame::HLine );
sepLine->setFrameShadow( QFrame::Sunken );
ui->horizontalLayout->insertWidget( 0, sepLine );
m_toolBar = new QToolBar( tr( "Tomahawk Settings" ), this );
ui->horizontalLayout->insertWidget( 0, m_toolBar );
m_toolBar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
//Network settings //Network settings
TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode(); TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
@@ -102,8 +115,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
createIcons(); createIcons();
#ifdef Q_WS_X11 #ifdef Q_WS_X11
ui->listWidget->setFrameShape( QFrame::StyledPanel );
ui->listWidget->setFrameShadow( QFrame::Sunken );
setContentsMargins( 4, 4, 4, 4 ); setContentsMargins( 4, 4, 4, 4 );
#else #else
setContentsMargins( 0, 4, 4, 4 ); setContentsMargins( 0, 4, 4, 4 );
@@ -210,9 +221,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
connect( ui->upnpRadioButton, SIGNAL( toggled(bool) ), SLOT( toggleRemoteMode() ) ); connect( ui->upnpRadioButton, SIGNAL( toggled(bool) ), SLOT( toggleRemoteMode() ) );
connect( ui->enableProxyCheckBox, SIGNAL( toggled(bool) ), SLOT( toggleProxyEnabled() ) ); connect( ui->enableProxyCheckBox, SIGNAL( toggled(bool) ), SLOT( toggleProxyEnabled() ) );
connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) ); connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
ui->listWidget->setCurrentRow( 0 );
ui->listWidget->setItemDelegate(new SettingsListDelegate());
} }
@@ -280,56 +288,59 @@ SettingsDialog::serventReady()
void void
SettingsDialog::createIcons() SettingsDialog::createIcons()
{ {
/// Not fun but QListWidget sucks. Do our max-width calculation manually
/// so the icons arre lined up.
// Resolvers is the longest string... in english. fml.
ensurePolished(); ensurePolished();
int maxlen = 0; m_settingsGroup = new QActionGroup( m_toolBar );
QFontMetrics fm( font() );
QListWidgetItem *accountsButton = new QListWidgetItem( ui->listWidget );
accountsButton->setIcon( QIcon( RESPATH "images/account-settings.png" ) );
accountsButton->setText( tr( "Services" ) );
accountsButton->setTextAlignment( Qt::AlignHCenter );
accountsButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = fm.width( accountsButton->text() );
QListWidgetItem *musicButton = new QListWidgetItem( ui->listWidget ); QAction *accountsAction = new QAction( QIcon( RESPATH "images/account-settings.png" ),
musicButton->setIcon( QIcon( RESPATH "images/music-settings.png" ) ); tr( "Services" ),
musicButton->setText( tr( "Collection" ) ); m_toolBar );
musicButton->setTextAlignment( Qt::AlignHCenter ); accountsAction->setCheckable( true );
musicButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); accountsAction->setToolTip( tr( "<b>Services</b><br>"
maxlen = qMax( fm.width( musicButton->text() ), maxlen ); "Configure the accounts and services used by Tomahawk "
"to search and retrieve music, find your friends and "
"update your status." ) );
m_settingsGroup->addAction( accountsAction );
QListWidgetItem *advancedButton = new QListWidgetItem( ui->listWidget ); QAction *musicAction = new QAction( QIcon( RESPATH "images/music-settings.png" ),
advancedButton->setIcon( QIcon( RESPATH "images/advanced-settings.png" ) ); tr( "Collection" ),
advancedButton->setText( tr( "Advanced" ) ); m_toolBar );
advancedButton->setTextAlignment( Qt::AlignHCenter ); musicAction->setCheckable( true );
advancedButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); musicAction->setToolTip( tr( "<b>Collection</b><br>"
maxlen = qMax( fm.width( advancedButton->text() ), maxlen ); "Manage how Tomahawk finds music on your computer." ) );
m_settingsGroup->addAction( musicAction );
maxlen += 15; // padding
accountsButton->setSizeHint( QSize( maxlen, 60 ) );
musicButton->setSizeHint( QSize( maxlen, 60 ) );
advancedButton->setSizeHint( QSize( maxlen, 60 ) );
#ifndef Q_WS_MAC QAction *advancedAction = new QAction( QIcon( RESPATH "images/advanced-settings.png" ),
// doesn't listen to sizehint... tr( "Advanced" ),
ui->listWidget->setFixedWidth( maxlen + 8 ); m_toolBar );
#endif advancedAction->setCheckable( true );
advancedAction->setToolTip( tr( "<b>Advanced</b><br>"
"Configure Tomahawk's advanced settings, including "
"network connectivity settings, browser interaction "
"and more." ) );
m_settingsGroup->addAction( advancedAction );
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem*, QListWidgetItem* ) ), SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) ); m_settingsGroup->setExclusive( true );
m_toolBar->addActions( m_settingsGroup->actions() );
connect( m_settingsGroup, SIGNAL( triggered( QAction * ) ),
this, SLOT( changePage( QAction * ) ) );
accountsAction->setChecked( true );
changePage( accountsAction );
} }
void void
SettingsDialog::changePage( QListWidgetItem* current, QListWidgetItem* previous ) SettingsDialog::changePage( QAction *action )
{ {
if ( !current ) int index = m_settingsGroup->actions().indexOf( action );
current = previous; if( ui->stackedWidget->currentIndex() != index )
{
ui->stackedWidget->setCurrentIndex( ui->listWidget->row(current) ); ui->stackedWidget->setCurrentIndex( index );
}
} }

View File

@@ -3,6 +3,7 @@
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,8 @@
#include <QtGui/QDialog> #include <QtGui/QDialog>
#include <QtCore/QModelIndex> #include <QtCore/QModelIndex>
#include <QtGui/QActionGroup>
#include <QtGui/QToolBar>
#include "config.h" #include "config.h"
@@ -94,7 +97,7 @@ private slots:
void updateScanOptionsView(); void updateScanOptionsView();
void changePage( QListWidgetItem*, QListWidgetItem* ); void changePage( QAction *action );
void serventReady(); void serventReady();
void aclEntryClearButtonClicked(); void aclEntryClearButtonClicked();
@@ -106,6 +109,9 @@ private:
Ui_StackedSettingsDialog* ui; Ui_StackedSettingsDialog* ui;
QToolBar *m_toolBar;
QActionGroup *m_settingsGroup;
ProxyDialog m_proxySettings; ProxyDialog m_proxySettings;
bool m_rejected; bool m_rejected;
bool m_restartRequired; bool m_restartRequired;

View File

@@ -1,74 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Michael Zanetti <mzanetti@kde.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SettingsListDelegate.h"
#include "utils/Logger.h"
#include <QPainter>
#include <QIcon>
#include <QApplication>
SettingsListDelegate::SettingsListDelegate(QObject *parent) :
QStyledItemDelegate(parent)
{
}
void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
painter->save();
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, QModelIndex() );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
#if defined(Q_WS_MAC) || defined(Q_WS_WIN)
// On mac draw our own selection rect as we don't get one from osx (around the whole icon or around just text)
if ( opt.state & QStyle::State_Selected )
{
painter->setRenderHint( QPainter::Antialiasing );
QPainterPath p;
p.addRoundedRect( opt.rect.adjusted( 2, 1, -1, -1 ), 5, 5 );
QColor fill( 214, 214, 214 );
QColor border( 107, 107, 107 );
painter->setPen( border );
painter->drawPath( p );
painter->fillPath( p, fill );
}
#else
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
{
painter->setPen( option.palette.color( QPalette::HighlightedText ) );
}
#endif
int horizontalOffset = ( option.rect.width() - option.decorationSize.width() ) /2;
QRect iconRect = option.rect.adjusted( horizontalOffset, 6, -horizontalOffset, -option.rect.height() + 6 + option.decorationSize.height() );
QPixmap avatar = index.data( Qt::DecorationRole ).value<QIcon>().pixmap( iconRect.size() );
painter->drawPixmap( iconRect, avatar );
QRect textRect = option.rect.adjusted( 6, iconRect.height() + 8, -6, 0 );
QString text = painter->fontMetrics().elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, textRect.width() );
QTextOption to( Qt::AlignHCenter );
painter->drawText( textRect, text, to );
painter->restore();
}

View File

@@ -1,39 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Michael Zanetti <mzanetti@kde.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SETTINGSLISTDELEGATE_H
#define SETTINGSLISTDELEGATE_H
#include <QStyledItemDelegate>
class SettingsListDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit SettingsListDelegate(QObject *parent = 0);
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
public slots:
};
#endif // SETTINGSLISTDELEGATE_H

View File

@@ -18,74 +18,11 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QVBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoScroll">
<bool>true</bool>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="spacing">
<number>1</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="accountsPage"> <widget class="QWidget" name="accountsPage">
<layout class="QVBoxLayout" name="verticalLayout_11"> <layout class="QVBoxLayout" name="verticalLayout_11">
@@ -93,9 +30,12 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="groupBox_4"> <widget class="QFrame" name="frame_4">
<property name="title"> <property name="frameShape">
<string>Internet Services</string> <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<property name="margin"> <property name="margin">
@@ -153,11 +93,17 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QFrame" name="frame_2">
<property name="title"> <property name="frameShape">
<string>Local Music Information</string> <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_17"> <layout class="QVBoxLayout" name="verticalLayout_17">
<property name="margin">
<number>2</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
@@ -234,17 +180,23 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="groupBoxNetworkAdvanced"> <widget class="QFrame" name="frameNetworkAdvanced">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="title"> <property name="frameShape">
<string>Advanced Settings</string> <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<property name="spacing">
<number>-1</number>
</property>
<property name="margin"> <property name="margin">
<number>2</number> <number>2</number>
</property> </property>
@@ -342,10 +294,13 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>10</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@@ -378,10 +333,13 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>10</height>
</size> </size>
</property> </property>
</spacer> </spacer>

View File

@@ -202,11 +202,7 @@ TomahawkWindow::saveSettings()
void void
TomahawkWindow::applyPlatformTweaks() TomahawkWindow::applyPlatformTweaks()
{ {
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle, qApp->setStyle( new ProxyStyle() );
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() );
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac( true ); setUnifiedTitleAndToolBarOnMac( true );

View File

@@ -84,6 +84,7 @@ ContextWidget::ContextWidget( QWidget* parent )
QPalette whitePal = ui->toggleButton->palette(); QPalette whitePal = ui->toggleButton->palette();
whitePal.setColor( QPalette::Foreground, Qt::white ); whitePal.setColor( QPalette::Foreground, Qt::white );
ui->toggleButton->setPalette( whitePal ); ui->toggleButton->setPalette( whitePal );
ui->toggleButton->setCursor( Qt::PointingHandCursor );
QFont boldFont = ui->toggleButton->font(); QFont boldFont = ui->toggleButton->font();
boldFont.setPixelSize( 12 ); boldFont.setPixelSize( 12 );

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -76,9 +77,29 @@ ProxyStyle::drawControl( ControlElement ce, const QStyleOption* opt, QPainter* p
if ( !splitter->sizes().contains( 0 ) ) if ( !splitter->sizes().contains( 0 ) )
{ {
p->setPen( QColor( 0x8c, 0x8c, 0x8c ) ); p->setPen( QColor( 0x8c, 0x8c, 0x8c ) );
p->drawLine( opt->rect.topLeft(), opt->rect.bottomRight() ); // We must special-case this because of the AnimatedSplitterHandle which has a
// SizeHint of 0,0.
if( splitter->orientation() == Qt::Vertical )
p->drawLine( opt->rect.topLeft(), opt->rect.topRight() );
else
p->drawLine( opt->rect.topLeft(), opt->rect.bottomRight() );
} }
} }
else else
QProxyStyle::drawControl( ce, opt, p, w ); QProxyStyle::drawControl( ce, opt, p, w );
} }
QSize
ProxyStyle::sizeFromContents( QStyle::ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget ) const
{
if( type == CT_Splitter )
{
const QSplitter* splitter = qobject_cast< const QSplitter* >( widget );
if( splitter->orientation() == Qt::Horizontal )
return QSize( 1, size.height() );
else
return QSize( size.width(), 1 );
}
else
return QProxyStyle::sizeFromContents( type, option, size, widget );
}

View File

@@ -31,6 +31,7 @@ public:
virtual void drawPrimitive( PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const; virtual void drawPrimitive( PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const;
virtual void drawControl( ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const; virtual void drawControl( ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const;
virtual QSize sizeFromContents( ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget ) const;
}; };
#endif // PROXYSTYLE_H #endif // PROXYSTYLE_H

View File

@@ -298,9 +298,8 @@ AnimatedSplitterHandle::sizeHint() const
m_lastCount = splitter()->count(); m_lastCount = splitter()->count();
} }
// sizeHint is 0,0 if widget below handle has size 0 or is hidden // Since we are in an AnimatedSplitter, we always return 0,0 for SizeHint, simply
if ( splitter()->widget( m_indexInSplitter )->height() == 0 ) // because we know there's going to be a handle in the bottom widget to move the
return QSize( 0, 0 ); // splitter.
else return QSize( 0, 0 );
return QSize( 1, 1 );
} }