Migrate QQC1 to QQC2

Summary:
The TableView in digital clock widget time zone configuration is replaced with ListView. Other UI didn't change.

{F7635385}

Reviewers: #plasma, #plasma_workspaces, ngraham

Reviewed By: ngraham

Subscribers: GB_2, ahiemstra, broulik, kmaterka, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24798
wilder-5.18
Guo Yunhe 7 years ago
parent 0fff726ca4
commit b7b25010aa
  1. 2
      applets/appmenu/package/contents/ui/main.qml
  2. 89
      applets/digital-clock/package/contents/ui/configTimeZones.qml
  3. 32
      applets/systemmonitor/common/contents/ui/ConfigGeneral.qml
  4. 8
      sddm-theme/KeyboardButton.qml
  5. 5
      sddm-theme/Main.qml
  6. 4
      sddm-theme/SessionButton.qml
  7. 6
      wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml
  8. 6
      wallpapers/image/imagepackage/platformcontents/phone/ui/customwallpaper.qml

@ -18,7 +18,7 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls 1.4 import QtQuick.Controls 2.8
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
import QtQuick 2.0 import QtQuick 2.13
import QtQuick.Controls 1.2 as QtControls import QtQuick.Controls 2.13 as QQC2
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
@ -45,90 +45,63 @@ ColumnLayout {
} }
} }
// This is just for getting the column width
QtControls.CheckBox {
id: checkbox
visible: false
}
Kirigami.InlineMessage { Kirigami.InlineMessage {
id: messageWidget id: messageWidget
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Kirigami.Units.smallSpacing
type: Kirigami.MessageType.Warning type: Kirigami.MessageType.Warning
text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.")
showCloseButton: true showCloseButton: true
} }
QtControls.TextField { QQC2.TextField {
id: filter id: filter
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: i18n("Search Time Zones") placeholderText: i18n("Search Time Zones")
} }
QtControls.TableView { Item {
id: timeZoneView
signal toggleCurrent
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Keys.onSpacePressed: toggleCurrent() QQC2.ScrollView {
anchors.fill: parent
clip: true
Component.onCompleted: background.visible = true // enable border
model: TimeZoneFilterProxy { ListView {
sourceModel: timeZones id: listView
filterString: filter.text focus: true // keyboard navigation
} activeFocusOnTab: true // keyboard navigation
QtControls.TableViewColumn { model: TimeZoneFilterProxy {
role: "checked" sourceModel: timeZones
width: checkbox.width filterString: filter.text
delegate: }
QtControls.CheckBox {
id: checkBox
anchors.centerIn: parent
checked: styleData.value
activeFocusOnTab: false // only let the TableView as a whole get focus
onClicked: {
//needed for model's setData to be called
model.checked = checked;
}
Connections { delegate: QQC2.CheckDelegate {
target: timeZoneView id: checkbox
onToggleCurrent: { focus: true // keyboard navigation
if (styleData.row === timeZoneView.currentRow) { width: parent.width
model.checked = !checkBox.checked text: !city || city.indexOf("UTC") === 0 ? comment : comment ? i18n("%1, %2 (%3)", city, region, comment) : i18n("%1, %2", city, region)
} checked: model.checked
} onToggled: {
model.checked = checkbox.checked
listView.currentIndex = index // highlight
listView.forceActiveFocus() // keyboard navigation
} }
highlighted: ListView.isCurrentItem
} }
}
resizable: false
movable: false
}
QtControls.TableViewColumn {
role: "city"
title: i18n("City")
}
QtControls.TableViewColumn {
role: "region"
title: i18n("Region")
}
QtControls.TableViewColumn {
role: "comment"
title: i18n("Comment")
} }
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
QtControls.CheckBox { QQC2.CheckBox {
id: enableWheelCheckBox id: enableWheelCheckBox
text: i18n("Switch time zone with mouse wheel") text: i18n("Switch time zone with mouse wheel")
} }
} }
} }

@ -17,7 +17,6 @@
*/ */
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 as QQC1
import QtQuick.Controls 2.5 as QQC2 import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
@ -119,23 +118,28 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
// QQC2 SpinBox doesn't cleanly support non-integer values, which can be QQC2.SpinBox {
// worked around, but the code is messy and the user experience is
// somewhat poor. So for now, we stick with the QQC1 SpinBox
QQC1.SpinBox {
id: updateIntervalSpinBox id: updateIntervalSpinBox
Kirigami.FormData.label: i18n("Update interval:") Kirigami.FormData.label: i18n("Update interval:")
decimals: 1 from: 100
suffix: i18ncp("Suffix for spinbox (seconds)", " second", stepSize: 100
" seconds") to: 1000000
maximumValue: 1000 editable: true
stepSize: 0.1 validator: DoubleValidator {
onValueChanged: cfg_updateInterval = value * 1000 bottom: spinbox.from
Component.onCompleted: value = cfg_updateInterval / 1000 top: spinbox.to
}
textFromValue: function(value) {
var seconds = value / 1000
return i18n("%1 seconds", seconds.toFixed(1))
}
valueFromText: function(text) {
return parseFloat(text) * 1000
}
value: cfg_updateInterval
onValueModified: cfg_updateInterval = value
} }
Item { Item {
Kirigami.FormData.isSection: true Kirigami.FormData.isSection: true
} }

