Skip to content

Commit

Permalink
Fix duplicate shortcut key configuration items in Keyboard shortcuts …
Browse files Browse the repository at this point in the history
…Window (fix aseprite#4387)

Introduced Key::isSkipListing() and Command::isSkipListing() to skip keyItem creation on Keyboard shortcut List Box.
Removed commands:
'Launch'
'OpenBrowser'
And removed unnecessary commands:
'Change Color Mode: Indexed'
'Contract Selection'
'Export Sprite Sheet'
'Flip Canvas Horizontally'
'Frame Properties'
'Load Palette'
'Open Sprite'
'Playback Speed 1x'
'Run Script'
'Save Palette'
'Select Used Colors'
'Set Palette Entry Size'
'Tileset Mode: Auto'
  • Loading branch information
Gasparoken committed Jul 2, 2024
1 parent 064ddef commit 84fc105
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/app/commands/cmd_change_pixel_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ class ChangePixelFormatCommand : public Command {
bool onChecked(Context* context) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return m_format == IMAGE_INDEXED && params.size() > 1;
}

private:
bool m_showDlg;
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_export_sprite_sheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ExportSpriteSheetCommand : public CommandWithNewParams<ExportSpriteSheetPa
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
};

} // namespace app
Expand Down
5 changes: 5 additions & 0 deletions src/app/commands/cmd_flip.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
Expand All @@ -9,6 +10,7 @@
#pragma once

#include "app/commands/command.h"
#include "app/commands/params.h"
#include "doc/algorithm/flip_type.h"

namespace app {
Expand All @@ -24,6 +26,9 @@ namespace app {
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}

private:
bool m_flipMask;
Expand Down
6 changes: 6 additions & 0 deletions src/app/commands/cmd_frame_properties.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand All @@ -14,6 +15,7 @@
#include "app/context.h"
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/i18n/strings.h"
#include "app/pref/preferences.h"
#include "app/tx.h"
#include "base/convert_to.h"
Expand All @@ -35,6 +37,10 @@ class FramePropertiesCommand : public Command {
void onLoadParams(const Params& params) override;
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty() &&
strcmp(params.begin()->second.c_str(), "all") == 0;
}

private:
enum Target {
Expand Down
4 changes: 4 additions & 0 deletions src/app/commands/cmd_goto_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class GotoNextFrameCommand : public GotoCommand {

return (frame < last ? frame+1: 0);
}

const bool isSkipListing(const Params& params) const override {
return params.empty();
}
};

class GotoNextFrameWithSameTagCommand : public GotoCommand {
Expand Down
3 changes: 2 additions & 1 deletion src/app/commands/cmd_keyboard_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ class KeyboardShortcutsWindow : public app::gen::KeyboardShortcuts {
if (key->type() == KeyType::Tool ||
key->type() == KeyType::Quicktool ||
key->type() == KeyType::WheelAction ||
key->type() == KeyType::DragAction) {
key->type() == KeyType::DragAction ||
key->isSkipListing()) {
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/commands/cmd_launch.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
Expand All @@ -20,6 +20,7 @@ namespace app {
class LaunchCommand : public Command {
public:
LaunchCommand();
const bool isSkipListing(const Params& params) const override { return true; }

protected:
void onLoadParams(const Params& params) override;
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_load_palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class LoadPaletteCommand : public Command {
protected:
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}

private:
std::string m_preset;
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_modify_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class ModifySelectionCommand : public Command {
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return m_modifier == doc::algorithm::SelectionModifier::Contract;
}

private:
std::string getActionName() const;
Expand Down
2 changes: 2 additions & 0 deletions src/app/commands/cmd_open_browser.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2016-2017 David Capello
//
// This program is distributed under the terms of
Expand All @@ -23,6 +24,7 @@ class OpenBrowserCommand : public Command {
protected:
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override { return true; }

private:
std::string m_filename;
Expand Down
4 changes: 4 additions & 0 deletions src/app/commands/cmd_open_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/pref/preferences.h"
#include "base/paths.h"

Expand All @@ -32,6 +33,9 @@ namespace app {
protected:
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}

private:
std::string m_filename;
Expand Down
1 change: 1 addition & 0 deletions src/app/commands/cmd_run_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RunScriptCommand : public Command {
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override { return params.empty(); }

private:
std::string m_filename;
Expand Down
1 change: 1 addition & 0 deletions src/app/commands/cmd_save_palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SavePaletteCommand : public Command {
protected:
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override { return !params.empty(); }

private:
std::string m_preset;
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_select_palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class SelectPaletteColorsCommand : public Command {
void onLoadParams(const Params& params) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}

private:
void selectTiles(const Layer* layer,
Expand Down
4 changes: 4 additions & 0 deletions src/app/commands/cmd_set_palette_entry_size.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (c) 2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
Expand All @@ -23,6 +24,9 @@ class SetPaletteEntrySizeCommand : public Command {
void onLoadParams(const Params& params) override;
bool onChecked(Context* context) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}

private:
int m_size;
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_tiled_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class TiledModeCommand : public Command {
bool onEnabled(Context* context) override;
bool onChecked(Context* context) override;
void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}

filters::TiledMode m_mode;
};
Expand Down
7 changes: 7 additions & 0 deletions src/app/commands/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ namespace app {
bool isEnabled(Context* context);
bool isChecked(Context* context);

// Not all Commands must be listed on KeyBoard Shortcut list, so
// this function returns if a key command should be listed or not.
// Used on 'cmd_keyboard_shorcuts.cpp'.
virtual const bool isSkipListing(const Params& params) const {
return false;
}

protected:
virtual bool onNeedsParams() const;
virtual void onLoadParams(const Params& params);
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/set_playback_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SetPlaybackSpeedCommand : public CommandWithNewParams<SetPlaybackSpeedPara
bool onChecked(Context* ctx) override;
void onExecute(Context* ctx) override;
std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
};

SetPlaybackSpeedCommand::SetPlaybackSpeedCommand()
Expand Down
4 changes: 4 additions & 0 deletions src/app/commands/tileset_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class TilesetModeCommand : public Command {
return Strings::commands_TilesetMode(mode);
}

const bool isSkipListing(const Params& params) const override {
return params.empty();
}

private:
TilesetMode m_mode;
};
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/key.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -138,6 +138,7 @@ namespace app {
const KeyboardShortcuts& globalKeys) const;
bool isPressed() const;
bool isLooselyPressed() const;
bool isSkipListing() const;

bool hasAccel(const ui::Accelerator& accel) const;
bool hasUserDefinedAccels() const;
Expand Down
5 changes: 5 additions & 0 deletions src/app/ui/keyboard_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ bool Key::isLooselyPressed() const
return false;
}

bool Key::isSkipListing() const
{
return type() == KeyType::Command && command()->isSkipListing(params());
}

bool Key::hasAccel(const ui::Accelerator& accel) const
{
return accels().has(accel);
Expand Down

0 comments on commit 84fc105

Please sign in to comment.