Skip to content

Commit

Permalink
Merge pull request #18 from locusf/wifi_panel
Browse files Browse the repository at this point in the history
[statusbar] Wifi panel added for statusbar
  • Loading branch information
locusf committed Jun 19, 2014
2 parents b12c667 + 28a33bf commit dadf526
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/qml/Statusbar.qml
Expand Up @@ -75,6 +75,7 @@ Item {
onAvailableChanged: updateTechnologies()
onTechnologiesEnabledChanged: updateTechnologies()
onTechnologiesChanged: updateTechnologies()

}

NetworkTechnology {
Expand All @@ -91,6 +92,23 @@ Item {
key: "Cellular.DataTechnology"
}

TechnologyModel {
id: wifimodel
name: "wifi"
onPoweredChanged: {
if (powered)
wifimodel.requestScan()
}
}

Loader {
id: panel_loader
anchors.bottom: root.top
height: 240
width: parent.width
visible: false
}

Row {
spacing: 16
StatusbarItem {
Expand Down Expand Up @@ -140,6 +158,7 @@ Item {
return "image://theme/icon_wifi_0"
}
}
panel: WifiPanel {}
}
StatusbarItem {
source: "image://theme/icon_bt_normal"
Expand Down
12 changes: 11 additions & 1 deletion src/qml/StatusbarItem.qml
Expand Up @@ -4,14 +4,24 @@ Item {
height: 48
width: 48
property alias source: icon.source

property string panel_source
property Component panel
Image {
id: icon
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
if (panel_source !== "" && !panel) {
panel_loader.source = panel_source
panel_loader.visible = !panel_loader.visible
}
if (panel && panel_source === "") {
panel_loader.sourceComponent = panel
panel_loader.visible = !panel_loader.visible
}

if (icon.source.toString().match("normal")) {
icon.source = icon.source.toString().replace("normal","focused")
} else {
Expand Down
80 changes: 80 additions & 0 deletions src/qml/WifiPanel.qml
@@ -0,0 +1,80 @@
/****************************************************************************************
**
** Copyright (C) 2014 Aleksi Suomalainen <suomalainen.aleksi@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/

import QtQuick 2.1
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

Component {
Rectangle {
height: 240
width: root.width
color: "#313131"
opacity: 0.5
Column {
Repeater {
model: wifimodel
delegate: Item {
width: root.width
height: 40
function getStrengthIndex(strength) {
var strengthIndex = "0"

if (strength >= 59) {
strengthIndex = "4"
} else if (strength >= 55) {
strengthIndex = "3"
} else if (strength >= 50) {
strengthIndex = "2"
} else if (strength >= 40) {
strengthIndex = "1"
}
return strengthIndex
}
Row {
spacing: 12
Image {
source: "image://theme/icon_wifi_focused" + getStrengthIndex(modelData.strength)
}

Label {
anchors.leftMargin: 20
width: root.width
font.pointSize: 8
text: modelData.name
wrapMode: Text.Wrap
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/resources-qml.qrc
Expand Up @@ -39,5 +39,6 @@
<file>qml/Statusbar.qml</file>
<file>qml/images/wallpaper-portrait-bubbles.png</file>
<file>qml/StatusbarItem.qml</file>
<file>qml/WifiPanel.qml</file>
</qresource>
</RCC>
3 changes: 2 additions & 1 deletion src/src.pro
Expand Up @@ -45,6 +45,7 @@ OTHER_FILES += qml/*.qml \
qml/scripts/desktop.js \
qml/FeedsPage.qml \
qml/Statusbar.qml \
qml/StatusbarItem.qml
qml/StatusbarItem.qml \
qml/WifiPanel.qml


0 comments on commit dadf526

Please sign in to comment.