@ -25,9 +25,9 @@ PlasmaComponents.ToolButton {
QQC2.Menu { QQC2.Menu {
id: keyboardMenu id: keyboardMenu
property int largestWidth: 9999 property int largestWidth: 9999
Component.onCompleted: { Component.onCompleted: {
var trueWidth = 0; var trueWidth = 0;
for (var i = 0; i < keyboardMenu.count; i++) { for (var i = 0; i < keyboardMenu.count; i++) {
@ -63,11 +63,11 @@ PlasmaComponents.ToolButton {
id: menuItem id: menuItem
property string name: modelData.longName property string name: modelData.longName
property string shortName: modelData.shortName property string shortName: modelData.shortName
property real textWidth: text.contentWidth + 20 property real textWidth: text.contentWidth + 20
implicitWidth: text.contentWidth + 20 implicitWidth: text.contentWidth + 20
implicitHeight: Math.round(text.contentHeight * 1.6) implicitHeight: Math.round(text.contentHeight * 1.6)
contentItem: QQC2.Label { contentItem: QQC2.Label {
id: text id: text
font.pointSize: config.fontSize font.pointSize: config.fontSize

@ -20,7 +20,7 @@
import QtQuick 2.8 import QtQuick 2.8
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0 as QQC2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
@ -148,7 +148,6 @@ PlasmaCore.ColorScope {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
StackView { StackView {
id: mainStack id: mainStack
anchors { anchors {
@ -435,7 +434,7 @@ PlasmaCore.ColorScope {
DropShadow { DropShadow {
id: logoShadow id: logoShadow
anchors.fill: logo anchors.fill: logo
source: logo source: logo
visible: !softwareRendering && config.showlogo == "shown" visible: !softwareRendering && config.showlogo == "shown"
horizontalOffset: 1 horizontalOffset: 1
verticalOffset: 1 verticalOffset: 1

@ -45,7 +45,7 @@ PlasmaComponents.ToolButton {
QQC2.Menu { QQC2.Menu {
id: sessionMenu id: sessionMenu
property int largestWidth: 9999 property int largestWidth: 9999
Component.onCompleted: { Component.onCompleted: {
@ -55,7 +55,7 @@ PlasmaComponents.ToolButton {
} }
sessionMenu.largestWidth = trueWidth sessionMenu.largestWidth = trueWidth
} }
background: Rectangle { background: Rectangle {
implicitHeight: 40 implicitHeight: 40
implicitWidth: sessionMenu.largestWidth > sessionButton.implicitWidth ? sessionMenu.largestWidth : sessionButton.implicitWidth implicitWidth: sessionMenu.largestWidth > sessionButton.implicitWidth ? sessionMenu.largestWidth : sessionButton.implicitWidth

@ -22,7 +22,7 @@ import QtQuick 2.0
import org.kde.plasma.core 2.0 as Plasmacore import org.kde.plasma.core 2.0 as Plasmacore
import org.kde.plasma.wallpapers.image 2.0 as Wallpaper import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
import QtQuick.Controls 1.0 as QtControls import QtQuick.Controls 2.8 as QQC2
Item { Item {
id: root id: root
@ -41,7 +41,7 @@ Item {
//Rectangle { color: "orange"; x: formAlignment; width: formAlignment; height: 20 } //Rectangle { color: "orange"; x: formAlignment; width: formAlignment; height: 20 }
QtControls.ScrollView { QQC2.ScrollView {
anchors.fill: parent anchors.fill: parent
frameVisible: true frameVisible: true
@ -71,7 +71,7 @@ Item {
} }
} }
QtControls.Button { QQC2.Button {
anchors { anchors {
bottom: parent.bottom bottom: parent.bottom
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter

@ -22,7 +22,7 @@ import Qt.labs.folderlistmodel 2.1
import org.kde.plasma.core 2.0 as Plasmacore import org.kde.plasma.core 2.0 as Plasmacore
import org.kde.plasma.wallpapers.image 2.0 as Wallpaper import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
import QtQuick.Controls 1.0 as QtControls import QtQuick.Controls 2.8 as QQC2
Rectangle { Rectangle {
id: root id: root
@ -31,7 +31,7 @@ Rectangle {
SystemPalette {id: syspal} SystemPalette {id: syspal}
QtControls.ScrollView { QQC2.ScrollView {
anchors.fill: parent anchors.fill: parent
frameVisible: true frameVisible: true
@ -76,7 +76,7 @@ Rectangle {
} }
} }
} }
QtControls.Button { QQC2.Button {
anchors { anchors {
bottom: parent.bottom bottom: parent.bottom
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter

Loading…
Cancel
Save