1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the demos of the Qt Toolkit. |
7 ** This file is part of the demos of the Qt Toolkit. |
8 ** |
8 ** |
48 : QWidget(parent) |
48 : QWidget(parent) |
49 { |
49 { |
50 menuPixmap.load(":/images/edit-find.png"); |
50 menuPixmap.load(":/images/edit-find.png"); |
51 backPixmap.load(":/images/go-previous.png"); |
51 backPixmap.load(":/images/go-previous.png"); |
52 forwardPixmap.load(":/images/go-next.png"); |
52 forwardPixmap.load(":/images/go-next.png"); |
|
53 closePixmap.load(":/images/button-close.png"); |
53 } |
54 } |
54 |
55 |
55 QSize ControlStrip::sizeHint() const |
56 QSize ControlStrip::sizeHint() const |
56 { |
57 { |
57 return minimumSizeHint(); |
58 return minimumSizeHint(); |
72 event->accept(); |
73 event->accept(); |
73 return; |
74 return; |
74 } |
75 } |
75 |
76 |
76 if (x > width() - h) { |
77 if (x > width() - h) { |
77 emit forwardClicked(); |
78 emit closeClicked(); |
78 event->accept(); |
79 event->accept(); |
79 return; |
80 return; |
80 } |
81 |
|
82 } |
81 |
83 |
82 if ((x < width() - 2 * h) && (x > width() - 3 * h)) { |
84 if ((x < width() - 2 * h) && (x > width() - 3 * h)) { |
83 emit backClicked(); |
85 emit forwardClicked(); |
84 event->accept(); |
86 event->accept(); |
85 return; |
87 return; |
86 } |
88 } |
|
89 |
|
90 if ((x < width() - 3 * h) && (x > width() - 5 * h)) { |
|
91 emit backClicked(); |
|
92 event->accept(); |
|
93 return; |
|
94 } |
87 } |
95 } |
88 |
96 |
89 void ControlStrip::paintEvent(QPaintEvent *event) |
97 void ControlStrip::paintEvent(QPaintEvent *event) |
90 { |
98 { |
91 int h = height(); |
99 int h = height(); |
92 int s = (h - menuPixmap.height()) / 2; |
100 int s = (h - menuPixmap.height()) / 2; |
93 |
101 |
94 QPainter p(this); |
102 |
95 p.fillRect(event->rect(), QColor(32, 32, 32, 192)); |
103 QPainter p(this); |
96 p.setCompositionMode(QPainter::CompositionMode_SourceOver); |
104 p.fillRect(event->rect(), QColor(32, 32, 32, 192)); |
97 p.drawPixmap(s, s, menuPixmap); |
105 p.setCompositionMode(QPainter::CompositionMode_SourceOver); |
98 p.drawPixmap(width() - 3 * h + s, s, backPixmap); |
106 p.drawPixmap(s, s, menuPixmap); |
99 p.drawPixmap(width() - h + s, s, forwardPixmap); |
107 p.drawPixmap(width() - h + s, s, closePixmap); |
100 p.end(); |
108 p.drawPixmap(width() - 3 * h + s, s, forwardPixmap); |
|
109 p.drawPixmap(width() - 5 * h + s, s, backPixmap); |
|
110 |
|
111 p.end(); |
101 } |
112 } |