summaryrefslogtreecommitdiffstats
path: root/wifi/picture.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /wifi/picture.cpp
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'wifi/picture.cpp')
-rw-r--r--wifi/picture.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/wifi/picture.cpp b/wifi/picture.cpp
new file mode 100644
index 00000000..11d77cae
--- /dev/null
+++ b/wifi/picture.cpp
@@ -0,0 +1,92 @@
+/***************************************************************************
+ picture.cpp - description
+ -------------------
+ begin : Mon Aug 19 2002
+ copyright : (C) 2002 by Stefan Winter
+ email : mail@stefan-winter.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qwidget.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <kstandarddirs.h>
+#include "picture.h"
+#include "interface_wireless.h"
+
+#define X_OFFSET 20
+#define Y_OFFSET 10
+
+Picture::Picture (QWidget * parent, Interface_wireless * device):QWidget (parent,
+ "picture")
+{
+ this->device = device;
+ KStandardDirs finder;
+ kdedir = finder.findResourceDir ("data", "kwifimanager/pics/no_card.png");
+ kdedir += "kwifimanager/pics/";
+ NO_CARD = new QPixmap (kdedir + "no_card.png");
+ AD_HOC = new QPixmap (kdedir + "ad_hoc.png");
+ ALL_ALONE = new QPixmap (kdedir + "all_alone.png");
+ AP_CONNECT = new QPixmap (kdedir + "ap_connect.png");
+}
+
+QSize Picture::mySizeHint() {
+ /* make this quite general, just in case someone uses different icons */
+ QSize* temp = new QSize(NO_CARD->size());
+ if (AD_HOC->size().width() > temp->width ()) { temp->setWidth (AD_HOC->size().width ()); }
+ if (AD_HOC->size().height() > temp->height()) { temp->setHeight(AD_HOC->size().height()); }
+ if (ALL_ALONE->size().width() > temp->width ()) { temp->setWidth (ALL_ALONE->size().width ()); }
+ if (ALL_ALONE->size().height() > temp->height()) { temp->setHeight(ALL_ALONE->size().height()); }
+ if (AP_CONNECT->size().width() > temp->width ()) { temp->setWidth (AP_CONNECT->size().width ()); }
+ if (AP_CONNECT->size().height() > temp->height()) { temp->setHeight(AP_CONNECT->size().height()); }
+ temp->setWidth (temp->width() + X_OFFSET);
+ temp->setHeight(temp->height() + Y_OFFSET);
+ return *temp;
+}
+
+Picture::~Picture ()
+{
+ delete NO_CARD;
+ delete AD_HOC;
+ delete ALL_ALONE;
+ delete AP_CONNECT;
+
+}
+
+void
+Picture::paintEvent (QPaintEvent *)
+{
+ QPainter *picturepainter = new QPainter (this);
+ double freq;
+ int mode;
+ device->get_mode (mode);
+ int sig, noise, qual;
+ device->get_current_quality (sig, noise, qual);
+ if (!device->get_device_freq (freq) || device->get_txpower_disabled())
+ {
+ picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *NO_CARD);
+ }
+ else if (mode == 1)
+ {
+ picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *AD_HOC);
+ }
+ else if (qual == 0)
+ {
+ picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *ALL_ALONE);
+ }
+ else if (qual > 0)
+ {
+ picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *AP_CONNECT);
+ }
+ else
+ picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *NO_CARD);
+ delete picturepainter;
+}