diff --git a/src/ExportManager.h b/src/ExportManager.h --- a/src/ExportManager.h +++ b/src/ExportManager.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -67,6 +68,8 @@ ImageGrabber::GrabMode grabMode() const; void setGrabMode(const ImageGrabber::GrabMode &grabMode); + static const QMap filenamePlaceholders; + Q_SIGNALS: void errorMessage(const QString &str); diff --git a/src/ExportManager.cpp b/src/ExportManager.cpp --- a/src/ExportManager.cpp +++ b/src/ExportManager.cpp @@ -513,3 +513,16 @@ delete printer; return; } + +const QMap ExportManager::filenamePlaceholders { + {QStringLiteral("%Y"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Year (4 digit)")}, + {QStringLiteral("%y"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Year (2 digit)")}, + {QStringLiteral("%M"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Month")}, + {QStringLiteral("%D"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Day")}, + {QStringLiteral("%H"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Hour")}, + {QStringLiteral("%m"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Minute")}, + {QStringLiteral("%S"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Second")}, + {QStringLiteral("%T"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Window Title")}, + {QStringLiteral("%d"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Sequential numbering")}, + {QStringLiteral("%Nd"), i18nc("A placeholder in the user configurable filename will replaced by the specified value","Sequential numbering, padded out to N digits")}, +}; diff --git a/src/Gui/SettingsDialog/SaveOptionsPage.cpp b/src/Gui/SettingsDialog/SaveOptionsPage.cpp --- a/src/Gui/SettingsDialog/SaveOptionsPage.cpp +++ b/src/Gui/SettingsDialog/SaveOptionsPage.cpp @@ -20,6 +20,7 @@ #include "SaveOptionsPage.h" #include "SpectacleConfig.h" +#include "ExportManager.h" #include #include @@ -123,35 +124,23 @@ saveNameLayout->addLayout(saveFieldLayout); // now the save filename format layout - const QString helpText = i18nc("%1 is the default filename of a screenshot", - "

You can use the following placeholders in the filename, which will be replaced " - "with actual text when the file is saved:

" - - "
" - "%Y: Year (4 digit)
" - "%y: Year (2 digit)
" - "%M: Month
" - "%D: Day
" - "%H: Hour
" - "%m: Minute
" - "%S: Second
" - "%T: Window title
" - "%d: Sequential numbering
" - "%Nd: Sequential numbering, padded out to N digits" - "
" - - "

To save to a sub-folder, use slashes, e.g.:

" - - "
" - "%Y/%M/%1" - "
", - SpectacleConfig::instance()->defaultFilename() + SpectacleConfig::instance()->defaultTimestampTemplate() + QString helpText = i18n( + "You can use the following placeholders in the filename, which will be replaced " + "with actual text when the file is saved:
" ); - + for (auto option = ExportManager::filenamePlaceholders.cbegin(); + option != ExportManager::filenamePlaceholders.cend(); ++option) { + helpText += QStringLiteral("%1: %2
").arg(option.key(), option.value()); + } + helpText += QStringLiteral("/: ") + i18n("To save to a sub-folder"); + helpText += QStringLiteral("
"); QLabel *fmtHelpText = new QLabel(helpText, this); fmtHelpText->setWordWrap(true); fmtHelpText->setTextFormat(Qt::RichText); fmtHelpText->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + connect(fmtHelpText, &QLabel::linkActivated, [this](const QString& placeholder) { + mSaveNameFormat->insert(placeholder); + }); saveNameLayout->addWidget(fmtHelpText); mainLayout->addRow(i18n("Filename:"), saveNameLayout);