2 * kPPP: A pppd Front End for the KDE project
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>
30 #include <kiconloader.h>
38 extern KPPPWidget
*p_kppp
;
41 DockWidget
*DockWidget::dock_widget
= 0;
43 DockWidget::DockWidget(QWidget
*parent
, const char *name
, PPPStats
*st
)
44 : KSystemTrayIcon(parent
), stats(st
) {
49 dock_none_pixmap
= UserIcon("dock_none");
50 dock_left_pixmap
= UserIcon("dock_left");
51 dock_right_pixmap
= UserIcon("dock_right");
52 dock_both_pixmap
= UserIcon("dock_both");
54 setIcon(dock_none_pixmap
);
56 // popup menu for right mouse button
57 popup_m
= contextMenu();
58 popup_m
->addAction(i18n("Details"), p_kppp
, SLOT(showStats()));
59 popup_m
->addSeparator();
60 popup_m
->addAction(i18n("Disconnect"), p_kppp
, SLOT(disconnect()));
61 // TODO see if we can rather connect the quit action to the
62 // main window's quit handling, bypassing KSystemTrayIcon::maybeQuit
64 actionCollection()->action(KStandardAction::name(KStandardAction::Quit
));
66 quit
->setVisible(false);
67 // connect to stats for little modem animation
68 connect(stats
, SIGNAL(statsChanged(int)), SLOT(paintIcon(int)));
70 DockWidget::dock_widget
= this;
74 DockWidget::~DockWidget() {
75 DockWidget::dock_widget
= 0;
79 void DockWidget::paintIcon (int status
) {
80 // animate modem lights
85 case PPPStats::BytesBoth
:
86 setIcon( dock_both_pixmap
);
88 case PPPStats::BytesIn
:
89 setIcon ( dock_left_pixmap
);
91 case PPPStats::BytesOut
:
92 setIcon ( dock_right_pixmap
);
94 case PPPStats::BytesNone
:
96 setIcon ( dock_none_pixmap
);
103 void DockWidget::take_stats() {
111 void DockWidget::stop_stats() {
115 #include "docking.moc"