Warning, /pim/itinerary/src/app/BarcodeScanModeController.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick
0008 import org.kde.solidextras as Solid
0009 
0010 /** Shared logic and state for the barcode scan mode.
0011  *  That is, disable screen locking and switch to full brightness.
0012  */
0013 QtObject {
0014     id: controller
0015     /** Whether or not we are in barcode scan mode. */
0016     property bool enabled: false
0017     /** The page showing the barcode.
0018      *  Scan mode will automatically be disabled when the page is left or moves down in the page stack.
0019      */
0020     property var page
0021     /** Enable full brightness. */
0022     property bool fullBrightness: true
0023 
0024     function toggle() {
0025         controller.enabled = !controller.enabled;
0026     }
0027 
0028     onEnabledChanged: function() {
0029         console.log("switching barcode scan mode", controller.enabled);
0030         if (controller.fullBrightness) {
0031             Solid.BrightnessManager.toggleBrightness();
0032         }
0033         Solid.LockManager.toggleInhibitScreenLock(i18n("In barcode scanning mode"));
0034     }
0035 
0036     property var __pageWatcher: Connections {
0037         target: page
0038         function onVisibleChanged() {
0039             controller.enabled = false;
0040         }
0041     }
0042 
0043     property var __pageStackWather: Connections {
0044         target: applicationWindow().pageStack
0045         function onCurrentItemChanged() {
0046             if (applicationWindow().pageStack.currentItem != page) {
0047                 controller.enabled = false;
0048             }
0049         }
0050     }
0051 
0052     Component.onDestruction: controller.enabled = false
0053 }