implemented 'links' in Event/EventDialog
[toast/confclerk.git] / src / gui / tabwidget.cpp
1 #include "tabwidget.h"
2
3 #include <QMouseEvent>
4 #include <QPainter>
5 #include <QTabBar>
6
7 TabWidget::TabWidget(QWidget *aParent)
8     : QTabWidget(aParent)
9     , mPressPoint(0,0)
10 {
11     mInfoImage = QImage(":/icons/info.png");
12 }
13
14 void TabWidget::paintEvent(QPaintEvent *event)
15 {
16     int height = tabBar()->tabRect(currentIndex()).height();
17     QImage image = mInfoImage.scaled(QSize(height,height),Qt::KeepAspectRatioByExpanding,Qt::SmoothTransformation);
18     QPainter painter(this);
19     painter.drawImage(rect().topRight()-QPoint(image.width(),0),image);
20 }
21
22 void TabWidget::mousePressEvent(QMouseEvent *event)
23 {
24     mPressPoint = event->pos();
25 }
26
27 void TabWidget::mouseReleaseEvent(QMouseEvent *event)
28 {
29     int height = tabBar()->tabRect(currentIndex()).height();
30     QImage image = mInfoImage.scaled(QSize(height,height),Qt::KeepAspectRatioByExpanding,Qt::SmoothTransformation);
31     QPoint topLeft = rect().topRight()-QPoint(image.width(),0);
32     QRect infoRect = QRect(topLeft, topLeft+QPoint(image.width(),image.height()));
33     if( (infoRect.contains(event->pos())) && (infoRect.contains(mPressPoint)) )
34     {
35         emit(infoIconClicked());
36     }
37 }
38