Add option to show filenames in the item tree (#4601)

And move item tree pref observer into the item tree itself.
This commit is contained in:
Abe Jellinek 2024-08-20 05:22:03 -04:00 • committed by Dan Stillman
parent c6a6832444
commit 2d79f1f959
4 changed files with 39 additions and 4 deletions

View file

@ -155,6 +155,13 @@ var ItemTree = class ItemTree extends LibraryTree {
50
);
}
this._prefsObserverIDs = [
Zotero.Prefs.registerObserver('recursiveCollections', this.refreshAndMaintainSelection.bind(this)),
Zotero.Prefs.registerObserver('showAttachmentFilenames', () => {
this._rowCache = {};
this.tree.invalidate();
}),
];
this._itemsPaneMessage = null;
@ -170,6 +177,9 @@ var ItemTree = class ItemTree extends LibraryTree {
unregister() {
this._uninitialized = true;
Zotero.Notifier.unregisterObserver(this._unregisterID);
for (let id of this._prefsObserverIDs) {
Zotero.Prefs.unregisterObserver(id);
}
this._writeColumnPrefsToFile(true);
}
@ -3407,7 +3417,16 @@ var ItemTree = class ItemTree extends LibraryTree {
}
row.numNotes = treeRow.numNotes() || "";
row.feed = (treeRow.ref.isFeedItem && Zotero.Feeds.get(treeRow.ref.libraryID).name) || "";
row.title = treeRow.ref.getDisplayTitle();
if (treeRow.ref.isFileAttachment()
// TODO: Adjust this if we localize "Snapshot"
&& !(treeRow.ref.isSnapshotAttachment() && /snapshot/i.test(treeRow.ref.getField('title')))
&& Zotero.Prefs.get('showAttachmentFilenames')) {
row.title = treeRow.ref.attachmentFilename;
}
else {
row.title = treeRow.ref.getDisplayTitle();
}
const columns = this.getColumns();
for (let col of columns) {

View file

@ -171,6 +171,20 @@
</vbox>
</groupbox>
<groupbox>
<label><html:h2 data-l10n-id="preferences-attachment-titles-title"/></label>
<description data-l10n-id="preferences-attachment-titles-intro">
<label is="zotero-text-link" href="https://www.zotero.org/support/kb/attachment_title_vs_filename" data-l10n-name="wiki-link"/>
</description>
<checkbox
data-l10n-id="preferences-attachment-titles-show-filenames"
preference="extensions.zotero.showAttachmentFilenames"
native="true"
/>
</groupbox>
<groupbox id="zotero-prefpane-reader-groupbox" aria-labelledby="preferences-reader-title">
<label><html:h2 id="preferences-reader-title" data-l10n-id="preferences-reader-title"/></label>

View file

@ -350,9 +350,6 @@ Zotero.Prefs = new function () {
["uiDensity", function () {
Zotero.UIProperties.setAll();
}],
["recursiveCollections", function () {
Zotero.getActiveZoteroPane().itemsView.refreshAndMaintainSelection();
}],
[ "layout", function (val) {
Zotero.getActiveZoteroPane().updateLayout();
}],

View file

@ -34,6 +34,11 @@ preferences-file-renaming-format-instructions-more = See the <label data-l10n-na
preferences-file-renaming-format-template = Filename Template:
preferences-file-renaming-format-preview = Preview:
preferences-attachment-titles-title = Attachment Titles
preferences-attachment-titles-intro = Attachment titles are <label data-l10n-name="wiki-link">different from filenames</label>. To support some workflows, { -app-name } can show filenames instead of attachment titles in the items list.
preferences-attachment-titles-show-filenames =
.label = Show attachment filenames in the items list
preferences-reader-title = Reader
preferences-reader-open-epubs-using = Open EPUBs using
preferences-reader-open-snapshots-using = Open snapshots using