Warning, /graphics/spectacle/src/Gui/MainToolBarContents.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2022 Noah Davis <noahadvs@gmail.com>
0002 * SPDX-License-Identifier: LGPL-2.0-or-later
0003 */
0004
0005 import QtQuick
0006 import QtQuick.Controls as QQC
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.spectacle.private
0009
0010 ButtonGrid {
0011 id: root
0012 property size imageSize: Qt.size(0, 0)
0013 property bool showSizeLabel: false
0014 property bool showUndoRedo: false
0015 property bool showNewScreenshotButton: true
0016 property bool showOptionsMenu: true
0017
0018 component ToolButton: QQC.ToolButton {
0019 implicitHeight: QmlUtils.iconTextButtonHeight
0020 width: display === QQC.ToolButton.IconOnly ? height : implicitWidth
0021 focusPolicy: root.focusPolicy
0022 display: root.displayMode
0023 QQC.ToolTip.text: text
0024 QQC.ToolTip.visible: (hovered || pressed) && display === QQC.ToolButton.IconOnly
0025 QQC.ToolTip.delay: Kirigami.Units.toolTipDelay
0026 }
0027
0028 AnimatedLoader {
0029 id: sizeLabelLoader
0030 state: root.showSizeLabel && root.imageSize.width > 0 && root.imageSize.height > 0 ?
0031 "active" : "inactive"
0032 sourceComponent: SizeLabel {
0033 height: QmlUtils.iconTextButtonHeight
0034 size: root.imageSize
0035 leftPadding: Kirigami.Units.mediumSpacing + QmlUtils.fontMetrics.descent
0036 rightPadding: leftPadding
0037 }
0038 }
0039
0040 AnimatedLoader {
0041 state: root.showUndoRedo ? "active" : "inactive"
0042 sourceComponent: UndoRedoGroup {
0043 animationsEnabled: root.animationsEnabled
0044 buttonHeight: QmlUtils.iconTextButtonHeight
0045 focusPolicy: root.focusPolicy
0046 flow: root.flow
0047 spacing: root.spacing
0048 }
0049 }
0050
0051 // We don't show this in video mode because the video is already automatically saved.
0052 // and you can't edit the video.
0053 ToolButton {
0054 visible: !SpectacleCore.videoMode
0055 icon.name: "document-save"
0056 text: i18n("Save")
0057 onClicked: contextWindow.save()
0058 }
0059
0060 ToolButton {
0061 icon.name: "document-save-as"
0062 text: i18n("Save As...")
0063 onClicked: contextWindow.saveAs()
0064 }
0065
0066 // We don't show this in video mode because you can't copy raw video to the clipboard,
0067 // or at least not elegantly.
0068 ToolButton {
0069 visible: !SpectacleCore.videoMode
0070 icon.name: "edit-copy"
0071 text: i18n("Copy")
0072 onClicked: contextWindow.copyImage()
0073 }
0074
0075 // We only show this in video mode to save space in screenshot mode
0076 ToolButton {
0077 visible: SpectacleCore.videoMode
0078 icon.name: "edit-copy-path"
0079 text: i18n("Copy Location")
0080 onClicked: contextWindow.copyLocation()
0081 }
0082
0083 ToolButton {
0084 // FIXME: make export menu actually work with videos
0085 visible: !SpectacleCore.videoMode
0086 icon.name: "document-share"
0087 text: i18n("Export")
0088 down: pressed || ExportMenu.visible
0089 Accessible.role: Accessible.ButtonMenu
0090 onPressed: ExportMenu.popup(this)
0091 }
0092
0093 ToolButton {
0094 id: annotationsButton
0095 icon.name: "edit-image"
0096 text: i18n("Show Annotation Tools")
0097 visible: !SpectacleCore.videoMode
0098 checkable: true
0099 checked: contextWindow.annotating
0100 onToggled: contextWindow.annotating = checked
0101 }
0102
0103 ToolButton {
0104 // Can't rely on checked since clicking also toggles checked
0105 readonly property bool showCancel: SpectacleCore.captureTimeRemaining > 0
0106 readonly property real cancelWidth: QmlUtils.getButtonSize(display, cancelText(Settings.captureDelay), icon.name).width
0107
0108 function cancelText(seconds) {
0109 return i18np("Cancel (%1 second)", "Cancel (%1 seconds)", Math.ceil(seconds))
0110 }
0111
0112 visible: root.showNewScreenshotButton
0113 checked: showCancel
0114 width: if (showCancel) {
0115 return cancelWidth
0116 } else {
0117 return display === QQC.ToolButton.IconOnly ? height : implicitWidth
0118 }
0119 icon.name: showCancel ? "dialog-cancel" : "list-add"
0120 text: showCancel ?
0121 cancelText(SpectacleCore.captureTimeRemaining / 1000)
0122 : i18n("New Screenshot")
0123 onClicked: if (showCancel) {
0124 SpectacleCore.cancelScreenshot()
0125 } else {
0126 SpectacleCore.takeNewScreenshot()
0127 }
0128 }
0129
0130 ToolButton {
0131 visible: root.showOptionsMenu
0132 icon.name: "configure"
0133 text: i18n("Options")
0134 down: pressed || OptionsMenu.visible
0135 Accessible.role: Accessible.ButtonMenu
0136 onPressed: OptionsMenu.popup(this)
0137 }
0138 ToolButton {
0139 visible: !root.showOptionsMenu
0140 icon.name: "configure"
0141 text: i18n("Configure...")
0142 onClicked: OptionsMenu.showPreferencesDialog();
0143 }
0144
0145 ToolButton {
0146 id: helpButton
0147 icon.name: "help-contents"
0148 text: i18n("Help")
0149 down: pressed || HelpMenu.visible
0150 Accessible.role: Accessible.ButtonMenu
0151 onPressed: HelpMenu.popup(this)
0152 }
0153 }