[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/graphics/digikam/libs/widgets/common
From: Gilles Caulier <caulier.gilles () gmail ! com>
Date: 2009-05-12 13:17:48
Message-ID: 1242134268.802678.2685.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 967030 by cgilles:
new DLabelExpander container widget
M +99 -0 clicklabel.cpp
M +34 -0 clicklabel.h
--- trunk/extragear/graphics/digikam/libs/widgets/common/clicklabel.cpp #967029:967030
@@ -7,6 +7,7 @@
* Description : User interface for searches
*
* Copyright (C) 2008-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ * Copyright (C) 2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
@@ -31,11 +32,14 @@
#include <QPen>
#include <QStyle>
#include <QStyleOption>
+#include <QGridLayout>
// KDE includes
+#include <kseparator.h>
#include <kdebug.h>
#include <kglobalsettings.h>
+#include <kdialog.h>
#include <klocale.h>
// Local includes
@@ -233,4 +237,99 @@
return QSize(m_size + 2*m_margin, m_size + 2*m_margin);
}
+// ------------------------------------------------------------------------
+
+class DLabelExpanderPriv
+{
+
+public:
+
+ DLabelExpanderPriv()
+ {
+ clickLabel = 0;
+ containerWidget = 0;
+ pixmapLabel = 0;
+ grid = 0;
+ arrow = 0;
+ line = 0;
+ }
+
+ QLabel *pixmapLabel;
+ QWidget *containerWidget;
+ QGridLayout *grid;
+
+ KSeparator *line;
+
+ ArrowClickLabel *arrow;
+ SqueezedClickLabel *clickLabel;
+};
+
+DLabelExpander::DLabelExpander(QWidget *parent)
+ : QWidget(parent), d(new DLabelExpanderPriv)
+{
+ d->grid = new QGridLayout(this);
+ d->line = new KSeparator(Qt::Horizontal, this);
+ d->arrow = new ArrowClickLabel(this);
+ d->pixmapLabel = new QLabel(this);
+ d->clickLabel = new SqueezedClickLabel(this);
+
+ d->grid->addWidget(d->line, 0, 0, 1, 3);
+ d->grid->addWidget(d->arrow, 1, 0, 1, 1);
+ d->grid->addWidget(d->pixmapLabel, 1, 1, 1, 1);
+ d->grid->addWidget(d->clickLabel, 1, 2, 1, 1);
+ d->grid->setColumnStretch(2, 10);
+ d->grid->setMargin(KDialog::spacingHint());
+ d->grid->setSpacing(KDialog::spacingHint());
+
+ connect(d->arrow, SIGNAL(leftClicked()),
+ this, SLOT(slotToggleContainer()));
+
+ connect(d->clickLabel, SIGNAL(activated()),
+ this, SLOT(slotToggleContainer()));
+}
+
+DLabelExpander::~DLabelExpander()
+{
+ delete d;
+}
+
+void DLabelExpander::setLineVisible(bool b)
+{
+ d->line->setVisible(b);
+}
+
+void DLabelExpander::setText(const QString& text)
+{
+ d->clickLabel->setText(QString("<qt><b>%1</b></qt>").arg(text));
+}
+
+void DLabelExpander::setPixmap(const QPixmap& pix)
+{
+ d->pixmapLabel->setPixmap(pix);
+}
+
+void DLabelExpander::setContainer(QWidget* widget)
+{
+ if (widget)
+ {
+ d->containerWidget = widget;
+ d->containerWidget->setParent(this);
+ d->grid->addWidget(d->containerWidget, 2, 0, 1, 3);
+ }
+}
+
+bool DLabelExpander::isExpanded()
+{
+ if (d->containerWidget)
+ return (d->containerWidget->isVisible());
+
+ return false;
+}
+
+void DLabelExpander::slotToggleContainer()
+{
+ if(d->containerWidget)
+ d->containerWidget->setVisible(!d->containerWidget->isVisible());
+}
+
} // namespace Digikam
--- trunk/extragear/graphics/digikam/libs/widgets/common/clicklabel.h #967029:967030
@@ -7,6 +7,7 @@
* Description : User interface for searches
*
* Copyright (C) 2008-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ * Copyright (C) 2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
@@ -29,6 +30,7 @@
#include <QObject>
#include <QWidget>
#include <QLabel>
+#include <QPixmap>
// KDE includes
@@ -41,6 +43,8 @@
namespace Digikam
{
+class DLabelExpanderPriv;
+
class DIGIKAM_EXPORT ClickLabel : public QLabel
{
Q_OBJECT
@@ -49,6 +53,7 @@
ClickLabel(QWidget *parent = 0);
ClickLabel(const QString& text, QWidget *parent = 0);
+ ~ClickLabel(){};
Q_SIGNALS:
@@ -73,6 +78,7 @@
SqueezedClickLabel(QWidget *parent = 0);
SqueezedClickLabel(const QString& text, QWidget *parent = 0);
+ ~SqueezedClickLabel(){};
Q_SIGNALS:
@@ -94,6 +100,7 @@
public:
ArrowClickLabel(QWidget *parent = 0);
+ ~ArrowClickLabel(){};
void setArrowType(Qt::ArrowType arrowType);
virtual QSize sizeHint () const;
@@ -114,6 +121,33 @@
int m_margin;
};
+// -------------------------------------------------------------------------
+
+class DIGIKAM_EXPORT DLabelExpander : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ DLabelExpander(QWidget *parent = 0);
+ ~DLabelExpander();
+
+ void setLineVisible(bool b);
+ void setText(const QString& text);
+ void setPixmap(const QPixmap& pix);
+ void setContainer(QWidget* widget);
+
+ bool isExpanded();
+
+private slots:
+
+ void slotToggleContainer();
+
+private:
+
+ DLabelExpanderPriv* const d;
+};
+
} // namespace Digikam
#endif // CLICKLABEL_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic