Bug 145019 - keep passive dialog-info for longer
Summary: keep passive dialog-info for longer
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE RPMs Linux
: NOR wishlist with 1 vote (vote)
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-04 14:39 UTC by Maciej Pilichowski
Modified: 2007-05-05 13:34 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Pilichowski 2007-05-04 14:39:53 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    SuSE RPMs

When you move your mouse over the systray icon the popup dialog appears with info about down/up-loads. Sometimes it is persistent-like (it disappears when you leave the icon area) sometimes it vanishes in 1 second. I think the latter one is kind of side-effect of something, please fix this, so the user could read info in her/his pace.
Comment 1 Joris Guisson 2007-05-05 13:34:49 UTC
SVN commit 661372 by guisson:

Improved system tray popup box : 
- We now use balloon style KPassivePopup instead of Qt tooltips
- It also only disappears when the cursor is moved away from the tray icon 
- The text can be updated 

BUG: 145019



 M  +3 -0      ChangeLog  
 M  +3 -2      apps/ktorrent/Makefile.am  
 A             apps/ktorrent/trayhoverpopup.cpp   [License: GPL (v2+)]
 A             apps/ktorrent/trayhoverpopup.h   [License: GPL (v2+)]
 M  +39 -17    apps/ktorrent/trayicon.cpp  
 M  +10 -3     apps/ktorrent/trayicon.h  


--- trunk/extragear/network/ktorrent/ChangeLog #661371:661372
@@ -23,6 +23,9 @@
 - Added speed limits for individual torrents
 - Added dynamic diskspace checking.
 - Added option to disable diskspace preallocation
+- Improved system tray popup icon : we now use balloon style and use
+KPassivePopup instead of Qt tooltips, it also only disappears when the cursor
+is moved away from the tray icon and the text can be updated
 
 Changes in 2.1.4
 - Fixed crash in parsing of DHT messages
--- trunk/extragear/network/ktorrent/apps/ktorrent/Makefile.am #661371:661372
@@ -26,7 +26,7 @@
 	ktorrentviewmenu.cpp leaktrace.cpp main.cpp pastedialog.cpp pastedlgbase.ui pref.cpp \
 	queuedialog.cpp queuedialog.h queuedlg.ui scandialog.cpp scandlgbase.ui \
 	speedlimitsdlg.cpp speedlimitsdlgbase.ui torrentcreatordlg.cpp torrentcreatordlg.h \
-	torrentcreatordlgbase.ui trayicon.cpp viewmanager.cpp
+	torrentcreatordlgbase.ui trayhoverpopup.cpp trayicon.cpp viewmanager.cpp
 
 xdg_apps_DATA = ktorrent.desktop
 
@@ -34,7 +34,8 @@
 # these are the headers for your project
 noinst_HEADERS = dcopinterface.h fileselectdlg.h ipfilterwidget.h ktorrent.h \
 	ktorrentcore.h ktorrentdcop.h ktorrentview.h ktorrentviewitem.h ktorrentviewmenu.h \
-	pastedialog.h pref.h scandialog.h speedlimitsdlg.h trayicon.h viewmanager.h
+	pastedialog.h pref.h scandialog.h speedlimitsdlg.h trayhoverpopup.h trayicon.h \
+	viewmanager.h
 
 # client stuff
 
--- trunk/extragear/network/ktorrent/apps/ktorrent/trayicon.cpp #661371:661372
@@ -29,6 +29,8 @@
 #include "ktorrentcore.h"
 #include <interfaces/functions.h>
 #include <net/socketmonitor.h>
+#include <util/log.h>
+#include "trayhoverpopup.h"
 
 
 using namespace bt;
