-
-
Notifications
You must be signed in to change notification settings - Fork 317
Add terminal multiplexer launcher #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
salah-walid
wants to merge
12
commits into
AvengeMedia:master
Choose a base branch
from
salah-walid:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a5866f0
Add tmux
salah-walid 2d2d921
Add mux modal
salah-walid 29d1e19
Restore the settings config version
salah-walid 704a8f6
Revert typo
salah-walid 9469d18
Use DankModal for InputModal
salah-walid 8fd1866
Simplify terminal flags
salah-walid 8084245
use showWithOptions for inputModals instead
salah-walid 800cfea
Fix translation
salah-walid 9022d2e
Fix precommit
salah-walid 20626c1
use Quickshell.env("TERMINAL") to choose terminal
salah-walid 3c82236
Fix typo
salah-walid 8d20cb1
Hide muxModal after creating new session
salah-walid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,312 @@ | ||
| import QtQuick | ||
| import qs.Common | ||
| import qs.Modals.Common | ||
| import qs.Widgets | ||
|
|
||
| DankModal { | ||
| id: root | ||
|
|
||
| layerNamespace: "dms:input-modal" | ||
| keepPopoutsOpen: true | ||
|
|
||
| property string inputTitle: "" | ||
| property string inputMessage: "" | ||
| property string inputPlaceholder: "" | ||
| property string inputText: "" | ||
| property string confirmButtonText: "Confirm" | ||
| property string cancelButtonText: "Cancel" | ||
| property color confirmButtonColor: Theme.primary | ||
| property var onConfirm: function (text) {} | ||
| property var onCancel: function () {} | ||
| property int selectedButton: -1 | ||
| property bool keyboardNavigation: false | ||
|
|
||
| function show(title, message, onConfirmCallback, onCancelCallback) { | ||
| inputTitle = title || ""; | ||
| inputMessage = message || ""; | ||
| inputPlaceholder = ""; | ||
| inputText = ""; | ||
| confirmButtonText = "Confirm"; | ||
| cancelButtonText = "Cancel"; | ||
| confirmButtonColor = Theme.primary; | ||
| onConfirm = onConfirmCallback || ((text) => {}); | ||
| onCancel = onCancelCallback || (() => {}); | ||
| selectedButton = -1; | ||
| keyboardNavigation = false; | ||
| open(); | ||
| } | ||
|
|
||
| function showWithOptions(options) { | ||
| inputTitle = options.title || ""; | ||
| inputMessage = options.message || ""; | ||
| inputPlaceholder = options.placeholder || ""; | ||
| inputText = options.initialText || ""; | ||
| confirmButtonText = options.confirmText || "Confirm"; | ||
| cancelButtonText = options.cancelText || "Cancel"; | ||
| confirmButtonColor = options.confirmColor || Theme.primary; | ||
| onConfirm = options.onConfirm || ((text) => {}); | ||
| onCancel = options.onCancel || (() => {}); | ||
| selectedButton = -1; | ||
| keyboardNavigation = false; | ||
| open(); | ||
| } | ||
|
|
||
| function confirmAndClose() { | ||
| const text = inputText; | ||
| close(); | ||
| if (onConfirm) { | ||
| onConfirm(text); | ||
| } | ||
| } | ||
|
|
||
| function cancelAndClose() { | ||
| close(); | ||
| if (onCancel) { | ||
| onCancel(); | ||
| } | ||
| } | ||
|
|
||
| function selectButton() { | ||
| if (selectedButton === 0) { | ||
| cancelAndClose(); | ||
| } else { | ||
| confirmAndClose(); | ||
| } | ||
| } | ||
|
|
||
| shouldBeVisible: false | ||
| allowStacking: true | ||
| modalWidth: 350 | ||
| modalHeight: contentLoader.item ? contentLoader.item.implicitHeight + Theme.spacingM * 2 : 200 | ||
| enableShadow: true | ||
| shouldHaveFocus: true | ||
| onBackgroundClicked: cancelAndClose() | ||
| onOpened: { | ||
| Qt.callLater(function () { | ||
| if (contentLoader.item && contentLoader.item.textInputRef) { | ||
| contentLoader.item.textInputRef.forceActiveFocus(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| content: Component { | ||
| FocusScope { | ||
| anchors.fill: parent | ||
| implicitHeight: mainColumn.implicitHeight | ||
| focus: true | ||
|
|
||
| property alias textInputRef: textInput | ||
|
|
||
| Keys.onPressed: function (event) { | ||
| const textFieldFocused = textInput.activeFocus; | ||
|
|
||
| switch (event.key) { | ||
| case Qt.Key_Escape: | ||
| root.cancelAndClose(); | ||
| event.accepted = true; | ||
| break; | ||
| case Qt.Key_Tab: | ||
| if (textFieldFocused) { | ||
| root.keyboardNavigation = true; | ||
| root.selectedButton = 0; | ||
| textInput.focus = false; | ||
| } else { | ||
| root.keyboardNavigation = true; | ||
| if (root.selectedButton === -1) { | ||
| root.selectedButton = 0; | ||
| } else if (root.selectedButton === 0) { | ||
| root.selectedButton = 1; | ||
| } else { | ||
| root.selectedButton = -1; | ||
| textInput.forceActiveFocus(); | ||
| } | ||
| } | ||
| event.accepted = true; | ||
| break; | ||
| case Qt.Key_Left: | ||
| if (!textFieldFocused) { | ||
| root.keyboardNavigation = true; | ||
| root.selectedButton = 0; | ||
| event.accepted = true; | ||
| } | ||
| break; | ||
| case Qt.Key_Right: | ||
| if (!textFieldFocused) { | ||
| root.keyboardNavigation = true; | ||
| root.selectedButton = 1; | ||
| event.accepted = true; | ||
| } | ||
| break; | ||
| case Qt.Key_Return: | ||
| case Qt.Key_Enter: | ||
| if (root.selectedButton !== -1) { | ||
| root.selectButton(); | ||
| } else { | ||
| root.confirmAndClose(); | ||
| } | ||
| event.accepted = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| Column { | ||
| id: mainColumn | ||
| anchors.left: parent.left | ||
| anchors.right: parent.right | ||
| anchors.top: parent.top | ||
| anchors.leftMargin: Theme.spacingL | ||
| anchors.rightMargin: Theme.spacingL | ||
| anchors.topMargin: Theme.spacingL | ||
| spacing: 0 | ||
|
|
||
| StyledText { | ||
| text: root.inputTitle | ||
| font.pixelSize: Theme.fontSizeLarge | ||
| color: Theme.surfaceText | ||
| font.weight: Font.Medium | ||
| width: parent.width | ||
| horizontalAlignment: Text.AlignHCenter | ||
| } | ||
|
|
||
| Item { | ||
| width: 1 | ||
| height: Theme.spacingL | ||
| } | ||
|
|
||
| StyledText { | ||
| text: root.inputMessage | ||
| font.pixelSize: Theme.fontSizeMedium | ||
| color: Theme.surfaceText | ||
| width: parent.width | ||
| horizontalAlignment: Text.AlignHCenter | ||
| wrapMode: Text.WordWrap | ||
| visible: root.inputMessage !== "" | ||
| } | ||
|
|
||
| Item { | ||
| width: 1 | ||
| height: root.inputMessage !== "" ? Theme.spacingL : 0 | ||
| visible: root.inputMessage !== "" | ||
| } | ||
|
|
||
| Rectangle { | ||
| width: parent.width | ||
| height: 40 | ||
| radius: Theme.cornerRadius | ||
| color: Theme.surfaceVariantAlpha | ||
| border.color: textInput.activeFocus ? Theme.primary : "transparent" | ||
| border.width: textInput.activeFocus ? 1 : 0 | ||
|
|
||
| TextInput { | ||
| id: textInput | ||
|
|
||
| anchors.fill: parent | ||
| anchors.leftMargin: Theme.spacingM | ||
| anchors.rightMargin: Theme.spacingM | ||
| verticalAlignment: TextInput.AlignVCenter | ||
| font.pixelSize: Theme.fontSizeMedium | ||
| color: Theme.surfaceText | ||
| selectionColor: Theme.primary | ||
| selectedTextColor: Theme.primaryText | ||
| clip: true | ||
| text: root.inputText | ||
| onTextChanged: root.inputText = text | ||
|
|
||
| StyledText { | ||
| anchors.fill: parent | ||
| verticalAlignment: Text.AlignVCenter | ||
| font.pixelSize: Theme.fontSizeMedium | ||
| color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.4) | ||
| text: root.inputPlaceholder | ||
| visible: textInput.text === "" && !textInput.activeFocus | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
| width: 1 | ||
| height: Theme.spacingL * 1.5 | ||
| } | ||
|
|
||
| Row { | ||
| anchors.horizontalCenter: parent.horizontalCenter | ||
| spacing: Theme.spacingM | ||
|
|
||
| Rectangle { | ||
| width: 120 | ||
| height: 40 | ||
| radius: Theme.cornerRadius | ||
| color: { | ||
| if (root.keyboardNavigation && root.selectedButton === 0) { | ||
| return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12); | ||
| } else if (cancelButton.containsMouse) { | ||
| return Theme.surfacePressed; | ||
| } else { | ||
| return Theme.surfaceVariantAlpha; | ||
| } | ||
| } | ||
| border.color: (root.keyboardNavigation && root.selectedButton === 0) ? Theme.primary : "transparent" | ||
| border.width: (root.keyboardNavigation && root.selectedButton === 0) ? 1 : 0 | ||
|
|
||
| StyledText { | ||
| text: root.cancelButtonText | ||
| font.pixelSize: Theme.fontSizeMedium | ||
| color: Theme.surfaceText | ||
| font.weight: Font.Medium | ||
| anchors.centerIn: parent | ||
| } | ||
|
|
||
| MouseArea { | ||
| id: cancelButton | ||
|
|
||
| anchors.fill: parent | ||
| hoverEnabled: true | ||
| cursorShape: Qt.PointingHandCursor | ||
| onClicked: root.cancelAndClose() | ||
| } | ||
| } | ||
|
|
||
| Rectangle { | ||
| width: 120 | ||
| height: 40 | ||
| radius: Theme.cornerRadius | ||
| color: { | ||
| const baseColor = root.confirmButtonColor; | ||
| if (root.keyboardNavigation && root.selectedButton === 1) { | ||
| return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, 1); | ||
| } else if (confirmButton.containsMouse) { | ||
| return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, 0.9); | ||
| } else { | ||
| return baseColor; | ||
| } | ||
| } | ||
| border.color: (root.keyboardNavigation && root.selectedButton === 1) ? "white" : "transparent" | ||
| border.width: (root.keyboardNavigation && root.selectedButton === 1) ? 1 : 0 | ||
|
|
||
| StyledText { | ||
| text: root.confirmButtonText | ||
| font.pixelSize: Theme.fontSizeMedium | ||
| color: Theme.primaryText | ||
| font.weight: Font.Medium | ||
| anchors.centerIn: parent | ||
| } | ||
|
|
||
| MouseArea { | ||
| id: confirmButton | ||
|
|
||
| anchors.fill: parent | ||
| hoverEnabled: true | ||
| cursorShape: Qt.PointingHandCursor | ||
| onClicked: root.confirmAndClose() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
| width: 1 | ||
| height: Theme.spacingL | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should wrap in a LazyLoader here, like other modals - allow it to unload from memory