WQtCombinerToolbar.cpp 3.08 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 25 26 27 28
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------

#include <list>

#include <QtGui/QAction>
#include <QtGui/QPushButton>
29
#include <QtGui/QLabel>
30 31 32
#include <QtGui/QMenu>

#include "../../common/WPreferences.h"
33 34
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleCombiner.h"
35 36 37 38 39 40

#include "WMainWindow.h"
#include "WQtToolBar.h"

#include "WQtCombinerToolbar.h"

41
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerActionList& compatibles )
42
    : QToolBar( "Compatible Modules", parent ),
43
      m_parent( parent )
44 45 46
{
    // setup toolbar
    setAllowedAreas( Qt::AllToolBarAreas );
47
    setObjectName( QString( "Compatible Modules" ) );
48

49 50 51
    setMinimumWidth( 50 );
    setMinimumHeight( 30 );

52 53 54 55 56 57 58 59 60 61 62
    // this sets the toolbar style
    int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
    WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
    if ( ( compToolBarStyle < 0 ) || ( compToolBarStyle > 3 ) ) // ensure a valid value
    {
        compToolBarStyle = 0;
    }

    // cast and set
    setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) );

63
    // create the list of actions possible
64
    addActions( compatibles );
65 66
}

67 68 69
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent )
    : QToolBar( "Compatible Modules", parent ),
      m_parent( parent )
70
{
71 72
    // setup toolbar
    setAllowedAreas( Qt::AllToolBarAreas );
73

74 75 76 77
    // this sets the toolbar style
    int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
    WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
    if ( ( compToolBarStyle < 0 ) || ( compToolBarStyle > 3 ) ) // ensure a valid value
78
    {
79
        compToolBarStyle = 0;
80
    }
81 82 83 84 85 86 87

    // cast and set
    setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) );
}

WQtCombinerToolbar::~WQtCombinerToolbar()
{
88
}
89 90 91 92 93 94

void WQtCombinerToolbar::makeEmpty()
{
    clear();
}

95
void WQtCombinerToolbar::updateButtons( const WQtCombinerActionList& compatibles )
96 97
{
    clear();
98
    addActions( compatibles );
99
}
100