Skip to content

Commit

Permalink
Menu option to open the info panel when the info panel would not open…
Browse files Browse the repository at this point in the history
… automatically
  • Loading branch information
TomNCatz committed Nov 19, 2023
1 parent afe70db commit 1694fdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Loc/Languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default
IMAGE_MENU_COMMAND_15: "Delete just meta",
IMAGE_MENU_COMMAND_16: "Copy image",
IMAGE_MENU_COMMAND_17: "Share media",
IMAGE_MENU_COMMAND_18: "Open info panel",
MENU_OPTION_FAULT: "context options {0} is not accounted for",
MASS_CONTEXT_CONFIRM: "There are {0} files selected for '{1}' are you sure?",
COPIED_MEDIA: "Media copied to clipboard",
Expand Down
25 changes: 23 additions & 2 deletions src/Modals/ImageMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MediaSearch } from "../TechnicalFiles/MediaSearch"
import type GalleryTagsPlugin from "../main";
import { addEmbededTags, addTag, createMetaFile, getImageInfo, isRemoteMedia, preprocessUri, removeTag, validString } from "../utils";
import { Notice, Platform, TFile } from "obsidian";
import type { GalleryInfoView } from "../DisplayObjects/GalleryInfoView";
import { GalleryInfoView } from "../DisplayObjects/GalleryInfoView";
import { FuzzyFolders, FuzzyTags } from "./FuzzySearches";
import { ConfirmModal } from "./ConfirmPopup";
import { ProgressModal } from "./ProgressPopup";
Expand Down Expand Up @@ -32,7 +32,8 @@ enum Options
DeleteImage = 14,
DeleteMeta = 15,
CopyImage = 16,
ShareMedia = 17
ShareMedia = 17,
OpenInfoLeaf = 18
}

export class ImageMenu extends MenuPopup
Expand Down Expand Up @@ -87,6 +88,13 @@ export class ImageMenu extends MenuPopup
{
this.#createItem(Options.OpenImageFile);
}

if((this.#mediaSearch && !this.#plugin.platformSettings().rightClickInfoGallery)
||(!this.#mediaSearch && !this.#plugin.platformSettings().rightClickInfo))
{
this.#createItem(Options.OpenInfoLeaf);
}

this.#createItem(Options.OpenMetaFile);
}

Expand Down Expand Up @@ -219,6 +227,7 @@ export class ImageMenu extends MenuPopup
case Options.DeleteMeta: this.#resultDeleteMeta(); break;
case Options.CopyImage: this.#resultCopyImage(); break;
case Options.ShareMedia: this.#resultShareMedia(); break;
case Options.OpenInfoLeaf: this.#resultOpenInfoLeaf(); break;
default:
const error = loc('MENU_OPTION_FAULT', Options[result]);
new Notice(error);
Expand Down Expand Up @@ -256,6 +265,18 @@ export class ImageMenu extends MenuPopup
}
}

async #resultOpenInfoLeaf()
{
if(this.#infoView)
{
this.#infoView.clear()
}

const source = this.#getSource(this.#targets[0]);

await GalleryInfoView.OpenLeaf(this.#plugin, source);
}

async #resultShareMedia()
{
if(this.#infoView)
Expand Down

0 comments on commit 1694fdb

Please sign in to comment.