Skip to content
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

"Search actions" widget #3449

Merged
merged 29 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
150aa9d
initial POC of "action search" widget
dogboydog Jul 2, 2022
c1ebcac
remove debug logging from action search
dogboydog Aug 12, 2022
5b8dad0
deduplicate ActionResultsView -> ResultsView
dogboydog Sep 14, 2022
4d15762
deduplicate results view
dogboydog Sep 15, 2022
2ddf175
Merge pull request #2 from dogboydog/search_actions_PR_feedback
dogboydog Sep 15, 2022
ae2c76f
adding locator source class, WIP
dogboydog Oct 26, 2022
f6666a8
continue to deduplicate code
dogboydog Nov 20, 2022
5b0fc2d
add edit-find icon for search actions from gnome-icons pack. move Pro…
dogboydog Dec 12, 2022
41675fc
Some cleanups
bjorn Dec 12, 2022
bd37927
Replaced ActionSearchWidget with LocatorWidget
bjorn Dec 12, 2022
4f98cc2
Merged LocatorSource interface with model
bjorn Dec 12, 2022
38704c3
Merge branch 'master' into search_actions
bjorn Dec 12, 2022
d1c7bc6
Avoid penalizing of results for including accelerators
bjorn Dec 12, 2022
3f5c06d
WIP: Custom delegate for action search
bjorn Dec 12, 2022
1d5e8f3
Fixed missing call to ActionMatchDelegate::setWords
bjorn Dec 12, 2022
0fc0bd6
adjust spacing of action name text in actionsearch.cpp
dogboydog Dec 13, 2022
02ea366
Fixed icon alignment
bjorn Dec 14, 2022
6920909
Added display of action shortcut to action search
bjorn Dec 14, 2022
c2ca926
Don't show "Search Actions" action in action search
bjorn Dec 14, 2022
65e5e86
Simplify check, we don't need to look up the actual action
bjorn Dec 14, 2022
fc86d7d
Tweaked position of action in menu and added ...
bjorn Dec 14, 2022
7629f1e
fix qt 5 compilation error in actionsearch.cpp
dogboydog Dec 15, 2022
7d371b2
Avoid needless string copies
bjorn Dec 15, 2022
b2cce62
add search actions to keyboard-shortcuts.rst
dogboydog Dec 24, 2022
7cf6cc7
Hide actions from inactive tools from the search results
bjorn Jan 6, 2023
3ab9b51
Fixed possible crash on activating search action
bjorn Jan 19, 2023
6a512e6
Allow triggering "Open File in Project" from action search
bjorn Jan 19, 2023
dde45ea
Updated NEWS.md
bjorn Jan 19, 2023
147ca07
docs: Added hint about action search to introduction
bjorn Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

