Konsole
WarningBox.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "WarningBox.h"
00022
00023
00024 #include <QLabel>
00025 #include <QHBoxLayout>
00026
00027
00028 #include <KIcon>
00029 #include <KColorScheme>
00030 #include <KDebug>
00031
00032 using namespace Konsole;
00033
00034 WarningBox::WarningBox(QWidget* parent)
00035 : QFrame(parent)
00036 {
00037 KColorScheme colorScheme(QPalette::Active);
00038 QColor warningColor = colorScheme.background(KColorScheme::NeutralBackground).color();
00039 QColor warningColorLight = KColorScheme::shade(warningColor,KColorScheme::LightShade,0.1);
00040 QColor borderColor = KColorScheme::shade(warningColor,KColorScheme::DarkShade,0.15);
00041 QString gradient = "qlineargradient(x1:0, y1:0, x2:0, y2:1,"
00042 "stop: 0 %1, stop: 0.6 %1 ,stop: 1.0 %2)";
00043 gradient = gradient.arg(warningColor.name()).arg(warningColorLight.name());
00044
00045 QString styleSheet = "Konsole--WarningBox { background: %1;"
00046 "border: 2px solid %2; }";
00047 setStyleSheet(styleSheet.arg(gradient).arg(borderColor.name()));
00048
00049 _label = new QLabel();
00050 _label->setWordWrap(true);
00051 _label->setAlignment(Qt::AlignLeft);
00052
00053 QLabel* icon = new QLabel();
00054 icon->setPixmap(KIcon("dialog-warning").pixmap(QSize(48,48)));
00055 icon->setAlignment(Qt::AlignCenter);
00056
00057 QHBoxLayout* layout = new QHBoxLayout(this);
00058 layout->addWidget(icon);
00059 layout->addWidget(_label);
00060 layout->setStretchFactor(icon,2);
00061 layout->setStretchFactor(_label,5);
00062 }
00063 void WarningBox::setText(const QString& text)
00064 {
00065 _label->setText(text);
00066 }
00067 QString WarningBox::text() const
00068 {
00069 return _label->text();
00070 }
00071
00072 #include "WarningBox.moc"
00073
00074