Skip to content

Commit

Permalink
Добавлена поддержка картинок в табах + сохранение файла функцией!
Browse files Browse the repository at this point in the history
  • Loading branch information
meigoc committed Mar 26, 2024
1 parent 7a56b0d commit e562ec9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/meigo/modules/MainModule.module
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"props": [],
"components": {
"dirChooser": {
"type": "script\\DirectoryChooserScript",
"x": 192.0,
"y": 32.0,
"props": {
"title": "Выбери папку для сохранения",
"inputNode": "",
"actionNode": ""
}
},
"fileChooser": {
"type": "script\\FileChooserScript",
"x": 48,
Expand Down
32 changes: 32 additions & 0 deletions src/meigo/modules/MainModule.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace meigo\modules;

use php\io\IOException;
use std, gui, framework, app;


Expand All @@ -22,6 +23,37 @@ function doFileChooserAction(ScriptEvent $e = null)
}
}

function SaveFile() // Сохранение файла
{
// Инициализация
$a = $this->dirChooser->execute(); // Получаем директорию
$b = app()->form("MainForm")->tabs->tabs[app()->form("MainForm")->tabs->selectedIndex]->text; // Получаем имя файла сгенерированное ранее
// ============================
if (fs::isFile($a."\\".$b)) { // Проверяем существует ли файл, если существует, то текст будет заменяться, если нет - создаваться файл с текстом.
// существует
try {
Stream::putContents($a."\\".$b, app()->form("MainForm")->getActiveBrowser()->executeScript("editor.getValue();"));
} catch (IOException $e) {
alert('Ошибка записи: ' . $e->getMessage());
}
} else {
// не существует
fs::makeFile($a."\\".$b);
try {
Stream::putContents($a."\\".$b, app()->form("MainForm")->getActiveBrowser()->executeScript("editor.getValue();"));
} catch (IOException $e) {
alert('Ошибка записи: ' . $e->getMessage());
}
}

}

function addTabImage($image = 'res://.data/img/plus16.png')
{
$b = app()->form("MainForm")->tabs->tabs[app()->form("MainForm")->tabs->selectedIndex]->graphic = new UXImageView(new UXImage($image));
return $b;
}




Expand Down

0 comments on commit e562ec9

Please sign in to comment.