* Added action search popup on Ctrl+Shift+P (with dogboydog, #3449)
* Fixed new layer names to be always unique (by Logan Higinbotham, #3452)
* Scripting: Added Object.setColorProperty and Object.setFloatProperty (#3423)
* Scripting: Added tiled.projectFilePath
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# Options for localization
locale_dirs = ['locale/']
Expand Down
25 changes: 16 additions & 9 deletions docs/manual/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,22 @@ as well as to be able to quickly switch between multiple projects, it is
recommended to first set up a :doc:`Tiled project <projects>`. This is however
an entirely optional step that can be skipped when desired.

Choose *Project -> Save Project As...* to save a new project file. The
recommended location is the root of your project, but you can place it
anywhere you want.

Next, we'll add at least one folder, either some "assets" folder or simply the
root of your project, but you can also choose to add several top-level folders
like "tilesets", "maps", "templates", etc. Right-click in the Project view and
choose *Add Folder to Project...* to add the relevant folders.

Choose *File -> New -> New Project...* to create a new project file. It is
recommended to save this file in the root of your project. The directory in
which you store the project will be automatically added, so that its files are
visible in the Project view.

When necessary, you can add additional folders to the project or replace the
one added by default. For example, you could choose to add several top-level
folders like "tilesets", "maps", "templates", etc. Right-click in the
Project view and choose *Add Folder to Project...* to add the
relevant folders.

.. hint::

You can press ``Ctrl+Shift+P`` to open the action search widget,
which can provide a faster way to get to actions than looking for them in
the menus!

Creating a New Map
~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions docs/manual/keyboard-shortcuts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ General
- ``Ctrl + N`` - Create a new map
- ``Ctrl + O`` - Open any file or project
- ``Ctrl + P`` - Open a file in the current project
- ``Ctrl + Shift + P`` - Search for available actions
- ``Ctrl + Shift + T`` - Reopen a recently closed file
- ``Ctrl + S`` - Save current document
- ``Ctrl + Alt + S`` - Save current document to another file
Expand Down
22 changes: 22 additions & 0 deletions src/tiled/abstractobjecttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,23 @@ AbstractObjectTool::AbstractObjectTool(Id id,
connect(mRotateLeft, &QAction::triggered, this, &AbstractObjectTool::rotateLeft);
connect(mRotateRight, &QAction::triggered, this, &AbstractObjectTool::rotateRight);

setActionsEnabled(false);

AbstractObjectTool::languageChanged();
}

void AbstractObjectTool::activate(MapScene *scene)
{
AbstractTool::activate(scene);
setActionsEnabled(true);
}

void AbstractObjectTool::deactivate(MapScene *scene)
{
setActionsEnabled(false);
AbstractTool::deactivate(scene);
}

void AbstractObjectTool::keyPressed(QKeyEvent *event)
{
switch (event->key()) {
Expand Down Expand Up @@ -739,4 +753,12 @@ void AbstractObjectTool::showContextMenu(MapObject *clickedObject,
}
}

void AbstractObjectTool::setActionsEnabled(bool enabled)
{
mFlipHorizontal->setEnabled(enabled);
mFlipVertical->setEnabled(enabled);
mRotateLeft->setEnabled(enabled);
mRotateRight->setEnabled(enabled);
}

#include "moc_abstractobjecttool.cpp"
5 changes: 5 additions & 0 deletions src/tiled/abstractobjecttool.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class AbstractObjectTool : public AbstractTool
const QKeySequence &shortcut,
QObject *parent = nullptr);

void activate(MapScene *scene) override;
void deactivate(MapScene *scene) override;

void keyPressed(QKeyEvent *event) override;
void mouseLeft() override;
void mouseMoved(const QPointF &pos, Qt::KeyboardModifiers modifiers) override;
Expand Down Expand Up @@ -107,6 +110,8 @@ class AbstractObjectTool : public AbstractTool
void showContextMenu(MapObject *clickedObject,
QPoint screenPos);

void setActionsEnabled(bool enabled);

QAction *mFlipHorizontal;
QAction *mFlipVertical;
QAction *mRotateLeft;
Expand Down
7 changes: 7 additions & 0 deletions src/tiled/abstracttilefilltool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ AbstractTileFillTool::~AbstractTileFillTool()
{
}

void AbstractTileFillTool::activate(MapScene *scene)
{
AbstractTileTool::activate(scene);
mStampActions->setEnabled(true);
}

void AbstractTileFillTool::deactivate(MapScene *scene)
{
mCaptureStampHelper.reset();
mStampActions->setEnabled(false);
AbstractTileTool::deactivate(scene);
}

Expand Down
1 change: 1 addition & 0 deletions src/tiled/abstracttilefilltool.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AbstractTileFillTool : public AbstractTileTool
QObject *parent = nullptr);
~AbstractTileFillTool() override;

void activate(MapScene *scene) override;
void deactivate(MapScene *scene) override;

void mousePressed(QGraphicsSceneMouseEvent *event) override;
Expand Down
13 changes: 13 additions & 0 deletions src/tiled/actionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ QAction *ActionManager::findAction(Id id)
return d->mIdToActions.value(id);
}

QAction *ActionManager::findEnabledAction(Id id)
{
auto d = instance();

const auto [start, end] = qAsConst(d->mIdToActions).equal_range(id);
for (auto it = start; it != end; ++it) {
if (it.value()->isEnabled())
return it.value();
}

return nullptr;
}

bool ActionManager::hasMenu(Id id)
{
return instance()->mIdToMenu.contains(id);
Expand Down
1 change: 1 addition & 0 deletions src/tiled/actionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ActionManager : public QObject

static QAction *action(Id id);
static QAction *findAction(Id id);
static QAction *findEnabledAction(Id id);

static bool hasMenu(Id id);

Expand Down
Loading