Fix duplicate shortcut key configuration items in Keyboard shortcuts Window (fix #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'
This commit is contained in:
Gaspar Capello 2024-05-21 12:36:33 -03:00
parent 064ddef190
commit 84fc105510
21 changed files with 70 additions and 3 deletions

View File

@ -482,6 +482,9 @@ protected:
bool onChecked(Context* context) override; bool onChecked(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return m_format == IMAGE_INDEXED && params.size() > 1;
}
private: private:
bool m_showDlg; bool m_showDlg;

View File

@ -64,6 +64,9 @@ public:
protected: protected:
bool onEnabled(Context* context) override; bool onEnabled(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
}; };
} // namespace app } // namespace app

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello // Copyright (C) 2001-2015 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -9,6 +10,7 @@
#pragma once #pragma once
#include "app/commands/command.h" #include "app/commands/command.h"
#include "app/commands/params.h"
#include "doc/algorithm/flip_type.h" #include "doc/algorithm/flip_type.h"
namespace app { namespace app {
@ -24,6 +26,9 @@ namespace app {
bool onEnabled(Context* context) override; bool onEnabled(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
private: private:
bool m_flipMask; bool m_flipMask;

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -14,6 +15,7 @@
#include "app/context.h" #include "app/context.h"
#include "app/context_access.h" #include "app/context_access.h"
#include "app/doc_api.h" #include "app/doc_api.h"
#include "app/i18n/strings.h"
#include "app/pref/preferences.h" #include "app/pref/preferences.h"
#include "app/tx.h" #include "app/tx.h"
#include "base/convert_to.h" #include "base/convert_to.h"
@ -35,6 +37,10 @@ protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
bool onEnabled(Context* context) override; bool onEnabled(Context* context) override;
void onExecute(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: private:
enum Target { enum Target {

View File

@ -100,6 +100,10 @@ protected:
return (frame < last ? frame+1: 0); return (frame < last ? frame+1: 0);
} }
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
}; };
class GotoNextFrameWithSameTagCommand : public GotoCommand { class GotoNextFrameWithSameTagCommand : public GotoCommand {

View File

@ -606,7 +606,8 @@ private:
if (key->type() == KeyType::Tool || if (key->type() == KeyType::Tool ||
key->type() == KeyType::Quicktool || key->type() == KeyType::Quicktool ||
key->type() == KeyType::WheelAction || key->type() == KeyType::WheelAction ||
key->type() == KeyType::DragAction) { key->type() == KeyType::DragAction ||
key->isSkipListing()) {
continue; continue;
} }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -20,6 +20,7 @@ namespace app {
class LaunchCommand : public Command { class LaunchCommand : public Command {
public: public:
LaunchCommand(); LaunchCommand();
const bool isSkipListing(const Params& params) const override { return true; }
protected: protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;

View File

@ -32,6 +32,9 @@ public:
protected: protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
private: private:
std::string m_preset; std::string m_preset;

View File

@ -45,6 +45,9 @@ protected:
bool onEnabled(Context* context) override; bool onEnabled(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return m_modifier == doc::algorithm::SelectionModifier::Contract;
}
private: private:
std::string getActionName() const; std::string getActionName() const;

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2016-2017 David Capello // Copyright (C) 2016-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -23,6 +24,7 @@ public:
protected: protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override { return true; }
private: private:
std::string m_filename; std::string m_filename;

View File

@ -10,6 +10,7 @@
#pragma once #pragma once
#include "app/commands/command.h" #include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/pref/preferences.h" #include "app/pref/preferences.h"
#include "base/paths.h" #include "base/paths.h"
@ -32,6 +33,9 @@ namespace app {
protected: protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
private: private:
std::string m_filename; std::string m_filename;

View File

@ -39,6 +39,7 @@ protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override { return params.empty(); }
private: private:
std::string m_filename; std::string m_filename;

View File

@ -34,6 +34,7 @@ public:
protected: protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override { return !params.empty(); }
private: private:
std::string m_preset; std::string m_preset;

View File

@ -45,6 +45,9 @@ protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
private: private:
void selectTiles(const Layer* layer, void selectTiles(const Layer* layer,

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (c) 2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -23,6 +24,9 @@ protected:
void onLoadParams(const Params& params) override; void onLoadParams(const Params& params) override;
bool onChecked(Context* context) override; bool onChecked(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return !params.empty();
}
private: private:
int m_size; int m_size;

View File

@ -26,6 +26,9 @@ protected:
bool onEnabled(Context* context) override; bool onEnabled(Context* context) override;
bool onChecked(Context* context) override; bool onChecked(Context* context) override;
void onExecute(Context* context) override; void onExecute(Context* context) override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
filters::TiledMode m_mode; filters::TiledMode m_mode;
}; };

View File

@ -37,6 +37,13 @@ namespace app {
bool isEnabled(Context* context); bool isEnabled(Context* context);
bool isChecked(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: protected:
virtual bool onNeedsParams() const; virtual bool onNeedsParams() const;
virtual void onLoadParams(const Params& params); virtual void onLoadParams(const Params& params);

View File

@ -26,6 +26,9 @@ protected:
bool onChecked(Context* ctx) override; bool onChecked(Context* ctx) override;
void onExecute(Context* ctx) override; void onExecute(Context* ctx) override;
std::string onGetFriendlyName() const override; std::string onGetFriendlyName() const override;
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
}; };
SetPlaybackSpeedCommand::SetPlaybackSpeedCommand() SetPlaybackSpeedCommand::SetPlaybackSpeedCommand()

View File

@ -54,6 +54,10 @@ protected:
return Strings::commands_TilesetMode(mode); return Strings::commands_TilesetMode(mode);
} }
const bool isSkipListing(const Params& params) const override {
return params.empty();
}
private: private:
TilesetMode m_mode; TilesetMode m_mode;
}; };

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A. // Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -138,6 +138,7 @@ namespace app {
const KeyboardShortcuts& globalKeys) const; const KeyboardShortcuts& globalKeys) const;
bool isPressed() const; bool isPressed() const;
bool isLooselyPressed() const; bool isLooselyPressed() const;
bool isSkipListing() const;
bool hasAccel(const ui::Accelerator& accel) const; bool hasAccel(const ui::Accelerator& accel) const;
bool hasUserDefinedAccels() const; bool hasUserDefinedAccels() const;

View File

@ -494,6 +494,11 @@ bool Key::isLooselyPressed() const
return false; return false;
} }
bool Key::isSkipListing() const
{
return type() == KeyType::Command && command()->isSkipListing(params());
}
bool Key::hasAccel(const ui::Accelerator& accel) const bool Key::hasAccel(const ui::Accelerator& accel) const
{ {
return accels().has(accel); return accels().has(accel);