source: src/gui/tabwidget.cpp @ 872aeaa

qt5
Last change on this file since 872aeaa was 885a3cc, checked in by pavelpa <pavelpa@…>, 12 years ago

conference tab header is hidden if there isn't active conference

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