Fix: after pause a download, it shows 100% progress. This is a regression of commit...
[kdenetwork.git] / kppp / docking.cpp
blobf9532f7a61cfd4b9513d7836b30e0d9aeb76dc7b
1 /*
2 * kPPP: A pppd Front End for the KDE project
4 * $Id$
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
9 * This file was contributed by Harri Porten <porten@tu-harburg.de>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <kactioncollection.h>
28 #include <kwindowsystem.h>
29 #include <klocale.h>
30 #include <kiconloader.h>
31 #include <kmenu.h>
33 #include "docking.h"
34 #include "main.h"
35 #include "pppstats.h"
36 //Added by qt3to4:
37 #include <QPixmap>
38 #include <QMouseEvent>
39 #include <QPaintEvent>
41 extern KPPPWidget *p_kppp;
43 // static member
44 DockWidget *DockWidget::dock_widget = 0;
46 DockWidget::DockWidget(QWidget *parent, const char *name, PPPStats *st)
47 : KSystemTrayIcon(parent), stats(st) {
49 setObjectName(name);
51 // load pixmaps
52 dock_none_pixmap = UserIcon("dock_none");
53 dock_left_pixmap = UserIcon("dock_left");
54 dock_right_pixmap = UserIcon("dock_right");
55 dock_both_pixmap = UserIcon("dock_both");
57 setIcon(dock_none_pixmap);
59 // popup menu for right mouse button
60 popup_m = contextMenu();
61 popup_m->addAction(i18n("Details"), p_kppp, SLOT(showStats()));
62 popup_m->addSeparator();
63 popup_m->addAction(i18n("Disconnect"), p_kppp, SLOT(disconnect()));
64 // TODO see if we can rather connect the quit action to the
65 // main window's quit handling, bypassing KSystemTrayIcon::maybeQuit
66 QAction *quit =
67 actionCollection()->action(KStandardAction::name(KStandardAction::Quit));
68 if (quit != 0)
69 quit->setVisible(false);
70 // connect to stats for little modem animation
71 connect(stats, SIGNAL(statsChanged(int)), SLOT(paintIcon(int)));
73 DockWidget::dock_widget = this;
77 DockWidget::~DockWidget() {
78 DockWidget::dock_widget = 0;
82 void DockWidget::paintIcon (int status) {
83 // animate modem lights
85 if(isVisible()) {
86 switch(status)
88 case PPPStats::BytesBoth:
89 setIcon( dock_both_pixmap );
90 break;
91 case PPPStats::BytesIn:
92 setIcon ( dock_left_pixmap );
93 break;
94 case PPPStats::BytesOut:
95 setIcon ( dock_right_pixmap );
96 break;
97 case PPPStats::BytesNone:
98 default:
99 setIcon ( dock_none_pixmap );
100 break;
106 void DockWidget::take_stats() {
107 if (isVisible()) {
108 stats->initStats();
109 stats->start();
114 void DockWidget::stop_stats() {
115 stats->stop();
118 #include "docking.moc"