diff --git a/bin/assets/i18n/de.xml b/bin/assets/i18n/de.xml index 262635114..1ea608b9d 100644 --- a/bin/assets/i18n/de.xml +++ b/bin/assets/i18n/de.xml @@ -946,4 +946,5 @@ Verwendet strftime-Formatbezeichner. Die Dateierweiterung richtet sich nach dem Es konnte kein verfügbarer Dateiname für das Bildschirmfoto gefunden werden. Das Bildschirmfoto konnte nicht gespeichert werden. Bildschirmfoto gespeichert: + Ordner öffnen diff --git a/bin/assets/i18n/en.xml b/bin/assets/i18n/en.xml index 3e29de6bc..8f6462b23 100644 --- a/bin/assets/i18n/en.xml +++ b/bin/assets/i18n/en.xml @@ -930,4 +930,5 @@ Uses strftime format specifiers. The file extension follows the selected screens Couldn't find an available screenshot filename. Couldn't save the screenshot. Screenshot saved: + Open Folder diff --git a/bin/assets/i18n/fr.xml b/bin/assets/i18n/fr.xml index 449f784cd..6b5233662 100644 --- a/bin/assets/i18n/fr.xml +++ b/bin/assets/i18n/fr.xml @@ -925,4 +925,5 @@ Utilise les spécificateurs de format strftime. L’extension du fichier corresp Impossible de trouver un nom de fichier disponible pour la capture d’écran. Impossible d’enregistrer la capture d’écran. Capture d’écran enregistrée : + Ouvrir le dossier diff --git a/bin/assets/i18n/zh.xml b/bin/assets/i18n/zh.xml index 4e6ef0d87..01ab61456 100644 --- a/bin/assets/i18n/zh.xml +++ b/bin/assets/i18n/zh.xml @@ -704,4 +704,5 @@ file in the directory tree. 无法找到可用的屏幕截图文件名。 无法保存屏幕截图。 屏幕截图已保存: + 打开屏幕截图文件夹 diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index fe963b6cd..030733c88 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2912,9 +2912,16 @@ void App::takeScreenshot() { } if ( mWindow->takeScreenshot( filepath, format ) ) { + std::vector actions; + actions.reserve( 2 ); + actions.emplace_back( NotificationCenter::InteractiveAction{ + i18n( "open", "Open" ), [this, filepath] { openFileFromPath( filepath ); } } ); + actions.emplace_back( NotificationCenter::InteractiveAction{ + i18n( "open_screenshot_folder", "Open Folder" ), + [savePath] { Engine::instance()->openURI( savePath ); } } ); mNotificationCenter->addInteractiveNotification( i18n( "screenshot_saved", "Screenshot saved:" ) + "\n" + filepath, - i18n( "open", "Open" ), [this, filepath] { openFileFromPath( filepath ); } ); + std::move( actions ) ); } else { errorMsgBox( i18n( "couldnt_save_screenshot", "Couldn't save the screenshot." ) ); } diff --git a/src/tools/ecode/notificationcenter.cpp b/src/tools/ecode/notificationcenter.cpp index 66f0751b3..69c387fef 100644 --- a/src/tools/ecode/notificationcenter.cpp +++ b/src/tools/ecode/notificationcenter.cpp @@ -99,14 +99,21 @@ void NotificationCenter::addShowRequest( const String& uri, const String& action void NotificationCenter::addInteractiveNotification( String text, String actionText, std::function onInteraction, const Time& delay, bool allowCopy ) { - auto action = [this, text = std::move( text ), actionText = std::move( actionText ), delay, - allowCopy, onInteraction = std::move( onInteraction )]() { + std::vector actions; + actions.emplace_back( + InteractiveAction{ std::move( actionText ), std::move( onInteraction ) } ); + addInteractiveNotification( std::move( text ), std::move( actions ), delay, allowCopy ); +} + +void NotificationCenter::addInteractiveNotification( String text, + std::vector actions, + const Time& delay, bool allowCopy ) { + auto action = [this, text = std::move( text ), actions = std::move( actions ), delay, + allowCopy]() mutable { static const auto layout = R"xml( - - - + )xml"; UILinearLayout* lay = mLayout->getUISceneNode() @@ -121,12 +128,20 @@ void NotificationCenter::addInteractiveNotification( String text, String actionT ( allowCopy ? EE_BUTTON_MMASK : ( EE_BUTTON_LMASK | EE_BUTTON_RMASK ) ) ) lay->close(); } ); - UIPushButton* pb = lay->findByType( UI_TYPE_PUSHBUTTON )->asType(); - pb->setText( actionText ); - pb->onClick( [actionText, onInteraction = std::move( onInteraction )]( const MouseEvent* ) { - if ( onInteraction ) - onInteraction(); - } ); + UILayout* actionsLayout = lay->find( "actions" ); + bool firstAction = true; + for ( auto& interactiveAction : actions ) { + UIPushButton* button = UIPushButton::New(); + if ( !firstAction ) + button->setLayoutMarginLeft( 4 ); + button->setText( interactiveAction.text )->setParent( actionsLayout ); + button->onClick( + [callback = std::move( interactiveAction.callback )]( const MouseEvent* ) { + if ( callback ) + callback(); + } ); + firstAction = false; + } Action* sequence = Actions::Sequence::New( { Actions::FadeIn::New( Seconds( 0.125 ) ), Actions::Delay::New( delay ), Actions::FadeOut::New( Seconds( 0.125 ) ), Actions::Close::New() } ); diff --git a/src/tools/ecode/notificationcenter.hpp b/src/tools/ecode/notificationcenter.hpp index b272c4975..9d3496931 100644 --- a/src/tools/ecode/notificationcenter.hpp +++ b/src/tools/ecode/notificationcenter.hpp @@ -7,6 +7,11 @@ namespace ecode { class NotificationCenter { public: + struct InteractiveAction { + String text; + std::function callback; + }; + static NotificationCenter* instance(); NotificationCenter( UILayout* layout, PluginManager* pluginManager ); @@ -21,6 +26,9 @@ class NotificationCenter { std::function onInteraction, const Time& delay = Seconds( 7.5 ), bool allowCopy = false ); + void addInteractiveNotification( String text, std::vector actions, + const Time& delay = Seconds( 7.5 ), bool allowCopy = false ); + protected: UILayout* mLayout{ nullptr }; PluginManager* mPluginManager{ nullptr };