Add "Copy Path" option when right-clicking a sprite tab

This commit is contained in:
David Capello 2023-01-05 10:46:18 -03:00
parent fa3bdf853c
commit 988cba2c2b
5 changed files with 60 additions and 2 deletions

View File

@ -1051,6 +1051,8 @@
<separator />
<item command="OpenWithApp" text="@.open_with_os" />
<item command="OpenInFolder" text="@.open_in_folder" group="document_tab_open" />
<separator />
<item command="CopyPath" text="@.copy_path" group="document_tab_path" />
</menu>
<menu id="layer_popup_menu">

View File

@ -1,5 +1,5 @@
# Aseprite
# Copyright (C) 2018-2022 Igara Studio S.A.
# Copyright (C) 2018-2023 Igara Studio S.A.
# Copyright (C) 2016-2018 David Capello
[advanced_mode]
@ -360,6 +360,7 @@ Copy = Copy
CopyCel = Copy Cel
CopyColors = Copy Colors
CopyMerged = Copy Merged
CopyPath = Copy Path
CopyTiles = Copy Tiles
CropSprite = Crop Sprite
Cut = Cut
@ -601,6 +602,7 @@ cancel = Cancel
duplicate_view = Duplicate &View
open_with_os = &Open with OS
open_in_folder = Open in &Folder
copy_path = Copy &Path
[dithering_selector]
no_dithering = No Dithering

View File

@ -579,6 +579,7 @@ add_library(app-lib
commands/command.cpp
commands/commands.cpp
commands/convert_layer.cpp
commands/copy_path.cpp
commands/export_tileset.cpp
commands/filters/cmd_brightness_contrast.cpp
commands/filters/cmd_color_curve.cpp

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -17,6 +17,7 @@ FOR_EACH_COMMAND(ColorQuantization)
FOR_EACH_COMMAND(ConvertLayer)
FOR_EACH_COMMAND(ConvolutionMatrix)
FOR_EACH_COMMAND(CopyColors)
FOR_EACH_COMMAND(CopyPath)
FOR_EACH_COMMAND(CopyTiles)
FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(DeselectMask)

View File

@ -0,0 +1,52 @@
// Aseprite
// Copyright (C) 2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/doc.h"
#include "app/util/clipboard.h"
#include <cstdio>
namespace app {
class CopyPathCommand : public Command {
public:
CopyPathCommand();
protected:
bool onEnabled(Context* ctx) override;
void onExecute(Context* ctx) override;
};
CopyPathCommand::CopyPathCommand()
: Command(CommandId::CopyPath(), CmdRecordableFlag)
{
}
bool CopyPathCommand::onEnabled(Context* ctx)
{
const ContextReader reader(ctx);
return
reader.document() &&
reader.document()->isAssociatedToFile();
}
void CopyPathCommand::onExecute(Context* ctx)
{
Clipboard::instance()->setClipboardText(
ctx->activeDocument()->filename());
}
Command* CommandFactory::createCopyPathCommand()
{
return new CopyPathCommand;
}
} // namespace app