~ubuntu-branches/ubuntu/precise/openwalnut/precise

« back to all changes in this revision

Viewing changes to src/qt4gui/qt4/commandPrompt/WQtCommandPromptToolbar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Eichelbaum
  • Date: 2011-06-21 10:26:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110621102654-rq0zf436q949biih
Tags: upstream-1.2.5
ImportĀ upstreamĀ versionĀ 1.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
10
// OpenWalnut is free software: you can redistribute it and/or modify
 
11
// it under the terms of the GNU Lesser General Public License as published by
 
12
// the Free Software Foundation, either version 3 of the License, or
 
13
// (at your option) any later version.
 
14
//
 
15
// OpenWalnut is distributed in the hope that it will be useful,
 
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
// GNU Lesser General Public License for more details.
 
19
//
 
20
// You should have received a copy of the GNU Lesser General Public License
 
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#include <QtGui/QAction>
 
26
#include <QtGui/QLabel>
 
27
 
 
28
#include "../WMainWindow.h"
 
29
 
 
30
#include "WQtCommandPrompt.h"
 
31
 
 
32
#include "WQtCommandPromptToolbar.h"
 
33
#include "WQtCommandPromptToolbar.moc"
 
34
 
 
35
WQtCommandPromptToolbar::WQtCommandPromptToolbar( const QString& title, WMainWindow* parent ):
 
36
    QToolBar( title, parent ),
 
37
    m_mainWindow( parent )
 
38
{
 
39
    setObjectName( title );
 
40
    this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
 
41
    setMinimumWidth( 50 );
 
42
    setMinimumHeight( 20 );
 
43
    setVisible( false );
 
44
 
 
45
    // toggle it using ":"
 
46
    QList< QKeySequence > commandPromptShortcut;
 
47
    commandPromptShortcut.append( QKeySequence( Qt::Key_Colon ) );
 
48
    toggleViewAction()->setShortcuts( commandPromptShortcut );
 
49
 
 
50
    QLabel* label = new QLabel( this );
 
51
    label->setText( "<b>:</b>" );
 
52
    label->setStyleSheet( "background: #080808;" );
 
53
    addWidget( label );
 
54
 
 
55
    m_prompt = new WQtCommandPrompt( this );
 
56
    addWidget( m_prompt );
 
57
 
 
58
    // some nice style
 
59
    // TODO(ebaum): make this configurable
 
60
    setStyleSheet( "background: #080808;"
 
61
                   "border: 2px solid #080808;"
 
62
                   "margin: 0px;"
 
63
                   "padding: 0px;"
 
64
                   "spacing: 0;"
 
65
                   "color: white;"
 
66
    );
 
67
 
 
68
    // if the toolbar is triggered:
 
69
    connect( toggleViewAction(), SIGNAL( triggered( bool ) ), this, SLOT( show() ) );
 
70
    connect( m_prompt, SIGNAL( done() ), this, SLOT( exit() ) );
 
71
}
 
72
 
 
73
WQtCommandPromptToolbar::~WQtCommandPromptToolbar()
 
74
{
 
75
    // cleanup
 
76
}
 
77
 
 
78
void WQtCommandPromptToolbar::show()
 
79
{
 
80
    setVisible( true );
 
81
    m_prompt->setFocus();
 
82
}
 
83
 
 
84
void WQtCommandPromptToolbar::exit()
 
85
{
 
86
    setVisible( false );
 
87
}
 
88