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.Layouts 1.12
import ".."
HGridLayout {
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
import QtQuick 2.12
import QtQuick.Layouts 1.12
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 "../.."
import "../../Base"
import "../../Base/ButtonLayout"
import "../../Base/Buttons"
import "../../Dialogs"
HFlickableColumnPage {
@ -64,7 +64,7 @@ HFlickableColumnPage {
}
footer: ButtonLayout {
footer: AutoDirectionLayout {
ApplyButton {
id: saveButton

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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