Skip to content

Commit 8433f2e

Browse files
committed
#1789 misc: add remembered file manager open prompts
1 parent e3beff8 commit 8433f2e

11 files changed

Lines changed: 40 additions & 11 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# QOwnNotes Changelog
22

3+
## 26.4.15
4+
5+
- Added a rememberable confirmation dialog before opening items in the file
6+
manager from note reveal and export actions, so accidental folder windows can
7+
be suppressed per action after choosing **No** once with **Don't ask again!**
8+
(for [#1789](https://github.com/pbek/QOwnNotes/issues/1789))
9+
310
## 26.4.14
411

512
- Allow dragging a Markdown or text note file into the **note editor**, so it is

src/dialogs/storedattachmentsdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ void StoredAttachmentsDialog::on_openFolderButton_clicked() {
301301
}
302302

303303
QString filePath = getFilePath(item);
304-
Utils::Misc::openFolderSelect(filePath);
304+
Utils::Misc::openFolderSelect(filePath,
305+
QStringLiteral("show-stored-attachment-in-file-manager"));
305306
}
306307

307308
void StoredAttachmentsDialog::on_fileTreeWidget_customContextMenuRequested(const QPoint &pos) {

src/dialogs/storedimagesdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ void StoredImagesDialog::on_openFolderButton_clicked() {
499499
}
500500

501501
QString filePath = getFilePath(item);
502-
Utils::Misc::openFolderSelect(filePath);
502+
Utils::Misc::openFolderSelect(filePath, QStringLiteral("show-stored-image-in-file-manager"));
503503
}
504504

505505
void StoredImagesDialog::on_orphanedCheckBox_toggled(bool checked) {

src/entities/note.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ bool Note::exportToPath(const QString &destinationPath, bool withAttachedFiles)
969969

970970
file.flush();
971971
file.close();
972-
Utils::Misc::openFolderSelect(destinationPath);
972+
Utils::Misc::openFolderSelect(destinationPath,
973+
QStringLiteral("show-exported-note-in-file-manager"));
973974

974975
return true;
975976
}

src/mainwindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5469,7 +5469,8 @@ void MainWindow::pasteMediaIntoNote() {
54695469
}
54705470

54715471
void MainWindow::on_actionShow_note_in_file_manager_triggered() {
5472-
Utils::Misc::openFolderSelect(currentNote.fullNoteFilePath());
5472+
Utils::Misc::openFolderSelect(currentNote.fullNoteFilePath(),
5473+
QStringLiteral("show-note-in-file-manager"));
54735474
}
54745475

54755476
/**

src/managers/exportprintmanager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ void ExportPrintManager::exportNoteAsPDF(QTextDocument *doc) {
195195

196196
if (prepareExportNoteAsPDFPrinter(printer)) {
197197
doc->print(printer);
198-
Utils::Misc::openFolderSelect(printer->outputFileName());
198+
Utils::Misc::openFolderSelect(printer->outputFileName(),
199+
QStringLiteral("show-exported-pdf-in-file-manager"));
199200
}
200201

201202
delete printer;
@@ -283,7 +284,8 @@ void ExportPrintManager::on_actionExport_preview_HTML_triggered() {
283284
NoteFolder::currentLocalPath(), _mainWindow->getMaxImageWidth(), true, true, true);
284285
file.flush();
285286
file.close();
286-
Utils::Misc::openFolderSelect(fileName);
287+
Utils::Misc::openFolderSelect(
288+
fileName, QStringLiteral("show-exported-note-html-in-file-manager"));
287289
}
288290
}
289291
}

src/utils/misc.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <QtGui/QIcon>
5555
#include <utility>
5656

57+
#include "gui.h"
5758
#include "services/settingsservice.h"
5859
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
5960
#include <QHostInfo>
@@ -110,7 +111,19 @@ void Utils::Misc::openPath(const QString &absolutePath) {
110111
* (if possible) the item at the given path
111112
* (thank you to qBittorrent for the inspiration)
112113
*/
113-
void Utils::Misc::openFolderSelect(const QString &absolutePath) {
114+
void Utils::Misc::openFolderSelect(const QString &absolutePath,
115+
const QString &questionDialogIdentifier) {
116+
if (!questionDialogIdentifier.isEmpty() &&
117+
Utils::Gui::questionNoSkipOverride(
118+
QApplication::activeWindow(),
119+
QCoreApplication::translate("Utils::Misc", "Open folder in file manager"),
120+
QCoreApplication::translate("Utils::Misc",
121+
"Do you want to show this item in your file manager?"),
122+
questionDialogIdentifier, QMessageBox::Yes | QMessageBox::No,
123+
QMessageBox::Yes) != QMessageBox::Yes) {
124+
return;
125+
}
126+
114127
const QString path = QDir::fromNativeSeparators(absolutePath);
115128
#ifdef Q_OS_WIN
116129
if (QFileInfo(path).exists()) {

src/utils/misc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ struct SearchEngine {
6262
};
6363

6464
void openPath(const QString &absolutePath);
65-
void openFolderSelect(const QString &absolutePath);
65+
void openFolderSelect(const QString &absolutePath,
66+
const QString &questionDialogIdentifier = QString());
6667
QString removeIfStartsWith(QString text, const QString &removeString);
6768
QString removeIfEndsWith(QString text, const QString &removeString);
6869
QString prependIfDoesNotStartWith(QString text, const QString &startString);

src/widgets/fontcolorwidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ void FontColorWidget::on_exportSchemeButton_clicked() {
790790
exportSettings.setValue(key, value);
791791
}
792792

793-
Utils::Misc::openFolderSelect(fileName);
793+
Utils::Misc::openFolderSelect(
794+
fileName, QStringLiteral("show-exported-color-schema-in-file-manager"));
794795
}
795796
}
796797
}

src/widgets/htmlpreviewwidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ void HtmlPreviewWidgetInternal::exportAsHTMLFile() {
198198
out << html();
199199
file.flush();
200200
file.close();
201-
Utils::Misc::openFolderSelect(fileName);
201+
Utils::Misc::openFolderSelect(
202+
fileName, QStringLiteral("show-exported-preview-html-in-file-manager"));
202203
}
203204
}
204205
}

0 commit comments

Comments
 (0)