Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/main.qml
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
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.1 | ||
22 | import QtQuick.Controls 1.3 | 22 | import QtQuick.Layouts 1.1 | ||
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 int wheelDelta: 0 | ||
32 | property QtObject sinkModel: SinkModel { } | 33 | property QtObject sinkModel: SinkModel { } | ||
33 | property QtObject sourceModel: SourceModel { } | 34 | property QtObject sourceModel: SourceModel { } | ||
34 | ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.") | 35 | ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.") | ||
35 | 36 | | |||
36 | contentItem: MouseArea { | 37 | ColumnLayout { | ||
37 | acceptedButtons: Qt.NoButton | 38 | anchors.fill: parent | ||
38 | implicitWidth: units.gridUnit * 30 | 39 | | ||
39 | implicitHeight: units.gridUnit * 30 | 40 | TabBar { | ||
40 | 41 | id: tabView | |||
41 | onWheel: { | 42 | | ||
42 | if (tabView.childAt(wheel.x, wheel.y).objectName != "tabbar") { | 43 | // Without this, the tab bar is one pixel too far to the right because | ||
43 | wheel.accepted = false; | 44 | // the scrollviews that make up the content are inset one pixel | ||
44 | return; | 45 | // Also partially a workaround for | ||
45 | } | 46 | // https://bugs.kde.org/show_bug.cgi?id=394296 | ||
46 | var delta = wheel.angleDelta.y || wheel.angleDelta.x; | 47 | Layout.leftMargin: 1 | ||
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… | |||||
47 | wheelDelta += delta; | 48 | | ||
48 | // Magic number 120 for common "one click" | 49 | TabButton { | ||
49 | // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop | 50 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Devices") | ||
50 | while (wheelDelta >= 120) { | 51 | } | ||
51 | wheelDelta -= 120; | 52 | TabButton { | ||
52 | tabView.currentIndex = Math.max(0, tabView.currentIndex - 1); | 53 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Applications") | ||
53 | } | 54 | } | ||
54 | while (wheelDelta <= -120) { | 55 | TabButton { | ||
55 | wheelDelta += 120; | 56 | text: i18ndc("kcm_pulseaudio", "@title:tab", "Advanced") | ||
56 | tabView.currentIndex = Math.min(tabView.count - 1, tabView.currentIndex + 1); | | |||
57 | } | 57 | } | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | TabView { | 60 | SwipeView { | ||
61 | id: tabView | 61 | // Work around https://bugs.kde.org/show_bug.cgi?id=394296 | ||
62 | anchors.fill: parent | 62 | Layout.topMargin: -7 | ||
63 | Layout.fillWidth: true | ||||
64 | Layout.fillHeight: true | ||||
65 | | ||||
66 | clip: true | ||||
63 | 67 | | |||
64 | Tab { | 68 | currentIndex: tabView.currentIndex | ||
65 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Devices") | 69 | | ||
66 | Devices {} | 70 | Devices { | ||
67 | } | 71 | Layout.fillWidth: true | ||
68 | Tab { | 72 | Layout.fillHeight: true | ||
69 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Applications") | 73 | } | ||
70 | Applications {} | 74 | Applications { | ||
71 | } | 75 | Layout.fillWidth: true | ||
72 | Tab { | 76 | Layout.fillHeight: true | ||
73 | title: i18ndc("kcm_pulseaudio", "@title:tab", "Advanced") | 77 | } | ||
74 | Advanced {} | 78 | Advanced { | ||
79 | Layout.fillWidth: true | ||||
80 | Layout.fillHeight: true | ||||
75 | } | 81 | } | ||
76 | } | 82 | } | ||
77 | } | 83 | } | ||
78 | } | 84 | } |
I don't really like those hardcodes, are you sure it won't break when using different QWidget style?