diff options
author | Bruno dos Santos de Araujo <bruno.araujo@openbossa.org> | 2011-09-19 11:34:17 -0400 |
---|---|---|
committer | Bruno dos Santos de Araujo <bruno.araujo@openbossa.org> | 2011-09-19 17:33:45 -0400 |
commit | 055fec67791d6f2bead8346e15dfb0809695ffe6 (patch) | |
tree | cc1e7717f47b4a482882c4633b5d48eb927d99bc /mobility | |
parent | 72b7bab0de1c96183c28fc8919d2c1239e9e8ff2 (diff) |
Sysinfo example initial QML implementation
Diffstat (limited to 'mobility')
-rw-r--r-- | mobility/sysinfo/qml/AvailableLanguages.qml | 21 | ||||
-rw-r--r-- | mobility/sysinfo/qml/DevicePage.qml | 76 | ||||
-rw-r--r-- | mobility/sysinfo/qml/DisplayPage.qml | 57 | ||||
-rw-r--r-- | mobility/sysinfo/qml/GeneralPage.qml | 62 | ||||
-rw-r--r-- | mobility/sysinfo/qml/TabBarPage.qml | 26 | ||||
-rw-r--r-- | mobility/sysinfo/qml/main.py | 176 | ||||
-rw-r--r-- | mobility/sysinfo/qml/main.qml | 10 |
7 files changed, 428 insertions, 0 deletions
diff --git a/mobility/sysinfo/qml/AvailableLanguages.qml b/mobility/sysinfo/qml/AvailableLanguages.qml new file mode 100644 index 0000000..279ae0b --- /dev/null +++ b/mobility/sysinfo/qml/AvailableLanguages.qml @@ -0,0 +1,21 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +Page { + id: availableLanguages + anchors.margins: UiConstants.DefaultMargin + orientationLock: PageOrientation.LockPortrait + + ListView { + anchors.fill: parent + anchors.centerIn: parent + model: dataModel.availableManagers + delegate: Button { + text: modelData + onClicked: { + languageButton.text = text + pageStack.pop() + } + } + } +} diff --git a/mobility/sysinfo/qml/DevicePage.qml b/mobility/sysinfo/qml/DevicePage.qml new file mode 100644 index 0000000..7f64395 --- /dev/null +++ b/mobility/sysinfo/qml/DevicePage.qml @@ -0,0 +1,76 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +Page { + id: devicePage + orientationLock: PageOrientation.LockLandscape + Flickable { + id: flickableDevice + anchors.fill: parent + flickableDirection: Flickable.VerticalFlick + contentHeight: columnDevice.height + toolBarLayout.height + contentWidth: flickableDevice.width + Column { + id: columnDevice + anchors.top: parent.top + anchors.topMargin: 20 + anchors.left: parent.left + anchors.leftMargin: 20 + spacing: 25 + ProgressBar { + id: progressBar + minimumValue: 0 + maximumValue: 100 + value: 10 + width: parent.width + } + Label { text: "Power state" } + ButtonColumn { + RadioButton { text: "Unknown power" } + RadioButton { text: "Battery power" } + RadioButton { text: "Wall power" } + RadioButton { text: "Wall Power charging Battery" } + spacing: 10 + } + Row { + Label { text: "IMEI: " } + Label { id: labelIMEI; text: dataModel.imei } + } + Row { + Label { text: "IMSI: " } + Label { id: labelIMSI; text: dataModel.imsi } + } + Row { + Label { text: "Manufacturer: " } + Label { id: labelManufacturer; text: dataModel.manufacturer } + } + Row { + Label { text: "Model: " } + Label { id: labelModel; text: dataModel.model } + } + Row { + Label { text: "Product: " } + Label { id: labelProduct; text: dataModel.product } + } + Row { + Button { id: buttonLock; iconSource: "../general_unlock.png"; checked: dataModel.deviceLock } + Label { text: "Device lock"; anchors.verticalCenter: parent.verticalCenter } + } + Row { + Label { text: "Current profile: " } + Label { id: labelProfile; text: dataModel.profile } + } + Row { + Label { text: "Input method " } + Label { id: labelInputMethod; text: dataModel.inputMethod } + } + Row { + Label { text: "Bluetooth power: " } + Label { id: labelBluetoothPower; text: dataModel.bluetoothPower } + } + } + } + ScrollDecorator { + flickableItem: flickableColumn + } +} diff --git a/mobility/sysinfo/qml/DisplayPage.qml b/mobility/sysinfo/qml/DisplayPage.qml new file mode 100644 index 0000000..582f874 --- /dev/null +++ b/mobility/sysinfo/qml/DisplayPage.qml @@ -0,0 +1,57 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +Page { + id: displayPage + orientationLock: PageOrientation.LockLandscape + Flickable { + id: flickableDisplay + anchors.fill: parent + flickableDirection: Flickable.VerticalFlick + contentHeight: columnDisplay.height + toolBarLayout.height + contentWidth: flickableDisplay.width + Column { + id: columnDisplay + anchors.top: parent.top + anchors.topMargin: 20 + anchors.left: parent.left + anchors.leftMargin: 20 + spacing: 25 + Row { + Label { text: "Brightness: " } + Label { id: labelBrightness; text: dataModel.displayBrightness } + } + Row { + Label { text: "Color depth: " } + Label { id: labelColorDepth; text: dataModel.colorDepth } + } +/* Row { + Label { text: "Orientation: " } + Label { id: labelOrientation; text: "" } + } + Row { + Label { text: "Contrast: " } + Label { id: labelContrast; text: "" } + } + Row { + Label { text: "DPI Width: " } + Label { id: labelDPIWidth; text: "" } + } + Row { + Label { text: "DPI Height: " } + Label { id: labelDPIHeight; text: "" } + } + Row { + Label { text: "Physical Width: " } + Label { id: labelPhysicalWidth; text: "" } + } + Row { + Label { text: "Physical Height: " } + Label { id: labelPhysicalHeight; text: "" } + }*/ + } + } + ScrollDecorator { + flickableItem: flickableColumn + } +} diff --git a/mobility/sysinfo/qml/GeneralPage.qml b/mobility/sysinfo/qml/GeneralPage.qml new file mode 100644 index 0000000..69b4722 --- /dev/null +++ b/mobility/sysinfo/qml/GeneralPage.qml @@ -0,0 +1,62 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +Page { + id: generalPage + orientationLock: PageOrientation.LockLandscape + + Column { + anchors.top: parent.top + anchors.topMargin: 20 + anchors.left: parent.left + anchors.leftMargin: 20 + spacing: 25 + Row { + spacing: 20 + Label { text: "Current language:" } + Label { id: currentLanguage; text: dataModel.currentLanguage } + } + Row { + spacing: 20 + Label { text: "Current country:" } + Label { id: currentCountry; text: "currentCountry" } + } + Row { + spacing: 20 + Label { text: "Available languages:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: languageButton + text: "Select a language" + onClicked: { + pageStack.push(Qt.createComponent("AvailableLanguages.qml")) + } + } + } + Row { + spacing: 20 + Label { text: "Version"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: versionButton + text: "Select version" + onClicked: pageStack.push(Qt.createComponent("AvailableVersions.qml")) + + } + TextField { + text: "" + } + } + + Row { + spacing: 20 + Label { text: "Feature supported"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: featureButton + text: "Select feature" + onClicked: pageStack.push(Qt.createComponent("AvailableFeatures.qml")) + } + TextField { + text: "" + } + } + } +} diff --git a/mobility/sysinfo/qml/TabBarPage.qml b/mobility/sysinfo/qml/TabBarPage.qml new file mode 100644 index 0000000..6fd1a57 --- /dev/null +++ b/mobility/sysinfo/qml/TabBarPage.qml @@ -0,0 +1,26 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +Page { + id: tabBarPage + + orientationLock: PageOrientation.LockLandscape + tools: ToolBarLayout { + id: toolBarLayout + ButtonRow { + platformStyle: TabButtonStyle { } + TabButton { text: "General"; tab: generalTab } + TabButton { text: "Device"; tab: deviceTab } + TabButton { text: "Display"; tab: displayTab } + TabButton { text: "Storage"; tab: storageTab } + TabButton { text: "Network"; tab: networkTab } + TabButton { text: "Screen saver"; tab: screenSaverTab } + } + } + TabGroup { + currentTab: generalTab + GeneralPage { id: generalTab } + DevicePage { id: deviceTab } + DisplayPage { id: displayTab } + } +} diff --git a/mobility/sysinfo/qml/main.py b/mobility/sysinfo/qml/main.py new file mode 100644 index 0000000..389faca --- /dev/null +++ b/mobility/sysinfo/qml/main.py @@ -0,0 +1,176 @@ +#!/usr/bin/python + +import sys +import os + +from PySide import QtCore +from PySide import QtGui +from PySide import QtDeclarative +from PySide import QtOpenGL +from QtMobility.SystemInfo import QSystemInfo, QSystemDeviceInfo, QSystemDisplayInfo, QSystemStorageInfo, QSystemNetworkInfo, QSystemScreenSaver + + +class SystemInfoModel(QtCore.QObject): + changed = QtCore.Signal() + + def __init__(self): + super(SystemInfoModel, self).__init__() + + def _currentLanguage(self): return self.__currentLanguage + def _displayBrightness(self): return self.__displayBrightness + def _colorDepth(self): return self.__colorDepth + def _imsi(self): return self.__imsi + def _imei(self): return self.__imei + def _manufacturer(self): return self.__manufacturer + def _product(self): return self.__product + def _model(self): return self.__model + def _profile(self): return self.__profile + def _inputMethod(self): return self.__inputMethod + def _bluetoothPower(self): return self.__bluetoothPower + def _availableLanguages(self): return self.__availableLanguages + def _deviceLock(self): return self.__deviceLock + + #@QtCore.Property(str, notify=changed) + #def currentLanguage(self): + #return self.__currentLanguage + + currentLanguage = QtCore.Property(str, _currentLanguage, notify=changed) + displayBrightness = QtCore.Property(int, _displayBrightness, notify=changed) + colorDepth = QtCore.Property(int, _colorDepth, notify=changed) + imei = QtCore.Property(str, _imei, notify=changed) + imsi = QtCore.Property(str, _imsi, notify=changed) + manufacturer = QtCore.Property(str, _manufacturer, notify=changed) + product = QtCore.Property(str, _product, notify=changed) + model = QtCore.Property(str, _model, notify=changed) + profile = QtCore.Property(str, _profile, notify=changed) + inputMethod = QtCore.Property(str, _inputMethod, notify=changed) + deviceLock = QtCore.Property(bool, _deviceLock, notify=changed) + availableLanguages = QtCore.Property("QStringList", _availableLanguages, notify=changed) + + def setupAll(self): + self.setupGeneral() + self.setupDevice() + self.setupDisplay() + + def setupGeneral(self): + self.systemInfo = QSystemInfo(self) + + self.__currentLanguage = self.systemInfo.currentLanguage() + self.__availableLanguages = self.systemInfo.availableLanguages() + print self.__availableLanguages + self.emit(QtCore.SIGNAL('changed()')) + + def setupDevice(self): + self.di = QSystemDeviceInfo(self) + self.__batteryLevel = self.di.batteryLevel() + self.di.batteryLevelChanged.connect(self.updateBatteryStatus) + self.di.batteryStatusChanged.connect(self.displayBatteryStatus) + self.di.powerStateChanged.connect(self.updatePowerState) + self.__imei = self.di.imei() + self.__imsi = self.di.imsi() + self.__manufacturer = self.di.manufacturer() + self.__model = self.di.model() + self.__product = self.di.productName() + self.__deviceLock = self.di.isDeviceLocked() + + methods = self.di.inputMethodType() + inputs = [] + if methods & QSystemDeviceInfo.Keys: + inputs.append("Keys") + if methods & QSystemDeviceInfo.Keypad: + inputs.append("Keypad") + if methods & QSystemDeviceInfo.Keyboard: + inputs.append("Keyboard") + if methods & QSystemDeviceInfo.SingleTouch: + inputs.append("Touch Screen") + if methods & QSystemDeviceInfo.MultiTouch: + inputs.append("Multi touch") + if methods & QSystemDeviceInfo.Mouse: + inputs.append("Mouse") + + self.__inputMethod = " ".join(inputs) + self.updateSimStatus() + self.updateProfile() + + #self.di.currentProfileChanged.connect(self.onProfileChanged) + + self.emit(QtCore.SIGNAL('changed()')) + + def setupDisplay(self): + self.di = QSystemDisplayInfo() + self.__displayBrightness = self.di.displayBrightness(0) + self.__colorDepth = self.di.colorDepth(0) + self.emit(QtCore.SIGNAL('changed()')) + + + def updateBatteryStatus(self, status): + self.__batteryLevel = status + self.emit(QtCore.SIGNAL('changed()')) + + def displayBatteryStatus(self, status): + pass + + def updatePowerState(self, newState): + pass + + + def updateSimStatus(self): + if self.di: + status = self.di.simStatus() + if status == QSystemDeviceInfo.SimLocked: + simstring = "Sim Locked"; + elif status == QSystemDeviceInfo.SimNotAvailable: + simstring = "Sim not available"; + elif status == QSystemDeviceInfo.SingleSimAvailable: + simstring = "Single Sim Available"; + elif status == QSystemDeviceInfo.DualSimAvailable: + simstring = "Dual Sim available"; + else: + simstring = "" + + self.__simStatus = simstring + + + def updateProfile(self): + if self.di: + current = self.di.currentProfile() + if current == QSystemDeviceInfo.UnknownProfile: + profilestring = "Unknown" + elif current == QSystemDeviceInfo.SilentProfile: + profilestring = "Silent" + elif current == QSystemDeviceInfo.NormalProfile: + profilestring = "Normal" + elif current == QSystemDeviceInfo.LoudProfile: + profilestring = "Loud" + elif current == QSystemDeviceInfo.VibProfile: + profilestring = "Vibrate" + elif current == QSystemDeviceInfo.OfflineProfile: + profilestring = "Offline"; + elif current == QSystemDeviceInfo.PowersaveProfile: + profilestring = "Powersave"; + elif current == QSystemDeviceInfo.CustomProfile: + profilestring = "custom"; + + self.__profile = profilestring + +class SystemInfoUI(QtCore.QObject): + def __init__(self): + super(SystemInfoUI, self).__init__() + self.view = QtDeclarative.QDeclarativeView() + self.glw = QtOpenGL.QGLWidget() + self.view.setViewport(self.glw) + + #self.view.setSource(os.path.join('qml','main.qml')) + self.view.setSource('main.qml') + self.rc = self.view.rootContext() + self.model = SystemInfoModel() + self.model.setupAll() + self.rc.setContextProperty('dataModel', self.model) + self.view.showFullScreen() + self.systemInfo = QSystemInfo(self) + + +if __name__ == "__main__": + app = QtGui.QApplication([]) + ui = SystemInfoUI() + app.exec_() diff --git a/mobility/sysinfo/qml/main.qml b/mobility/sysinfo/qml/main.qml new file mode 100644 index 0000000..57bdc31 --- /dev/null +++ b/mobility/sysinfo/qml/main.qml @@ -0,0 +1,10 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +PageStackWindow { + id: appWindow + + initialPage: tabBarPage + + TabBarPage { id: tabBarPage } +} |