[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: New KMessageBox Style
From: Urs Wolfer <uwolfer () kde ! org>
Date: 2008-02-01 23:21:39
Message-ID: 200802020021.41379.uwolfer () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Hi
I have worked on a new KMessageBox style. Aaron has suggested to create
something similar to the new DrKonqi style. Thanks to Nuno's help, I have now
a patch ready. Patch is attached.
I don't think it's necessary to tell more about it. Let's talk the
screenshots :)
http://home.fwo.ch/~urs/temp/kmessagebox_info.png
http://home.fwo.ch/~urs/temp/kmessagebox_warning.png
http://home.fwo.ch/~urs/temp/kmessagebox_error.png
http://home.fwo.ch/~urs/temp/kmessagebox_list.png
Comments?
Bye
urs
["kmessagebox.patch" (text/x-diff)]
Index: kmessagebox.h
===================================================================
--- kmessagebox.h (revision 769736)
+++ kmessagebox.h (working copy)
@@ -16,6 +16,7 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
+
#ifndef KMESSAGEBOX_H
#define KMESSAGEBOX_H
Index: kmessagebox.cpp
===================================================================
--- kmessagebox.cpp (revision 769736)
+++ kmessagebox.cpp (working copy)
@@ -18,6 +18,7 @@
*/
#include "kmessagebox.h"
+#include "kmessagebox_p.h"
#include <QtCore/QPointer>
#include <QtGui/QCheckBox>
@@ -85,7 +86,7 @@
switch (icon) {
case QMessageBox::NoIcon:
- return QPixmap();
+ return QIcon();
break;
case QMessageBox::Information:
icon_name = "dialog-information";
@@ -100,7 +101,7 @@
break;
}
- QIcon ret = KIconLoader::global()->loadIcon(icon_name, KIconLoader::NoGroup, \
KIconLoader::SizeLarge, KIconLoader::DefaultState, QStringList(), 0, true); + QIcon \
ret = KIcon(icon_name);
if (ret.isNull()) {
return QMessageBox::standardIcon(icon);
@@ -157,7 +158,7 @@
const QString &ask, bool *checkboxReturn, Options \
options,
const QString &details, QMessageBox::Icon notifyType)
{
- QWidget *mainWidget = new QWidget(dialog);
+ BackgroundIconWidget *mainWidget = new BackgroundIconWidget(icon, \
!strlist.isEmpty(), dialog); QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setSpacing(KDialog::spacingHint() * 2);
mainLayout->setMargin(0);
@@ -168,16 +169,6 @@
mainLayout->addLayout(hLayout);
mainLayout->addStretch();
- QLabel *iconLabel = new QLabel(mainWidget);
-
- if (!icon.isNull()) {
- int size = IconSize(KIconLoader::Dialog);
- iconLabel->setPixmap(icon.pixmap(size, size));
- }
-
- hLayout->addWidget(iconLabel, 0, Qt::AlignCenter);
- hLayout->addSpacing(KDialog::spacingHint());
-
QLabel *messageLabel = new QLabel(text, mainWidget);
messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | \
Qt::TextSelectableByKeyboard); @@ -207,6 +198,8 @@
mainLayout->setStretchFactor(listWidget, 1);
}
+ mainWidget->setIconSize((messageLabel->sizeHint().height() >= 128) ? 128 : 64);
+
QPointer<QCheckBox> checkbox = 0;
if (!ask.isEmpty()) {
checkbox = new QCheckBox(ask, mainWidget);
Index: kmessagebox_p.h
===================================================================
--- kmessagebox_p.h (revision 0)
+++ kmessagebox_p.h (revision 0)
@@ -0,0 +1,62 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KMESSAGEBOX_P_H
+#define KMESSAGEBOX_P_H
+
+#include <QtGui/QIcon>
+#include <QtGui/QPainter>
+#include <QtGui/QWidget>
+
+class BackgroundIconWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ BackgroundIconWidget(const QIcon &_icon, bool _alignTop, QWidget *parent)
+ : QWidget(parent),
+ icon(_icon),
+ alignTop(_alignTop),
+ iconSize(64),
+ paintIcon(false) {}
+
+ void setIconSize(int size) {
+ iconSize = size;
+ paintIcon = true;
+ setMinimumHeight(size);
+ }
+
+protected:
+ void paintEvent(QPaintEvent *event) {
+ if (paintIcon) { // do not unnecessary paints of the pixmap before we need \
it... + QPainter p(this);
+ p.setOpacity(0.15);
+ p.drawPixmap(QPoint(width() - iconSize, alignTop ? 0 : height() / 2 - \
(iconSize / 2)), + icon.pixmap(iconSize));
+ }
+ QWidget::paintEvent(event);
+ }
+
+private:
+ QIcon icon;
+ bool alignTop;
+ int iconSize;
+ bool paintIcon;
+};
+
+#endif /* KMESSAGEBOX_P_H */
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic