KDE/kdebase/workspace/plasma/applets/battery
Sebastian Kügler
sebas at kde.org
Thu Aug 21 16:19:37 CEST 2008
SVN commit 850434 by sebas:
Don't squeeze multiple batteries into the space of one, change the
applet sizeHint instead so we get more space.
The emit sizeHint doesn't seem to trigger sizeHint(), though. Bug?
CCMAIL:plasma-devel at kde.org
M +30 -2 battery.cpp
M +1 -1 battery.h
--- trunk/KDE/kdebase/workspace/plasma/applets/battery/battery.cpp #850433:850434
@@ -110,10 +110,18 @@
{
if (constraints & (Plasma::FormFactorConstraint | Plasma::SizeConstraint)) {
if (formFactor() == Plasma::Vertical) {
- setMaximumSize(QWIDGETSIZE_MAX, qMax(m_textRect.height(), contentsRect().width()));
+ if (!m_showMultipleBatteries) {
+ setMaximumSize(QWIDGETSIZE_MAX, qMax(m_textRect.height(), contentsRect().width()));
+ } else {
+ setMaximumSize(QWIDGETSIZE_MAX, qMax(m_textRect.height(), contentsRect().width()*m_numOfBattery));
+ }
//kDebug() << "Vertical FormFactor";
} else if (formFactor() == Plasma::Horizontal) {
- setMaximumSize(qMax(m_textRect.width(), contentsRect().height()), QWIDGETSIZE_MAX);
+ if (!m_showMultipleBatteries) {
+ setMaximumSize(qMax(m_textRect.width(), contentsRect().height()), QWIDGETSIZE_MAX);
+ } else {
+ setMaximumSize(qMax(m_textRect.width(), contentsRect().height()*m_numOfBattery), QWIDGETSIZE_MAX);
+ }
//kDebug() << "Horizontal FormFactor" << m_textRect.width() << contentsRect().height();
}
}
@@ -125,6 +133,26 @@
}
}
+
+QSizeF Battery::sizeHint(const Qt::SizeHint which, const QSizeF& constraint) const
+{
+ Q_UNUSED( which );
+ Q_UNUSED( constraint );
+ QSizeF sizeHint = contentsRect().size();
+ switch (formFactor()) {
+ case Plasma::Vertical:
+ sizeHint.setHeight(sizeHint.width() * m_numOfBattery);
+ break;
+
+ default:
+ sizeHint.setWidth(sizeHint.height() * m_numOfBattery);
+ break;
+ }
+ kDebug() << "SizeHint" << sizeHint;
+ return sizeHint;
+}
+
+
void Battery::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
if (source.startsWith(I18N_NOOP("Battery"))) {
--- trunk/KDE/kdebase/workspace/plasma/applets/battery/battery.h #850433:850434
@@ -46,7 +46,7 @@
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
const QRect &contents);
void setPath(const QString&);
- QSizeF contentSizeHint() const;
+ QSizeF sizeHint(const Qt::SizeHint which, const QSizeF& constraint) const;
Qt::Orientations expandingDirections() const;
void constraintsEvent(Plasma::Constraints constraints);
More information about the Plasma-devel
mailing list