Skip to content

Commit

Permalink
Add select all feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcurtis committed Jul 1, 2017
1 parent 11cd8ab commit 0273ef8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/imagecanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,17 @@ void ImageCanvas::paste()
update();
}

void ImageCanvas::selectAll()
{
if (mTool == SelectionTool) {
clearOrConfirmSelection();
} else {
setTool(SelectionTool);
}

setSelectionArea(QRect(0, 0, mProject->widthInPixels(), mProject->heightInPixels()));
}

void ImageCanvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
QQuickItem::geometryChanged(newGeometry, oldGeometry);
Expand Down
1 change: 1 addition & 0 deletions app/imagecanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public slots:
void flipSelection(Qt::Orientation orientation);
void copySelection();
void paste();
void selectAll();

protected slots:
virtual void reset();
Expand Down
1 change: 0 additions & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import "ui" as Ui

/*
TODO:
- Ctrl+A selection when selection tool active
- rulers, guides
- Fill-all-of-this-colour tool
- fix performance when drawing pixels
Expand Down
9 changes: 9 additions & 0 deletions app/qml/ui/+windows/MenuBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ RowLayout {

MenuSeparator {}

MenuItem {
objectName: "selectAllMenuButton"
text: qsTr("Select All")
onTriggered: canvas.selectAll()
enabled: isImageProjectType && canvas
}

MenuSeparator {}

MenuItem {
objectName: "copyMenuButton"
text: qsTr("Copy")
Expand Down
9 changes: 9 additions & 0 deletions app/qml/ui/MenuBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ Platform.MenuBar {

Platform.MenuSeparator {}

Platform.MenuItem {
objectName: "selectAllMenuButton"
text: qsTr("Select All")
onTriggered: canvas.selectAll()
enabled: isImageProjectType && canvas
}

Platform.MenuSeparator {}

Platform.MenuItem {
objectName: "flipHorizontallyMenuButton"
text: qsTr("Flip Horizontally")
Expand Down
7 changes: 7 additions & 0 deletions app/qml/ui/Shortcuts.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Item {
enabled: isImageProjectType && canvasHasActiveFocus
}

Shortcut {
objectName: "selectAllShortcut"
sequence: StandardKey.SelectAll
onActivated: canvas.selectAll()
enabled: isImageProjectType && canvasHasActiveFocus
}

Shortcut {
objectName: "gridVisibleShortcut"
sequence: settings.gridVisibleShortcut
Expand Down

0 comments on commit 0273ef8

Please sign in to comment.