Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/main.qml
Show All 12 Lines | 1 | /* | |||
---|---|---|---|---|---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 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/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.1 | 21 | import QtQuick 2.7 | ||
22 | import QtQuick.Controls 1.3 | 22 | import QtQuick.Layouts 1.3 | ||
23 | import QtQuick.Controls 2.0 | ||||
23 | 24 | | |||
24 | import org.kde.kcm 1.0 | 25 | import org.kde.kcm 1.0 | ||
25 | import org.kde.plasma.core 2.0 as PlasmaCore /* for units.gridUnit */ | 26 | 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.kirigami 2.5 as Kirigami | ||
27 | import org.kde.plasma.private.volume 0.1 | 28 | import org.kde.plasma.private.volume 0.1 | ||
28 | 29 | | |||
29 | Kirigami.Page { | 30 | Kirigami.Page { | ||
30 | title: kcm.name | 31 | title: kcm.name | ||
31 | property int wheelDelta: 0 | | |||
32 | property QtObject sinkModel: SinkModel { } | 32 | property QtObject sinkModel: SinkModel { } | ||
33 | property QtObject sourceModel: SourceModel { } | 33 | property QtObject sourceModel: SourceModel { } | ||
34 | ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.") | 34 | ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.") | ||
35 | 35 | | |||
36 | contentItem: MouseArea { | 36 | // TODO: replace this TabBar-plus-Frame-in-a-ColumnLayout with whatever shakes | ||
37 | acceptedButtons: Qt.NoButton | 37 | // out of https://bugs.kde.org/show_bug.cgi?id=394296 | ||
38 | implicitWidth: units.gridUnit * 30 | 38 | ColumnLayout { | ||
39 | implicitHeight: units.gridUnit * 30 | 39 | anchors.fill: parent | ||
40 | 40 | spacing: 0 | |||
41 | onWheel: { | 41 | | ||
42 | if (tabView.childAt(wheel.x, wheel.y).objectName != "tabbar") { | 42 | TabBar { | ||
43 | wheel.accepted = false; | 43 | id: tabView | ||
44 | return; | 44 | | ||
45 | } | 45 | TabButton { | ||
46 | var delta = wheel.angleDelta.y || wheel.angleDelta.x; | 46 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Devices") | ||
47 | wheelDelta += delta; | 47 | } | ||
drosca: I don't really like those hardcodes, are you sure it won't break when using different QWidget… | |||||
I don't like them either, but the only way we can get rid of them without making the presentation really ugly is if we fix the bugs listed in the comments, or else stick with the QQC1 TabView. ngraham: I don't like them either, but the only way we can get rid of them without making the… | |||||
48 | // Magic number 120 for common "one click" | 48 | TabButton { | ||
49 | // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop | 49 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Applications") | ||
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 | } | 50 | } | ||
51 | TabButton { | ||||
52 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Advanced") | ||||
58 | } | 53 | } | ||
54 | } | ||||
55 | Frame { | ||||
56 | Layout.fillWidth: true | ||||
57 | Layout.fillHeight: true | ||||
59 | 58 | | |||
60 | TabView { | 59 | StackLayout { | ||
61 | id: tabView | | |||
62 | anchors.fill: parent | 60 | anchors.fill: parent | ||
63 | 61 | | |||
64 | Tab { | 62 | currentIndex: tabView.currentIndex | ||
65 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Devices") | 63 | | ||
66 | Devices {} | 64 | Devices { | ||
67 | } | 65 | Layout.fillWidth: true | ||
68 | Tab { | 66 | Layout.fillHeight: true | ||
69 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Applications") | 67 | } | ||
70 | Applications {} | 68 | Applications { | ||
71 | } | 69 | Layout.fillWidth: true | ||
72 | Tab { | 70 | Layout.fillHeight: true | ||
73 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Advanced") | 71 | } | ||
74 | Advanced {} | 72 | Advanced { | ||
73 | Layout.fillWidth: true | ||||
74 | Layout.fillHeight: true | ||||
75 | } | ||||
75 | } | 76 | } | ||
76 | } | 77 | } | ||
77 | } | 78 | } | ||
78 | } | 79 | } |
I don't really like those hardcodes, are you sure it won't break when using different QWidget style?