Refactor ButtonLayout module components

- Rename ButtonLayout module to just Buttons

- Rename ButtonLayout into AutoDirectionLayout and move it to Base,
  it's useful not just for buttons

- Rename OtherButton into GroupButton, which is now the base of all
  other Buttons buttons

- Add generic (Positive|Middle|Negative)Button components, which are now
  the base for (Apply|Cancel)Button
This commit is contained in:
miruka 2020-07-11 22:52:14 -04:00
parent 67f1572a18
commit ed030f7dd9
33 changed files with 90 additions and 91 deletions

View File

@ -2,7 +2,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import ".."
HGridLayout { HGridLayout {
readonly property real summedImplicitWidth: { readonly property real summedImplicitWidth: {

View File

@ -1,14 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import ".."
HButton {
text: qsTr("Apply")
icon.name: "apply"
icon.color: theme.colors.positiveBackground
Layout.preferredHeight: theme.baseElementsHeight
Layout.fillWidth: true
}

View File

@ -1,14 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import ".."
HButton {
text: qsTr("Cancel")
icon.name: "cancel"
icon.color: theme.colors.negativeBackground
Layout.preferredHeight: theme.baseElementsHeight
Layout.fillWidth: true
}

View File

@ -0,0 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
PositiveButton {
text: qsTr("Apply")
icon.name: "apply"
}

View File

@ -0,0 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
NegativeButton {
text: qsTr("Cancel")
icon.name: "cancel"
}

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import ".." import ".."

View File

@ -0,0 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
GroupButton {
icon.color: theme.colors.middleBackground
}

View File

@ -0,0 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
GroupButton {
icon.color: theme.colors.negativeBackground
}

View File

@ -0,0 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
GroupButton {
icon.color: theme.colors.positiveBackground
}

View File

@ -5,7 +5,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../.." import "../.."
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
import "../../Dialogs" import "../../Dialogs"
HFlickableColumnPage { HFlickableColumnPage {
@ -64,7 +64,7 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: saveButton id: saveButton

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
import "../../Base/HTile" import "../../Base/HTile"
HTile { HTile {
@ -133,10 +133,10 @@ HTile {
label.text: qsTr("Actions:") label.text: qsTr("Actions:")
label.horizontalAlignment: Qt.AlignHCenter label.horizontalAlignment: Qt.AlignHCenter
ButtonLayout { AutoDirectionLayout {
width: parent.width width: parent.width
ApplyButton { PositiveButton {
enabled: model.type !== "no_keys" enabled: model.type !== "no_keys"
icon.name: "device-verify" icon.name: "device-verify"
text: text:
@ -163,7 +163,7 @@ HTile {
} }
} }
CancelButton { NegativeButton {
text: qsTr("Sign out") text: qsTr("Sign out")
icon.name: "device-delete" icon.name: "device-delete"
onClicked: deviceTile.deleteRequest() onClicked: deviceTile.deleteRequest()

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -15,8 +15,8 @@ HFlickableColumnPage {
function takeFocus() { exportButton.forceActiveFocus() } function takeFocus() { exportButton.forceActiveFocus() }
footer: ButtonLayout { footer: AutoDirectionLayout {
OtherButton { GroupButton {
id: exportButton id: exportButton
text: qsTr("Export") text: qsTr("Export")
icon.name: "export-keys" icon.name: "export-keys"
@ -32,7 +32,7 @@ HFlickableColumnPage {
) )
} }
OtherButton { GroupButton {
text: qsTr("Import") text: qsTr("Import")
icon.name: "import-keys" icon.name: "import-keys"

View File

@ -5,7 +5,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../.." import "../.."
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
import "../../PythonBridge" import "../../PythonBridge"
import "../../ShortcutBundles" import "../../ShortcutBundles"
@ -100,15 +100,15 @@ HColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
OtherButton { GroupButton {
id: refreshButton id: refreshButton
text: qsTr("Refresh") text: qsTr("Refresh")
icon.name: "device-refresh-list" icon.name: "device-refresh-list"
onClicked: page.loadDevices() onClicked: page.loadDevices()
} }
OtherButton { NegativeButton {
id: signOutCheckedButton id: signOutCheckedButton
enabled: deviceList.model.count > 0 enabled: deviceList.model.count > 0
text: text:
@ -117,7 +117,6 @@ HColumnPage {
qsTr("Sign out checked") qsTr("Sign out checked")
icon.name: "device-delete-checked" icon.name: "device-delete-checked"
icon.color: theme.colors.negativeBackground
onClicked: onClicked:
deviceList.selectedCount ? deviceList.selectedCount ?
page.deleteDevices(...deviceList.checkedIndice) : page.deleteDevices(...deviceList.checkedIndice) :

View File

@ -3,13 +3,13 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
function takeFocus() { registerButton.forceActiveFocus() } function takeFocus() { registerButton.forceActiveFocus() }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: registerButton id: registerButton
text: qsTr("Register from Riot") text: qsTr("Register from Riot")

View File

@ -3,13 +3,13 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
function takeFocus() { resetButton.forceActiveFocus() } function takeFocus() { resetButton.forceActiveFocus() }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: resetButton id: resetButton
text: qsTr("Reset password from Riot") text: qsTr("Reset password from Riot")

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -77,7 +77,7 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
enabled: page.canSignIn enabled: page.canSignIn
text: qsTr("Sign in") text: qsTr("Sign in")

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../.." import "../.."
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -52,7 +52,7 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: applyButton id: applyButton
text: qsTr("Create") text: qsTr("Create")

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../.." import "../.."
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -64,7 +64,7 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: applyButton id: applyButton
text: qsTr("Start chat") text: qsTr("Start chat")

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../.." import "../.."
import "../../Base" import "../../Base"
import "../../Base/ButtonLayout" import "../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -57,7 +57,7 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: joinButton id: joinButton
text: qsTr("Join") text: qsTr("Join")

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../../../Base" import "../../../../Base"
import "../../../../Base/ButtonLayout" import "../../../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: page id: page
@ -27,8 +27,8 @@ HFlickableColumnPage {
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { PositiveButton {
text: qsTr("They're the same") text: qsTr("They're the same")
icon.name: "device-verified" icon.name: "device-verified"
onClicked: { onClicked: {
@ -46,7 +46,7 @@ HFlickableColumnPage {
} }
} }
CancelButton { NegativeButton {
text: qsTr("They differ") text: qsTr("They differ")
icon.name: "device-blacklisted" icon.name: "device-blacklisted"
onClicked: { onClicked: {

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../../../Base" import "../../../../Base"
import "../../../../Base/ButtonLayout" import "../../../../Base/Buttons"
import "../../../../Base/HTile" import "../../../../Base/HTile"
HTile { HTile {

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../../Base" import "../../../Base"
import "../../../Base/ButtonLayout" import "../../../Base/Buttons"
HFlickableColumnPage { HFlickableColumnPage {
id: settingsView id: settingsView
@ -63,7 +63,7 @@ HFlickableColumnPage {
color: theme.chat.roomPane.roomSettings.background color: theme.chat.roomPane.roomSettings.background
} }
footer: ButtonLayout { footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
enabled: anyChange enabled: anyChange
loading: saveFuture !== null loading: saveFuture !== null

View File

@ -1,7 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12 import QtQuick 2.12
import "../Base/ButtonLayout" import "../Base"
import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -12,7 +13,7 @@ HFlickableColumnPopup {
property var preClearCallback: null property var preClearCallback: null
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: clearButton id: clearButton
text: qsTr("Clear") text: qsTr("Clear")

View File

@ -2,7 +2,7 @@
import QtQuick 2.12 import QtQuick 2.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
import "../PythonBridge" import "../PythonBridge"
PasswordPopup { PasswordPopup {

View File

@ -1,7 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12 import QtQuick 2.12
import "../Base/ButtonLayout" import "../Base"
import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -29,7 +30,7 @@ HFlickableColumnPopup {
} }
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: forgetButton id: forgetButton
text: qsTr("Forget") text: qsTr("Forget")

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HColumnPopup { HColumnPopup {
id: popup id: popup
@ -46,7 +46,7 @@ HColumnPopup {
} }
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: inviteButton id: inviteButton
text: qsTr("Invite") text: qsTr("Invite")

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -18,8 +18,8 @@ HFlickableColumnPopup {
property var blacklistedCallback: null property var blacklistedCallback: null
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { PositiveButton {
visible: ! deviceIsCurrent visible: ! deviceIsCurrent
text: qsTr("They match") text: qsTr("They match")
icon.name: "device-verified" icon.name: "device-verified"
@ -37,7 +37,7 @@ HFlickableColumnPopup {
} }
} }
CancelButton { NegativeButton {
visible: ! popup.deviceIsCurrent visible: ! popup.deviceIsCurrent
text: qsTr("They differ") text: qsTr("They differ")
icon.name: "device-blacklisted" icon.name: "device-blacklisted"

View File

@ -1,7 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12 import QtQuick 2.12
import "../Base/ButtonLayout" import "../Base"
import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -13,7 +14,7 @@ HFlickableColumnPopup {
property var leftCallback: null property var leftCallback: null
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: leaveButton id: leaveButton
icon.name: "room-leave" icon.name: "room-leave"

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -51,7 +51,7 @@ HFlickableColumnPopup {
} }
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
id: validateButton id: validateButton
text: qsTr("Confirm") text: qsTr("Confirm")

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -38,7 +38,7 @@ HFlickableColumnPopup {
} }
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
text: qsTr("Remove") text: qsTr("Remove")
icon.name: "remove-message" icon.name: "remove-message"

View File

@ -3,7 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -30,7 +30,7 @@ HFlickableColumnPopup {
} }
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { ApplyButton {
text: text:
operation === "disinvite" ? qsTr("Disinvite") : operation === "disinvite" ? qsTr("Disinvite") :

View File

@ -2,7 +2,8 @@
import QtQuick 2.12 import QtQuick 2.12
import ".." import ".."
import "../Base/ButtonLayout" import "../Base"
import "../Base/Buttons"
HFlickableColumnPopup { HFlickableColumnPopup {
id: popup id: popup
@ -11,8 +12,8 @@ HFlickableColumnPopup {
property string userId: "" property string userId: ""
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { PositiveButton {
id: exportButton id: exportButton
text: qsTr("Export keys") text: qsTr("Export keys")
icon.name: "export-keys" icon.name: "export-keys"
@ -29,11 +30,10 @@ HFlickableColumnPopup {
) )
} }
OtherButton { MiddleButton {
id: signOutButton id: signOutButton
text: qsTr("Sign out now") text: qsTr("Sign out now")
icon.name: "sign-out" icon.name: "sign-out"
icon.color: theme.colors.middleBackground
onClicked: { onClicked: {
if (ModelStore.get("accounts").count < 2 || if (ModelStore.get("accounts").count < 2 ||

View File

@ -4,7 +4,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/Buttons"
HColumnPopup { HColumnPopup {
id: popup id: popup
@ -15,8 +15,8 @@ HColumnPopup {
property string traceback: "" property string traceback: ""
page.footer: ButtonLayout { page.footer: AutoDirectionLayout {
ApplyButton { PositiveButton {
text: qsTr("Report") text: qsTr("Report")
icon.name: "report-error" icon.name: "report-error"
enabled: false // TODO enabled: false // TODO