Blob Blame History Raw
commit 7dbec1171386f182be77942ae43dc3684a96cfc4
Author: Mark Kretschmann <kretschmann@kde.org>
Date:   Sat Oct 2 09:06:11 2010 +0200

    Better workaround for wrong applet size on startup.
    
    This version also works in the case that Amarok was hidden to tray before
    starting, and it does not produce a jerking motion when starting in fullscreen
    mode.
    Thanks to Felix Geyer <debfx-pkg@fobos.de> for the idea.
    
    It might worth to include this patch in Amarok packages.
    
    CCMAIL: debfx-pkg@fobos.de
    CCMAIL: amarok-packagers@googlegroups.com

diff --git a/src/App.cpp b/src/App.cpp
index cd0efa3..507cf21 100644
--- a/src/App.cpp
+++ b/src/App.cpp
@@ -790,18 +790,6 @@ App::continueInit()
         aUrl.run();
     }
     s_delayedAmarokUrls.clear();
-
-    QTimer::singleShot( 1500, this, SLOT( resizeMainWindow() ) );
-}
-
-
-void App::resizeMainWindow() // SLOT
-{
-    // HACK
-    // This code works around a bug in KDE 4.5, which causes our Plasma applets to show
-    // with a wrong initial size. Remove when this bug is fixed in Plasma.
-    m_mainWindow->resize( m_mainWindow->width(), m_mainWindow->height() - 1 );
-    m_mainWindow->resize( m_mainWindow->width(), m_mainWindow->height() + 1 );
 }
 
 
diff --git a/src/App.h b/src/App.h
index 9c05eea..5866aa2 100644
--- a/src/App.h
+++ b/src/App.h
@@ -83,7 +83,6 @@ class AMAROK_EXPORT App : public KUniqueApplication
 
     private slots:
         void continueInit();
-        void resizeMainWindow();
 
     public slots:
         void applySettings( bool firstTime = false );
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 9a2c194..54c6751 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -506,6 +506,13 @@ MainWindow::showEvent(QShowEvent* e)
     if (!m_layoutEverRestored)
         restoreLayout();
 
+    static bool windowEverShown = false;
+    if ( !windowEverShown )
+    {
+        windowEverShown = true;
+        QTimer::singleShot( 250, this, SLOT( resizeWindowHack() ) );
+    }
+
     QWidget::showEvent(e);
 }
 
@@ -1704,4 +1711,14 @@ MainWindow::isWaitingForCd() const
     return m_waitingForCd;
 }
 
+void
+MainWindow::resizeWindowHack()
+{
+    // HACK
+    // This code works around a bug in KDE 4.5, which causes our Plasma applets to show
+    // with a wrong initial size. Remove when this bug is fixed in Plasma.
+    resize( width(), height() - 1 );
+    resize( width(), height() + 1 );
+}
+
 #include "MainWindow.moc"
diff --git a/src/MainWindow.h b/src/MainWindow.h
index e6ae0b3..b86470e 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -148,6 +148,7 @@ class AMAROK_EXPORT MainWindow : public KMainWindow, public Engine::EngineObserv
         void slotAddStream();
         void slotJumpTo();
         void showScriptSelector();
+        void resizeWindowHack();
 #ifdef DEBUG_BUILD_TYPE
         void showNetworkRequestViewer();
 #endif // DEBUG_BUILD_TYPE