menubar.cpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #include "menubar.h"
8 #include <QDebug>
9 #include <QFontDatabase>
10 #include <QFont>
11 #include <QColor>
12 #include <QFontMetrics>
13 
14 MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
15 {
16  int font_id = QFontDatabase::addApplicationFont("://resources/"
17  "DejaVuSans-ExtraLight.ttf");
18  QString family = QFontDatabase::applicationFontFamilies(font_id).at(0);
19 
20  _font.setFamily(family);
21  _font.setStyleStrategy(QFont::PreferAntialias);
22  _font.setPixelSize(18);
23 
24  QFontMetrics fm(_font);
25  _width_plot = fm.width("Plot");
26  _width_juggler = fm.width("Juggler");
27 }
28 
29 // void MenuBar::paintEvent(QPaintEvent* event)
30 //{
31 // QMenuBar::paintEvent(event);
32 // QPainter painter(this);
33 // painter.setFont(_font);
34 
35 // int text_width = _width_plot + _width_juggler;
36 // {
37 // QPoint topleft(this->rect().width() - text_width - 12, 0);
38 // QSize rect_size(_width_plot, this->rect().height());
39 // painter.setPen(QColor("#dd22dd"));
40 // painter.drawText(QRect(topleft, rect_size), Qt::AlignHCenter | Qt::AlignVCenter,
41 // "Plot");
42 // }
43 // {
44 // QPoint topleft(this->rect().width() - _width_juggler - 10, 0);
45 // QSize rect_size(_width_juggler, this->rect().height());
46 // painter.setPen(QColor("#2288ff"));
47 // painter.drawText(QRect(topleft, rect_size), Qt::AlignHCenter | Qt::AlignVCenter,
48 // "Juggler");
49 // }
50 //}
menubar.h
MenuBar::_font
QFont _font
Definition: menubar.h:21
MenuBar::_width_plot
int _width_plot
Definition: menubar.h:22
MenuBar::_width_juggler
int _width_juggler
Definition: menubar.h:23
MenuBar::MenuBar
MenuBar(QWidget *parent)
Definition: menubar.cpp:14


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:23