mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-09-26 22:00:01 +03:00
eepp: Added UIImageViewer new tool widget to view images.
Added a new UIMessageBox event: `Event::OnDiscard`, this will triggered when window is closed without confirmation (`Event::OnConfirm`). And now `Event::OnCancel` is only triggered when is manually cancelled (click the cancel button). ecode: Greatly improved image viewing experience. Now you can switch images from the same directory with the mouse wheel, also zoom, translate and rotate the images, images open in a new tab by default but quick-preview can be activated in `Settings -> Window -> Quick Preview Images` (SpartanJ/ecode#96).
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
#include <eepp/system/md5.hpp>
|
||||
#include <eepp/system/sys.hpp>
|
||||
#include <eepp/ui/tools/uiimageviewer.hpp>
|
||||
#include <eterm/ui/uiterminal.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -125,6 +126,7 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
|
||||
ui.openFilesInNewWindow = ini.getValueB( "ui", "open_files_in_new_window", false );
|
||||
ui.openProjectInNewWindow = ini.getValueB( "ui", "open_project_in_new_window", false );
|
||||
ui.nativeFileDialogs = ini.getValueB( "ui", "native_file_dialogs", false );
|
||||
ui.imagesQuickPreview = ini.getValueB( "ui", "images_quick_preview", false );
|
||||
ui.panelPosition = panelPositionFromString( ini.getValue( "ui", "panel_position", "left" ) );
|
||||
ui.serifFont = ini.getValue( "ui", "serif_font", "fonts/NotoSans-Regular.ttf" );
|
||||
ui.monospaceFont = ini.getValue( "ui", "monospace_font", "fonts/DejaVuSansMono.ttf" );
|
||||
@@ -309,6 +311,7 @@ void AppConfig::save( const std::vector<std::string>& recentFiles,
|
||||
ini.setValueB( "ui", "open_files_in_new_window", ui.openFilesInNewWindow );
|
||||
ini.setValueB( "ui", "open_project_in_new_window", ui.openProjectInNewWindow );
|
||||
ini.setValueB( "ui", "native_file_dialogs", ui.nativeFileDialogs );
|
||||
ini.setValueB( "ui", "images_quick_preview", ui.imagesQuickPreview );
|
||||
ini.setValue( "ui", "panel_position", panelPositionToString( ui.panelPosition ) );
|
||||
ini.setValue( "ui", "serif_font", ui.serifFont );
|
||||
ini.setValue( "ui", "monospace_font", ui.monospaceFont );
|
||||
@@ -474,6 +477,14 @@ json AppConfig::saveNode( Node* node ) {
|
||||
if ( term->isUsingCustomTitle() )
|
||||
f["title"] = term->getTitle();
|
||||
files.emplace_back( f );
|
||||
} else if ( ownedWidget->isType( UI_TYPE_IMAGE_VIEWER ) ) {
|
||||
UIImageViewer* iv = ownedWidget->asType<UIImageViewer>();
|
||||
if ( iv->getImagePath().empty() )
|
||||
continue;
|
||||
json f;
|
||||
f["type"] = "image_viewer";
|
||||
f["path"] = iv->getImagePath();
|
||||
files.emplace_back( f );
|
||||
} else if ( node->isWidget() ) {
|
||||
UIWidget* widget = ownedWidget->asType<UIWidget>();
|
||||
if ( widget->getClasses().size() == 1 ) {
|
||||
@@ -727,6 +738,9 @@ void AppConfig::loadDocuments( UICodeEditorSplitter* editorSplitter, json j,
|
||||
if ( curTabWidget->getTabCount() == totalToLoad )
|
||||
curTabWidget->setTabSelected(
|
||||
eeclamp<Int32>( currentPage, 0, curTabWidget->getTabCount() - 1 ) );
|
||||
} else if ( file["type"] == "image_viewer" ) {
|
||||
if ( file.contains( "path" ) && file["path"].is_string() )
|
||||
app->loadImageFromMedium( file["path"].get<std::string>(), false, false, true );
|
||||
} else {
|
||||
auto found = tabWidgetTypes.find( file["type"] );
|
||||
if ( found != tabWidgetTypes.end() ) {
|
||||
|
||||
Reference in New Issue
Block a user