menubar.cpp
Go to the documentation of this file.
00001 #include "menubar.h"
00002 #include <QDebug>
00003 #include <QFontDatabase>
00004 #include <QPainter>
00005 #include <QFont>
00006 #include <QColor>
00007 
00008 void MenuBar::paintEvent(QPaintEvent *event)
00009 {
00010     QMenuBar::paintEvent(event);
00011 
00012     int font_id = QFontDatabase::addApplicationFont("://resources/DejaVuSans-ExtraLight.ttf");
00013     QString family = QFontDatabase::applicationFontFamilies(font_id).at(0);
00014     QFont font(family);
00015     font.setStyleStrategy(QFont::PreferAntialias);
00016 
00017     QPainter painter(this);
00018     painter.setFont( QFont(family, 12) );
00019 
00020     int width_plot = painter.fontMetrics().width("Plot");
00021     int width_juggler = painter.fontMetrics().width("Juggler");
00022     int text_width = width_plot + width_juggler;
00023     {
00024         QPoint topleft( this->rect().width() - text_width - 12 , 0);
00025         QSize rect_size( width_plot, this->rect().height() );
00026         painter.setPen( QColor("#ce0e73"));
00027         painter.drawText( QRect(topleft, rect_size),
00028                           Qt::AlignHCenter | Qt::AlignVCenter, "Plot" );
00029     }
00030     {
00031         QPoint topleft( this->rect().width() - width_juggler - 10 , 0);
00032         QSize rect_size( width_juggler, this->rect().height() );
00033         painter.setPen( QColor("#1b72cf"));
00034         painter.drawText( QRect(topleft, rect_size),
00035                           Qt::AlignHCenter | Qt::AlignVCenter, "Juggler" );
00036     }
00037 }
00038 


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:04