2 Copyright 2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "WarningBox.h"
25 #include <QHBoxLayout>
29 #include <KColorScheme>
32 using namespace Konsole
;
34 WarningBox::WarningBox(QWidget
* parent
)
37 KColorScheme
colorScheme(QPalette::Active
);
38 QColor warningColor
= colorScheme
.background(KColorScheme::NeutralBackground
).color();
39 QColor warningColorLight
= KColorScheme::shade(warningColor
,KColorScheme::LightShade
,0.1);
40 QColor borderColor
= KColorScheme::shade(warningColor
,KColorScheme::DarkShade
,0.15);
41 QString gradient
= "qlineargradient(x1:0, y1:0, x2:0, y2:1,"
42 "stop: 0 %1, stop: 0.6 %1 ,stop: 1.0 %2)";
43 gradient
= gradient
.arg(warningColor
.name()).arg(warningColorLight
.name());
45 QString styleSheet
= "Konsole--WarningBox { background: %1;"
46 "border: 2px solid %2; }";
47 setStyleSheet(styleSheet
.arg(gradient
).arg(borderColor
.name()));
49 _label
= new QLabel();
50 _label
->setWordWrap(true);
51 _label
->setAlignment(Qt::AlignLeft
);
53 QLabel
* icon
= new QLabel();
54 icon
->setPixmap(KIcon("dialog-warning").pixmap(QSize(48,48)));
55 icon
->setAlignment(Qt::AlignCenter
);
57 QHBoxLayout
* layout
= new QHBoxLayout(this);
58 layout
->addWidget(icon
);
59 layout
->addWidget(_label
);
60 layout
->setStretchFactor(icon
,2);
61 layout
->setStretchFactor(_label
,5);
63 void WarningBox::setText(const QString
& text
)
65 _label
->setText(text
);
67 QString
WarningBox::text() const
69 return _label
->text();
72 #include "WarningBox.moc"