• 版块
    • 热门
    • 最新
    • 标签
    • 关于
    • 捐赠
    • 注册
    • 登录

    让APP某一个页面保持屏幕常亮的方法

    已定时 已固定 已锁定 已移动 教程
    3 帖子 2 发布者 1.1k 浏览
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • BirdZhangB 在线
      BirdZhang 船长
      最后由 编辑

      https://git.merproject.org/mer-core/nemo-keepalive/tree/master

      有时候我们需要在某些页面让屏幕一直亮着,不要熄屏,这时候就需要它了

      • 添加依赖
        在spec或yaml中添加libkeepalive
      • 在qml中使用
      /* ------------------------------------------------------------------------- *
       * Copyright (C) 2014 Jolla Ltd.
       * Contact: Martin Jones <[email protected]>
       * License: BSD
       * ------------------------------------------------------------------------- */
      import QtQuick 2.0
      import Sailfish.Silica 1.0
      import Nemo.KeepAlive 1.1
      ApplicationWindow {
          property var startTime
          property var currentTime
          initialPage: Component {
              Page {
                  KeepAlive {
                      id: keepAlive
                  }
                  Timer {
                      id: timer
                      property int count
                      interval: 1000
                      repeat: true
                      onTriggered: {
                          ++count
                          currentTime = new Date()
                      }
                  }
                  Column {
                      width: parent.width
                      spacing: Theme.paddingLarge
                      anchors.centerIn: parent
                      TextSwitch {
                          text: "Keep Alive"
                          anchors.horizontalCenter: parent.horizontalCenter
                          onCheckedChanged: {
                              startTime = new Date()
                              currentTime = new Date()
                              timer.count = 0
                              timer.restart()
                              keepAlive.enabled = checked
                          }
                      }
                      Label {
                          anchors.horizontalCenter: parent.horizontalCenter
                          text: "Duration: " + Math.round((currentTime.getTime() - startTime.getTime())/1000)
                      }
                      Label {
                          anchors.horizontalCenter: parent.horizontalCenter
                          text: "Timer triggered: " + timer.count
                      }
                  }
                  Component.onCompleted: {
                      startTime = new Date()
                      currentTime = new Date()
                      timer.start()
                  }
              }
          }
      }
      

      ———扬帆起航🚢

      1 条回复 最后回复 回复 引用 0
      • 天苯天 离线
        天苯 大副
        最后由 编辑

        也许该试着学学qml了……?

        Welcome to our Telegram group: https://t.me/jollacn
        —— I can do nothing but behave like a clown. 🖋️

        BirdZhangB 1 条回复 最后回复 回复 引用 0
        • BirdZhangB 在线
          BirdZhang 船长 @天苯
          最后由 编辑

          @天苯 可以学学,这东西跨平台,写客户端界面首选

          ———扬帆起航🚢

          1 条回复 最后回复 回复 引用 0
          • 1 / 1
          • 第一个帖子
            最后一个帖子
          Copyright © 2017-2024 旗鱼俱乐部 旗鱼系统交流论坛
          🐟🐠🐡论坛客户端下载🐟🐠🐡
          友情链接 SailfishOS.org | Jolla | 官方论坛 | 移植wiki| 第三方商店 | BirdZhang的博客| Securest
          除非另有声明,本网站采用知识共享“署名 4.0 中国大陆”许可协议授权。
          根据相关法律法规,本站不对欧盟用户提供服务。
          Powered by NodeBB