/usr/share
directory. This directory contains the interface codes and scripts of almost all applications installed on the phone.harbour
prefix followed by the program identifier. Such a prefix avoids the possible intersection of names with system names. Catalogs of standard applications are accompanied by jolla
and sailfish
. The rest is related to system functions./usr/share/jolla-settings
, which contains the following objects:entries
- stores information about the structure of the settings;pages
directory - stores pages and settings items;widgets
directory is usually not used;settings.qml
file is the main application launch file;x-openvpn.xml
- stores information about connecting to a VPN server.pages
directory. It is divided into subdirectories according to the types of settings: bluetooth
, sounds
, etc. The screen settings are located in the display
directory. Therefore, /usr/share/jolla-settings/pages/display
is the complete path relative to which the subsequent work will take place.$ cd /usr/share/jolla-settings/pages/display
$ grep -H 'brightness' *
BrightnessSlider.qml: label: qsTrId("settings_display-la-brightness")
BrightnessSlider.qml: value: displaySettings.brightness
BrightnessSlider.qml: onValueChanged: displaySettings.brightness = Math.round(value)
BrightnessSlider.qml: onBrightnessChanged: slider.value = brightness
display.qml: id: brightnessSlider
display.qml: entryPath: "system_settings/look_and_feel/display/brightness_slider"
display.qml: text: qsTrId("settings_display-la-adaptive_brightness")
BrightnessSlider.qml
file.$ grep -C 1 'displaySettings' ./BrightnessSlider.qml
label: qsTrId("settings_display-la-brightness")
maximumValue: displaySettings.maximumBrightness
minimumValue: 1
value: displaySettings.brightness
stepSize: 1
onValueChanged: displaySettings.brightness = Math.round(value)
DisplaySettings {
id: displaySettings
onBrightnessChanged: slider.value = brightness
DisplaySettings
object and change the brightness
field value, taking into account that the minimum brightness value is one and the maximum is stored in the maximumBrightness
field.$ grep 'import' ./BrightnessSlider.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import com.jolla.settings.system 1.0
import org.nemomobile.systemsettings 1.0
QtQuick
and Sailfish.Silica
are standard interface development modules and do not provide access to settings. com.jolla.settings.system
contains internal objects for the settings application to work and is not of interest to other programs. It remains org.nemomobile.systemsettings
, describing the necessary component. import QtQuick 2.0 import org.nemomobile.systemsettings 1.0 Item { id: brightnessControl /* . * @param: value -- 1 () maximumBrightness () */ function setBrightness(value) { if (value <= 1) setMinimumBrightness(); else if (value >= displaySettings.maximumBrightness) setMaximumBrightness(); else displaySettings.brightness = value; } /* . * @param: percents -- . */ function increaseBrightness(percents) { setBrightness(displaySettings.brightness + _calcDelta(percents)) } /* . * @param: percents -- . */ function decreaseBrightness(percents) { setBrightness(displaySettings.brightness - _calcDelta(percents)) } /* . */ function setMinimumBrightness() { displaySettings.brightness = 1 } /* . */ function setMaximumBrightness() { displaySettings.brightness = displaySettings.maximumBrightness } /* . * @param: percents -- . * @return: . */ function _calcDelta(percents) { return Math.round(displaySettings.maximumBrightness / 100 * percents) } DisplaySettings { id: displaySettings } }
/usr/share/jolla-settings/pages/sounds
directory and check the keywords:$ cd /usr/share/jolla-settings/pages/sounds
$ grep -i -C 1 -H 'volume' *
SoundsPage.qml-
SoundsPage.qml: VolumeSlider {
SoundsPage.qml: id: volumeSlider
SoundsPage.qml: property string entryPath: "system_settings/look_and_feel/sounds/ringer_volume"
SoundsPage.qml- width: parent.width
--
VolumeSlider.qml- height: implicitHeight + valueLabel.height + Theme.paddingSmall
VolumeSlider.qml: //% "Ringtone volume"
VolumeSlider.qml: label: qsTrId("settings_sounds_la_volume")
VolumeSlider.qml- maximumValue: 100
--
VolumeSlider.qml- if (!externalChange) {
VolumeSlider.qml: profileControl.ringerVolume = value
VolumeSlider.qml- profileControl.profile = (value > 0) ? "general" : "silent"
--
VolumeSlider.qml- slider.externalChange = true
VolumeSlider.qml: slider.value = profileControl.ringerVolume
VolumeSlider.qml- slider.externalChange = false
--
VolumeSlider.qml-
VolumeSlider.qml: onRingerVolumeChanged: {
VolumeSlider.qml- slider.externalChange = true
VolumeSlider.qml: slider.value = profileControl.ringerVolume
VolumeSlider.qml- slider.externalChange = false
profileControl
element, and requires not only specifying the volume value, but also switching the profile. We will get more detailed information about the mentioned element:$ grep -C 1 'profileControl' ./VolumeSlider.qml
if (!externalChange) {
profileControl.ringerVolume = value
profileControl.profile = (value > 0) ? "general" : "silent"
}
--
slider.externalChange = true
slider.value = profileControl.ringerVolume
slider.externalChange = false
--
ProfileControl {
id: profileControl
--
slider.externalChange = true
slider.value = profileControl.ringerVolume
slider.externalChange = false
$ grep 'import' ./VolumeSlider.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import com.jolla.settings.system 1.0
import org.nemomobile.systemsettings 1.0
import QtQuick 2.0 import org.nemomobile.systemsettings 1.0 Item { id: volumeControl /* . * @param: value -- 0 () 100 (). */ function setVolume(value) { if (value <= 0) { setMinimumVolume(); } else if (value >= 100) { setMaximumVolume(); } else { profileControl.ringerVolume = value; _setProfile(); } } /* . * @param: percents -- . */ function increaseVolume(percents) { setVolume(profileControl.ringerVolume + percents) } /* . * @param: percents -- . */ function decreaseVolume(percents) { setVolume(profileControl.ringerVolume - percents) } /* . */ function setMinimumVolume() { profileControl.ringerVolume = 0; _setProfile(); } /* . */ function setMaximumVolume() { profileControl.ringerVolume = 100; _setProfile(); } /* . */ function _setProfile() { profileControl.profile = (profileControl.ringerVolume > 0) ? "general" : "silent" } ProfileControl { id: profileControl } }
general
and silent
keywords to control the sound profile of the system (main and silent, respectively). These are two reserved values ββthat determine the behavior of the system depending on the set volume value.MeeGo.Connman
module, which provides the NetworkManagerFactory
component. By setting the value of the instance.offlineMode
field of this object to true
or false
, it becomes possible to turn the specified mode on and off, respectively. import QtQuick 2.0 import MeeGo.Connman 0.2 Item { id: flightControl /* β β. */ function turnOnFlightMode() { connMgr.instance.offlineMode = true } /* β β. */ function turnOffFlightMode() { connMgr.instance.offlineMode = false } /* β β. */ function switchFlightMode() { connMgr.instance.offlineMode = !connMgr.instance.offlineMode } NetworkManagerFactory { id: connMgr } }
MeeGo.Connman
module is also connected, but it uses the TechnologyModel
component, the value of the field whose powered
accepts is true
or false
to turn on or turn off Bluetooth, respectively. It is worth noting that the rest of the work with the interface is performed using standard Qt features . import QtQuick 2.0 import MeeGo.Connman 0.2 Item { id: bluetoothControl /* bluetooth. */ function turnOnBluetooth() { btTechModel.powered = true } /* bluetooth. */ function turnOffBluetooth() { btTechModel.powered = false } /* bluetooth. */ function switchBluetooth() { btTechModel.powered = !btTechModel.powered } TechnologyModel { id: btTechModel name: "bluetooth" } }
ambience
) or system font size ( fontSize
), control Wi-Fi ( wifi
) or Internet sharing ( tethering
).Source: https://habr.com/ru/post/336278/
All Articles