source: src/gui/tabwidget.cpp @ 9859cac

qt5
Last change on this file since 9859cac was cb18bc7, checked in by pavelpa <pavelpa@…>, 12 years ago

new TabWidget? - contains "info" icon/button to show "AboutApplication?" dialog

  • Property mode set to 100644
File size: 871 bytes
Line 
1#include "tabwidget.h"
2
3#include <QMouseEvent>
4#include <QPainter>
5
6#include <QDebug>
7
8const int SPACER = 5;
9
10TabWidget::TabWidget(QWidget *aParent)
11    : QTabWidget(aParent)
12    , mPressPoint(0,0)
13{
14    mInfoImage = QImage(":/icons/info.png");
15}
16
17void TabWidget::paintEvent(QPaintEvent *event)
18{
19    QPainter painter(this);
20    painter.drawImage(rect().topRight()-QPoint(mInfoImage.width()+SPACER,-SPACER),mInfoImage);
21}
22
23void TabWidget::mousePressEvent(QMouseEvent *event)
24{
25    mPressPoint = event->pos();
26}
27
28void TabWidget::mouseReleaseEvent(QMouseEvent *event)
29{
30    QPoint topLeft = rect().topRight()-QPoint(mInfoImage.width()+SPACER,-SPACER);
31    QRect infoRect = QRect(topLeft, topLeft+QPoint(mInfoImage.width(),mInfoImage.height()));
32    if( (infoRect.contains(event->pos())) && (infoRect.contains(mPressPoint)) )
33    {
34        emit(infoIconClicked());
35    }
36}
37
Note: See TracBrowser for help on using the repository browser.