• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

WarningBox.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2008 by Robert Knight <robertknight@gmail.com>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301  USA.
00018 */
00019 
00020 // Own
00021 #include "WarningBox.h"
00022 
00023 // Qt
00024 #include <QLabel>
00025 #include <QHBoxLayout>
00026 
00027 // KDE
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 

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal