Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.87 KB | None | 0 0
  1. /*
  2.     Copyright 2014-2015 Harald Sitter <sitter@kde.org>
  3.  
  4.     This program is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU General Public License as
  6.     published by the Free Software Foundation; either version 2 of
  7.     the License or (at your option) version 3 or any later version
  8.     accepted by the membership of KDE e.V. (or its successor approved
  9.     by the membership of KDE e.V.), which shall act as a proxy
  10.     defined in Section 14 of version 3 of the license.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. */
  20.  
  21. import QtQuick 2.1
  22. import QtQuick.Controls 1.3
  23.  
  24. import org.kde.kcm 1.0
  25. import org.kde.plasma.core 2.0 as PlasmaCore /* for units.gridUnit */
  26. import org.kde.kirigami 2.5 as Kirigami
  27. import org.kde.plasma.private.volume 0.1
  28.  
  29. Kirigami.Page {
  30.     title: kcm.name
  31.     property int wheelDelta: 0
  32.     property QtObject sinkModel: SinkModel { }
  33.     property QtObject sourceModel: SourceModel { }
  34.     ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.")
  35.  
  36.     contentItem: MouseArea {
  37.         acceptedButtons: Qt.NoButton
  38.         implicitWidth: units.gridUnit * 30
  39.         implicitHeight: units.gridUnit * 30
  40.  
  41.         onWheel: {
  42.             if (tabView.childAt(wheel.x, wheel.y).objectName != "tabbar") {
  43.                 wheel.accepted = false;
  44.                 return;
  45.             }
  46.             var delta = wheel.angleDelta.y || wheel.angleDelta.x;
  47.             wheelDelta += delta;
  48.             // Magic number 120 for common "one click"
  49.             // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
  50.             while (wheelDelta >= 120) {
  51.                 wheelDelta -= 120;
  52.                 tabView.currentIndex = Math.max(0, tabView.currentIndex - 1);
  53.             }
  54.             while (wheelDelta <= -120) {
  55.                 wheelDelta += 120;
  56.                 tabView.currentIndex = Math.min(tabView.count - 1, tabView.currentIndex + 1);
  57.             }
  58.         }
  59.  
  60.         TabView {
  61.             id: tabView
  62.             anchors.fill: parent
  63.  
  64.             Tab {
  65.                 title: i18ndc("kcm_pulseaudio", "@title:tab", "Devices")
  66.                 Devices {}
  67.             }
  68.             Tab {
  69.                 title: i18ndc("kcm_pulseaudio", "@title:tab", "Applications")
  70.                 Applications {}
  71.             }
  72.             Tab {
  73.                 title: i18ndc("kcm_pulseaudio", "@title:tab", "Advanced")
  74.                 Advanced {}
  75.             }
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement