[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. b824d77469af4d8ecea6d0829019a959b5bb69de

Modestas Vainius modax-guest at alioth.debian.org
Sun Mar 1 13:37:48 UTC 2009


The following commit has been merged in the master branch:
commit 82be14207fe6e863e8ffaaa900c82d62422005e1
Author: Modestas Vainius <modestas at vainius.eu>
Date:   Sun Mar 1 03:31:42 2009 +0200

    Add details label and tooltips to RichRadioButton.
    
    Signed-off-by: Modestas Vainius <modestas at vainius.eu>

diff --git a/richradiobutton.cpp b/richradiobutton.cpp
index c85f6d8..50548cc 100644
--- a/richradiobutton.cpp
+++ b/richradiobutton.cpp
@@ -1,5 +1,6 @@
 /*
     Copyright (C) 2009  George Kiagiadakis <gkiagia at users.sourceforge.net>
+              (C) 2009  Modestas Vainius <modestas at vainius.eu>
 
     This library is free software; you can redistribute it and/or modify
     it under the terms of the GNU Lesser General Public License as published
@@ -87,34 +88,50 @@ struct RichRadioButton::Private
 {
     PrivateRadioButton *m_button;
     QLabel *m_label;
+    QLabel *m_detailsLabel;
 
     void init(RichRadioButton *q);
 };
 
 void RichRadioButton::Private::init(RichRadioButton *q)
 {
-    QHBoxLayout *layout = new QHBoxLayout(q);
+    QGridLayout *layout = new QGridLayout(q);
     m_button = new PrivateRadioButton(q);
     m_button->setFocusPolicy(Qt::NoFocus);
-    m_label = new QLabel(q);
-    m_label->setWordWrap(q);
 
-    layout->addWidget(m_button);
-    layout->addWidget(m_label);
+    m_label = new QLabel(q);
+    m_label->setWordWrap(true);
+
+    QFont detailsFont;
+    m_detailsLabel = new QLabel(q);
+    detailsFont.setItalic(true);
+    detailsFont.setPointSize(m_detailsLabel->font().pointSize() - 2);
+    m_detailsLabel->setFont(detailsFont);
+    m_detailsLabel->setWordWrap(true);
+    m_detailsLabel->setVisible(false);
+    m_detailsLabel->setAlignment(Qt::AlignJustify);
+
+    layout->addWidget(m_button, 0, 0);
+    layout->addWidget(m_label, 0, 1);
+    layout->addWidget(m_detailsLabel, 1, 1);
+    layout->setRowMinimumHeight(1, 0);
 
     m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+    m_detailsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 
     //install event filter to reject keyboard & mouse events from child objects
     EventEater *eventEater = new EventEater(q);
     m_button->installEventFilter(eventEater);
     m_label->installEventFilter(eventEater);
+    m_detailsLabel->installEventFilter(eventEater);
 
     q->setCheckable(true);
     q->setAutoExclusive(true);
     q->setAttribute(Qt::WA_Hover);
-}
 
+    connect(q, SIGNAL(toggled(bool)), q, SLOT(setDetailsVisible(bool)));
+}
 
 RichRadioButton::RichRadioButton(QWidget *parent)
     : QAbstractButton(parent), d(new Private)
@@ -129,6 +146,14 @@ RichRadioButton::RichRadioButton(const QString & text, QWidget *parent)
     setText(text);
 }
 
+RichRadioButton::RichRadioButton(const QString & text, const QString & details, QWidget *parent)
+    : QAbstractButton(parent), d(new Private)
+{
+    d->init(this);
+    setText(text);
+    setDetailsText(details);
+}
+
 RichRadioButton::~RichRadioButton()
 {
     delete d;
@@ -140,6 +165,18 @@ void RichRadioButton::setText(const QString & text)
     QAbstractButton::setText(text);
 }
 
+void RichRadioButton::setDetailsText(const QString & text)
+{
+    d->m_detailsLabel->setText(text);
+    setToolTip(text);
+}
+
+void RichRadioButton::setDetailsVisible(bool visible)
+{
+    visible &= !(d->m_detailsLabel->text().isEmpty());
+    d->m_detailsLabel->setVisible(visible);
+}
+
 bool RichRadioButton::event(QEvent *event)
 {
     switch (event->type()) {
diff --git a/richradiobutton.h b/richradiobutton.h
index af2b578..0fc29d5 100644
--- a/richradiobutton.h
+++ b/richradiobutton.h
@@ -25,10 +25,15 @@ class RichRadioButton : public QAbstractButton
 public:
     explicit RichRadioButton(QWidget *parent = 0);
     explicit RichRadioButton(const QString & text, QWidget *parent = 0);
+    explicit RichRadioButton(const QString & text, const QString & details, QWidget *parent = 0);
     virtual ~RichRadioButton();
 
     //not virtual, do not call the parent's implementation!
     void setText(const QString & text);
+    void setDetailsText(const QString & text);
+
+public slots:
+    void setDetailsVisible(bool visible);
 
 protected:
     virtual bool event(QEvent *event);

-- 
Kaboom - Debian KDE 3->4 migration tool



More information about the pkg-kde-commits mailing list