1 /*
2 SuperCollider Qt IDE
3 Copyright (c) 2012 - 2013 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "status_box.hpp"
22
23 namespace ScIDE {
24
StatusLabel(QWidget * parent)25 StatusLabel::StatusLabel(QWidget* parent): QLabel(parent) {
26 setAutoFillBackground(true);
27 setMargin(3);
28 setAlignment(Qt::AlignCenter);
29 setBackground(Qt::black);
30 setTextColor(Qt::white);
31
32 QFont font("Monospace");
33 font.setStyleHint(QFont::Monospace);
34 font.setBold(true);
35 setFont(font);
36 }
37
setBackground(const QBrush & brush)38 void StatusLabel::setBackground(const QBrush& brush) {
39 QPalette plt(palette());
40 plt.setBrush(QPalette::Window, brush);
41 setPalette(plt);
42 }
43
setTextColor(const QColor & color)44 void StatusLabel::setTextColor(const QColor& color) {
45 QPalette plt(palette());
46 plt.setColor(QPalette::WindowText, color);
47 setPalette(plt);
48 }
49
StatusBox(QWidget * parent)50 StatusBox::StatusBox(QWidget* parent): QWidget(parent), mMenu(0) {}
51
showContextMenu()52 void StatusBox::showContextMenu() {
53 if (!mMenu) {
54 QList<QAction*> actions = this->actions();
55 if (actions.count()) {
56 StatusBoxMenu* menu = new StatusBoxMenu;
57 menu->addActions(actions);
58 mMenu = menu;
59 }
60 }
61
62 if (!mMenu->isVisible())
63 mMenu->popup(mapToGlobal(QPoint(0, -mMenu->sizeHint().height() - 2)));
64 }
65
66
mousePressEvent(QMouseEvent *)67 void StatusBox::mousePressEvent(QMouseEvent*) { showContextMenu(); }
68
addActionSeparator()69 void StatusBox::addActionSeparator() {
70 QAction* separator = new QAction(this);
71 separator->setSeparator(true);
72 addAction(separator);
73 }
74
75 } // namespace ScIDE
76