pDockWidgetTitleBar::pDockWidgetTitleBar( pDockWidget* parent )
    : QToolBar( parent )
{
    Q_ASSERT( parent );
    mDock = parent;
    
    // a fake spacer widget
    QWidget* widget = new QWidget( this );
    QHBoxLayout* hlayout = new QHBoxLayout( widget );
    hlayout->setMargin( 0 );
    hlayout->setSpacing( 0 );
    hlayout->addStretch();
    
    // fake spacer item
    mSpacer = new QWidgetAction( this );
    mSpacer->setDefaultWidget( widget );
    
    setMovable( false );
    setFloatable( false );
    setIconSize( QSize( 12, 12 ) );
    layout()->setSpacing( 0 );
    layout()->setMargin( 2 );
    
    aOrientation = new QAction( this );
    aFloat = new QAction( this );
    aClose = new QAction( this );
    
    addAction( mSpacer );
    addAction( aOrientation );
    addAction( aFloat );
    addAction( aClose );
    
    updateStandardIcons();
    dockWidget_featuresChanged( mDock->features() );
    
    connect( mDock, SIGNAL( featuresChanged( QDockWidget::DockWidgetFeatures ) ), this, SLOT( dockWidget_featuresChanged( QDockWidget::DockWidgetFeatures ) ) );
    connect( aOrientation, SIGNAL( triggered() ), this, SLOT( aOrientation_triggered() ) );
    connect( aFloat, SIGNAL( triggered() ), this, SLOT( aFloat_triggered() ) );
    connect( aClose, SIGNAL( triggered() ), mDock, SLOT( close() ) );
}
Example #2
0
pDockWidgetTitleBar::pDockWidgetTitleBar( QDockWidget* parent )
	: QToolBar( parent )
{
	Q_ASSERT( parent );
	mDock = parent;
	mUseNativePaint = mUseNativePaintDefault;
	
	// a fake spacer widget
	QWidget* spacer = new QWidget( this );
	spacer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ) );
	
	tbOrientation = new pToolButton( this );
	tbOrientation->installEventFilter( this );
	tbFloat = new pToolButton( this );
	tbFloat->installEventFilter( this );
	tbClose = new pToolButton( this );
	tbClose->installEventFilter( this );
	
	addWidget( spacer );
	aOrientation = addWidget( tbOrientation );
	aFloat = addWidget( tbFloat );
	aClose = addWidget( tbClose );
	
	tbOrientation->setDefaultAction( aOrientation );
	tbFloat->setDefaultAction( aFloat );
	tbClose->setDefaultAction( aClose );
	
	setMovable( false );
	setFloatable( false );
	
	updateStyleChange();
	dockWidget_featuresChanged( mDock->features() );
	
	connect( mDock, SIGNAL( featuresChanged( QDockWidget::DockWidgetFeatures ) ), this, SLOT( dockWidget_featuresChanged( QDockWidget::DockWidgetFeatures ) ) );
	connect( aOrientation, SIGNAL( triggered() ), this, SLOT( aOrientation_triggered() ) );
	connect( aFloat, SIGNAL( triggered() ), this, SLOT( aFloat_triggered() ) );
	connect( aClose, SIGNAL( triggered() ), mDock, SLOT( close() ) );
}