[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/nowplaying
From:       Alex Merry <kde () randomguy3 ! me ! uk>
Date:       2008-11-23 22:18:30
Message-ID: 1227478710.880418.17021.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 888165 by alexmerry:

It works nicely in the plasmoidviewer... why are the icons spaced out on the panel?

Does the panel even pay attention to the KeepAspectRatio hint?  I guess not.  I think \
we need the plasmoidviewer to actually act like the panel in linear form factors.

Sorry for the mountains of debug.



 M  +24 -17    controls.cpp  
 M  +35 -11    nowplaying.cpp  
 M  +1 -1      nowplaying.h  


--- trunk/KDE/kdeplasma-addons/applets/nowplaying/controls.cpp #888164:888165
@@ -10,7 +10,6 @@
       m_stop(new Plasma::IconWidget(this)),
       m_prev(new Plasma::IconWidget(this)),
       m_next(new Plasma::IconWidget(this)),
-      m_layout(0),
       m_state(NoPlayer)
 {
     m_playpause->setIcon("media-playback-start");
@@ -26,9 +25,6 @@
     connect(m_next, SIGNAL(clicked()), this, SIGNAL(next()));
     m_next->setMinimumSize(m_next->sizeFromIconSize(16));
 
-    m_layout = new QGraphicsLinearLayout(Qt::Horizontal);
-    setLayout(m_layout);
-
     setDisplayedButtons(AllButtons);
 }
 
@@ -94,19 +90,19 @@
 Controls::Buttons Controls::displayedButtons() const
 {
     Buttons result;
-    if (m_prev->layout() == m_layout)
+    if (m_prev->isVisible())
     {
         result |= PreviousButton;
     }
-    if (m_next->layout() == m_layout)
+    if (m_next->isVisible())
     {
         result |= NextButton;
     }
-    if (m_playpause->layout() == m_layout)
+    if (m_playpause->isVisible())
     {
         result |= PlayPauseButton;
     }
-    if (m_stop->layout() == m_layout)
+    if (m_stop->isVisible())
     {
         result |= StopButton;
     }
@@ -121,6 +117,8 @@
     {
         button->show();
         layout->addItem(button);
+        kDebug() << "Button minimum size:" << button->minimumSize();
+        kDebug() << "Button preferred size:" << button->preferredSize();
     }
     else
     {
@@ -130,15 +128,24 @@
 
 void Controls::setDisplayedButtons(Buttons buttons)
 {
-    while (m_layout->count() != 0)
-    {
-        m_layout->removeAt(0);
-    }
-    showHideButton(m_layout, m_prev, (buttons & PreviousButton));
-    showHideButton(m_layout, m_playpause, (buttons & PlayPauseButton));
-    showHideButton(m_layout, m_stop, (buttons & StopButton));
-    showHideButton(m_layout, m_next, (buttons & NextButton));
-    m_layout->invalidate();
+    kDebug() << "Minimum size before changing buttons:" << minimumSize();
+
+    setLayout(0);
+    kDebug() << "Layout:" << (QObject*)layout();
+    delete layout();
+
+    QGraphicsLinearLayout* newLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+
+    newLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+    showHideButton(newLayout, m_prev, (buttons & PreviousButton));
+    showHideButton(newLayout, m_playpause, (buttons & PlayPauseButton));
+    showHideButton(newLayout, m_stop, (buttons & StopButton));
+    showHideButton(newLayout, m_next, (buttons & NextButton));
+    //newLayout->addStretch();
+    setLayout(newLayout);
+
+    kDebug() << "Minimum size after changing buttons:" << minimumSize();
 }
 
 // vim: sw=4 sts=4 et tw=100
--- trunk/KDE/kdeplasma-addons/applets/nowplaying/nowplaying.cpp #888164:888165
@@ -45,9 +45,7 @@
       m_volumeSlider(new Plasma::Slider(this)),
       m_positionSlider(new Plasma::Slider(this))
 {
-    setAspectRatioMode(Plasma::IgnoreAspectRatio);
-    resize(300, 200);
-    setMinimumSize(300, 200);
+    resize(300, 200); // ideal planar size
 
     connect(m_buttonPanel, SIGNAL(play()), this, SLOT(play()));
     connect(m_buttonPanel, SIGNAL(pause()), this, SLOT(pause()));
@@ -120,8 +118,8 @@
 {
     if (m_currentLayout != PlanarLayout)
     {
+        setAspectRatioMode(Plasma::IgnoreAspectRatio);
         setMinimumSize(300, 200);
-        setAspectRatioMode(Plasma::IgnoreAspectRatio);
 
         QGraphicsGridLayout* layout = new QGraphicsGridLayout();
         m_textPanel->show();
@@ -146,11 +144,7 @@
 {
     if (m_currentLayout != HorizontalLayout)
     {
-        setMinimumSize(20, 10);
-        resize(preferredHeight() * 2, preferredHeight());
-        kDebug() << "preferredHeight():" << preferredHeight();
-        kDebug() << "preferredSize():" << preferredSize();
-        setAspectRatioMode(Plasma::KeepAspectRatio);
+        setMinimumSize(QSizeF());
 
         m_textPanel->hide();
         m_positionSlider->hide();
@@ -158,23 +152,33 @@
 
         QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
         m_buttonPanel->show();
-        kDebug() << "m_buttonPanel->preferredSize():" << \
                m_buttonPanel->preferredSize();
         m_buttonPanel->setDisplayedButtons(Controls::PlayPauseButton | \
Controls::NextButton); +        kDebug() << "Button Panel Preferred Size:" << \
m_buttonPanel->preferredSize(); +        kDebug() << "Button Panel Minimum Size:" << \
m_buttonPanel->minimumSize();  layout->addItem(m_buttonPanel);
 
         QGraphicsLayout* oldLayout = this->layout();
+        kDebug() << "Minimum size before changing layout" << minimumSize();
+        kDebug() << "Preferred size before changing layout" << preferredSize();
         setLayout(layout);
+        kDebug() << "Minimum size after changing layout" << minimumSize();
+        kDebug() << "Preferred size after changing layout" << preferredSize();
         delete oldLayout;
 
         m_currentLayout = HorizontalLayout;
+
+        updateGeometry();
+        kDebug() << "Minimum size after updating geometry" << minimumSize();
+        kDebug() << "Preferred size after updating geometry" << preferredSize();
     }
 }
 
-void NowPlaying::constraintsUpdated(Plasma::Constraints constraints)
+void NowPlaying::constraintsEvent(Plasma::Constraints constraints)
 {
     kDebug() << "Constraints:" << constraints;
     kDebug() << "Maximum size:" << maximumSize();
     kDebug() << "Preferred size:" << preferredSize();
+    kDebug() << "Minimum size:" << minimumSize();
     if (constraints & Plasma::FormFactorConstraint)
     {
         switch (formFactor())
@@ -190,11 +194,31 @@
                 break;
         }
     }
+    /*
     if (constraints & Plasma::SizeConstraint && formFactor() == Plasma::Horizontal)
     {
         resize(preferredHeight() * 2, preferredHeight());
         setAspectRatioMode(Plasma::KeepAspectRatio);
     }
+    */
+
+        kDebug() << "minimumSize():" << minimumSize();
+        kDebug() << "preferredSize():" << preferredSize();
+        kDebug() << "maximumSize():" << maximumSize();
+        QSizePolicy policy(sizePolicy());
+        qreal left, top, right, bottom;
+        getContentsMargins(&left, &top, &right, &bottom);
+        kDebug() << "sizePolicy():"
+                 << "\n    horizontalPolicy:" << policy.horizontalPolicy()
+                 << "\n    horizontalStretch:" << policy.horizontalStretch()
+                 << "\n    verticalPolicy:" << policy.verticalPolicy()
+                 << "\n    verticalStretch:" << policy.verticalStretch()
+                 << "\n    expandingDirections:" << policy.expandingDirections()
+                 << "\n    hasHeightForWidth:" << policy.hasHeightForWidth()
+                 << "\n    contentsMargins:" << left << top << right << bottom;
+        kDebug() << "backgroundHints():" << backgroundHints();
+        kDebug() << "contentsRect():" << contentsRect();
+        kDebug() << "boundingRect():" << boundingRect();
 }
 
 void NowPlaying::dataUpdated(const QString &name,
--- trunk/KDE/kdeplasma-addons/applets/nowplaying/nowplaying.h #888164:888165
@@ -61,7 +61,7 @@
     NowPlaying(QObject *parent, const QVariantList &args);
     ~NowPlaying();
     void init();
-    void constraintsUpdated(Plasma::Constraints);
+    void constraintsEvent(Plasma::Constraints);
 
 signals:
     void stateChanged(State state);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic