Developer Documentation

StatusBar.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44
45
46 //=============================================================================
47 //
48 // CLASS CoreWidget - IMPLEMENTATION
49 //
50 //=============================================================================
51
52
53 //== INCLUDES =================================================================
54
55 // -------------------- mview
56 #include "CoreWidget.hh"
57
58 //== IMPLEMENTATION ==========================================================
59
60
61
62 void CoreWidget::statusMessage(QString _message, int _timeout) {
63 statusBar_->showMessage(_message,_timeout);
64 }
65
66
67 //=============================================================================
68
69
70 void CoreWidget::setupStatusBar()
71 {
72 statusBar_ = new ColorStatusBar();
73
74 setStatusBar( statusBar_ );
75
76 QPixmap pix;
77 pix.load(OpenFlipper::Options::iconDirStr() +
78 OpenFlipper::Options::dirSeparator() +
79 "status_green.png");
80
81
82 statusIcon_ = new QLabel();
83 statusIcon_->setPixmap(pix.scaled(12,12,Qt::KeepAspectRatio,Qt::SmoothTransformation));
84
85 statusBar_->addPermanentWidget(statusIcon_);
86
87 if ( ! OpenFlipperSettings().value("Core/Gui/StatusBar/hidden",false).toBool() )
88 statusBar()->show();
89 else
90 statusBar()->hide();
91 }
92
93 //=============================================================================
94
95 void CoreWidget::clearStatusMessage()
96 {
97 statusBar_->clearMessage();
98 }
99
100 //=============================================================================
101
102 void CoreWidget::setStatus( ApplicationStatus::applicationStatus _status)
103 {
104 QPixmap pix;
105
106 switch (_status) {
107 case ApplicationStatus::READY :
108 pix.load(OpenFlipper::Options::iconDirStr() +
109 OpenFlipper::Options::dirSeparator() +
110 "status_green.png");
111 break;
112 case ApplicationStatus::PROCESSING :
113 pix.load(OpenFlipper::Options::iconDirStr() +
114 OpenFlipper::Options::dirSeparator() +
115 "status_yellow.png");
116 break;
117 case ApplicationStatus::BLOCKED :
118 pix.load(OpenFlipper::Options::iconDirStr() +
119 OpenFlipper::Options::dirSeparator() +
120 "status_red.png");
121 break;
122 }
123
124 statusIcon_->setPixmap(pix.scaled(12,12,Qt::KeepAspectRatio,Qt::SmoothTransformation));
125
126 }
127
128 void CoreWidget::addWidgetToStatusbar(QWidget* _widget){
129
130 statusBar_->addPermanentWidget(_widget);
131
132 statusBar_->removeWidget(statusIcon_);
133 statusBar_->addPermanentWidget(statusIcon_);
134 statusIcon_->show();
135
136
137 }
138
139 //-----------------------------------------------------------------------------
140
143 void
144 CoreWidget::toggleStatusBar() {
145
146 //toggle
147 showStatusBar( OpenFlipperSettings().value("Core/Gui/StatusBar/hidden",false).toBool() );
148 }
149
150 //-----------------------------------------------------------------------------
151
154 void
155 CoreWidget::showStatusBar( bool _state ) {
156
157 //toggle
158 OpenFlipperSettings().setValue("Core/Gui/StatusBar/hidden",!_state);
159
160 if ( OpenFlipperSettings().value("Core/Gui/StatusBar/hidden",false).toBool() ){
161 statusBar_->setVisible(false);
162 }else{
163 statusBar_->setVisible(true);
164 }
165 emit statusBarVisChanged(_state);
166 }
167
168 //=============================================================================
OpenFlipperSettings
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
Definition: GlobalOptions.cc:1038
ApplicationStatus::READY
Status is ready (green light)
Definition: StatusbarInterface.hh:65
ApplicationStatus::BLOCKED
Status is processing and blocked system will not allow interaction (red light)
Definition: StatusbarInterface.hh:67
CoreWidget::toggleStatusBar
void toggleStatusBar()
Change visibility of the Status Bar.
Definition: StatusBar.cc:144
OpenFlipperQSettings::setValue
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
Definition: OpenFlipperQSettings.cc:61
CoreWidget.hh
CoreWidget::showStatusBar
void showStatusBar(bool _state)
Show or hide status bar.
Definition: StatusBar.cc:155
ApplicationStatus::applicationStatus
applicationStatus
Enum for the statusBar Status Icon.
Definition: StatusbarInterface.hh:64
ApplicationStatus::PROCESSING
Status is processing but system will allow interaction (yellow light)
Definition: StatusbarInterface.hh:66
CoreWidget::statusBarVisChanged
void statusBarVisChanged(bool _state)
will be emitted if the visibility of the statusbar is changed
ColorStatusBar
Definition: ColorStatusBar.hh:50