@@ -38,11 +40,14 @@
 		: KSystemTray(parent, name)
 {
 	m_core = tc;
-	setPixmap(loadIcon("ktorrent"));
+	m_kt_pix = loadIcon("ktorrent");
+	setPixmap(m_kt_pix);
 	paint=new QPainter( this );
 	drawContents ( paint );
 	previousDownloadHeight=0;
 	previousUploadHeight=0;
+	
+	m_hover_popup = new TrayHoverPopup(m_kt_pix,this);
 
 	connect(this,SIGNAL(quitSelected()),kapp,SLOT(quit()));
 	connect(m_core, SIGNAL(finished(kt::TorrentInterface* )),
@@ -64,11 +69,26 @@
 TrayIcon::~TrayIcon()
 {}
 
+void TrayIcon::enterEvent(QEvent* ev)
+{
+	KSystemTray::enterEvent(ev);
+	m_hover_popup->enterEvent();
+}
+
+void TrayIcon::leaveEvent(QEvent* )
+{
+	m_hover_popup->leaveEvent();
+}
+
 void TrayIcon::updateStats(const CurrentStats stats, bool showBars,int downloadBandwidth, int uploadBandwidth )
 {
-	QString tip = i18n("<center><b>KTorrent</b></center><table cellpadding='2' cellspacing='2' align='center'><tr><td><b>Speed:</b></td><td></td></tr><tr><td>Download: <font color='#1c9a1c'>%1</font></td><td>Upload: <font color='#990000'>%2</font></td></tr><tr><td><b>Transfer:</b></td><td></td></tr><tr><td>Download: <font color='#1c9a1c'>%3</font></td><td>Upload: <font color='#990000'>%4</font></td></tr></table>").arg(KBytesPerSecToString((double)stats.download_speed/1024.0)).arg(KBytesPerSecToString((double)stats.upload_speed/1024.0)).arg(BytesToString(stats.bytes_downloaded)).arg(BytesToString(stats.bytes_uploaded));
-	QToolTip::add
-		(this, tip);
+	QString tip = i18n("<table cellpadding='2' cellspacing='2' align='center'><tr><td><b>Speed:</b></td><td></td></tr><tr><td>Download: <font color='#1c9a1c'>%1</font></td><td>Upload: <font color='#990000'>%2</font></td></tr><tr><td><b>Transfer:</b></td><td></td></tr><tr><td>Download: <font color='#1c9a1c'>%3</font></td><td>Upload: <font color='#990000'>%4</font></td></tr></table>")
+			.arg(KBytesPerSecToString((double)stats.download_speed/1024.0))
+			.arg(KBytesPerSecToString((double)stats.upload_speed/1024.0))
+			.arg(BytesToString(stats.bytes_downloaded))
+			.arg(BytesToString(stats.bytes_uploaded));
+	m_hover_popup->updateText(tip);
+	
 	if(showBars)
 		drawSpeedBar(stats.download_speed/1024,stats.upload_speed/1024, downloadBandwidth, uploadBandwidth);
 }
@@ -97,6 +117,12 @@
 	previousUploadHeight=UploadHeight;	
 }
 
+void TrayIcon::showPassivePopup(const QString & msg,const QString & title)
+{
+	KPassivePopup::message(KPassivePopup::Balloon,title,msg,m_kt_pix, this);
+}
+
+
 void TrayIcon::finished(TorrentInterface* tc)
 {
 	if (!Settings::showPopups())
@@ -112,7 +138,7 @@
 						.arg(KBytesPerSecToString(speed_down / tc->getRunningTimeDL()))
 						.arg(KBytesPerSecToString(speed_up / tc->getRunningTimeUL()));
 
-	KPassivePopup::message(i18n("Download completed"),msg,loadIcon("ktorrent"), this);
+	showPassivePopup(msg,i18n("Download completed"));
 }
 
 void TrayIcon::maxShareRatioReached(kt::TorrentInterface* tc)
@@ -131,8 +157,7 @@
 			.arg(BytesToString(s.bytes_uploaded))
 			.arg(KBytesPerSecToString(speed_up / tc->getRunningTimeUL()));
 	
-	KPassivePopup::message(i18n("Seeding completed"),
-						   msg,loadIcon("ktorrent"), this);
+	showPassivePopup(msg,i18n("Seeding completed"));
 }
 
 void TrayIcon::torrentStoppedByError(kt::TorrentInterface* tc, QString msg)
@@ -143,7 +168,8 @@
 	const TorrentStats & s = tc->getStats();
 	QString err_msg = i18n("<b>%1</b> has been stopped with the following error: <br>%2")
 				.arg(s.torrent_name).arg(msg);
-	KPassivePopup::message(i18n("Error"),err_msg,loadIcon("ktorrent"),this);
+	
+	showPassivePopup(err_msg,i18n("Error"));
 }
 
 void TrayIcon::corruptedData(kt::TorrentInterface* tc)
