Branch: master

da2a2408 2014-07-08 08:21:31 Timothy Pearson
Avoid excessively long startup time due to oversized tray icon creation when icon widget has not yet been shown
M kteatime/toplevel.cpp
M kteatime/toplevel.h
diff --git a/kteatime/toplevel.cpp b/kteatime/toplevel.cpp
index 6b43fa4..1980eb3 100644
--- a/kteatime/toplevel.cpp
+++ b/kteatime/toplevel.cpp
@@ -171,10 +171,10 @@
 	action = config->readEntry("Action");
 	useTrayVis = config->readBoolEntry("UseTrayVis", true);
 
-	mugPixmap = loadSizedIcon("mug", width());
-	teaNotReadyPixmap = loadSizedIcon("tea_not_ready", width());
-	teaAnim1Pixmap = loadSizedIcon("tea_anim1", width());
-	teaAnim2Pixmap = loadSizedIcon("tea_anim2", width());
+	mugPixmap = loadIcon("mug");
+	teaNotReadyPixmap = loadIcon("tea_not_ready");
+	teaAnim1Pixmap = loadIcon("tea_anim1");
+	teaAnim2Pixmap = loadIcon("tea_anim2");
 
 	confdlg = 0L;
 	anondlg = 0L;
@@ -201,8 +201,8 @@
 	// FIXME: must delete more (like all the TQWidgets in config-window)?
 }
 
-void TopLevel::resizeEvent ( TQResizeEvent * )
-{
+void TopLevel::resizeTrayIcon () {
+	// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
 	mugPixmap = loadSizedIcon("mug", width());
 	teaNotReadyPixmap = loadSizedIcon("tea_not_ready", width());
 	teaAnim1Pixmap = loadSizedIcon("tea_anim1", width());
@@ -210,6 +210,18 @@
 	repaint();
 }
 
+void TopLevel::resizeEvent ( TQResizeEvent * )
+{
+	// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
+	resizeTrayIcon();
+}
+
+void TopLevel::showEvent ( TQShowEvent * )
+{
+	// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
+	resizeTrayIcon();
+}
+
 /** Handle mousePressEvent */
 void TopLevel::mousePressEvent(TQMouseEvent *event)
 {
diff --git a/kteatime/toplevel.h b/kteatime/toplevel.h
index 45567e5..02d8c20 100644
--- a/kteatime/toplevel.h
+++ b/kteatime/toplevel.h
@@ -56,6 +56,7 @@
 	void mousePressEvent(TQMouseEvent *);
 	void timerEvent(TQTimerEvent *);
 	void resizeEvent(TQResizeEvent *);
+	void showEvent(TQShowEvent *);
 
 private slots:
 
@@ -84,6 +85,9 @@
 	void actionEnableToggled(bool on);
 
 private:
+	void resizeTrayIcon();
+
+private:
 
 	static const int DEFAULT_TEA_TIME;