3 Copyright (C) 2010 Christian Pulvermacher
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <QScrollArea>
26 //fixes tearing during scrolling and can display messages
27 class ScrollArea : public QScrollArea
30 ScrollArea(QWidget *parent):
32 message.setParent(this);
33 message.setVisible(false);
34 message.setAlignment(Qt::AlignCenter);
35 message.setWordWrap(true);
37 QPalette pal = message.palette();
38 QColor backgroundColor = pal.color(backgroundRole());
39 backgroundColor.setAlpha(128);
40 pal.setColor(backgroundRole(), backgroundColor);
41 message.setPalette(pal);
42 message.setAutoFillBackground(true);
44 timer.setSingleShot(true);
45 timer.setInterval(2500);
46 connect(&timer, SIGNAL(timeout()),
47 &message, SLOT(hide()));
50 void showMessage(const QString &s) {
56 virtual void resizeEvent(QResizeEvent* ev) {
57 QScrollArea::resizeEvent(ev);
58 message.setFixedWidth(width());
60 virtual void scrollContentsBy(int dx, int dy) {
61 QScrollArea::scrollContentsBy(dx, dy);
63 widget()->update(); //update whole widget