Couple of fixes:
* Close empty extender when clicking in it. BUG:176545 * Saner size policy for Plasma::Meter. (the height should never be able to be smaller then svg's height because labels could otherwise overlap, actually, the whole current approach doesn't consider font size, I think we should think of a better approach for 4.3) * Use the same spacer as used in the panel for extenders. I think we would want some svg themable shared spacer widget for 4.3, but at least this adds some consistency. svn path=/trunk/KDE/kdelibs/; revision=891328
This commit is contained in:
parent
f25e5b82ff
commit
ab56a3a388
42
extender.cpp
42
extender.cpp
@ -22,14 +22,17 @@
|
||||
#include <QAction>
|
||||
#include <QGraphicsGridLayout>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QPainter>
|
||||
|
||||
#include "applet.h"
|
||||
#include "containment.h"
|
||||
#include "corona.h"
|
||||
#include "extenderitem.h"
|
||||
#include "framesvg.h"
|
||||
#include "paintutils.h"
|
||||
#include "popupapplet.h"
|
||||
#include "svg.h"
|
||||
#include "theme.h"
|
||||
#include "widgets/label.h"
|
||||
|
||||
#include "private/applet_p.h"
|
||||
@ -39,6 +42,34 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
//TODO: copied from panel containment. We'll probably want a spacer widget in libplasma for 4.3.
|
||||
class Spacer : public QGraphicsWidget
|
||||
{
|
||||
public:
|
||||
Spacer(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
~Spacer()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath p = Plasma::PaintUtils::roundedRectangle(contentsRect().adjusted(4, 4, -4, -4), 4);
|
||||
|
||||
QColor c = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
||||
c.setAlphaF(0.3);
|
||||
painter->fillPath(p, c);
|
||||
}
|
||||
};
|
||||
|
||||
Extender::Extender(Applet *applet)
|
||||
: QGraphicsWidget(applet),
|
||||
d(new ExtenderPrivate(applet, this))
|
||||
@ -61,7 +92,6 @@ Extender::Extender(Applet *applet)
|
||||
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
|
||||
|
||||
d->loadExtenderItems();
|
||||
}
|
||||
|
||||
@ -172,6 +202,14 @@ void Extender::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
emit geometryChanged();
|
||||
}
|
||||
|
||||
void Extender::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
PopupApplet *popupApplet = qobject_cast<PopupApplet*>(d->applet);
|
||||
if (attachedItems().isEmpty() && popupApplet) {
|
||||
popupApplet->hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
|
||||
{
|
||||
//this is a sane size policy imo.
|
||||
@ -229,7 +267,7 @@ void Extender::itemHoverMoveEvent(ExtenderItem *item, const QPointF &pos)
|
||||
|
||||
//Create a widget that functions as spacer, and add that to the layout.
|
||||
if (!d->spacerWidget) {
|
||||
QGraphicsWidget *widget = new QGraphicsWidget(this);
|
||||
Spacer *widget = new Spacer(this);
|
||||
widget->setMinimumSize(item->minimumSize());
|
||||
widget->setPreferredSize(item->preferredSize());
|
||||
widget->setMaximumSize(item->maximumSize());
|
||||
|
@ -216,6 +216,11 @@ class PLASMA_EXPORT Extender : public QGraphicsWidget
|
||||
*/
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
/**
|
||||
* Reimplemented from QGraphicsWidget
|
||||
*/
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Fires when an extender item is added to this extender.
|
||||
|
@ -36,6 +36,7 @@ class Applet;
|
||||
class Extender;
|
||||
class ExtenderItem;
|
||||
class Label;
|
||||
class Spacer;
|
||||
class Svg;
|
||||
|
||||
class ExtenderPrivate
|
||||
@ -59,7 +60,7 @@ class ExtenderPrivate
|
||||
FrameSvg *background;
|
||||
|
||||
int currentSpacerIndex;
|
||||
QGraphicsWidget *spacerWidget;
|
||||
Spacer *spacerWidget;
|
||||
|
||||
QString emptyExtenderMessage;
|
||||
Label *emptyExtenderLabel;
|
||||
|
@ -191,10 +191,10 @@ public:
|
||||
{
|
||||
switch (meterType) {
|
||||
case Meter::BarMeterHorizontal:
|
||||
meter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
meter->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
break;
|
||||
case Meter::BarMeterVertical:
|
||||
meter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
meter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
||||
break;
|
||||
case Meter::AnalogMeter:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user