@@ -155,7 +181,7 @@
 	QString err_msg = i18n("Corrupted data has been found in the torrent <b>%1</b>"
 			"<br>It would be a good idea to do a data integrity check on the torrent.")
 			.arg(s.torrent_name);
-	KPassivePopup::message(i18n("Error"),err_msg,loadIcon("ktorrent"),this);
+	showPassivePopup(err_msg,i18n("Error"));
 }
 
 void TrayIcon::queuedTorrentOverMaxRatio(kt::TorrentInterface* tc)
@@ -169,8 +195,7 @@
 	
 	QString msg = i18n("<b>%1</b> has reached its maximum share ratio of %2 and cannot be enqueued. Remove the limit manually if you want to continue seeding.").arg(s.torrent_name).arg(s.max_share_ratio);
 	
-	KPassivePopup::message(i18n("Torrent cannot be enqueued."),
-						   msg,loadIcon("ktorrent"), this);
+	showPassivePopup(msg,i18n("Torrent cannot be enqueued."));
 }
 
 void TrayIcon::canNotStart(kt::TorrentInterface* tc,kt::TorrentStartResponse reason)
@@ -194,13 +219,11 @@
 						"Cannot download more than %n torrents. <br>",Settings::maxDownloads());
 		}
 		msg += i18n("Go to Settings -> Configure KTorrent, if you want to change the limits.");
-		KPassivePopup::message(i18n("Torrent cannot be started"),
-							   msg,loadIcon("ktorrent"), this);
+		showPassivePopup(msg,i18n("Torrent cannot be started"));
 		break;
 	case kt::NOT_ENOUGH_DISKSPACE:
 		msg += i18n("There is not enough diskspace available.");
-		KPassivePopup::message(i18n("Torrent cannot be started"),
-							   msg,loadIcon("ktorrent"), this);
+		showPassivePopup(msg,i18n("Torrent cannot be started"));
 		break;
 	default:
 		break;
@@ -219,8 +242,7 @@
 	if(stopped)
 		msg.prepend(i18n("Torrent has been stopped.<br />"));
 	
-	KPassivePopup::message(i18n("Device running out of space"),
-						   msg,loadIcon("ktorrent"), this);
+	showPassivePopup(msg,i18n("Device running out of space"));
 }
 
 SetMaxRate::SetMaxRate( KTorrentCore* tc, int t, QWidget *parent, const char *name):KPopupMenu(parent, name)
--- trunk/extragear/network/ktorrent/apps/ktorrent/trayicon.h #661371:661372
@@ -21,6 +21,7 @@
 #ifndef TRAYICON_H
 #define TRAYICON_H
 
+
 #include <ksystemtray.h>
 #include <kpopupmenu.h>
 #include <qpainter.h>
@@ -32,6 +33,7 @@
 
 using namespace bt;
 class QString;
+class TrayHoverPopup;
 
 struct TrayStats
 {
@@ -39,8 +41,6 @@
 	bt::Uint32 upload_speed;
 	bt::Uint64 bytes_downloaded;
 	bt::Uint64 bytes_uploaded;
-
-
 };
 
 /**
@@ -54,9 +54,14 @@
 	TrayIcon(KTorrentCore* tc, QWidget *parent = 0, const char *name = 0);
 	virtual ~TrayIcon();
 
+	/// Update stats for system tray icon
 	void updateStats(const CurrentStats stats, bool showBars=false, int downloadBandwidth=0, int uploadBandwidth=0);
+	
 private:
 	void drawSpeedBar(int downloadSpeed, int uploadSpeed, int downloadBandwidth, int uploadBandwidth);
+	void showPassivePopup(const QString & msg,const QString & titile);
+	virtual void enterEvent(QEvent* ev);
+	virtual void leaveEvent(QEvent* ev);
 
 private slots:
 	/**
@@ -99,12 +104,14 @@
 	
 	///Shows passive popup message
 	void lowDiskSpace(kt::TorrentInterface* tc, bool stopped);
-
+	
 private:
 	KTorrentCore* m_core;
 	QPainter *paint;
 	int previousDownloadHeight;
 	int previousUploadHeight;
+	TrayHoverPopup* m_hover_popup;
+	QPixmap m_kt_pix;
 };
 
 class SetMaxRate : public KPopupMenu