Clean up context menus.
This commit is contained in:
2
build.rs
2
build.rs
@@ -12,6 +12,8 @@ fn main() {
|
|||||||
"qml/ClideLogger.qml",
|
"qml/ClideLogger.qml",
|
||||||
"qml/Components/ClideScrollBar.qml",
|
"qml/Components/ClideScrollBar.qml",
|
||||||
"qml/Components/ClideHandle.qml",
|
"qml/Components/ClideHandle.qml",
|
||||||
|
"qml/Components/ClideMenu.qml",
|
||||||
|
"qml/Components/ClideMenuItem.qml",
|
||||||
"qml/Logger/Logger.qml",
|
"qml/Logger/Logger.qml",
|
||||||
]))
|
]))
|
||||||
// Link Qt's Network library
|
// Link Qt's Network library
|
||||||
|
|||||||
@@ -15,122 +15,111 @@ MenuBar {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// File Menu
|
// File Menu
|
||||||
Action {
|
|
||||||
id: actionNewProject
|
|
||||||
|
|
||||||
text: qsTr("&New Project...")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionOpen
|
|
||||||
|
|
||||||
text: qsTr("&Open...")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionSave
|
|
||||||
|
|
||||||
text: qsTr("&Save")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionExit
|
|
||||||
|
|
||||||
text: qsTr("&Exit")
|
|
||||||
|
|
||||||
onTriggered: Qt.quit()
|
|
||||||
}
|
|
||||||
ClideMenu {
|
ClideMenu {
|
||||||
title: qsTr("&File")
|
title: qsTr("&File")
|
||||||
|
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionNewProject
|
action: Action {
|
||||||
|
id: actionNewProject
|
||||||
|
|
||||||
|
text: qsTr("&New Project...")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionOpen
|
action: Action {
|
||||||
|
id: actionOpen
|
||||||
|
|
||||||
|
text: qsTr("&Open...")
|
||||||
|
}
|
||||||
|
|
||||||
onTriggered: FileSystem.setDirectory(FileSystem.filePath)
|
onTriggered: FileSystem.setDirectory(FileSystem.filePath)
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionSave
|
action: Action {
|
||||||
|
id: actionSave
|
||||||
|
|
||||||
|
text: qsTr("&Save")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MenuSeparator {
|
MenuSeparator {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
border.color: color
|
border.color: color
|
||||||
color: RustColors.explorer_background
|
color: Qt.darker(RustColors.menubar, 1)
|
||||||
implicitHeight: 3
|
implicitHeight: 3
|
||||||
implicitWidth: 200
|
implicitWidth: 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionExit
|
action: Action {
|
||||||
|
id: actionExit
|
||||||
|
|
||||||
|
text: qsTr("&Exit")
|
||||||
|
|
||||||
|
onTriggered: Qt.quit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Edit Menu
|
// Edit Menu
|
||||||
Action {
|
|
||||||
id: actionUndo
|
|
||||||
|
|
||||||
text: qsTr("&Undo")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionRedo
|
|
||||||
|
|
||||||
text: qsTr("&Redo")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionCut
|
|
||||||
|
|
||||||
text: qsTr("&Cut")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionCopy
|
|
||||||
|
|
||||||
text: qsTr("&Copy")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionPaste
|
|
||||||
|
|
||||||
text: qsTr("&Paste")
|
|
||||||
}
|
|
||||||
ClideMenu {
|
ClideMenu {
|
||||||
title: qsTr("&Edit")
|
title: qsTr("&Edit")
|
||||||
|
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionUndo
|
action: Action {
|
||||||
|
id: actionUndo
|
||||||
|
|
||||||
|
text: qsTr("&Undo")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionRedo
|
action: Action {
|
||||||
|
id: actionRedo
|
||||||
|
|
||||||
|
text: qsTr("&Redo")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionCut
|
action: Action {
|
||||||
|
id: actionCut
|
||||||
|
|
||||||
|
text: qsTr("&Cut")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionCopy
|
action: Action {
|
||||||
|
id: actionCopy
|
||||||
|
|
||||||
|
text: qsTr("&Copy")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionPaste
|
action: Action {
|
||||||
|
id: actionPaste
|
||||||
|
|
||||||
|
text: qsTr("&Paste")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// View Menu
|
// View Menu
|
||||||
Action {
|
|
||||||
id: actionToolWindows
|
|
||||||
|
|
||||||
text: qsTr("&Tool Windows")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionAppearance
|
|
||||||
|
|
||||||
text: qsTr("&Appearance")
|
|
||||||
}
|
|
||||||
ClideMenu {
|
ClideMenu {
|
||||||
title: qsTr("&View")
|
title: qsTr("&View")
|
||||||
|
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionToolWindows
|
action: Action {
|
||||||
|
id: actionAppearance
|
||||||
|
|
||||||
|
text: qsTr("&Appearance")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionAppearance
|
action: Action {
|
||||||
|
id: actionToolWindows
|
||||||
|
|
||||||
|
text: qsTr("&Tool Windows")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,52 +129,25 @@ MenuBar {
|
|||||||
id: clideAbout
|
id: clideAbout
|
||||||
|
|
||||||
}
|
}
|
||||||
Action {
|
|
||||||
id: actionDocumentation
|
|
||||||
|
|
||||||
text: qsTr("&Documentation")
|
|
||||||
}
|
|
||||||
Action {
|
|
||||||
id: actionAbout
|
|
||||||
|
|
||||||
text: qsTr("&About")
|
|
||||||
|
|
||||||
// Toggle the about window with the menu item is clicked.
|
|
||||||
onTriggered: clideAbout.visible = !clideAbout.visible
|
|
||||||
}
|
|
||||||
ClideMenu {
|
ClideMenu {
|
||||||
title: qsTr("&Help")
|
title: qsTr("&Help")
|
||||||
|
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionDocumentation
|
action: Action {
|
||||||
|
id: actionDocumentation
|
||||||
|
|
||||||
|
text: qsTr("&Documentation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClideMenuItem {
|
ClideMenuItem {
|
||||||
action: actionAbout
|
action: Action {
|
||||||
}
|
id: actionAbout
|
||||||
}
|
|
||||||
|
|
||||||
// Base settings for each Menu.
|
text: qsTr("&About")
|
||||||
component ClideMenu: Menu {
|
|
||||||
background: Rectangle {
|
|
||||||
color: RustColors.explorer_background
|
|
||||||
border.color: Qt.darker(RustColors.menubar, 2)
|
|
||||||
implicitWidth: 100
|
|
||||||
radius: 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Base settings for each MenuItem.
|
// Toggle the about window with the menu item is clicked.
|
||||||
component ClideMenuItem: MenuItem {
|
onTriggered: clideAbout.visible = !clideAbout.visible
|
||||||
id: root
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: root.hovered ? RustColors.hovered : RustColors.unhovered
|
|
||||||
radius: 1.0
|
|
||||||
}
|
|
||||||
contentItem: IconLabel {
|
|
||||||
color: "black"
|
|
||||||
font.family: "Helvetica"
|
|
||||||
text: root.text
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,15 +69,17 @@ SplitView {
|
|||||||
|
|
||||||
onSingleTapped: (eventPoint, button) => contextMenu.popup()
|
onSingleTapped: (eventPoint, button) => contextMenu.popup()
|
||||||
}
|
}
|
||||||
Menu {
|
ClideMenu {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
|
||||||
Action {
|
ClideMenuItem {
|
||||||
text: qsTr("Reset root index")
|
action: Action {
|
||||||
|
text: qsTr("Reset root")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Logger.log("Resetting root directory: " + clideTreeView.originalRootDirectory);
|
Logger.log("Resetting root directory: " + clideTreeView.originalRootDirectory);
|
||||||
clideTreeView.rootDirectory = clideTreeView.originalRootDirectory;
|
clideTreeView.rootDirectory = clideTreeView.originalRootDirectory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,24 +142,28 @@ TreeView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Menu {
|
ClideMenu {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
|
||||||
Action {
|
ClideMenuItem {
|
||||||
enabled: treeDelegate.hasChildren
|
action: Action {
|
||||||
text: qsTr("Set as root index")
|
enabled: treeDelegate.hasChildren
|
||||||
|
text: qsTr("Set root")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Logger.debug("Setting new root directory: " + treeDelegate.filePath);
|
Logger.debug("Setting new root directory: " + treeDelegate.filePath);
|
||||||
fileSystemTreeView.rootDirectory = treeDelegate.filePath;
|
fileSystemTreeView.rootDirectory = treeDelegate.filePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action {
|
ClideMenuItem {
|
||||||
text: qsTr("Reset root index")
|
action: Action {
|
||||||
|
text: qsTr("Reset root")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Logger.log("Resetting root directory: " + fileSystemTreeView.originalRootDirectory);
|
Logger.log("Resetting root directory: " + fileSystemTreeView.originalRootDirectory);
|
||||||
fileSystemTreeView.rootDirectory = fileSystemTreeView.originalRootDirectory;
|
fileSystemTreeView.rootDirectory = fileSystemTreeView.originalRootDirectory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
qml/Components/ClideMenu.qml
Normal file
13
qml/Components/ClideMenu.qml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
|
|
||||||
|
import clide.module 1.0
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
background: Rectangle {
|
||||||
|
border.color: Qt.darker(RustColors.menubar, 2)
|
||||||
|
color: RustColors.menubar
|
||||||
|
implicitWidth: 100
|
||||||
|
radius: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
18
qml/Components/ClideMenuItem.qml
Normal file
18
qml/Components/ClideMenuItem.qml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
|
|
||||||
|
import clide.module 1.0
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: root.hovered ? RustColors.hovered : RustColors.unhovered
|
||||||
|
radius: 1.0
|
||||||
|
}
|
||||||
|
contentItem: IconLabel {
|
||||||
|
color: "black"
|
||||||
|
font.family: "Helvetica"
|
||||||
|
text: root.text
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
ClideScrollBar ClideScrollBar.qml
|
ClideScrollBar ClideScrollBar.qml
|
||||||
ClideHandle ClideHandle.qml
|
ClideHandle ClideHandle.qml
|
||||||
|
ClideMenu ClideMenu.qml
|
||||||
|
ClideMenuItem ClideMenuItem.qml
|
||||||
|
|||||||
Reference in New Issue
Block a user