WQtToolBarBase.cpp 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

25 26
#include "WMainWindow.h"

27 28
#include "WSettingMenu.h"

29
#include "WQtToolBarBase.h"
30
#include "WQtToolBarBase.moc"
31

32
WQtToolBarBase::WQtToolBarBase( const QString& title, WMainWindow* parent ):
33 34
    QToolBar( title, parent ),
    m_mainWindow( parent )
35 36 37 38 39 40 41
{
    setObjectName( title );

    setAllowedAreas( Qt::AllToolBarAreas );

    setMinimumWidth( 60 );
    setMinimumHeight( 40 );
42

43 44 45 46
    // automatism for toolbar style
    QList< QString > styleOptions;
    styleOptions.push_back( "Icon Only" );
    styleOptions.push_back( "Text Only" );
Alexander Wiebel's avatar
Alexander Wiebel committed
47 48
    styleOptions.push_back( "Text Besides Icon" );
    styleOptions.push_back( "Text Under Icon" );
49 50 51
    styleOptions.push_back( "Follow Style" );
    m_styleOptionMenu = new WSettingMenu( parent, "qt4gui/" + windowTitle().toStdString() + "toolbarStyle",
                                                  title.toStdString(),
52
                                                  "Allows one to change the style of toolbars.",
53 54 55 56
                                                  0,
                                                  styleOptions );
    connect( m_styleOptionMenu, SIGNAL( change( unsigned int ) ), this, SLOT( handleStyleUpdate( unsigned int ) ) );
    handleStyleUpdate( m_styleOptionMenu->get() );
57 58 59 60 61
}

WQtToolBarBase::~WQtToolBarBase()
{
    // cleanup
62
    delete m_styleOptionMenu;
63 64 65 66
}

QMenu* WQtToolBarBase::getStyleMenu( QString title ) const
{
67 68 69
    m_styleOptionMenu->setTitle( title );
    return m_styleOptionMenu;
}
70

71 72 73
void WQtToolBarBase::handleStyleUpdate( unsigned int index )
{
    setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( index ) );
74 75
}