From bd3d0ae95a18882833210061624eab642b4f88fa Mon Sep 17 00:00:00 2001 From: jackson <63016612+fairybow@users.noreply.github.com> Date: Mon, 30 Jan 2023 18:44:18 -0500 Subject: [PATCH] Exporting combined text file :flamingo: - Added dev menu actions for dumping internal resource files (themes, fonts) to disk - Added a method for preserving file extension in Path::getName - Added ability to export combined text file - Adjusted source file license text --- fernanda/docs/dependencies.md | 1 + fernanda/src/archiver.cpp | 16 +++--- fernanda/src/archiver.h | 16 +++--- fernanda/src/colorbar.cpp | 16 +++--- fernanda/src/colorbar.h | 16 +++--- fernanda/src/delegate.h | 16 +++--- fernanda/src/dom.cpp | 16 +++--- fernanda/src/dom.h | 16 +++--- fernanda/src/editor.cpp | 16 +++--- fernanda/src/editor.h | 16 +++--- fernanda/src/fernanda.cpp | 102 +++++++++++++++++++++++---------- fernanda/src/fernanda.h | 17 +++--- fernanda/src/icon.h | 16 +++--- fernanda/src/index.h | 16 +++--- fernanda/src/indicator.cpp | 16 +++--- fernanda/src/indicator.h | 16 +++--- fernanda/src/io.h | 16 +++--- fernanda/src/keyfilter.cpp | 16 +++--- fernanda/src/keyfilter.h | 16 +++--- fernanda/src/layout.h | 16 +++--- fernanda/src/main.cpp | 16 +++--- fernanda/src/pane.cpp | 16 +++--- fernanda/src/pane.h | 16 +++--- fernanda/src/path.h | 47 ++++++++++----- fernanda/src/plaintextedit.cpp | 16 +++--- fernanda/src/plaintextedit.h | 16 +++--- fernanda/src/popup.cpp | 16 +++--- fernanda/src/popup.h | 16 +++--- fernanda/src/resource.h | 16 +++--- fernanda/src/sample.h | 16 +++--- fernanda/src/splitter.h | 16 +++--- fernanda/src/startcop.h | 16 +++--- fernanda/src/story.cpp | 44 ++++++++------ fernanda/src/story.h | 22 ++++--- fernanda/src/style.h | 27 ++++++--- fernanda/src/text.cpp | 16 +++--- fernanda/src/text.h | 16 +++--- fernanda/src/tool.cpp | 16 +++--- fernanda/src/tool.h | 16 +++--- fernanda/src/userdata.cpp | 16 +++--- fernanda/src/userdata.h | 16 +++--- fernanda/src/version.h | 20 +++---- 42 files changed, 455 insertions(+), 369 deletions(-) diff --git a/fernanda/docs/dependencies.md b/fernanda/docs/dependencies.md index e578069..7c404a1 100644 --- a/fernanda/docs/dependencies.md +++ b/fernanda/docs/dependencies.md @@ -233,6 +233,7 @@ #include #include #include +#include ``` ### plaintextedit.h diff --git a/fernanda/src/archiver.cpp b/fernanda/src/archiver.cpp index 409e9ee..1926a79 100644 --- a/fernanda/src/archiver.cpp +++ b/fernanda/src/archiver.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // archiver.cpp, Fernanda diff --git a/fernanda/src/archiver.h b/fernanda/src/archiver.h index 8eee8a0..cb770b4 100644 --- a/fernanda/src/archiver.h +++ b/fernanda/src/archiver.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // archiver.h, Fernanda diff --git a/fernanda/src/colorbar.cpp b/fernanda/src/colorbar.cpp index 8c8a477..c61fdda 100644 --- a/fernanda/src/colorbar.cpp +++ b/fernanda/src/colorbar.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // colorbar.cpp, Fernanda diff --git a/fernanda/src/colorbar.h b/fernanda/src/colorbar.h index b35a828..797a106 100644 --- a/fernanda/src/colorbar.h +++ b/fernanda/src/colorbar.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // colorbar.h, Fernanda diff --git a/fernanda/src/delegate.h b/fernanda/src/delegate.h index 5184701..79e8490 100644 --- a/fernanda/src/delegate.h +++ b/fernanda/src/delegate.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // delegate.h, Fernanda diff --git a/fernanda/src/dom.cpp b/fernanda/src/dom.cpp index 121892f..9472045 100644 --- a/fernanda/src/dom.cpp +++ b/fernanda/src/dom.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // dom.cpp, Fernanda diff --git a/fernanda/src/dom.h b/fernanda/src/dom.h index b69b6d5..4eb090c 100644 --- a/fernanda/src/dom.h +++ b/fernanda/src/dom.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // dom.h, Fernanda diff --git a/fernanda/src/editor.cpp b/fernanda/src/editor.cpp index 3bddbff..911577a 100644 --- a/fernanda/src/editor.cpp +++ b/fernanda/src/editor.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // editor.cpp, Fernanda diff --git a/fernanda/src/editor.h b/fernanda/src/editor.h index 38d1d88..d92c149 100644 --- a/fernanda/src/editor.h +++ b/fernanda/src/editor.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // editor.h, Fernanda diff --git a/fernanda/src/fernanda.cpp b/fernanda/src/fernanda.cpp index c5aa47f..dae6cd5 100644 --- a/fernanda/src/fernanda.cpp +++ b/fernanda/src/fernanda.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // fernanda.cpp, Fernanda @@ -226,12 +226,15 @@ void Fernanda::makeFileMenu() connect(save, &QAction::triggered, this, &Fernanda::fileMenuSave); connect(quit, &QAction::triggered, this, &QCoreApplication::quit, Qt::QueuedConnection); auto file = menuBar->addMenu(tr("&File")); - for (const auto& action : { new_story_project, open_story_project }) + for (const auto& action : { + new_story_project, + open_story_project, + file->addSeparator(), + save, + file->addSeparator(), + quit + }) file->addAction(action); - file->addSeparator(); - file->addAction(save); - file->addSeparator(); - file->addAction(quit); save->setEnabled(false); connect(this, &Fernanda::storyMenuVisible, save, &QAction::setEnabled); } @@ -243,6 +246,7 @@ void Fernanda::makeStoryMenu() auto total_counts = new QAction(tr("&Total counts..."), this); auto export_directory = new QAction(tr("&Export to directory (last saved state)..."), this); auto export_PDF = new QAction(tr("&Export to PDF (current state)..."), this); + auto export_plain_text = new QAction(tr("&Export to plain text (current state)..."), this); connect(new_folder, &QAction::triggered, this, [&]() { askPaneAdd(Path::Type::Dir); }); connect(new_file, &QAction::triggered, this, [&]() { askPaneAdd(Path::Type::File); }); connect(total_counts, &QAction::triggered, this, &Fernanda::storyMenuTotals); @@ -253,19 +257,23 @@ void Fernanda::makeStoryMenu() }); connect(export_PDF, &QAction::triggered, this, [&]() { - auto& story = activeStory.value(); - auto file_name = QFileDialog::getSaveFileName(this, tr("Create a new PDF..."), Path::toQString(UserData::doThis(UserData::Operation::GetDocuments) / story.name()), tr("Portable Document Format (*.pdf)")); - story.exportTo(Path::toStdFs(file_name), Story::To::PDF); + storyMenuFileExport("Create a new PDF...", "Portable Document Format (*.pdf)", Story::To::PDF); + }); + connect(export_plain_text, &QAction::triggered, this, [&]() + { + storyMenuFileExport("Create a new text document...", "Text documents (*.txt)", Story::To::PlainText); }); auto story = menuBar->addMenu(tr("&Story")); - for (const auto& action : { new_folder, new_file }) - story->addAction(action); - story->addSeparator(); - for (const auto& action : { total_counts }) + for (const auto& action : { + new_folder, + new_file, + story->addSeparator(), + total_counts, + story->addSeparator() + }) story->addAction(action); - story->addSeparator(); auto exporting = story->addMenu(tr("&Export")); - for (const auto& action : { export_directory, export_PDF }) + for (const auto& action : { export_directory, export_PDF, export_plain_text }) exporting->addAction(action); story->menuAction()->setVisible(false); connect(this, &Fernanda::storyMenuVisible, story->menuAction(), &QAction::setVisible); @@ -518,19 +526,20 @@ void Fernanda::makeHelpMenu() connect(create_sample_project, &QAction::triggered, this, &Fernanda::helpMenuMakeSampleProject); connect(create_sample_themes, &QAction::triggered, this, &Fernanda::helpMenuMakeSampleRes); auto help = menuBar->addMenu(tr("&Help")); - for (const auto& action : { about, check_for_updates, shortcuts }) + for (const auto& action : { about, check_for_updates, shortcuts, help->addSeparator() }) help->addAction(action); - help->addSeparator(); auto open = help->addMenu(tr("&Open")); for (const auto& action : { documents, installation_folder, user_data_folder }) open->addAction(action); - help->addSeparator(); - for (const auto& action : { create_sample_project, create_sample_themes }) + for (const auto& action : { help->addSeparator(), create_sample_project, create_sample_themes }) help->addAction(action); } void Fernanda::makeDevMenu() { + auto dump_editor_themes = new QAction(tr("&Dump editor theme files"), this); + auto dump_fonts = new QAction(tr("&Dump font files"), this); + auto dump_window_themes = new QAction(tr("&Dump window theme files"), this); auto print_cursor_positions = new QAction(tr("&Print cursor positions"), this); auto print_cuts = new QAction(tr("&Print cuts"), this); auto print_dom = new QAction(tr("&Print DOM"), this); @@ -542,6 +551,18 @@ void Fernanda::makeDevMenu() auto open_installation_folder = new QAction(tr("&Open installation folder..."), this); auto open_temps = new QAction(tr("&Open temps..."), this); auto open_user_data = new QAction(tr("&Open user data..."), this); + connect(dump_editor_themes, &QAction::triggered, this, [&]() + { + Style::dump(editorThemes, UserData::doThis(UserData::Operation::GetDocuments)); + }); + connect(dump_fonts, &QAction::triggered, this, [&]() + { + Style::dump(editorFonts, UserData::doThis(UserData::Operation::GetDocuments)); + }); + connect(dump_window_themes, &QAction::triggered, this, [&]() + { + Style::dump(windowThemes, UserData::doThis(UserData::Operation::GetDocuments)); + }); connect(print_cursor_positions, &QAction::triggered, this, [&]() { devMenuWrite("__Cursor positions.txt", editor->devGetCursorPositions().join(Text::newLines())); @@ -594,10 +615,24 @@ void Fernanda::makeDevMenu() openLocalFolder(UserData::doThis(UserData::Operation::GetUserData)); }); auto dev = menuBar->addMenu(tr("&Dev")); - for (const auto& action : { print_cursor_positions, print_cuts, print_dom, print_dom_initial, print_edited_keys_delegate, print_edited_keys_story, print_renames }) - dev->addAction(action); - dev->addSeparator(); - for (const auto& action : { open_documents, open_installation_folder, open_temps, open_user_data }) + for (const auto& action : { + dump_editor_themes, + dump_fonts, + dump_window_themes, + dev->addSeparator(), + print_cursor_positions, + print_cuts, + print_dom, + print_dom_initial, + print_edited_keys_delegate, + print_edited_keys_story, + print_renames, + dev->addSeparator(), + open_documents, + open_installation_folder, + open_temps, + open_user_data + }) dev->addAction(action); } @@ -682,6 +717,13 @@ void Fernanda::toggleWidget(QWidget* widget, UserData::IniGroup group, UserData: UserData::saveConfig(group, valueType, value); } +void Fernanda::storyMenuFileExport(const char* caption, const char* extensionFilter, Story::To type) +{ + auto& story = activeStory.value(); + auto file_name = QFileDialog::getSaveFileName(this, tr(caption), Path::toQString(UserData::doThis(UserData::Operation::GetDocuments) / story.name()), tr(extensionFilter)); + story.exportTo(Path::toStdFs(file_name), type); +} + void Fernanda::adjustTitle() { auto current_title = windowTitle(); diff --git a/fernanda/src/fernanda.h b/fernanda/src/fernanda.h index da3b4d6..7a3bf60 100644 --- a/fernanda/src/fernanda.h +++ b/fernanda/src/fernanda.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // fernanda.h, Fernanda @@ -99,6 +99,7 @@ class Fernanda : public QMainWindow void loadMenuToggle(QAction* action, UserData::IniGroup group, UserData::IniValue valueType, QVariant fallback); void openStory(StdFsPath fileName, Story::Mode mode = Story::Mode::Normal); void toggleWidget(QWidget* widget, UserData::IniGroup group, UserData::IniValue valueType, bool value); + void storyMenuFileExport(const char* caption, const char* extensionFilter, Story::To type); void openLocalFolder(StdFsPath path) { QDesktopServices::openUrl(QUrl::fromLocalFile(Path::toQString(path))); } diff --git a/fernanda/src/icon.h b/fernanda/src/icon.h index 79a777f..f21366f 100644 --- a/fernanda/src/icon.h +++ b/fernanda/src/icon.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // icon.h, Fernanda diff --git a/fernanda/src/index.h b/fernanda/src/index.h index 898b359..52f5236 100644 --- a/fernanda/src/index.h +++ b/fernanda/src/index.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // index.h, Fernanda diff --git a/fernanda/src/indicator.cpp b/fernanda/src/indicator.cpp index 8e22afb..0f5e9bf 100644 --- a/fernanda/src/indicator.cpp +++ b/fernanda/src/indicator.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // indicator.cpp, Fernanda diff --git a/fernanda/src/indicator.h b/fernanda/src/indicator.h index 70e943e..093dcbc 100644 --- a/fernanda/src/indicator.h +++ b/fernanda/src/indicator.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // indicator.h, Fernanda diff --git a/fernanda/src/io.h b/fernanda/src/io.h index b4e0ddb..57113ba 100644 --- a/fernanda/src/io.h +++ b/fernanda/src/io.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // io.h, Fernanda diff --git a/fernanda/src/keyfilter.cpp b/fernanda/src/keyfilter.cpp index dc8792d..ff1bdf7 100644 --- a/fernanda/src/keyfilter.cpp +++ b/fernanda/src/keyfilter.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // keyfilter.cpp, Fernanda diff --git a/fernanda/src/keyfilter.h b/fernanda/src/keyfilter.h index 85aa46b..febd73e 100644 --- a/fernanda/src/keyfilter.h +++ b/fernanda/src/keyfilter.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // keyfilter.h, Fernanda diff --git a/fernanda/src/layout.h b/fernanda/src/layout.h index d1bc5ba..71d79bf 100644 --- a/fernanda/src/layout.h +++ b/fernanda/src/layout.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // layout.h, Fernanda diff --git a/fernanda/src/main.cpp b/fernanda/src/main.cpp index 9d10c64..7a5a542 100644 --- a/fernanda/src/main.cpp +++ b/fernanda/src/main.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // main.cpp, Fernanda diff --git a/fernanda/src/pane.cpp b/fernanda/src/pane.cpp index 11fc915..3b0b057 100644 --- a/fernanda/src/pane.cpp +++ b/fernanda/src/pane.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // pane.cpp, Fernanda diff --git a/fernanda/src/pane.h b/fernanda/src/pane.h index ac3e740..d2228c0 100644 --- a/fernanda/src/pane.h +++ b/fernanda/src/pane.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // pane.h, Fernanda diff --git a/fernanda/src/path.h b/fernanda/src/path.h index 8e0dc8d..69cf599 100644 --- a/fernanda/src/path.h +++ b/fernanda/src/path.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // path.h, Fernanda @@ -21,6 +21,7 @@ #include #include #include +#include namespace Path { @@ -81,16 +82,34 @@ namespace Path #endif template - inline const T getName(U path) + inline const T getName(U path, bool keepExtension = false) { + T result{}; if constexpr (std::is_same::value && std::is_same::value) - return QString::fromStdString(toStdFs(path).stem().string()); + { + (keepExtension) + ? result = QString::fromStdString(toStdFs(path).filename().string()) + : result = QString::fromStdString(toStdFs(path).stem().string()); + } if constexpr (std::is_same::value && std::is_same::value) - return QString::fromStdString(path.stem().string()); - if constexpr (std::is_same::value && std::is_same::value) - return toStdFs(path).stem(); + { + (keepExtension) + ? result = QString::fromStdString(path.filename().string()) + : result = QString::fromStdString(path.stem().string()); + } + if constexpr ((std::is_same::value && std::is_same::value) || (std::is_same::value && std::is_same::value)) + { + (keepExtension) + ? result = toStdFs(path).filename() + : result = toStdFs(path).stem(); + } if constexpr (std::is_same::value && std::is_same::value) - return path.stem(); + { + (keepExtension) + ? result = path.filename() + : result = path.stem(); + } + return result; } } diff --git a/fernanda/src/plaintextedit.cpp b/fernanda/src/plaintextedit.cpp index 511bef2..6fe8efd 100644 --- a/fernanda/src/plaintextedit.cpp +++ b/fernanda/src/plaintextedit.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // plaintextedit.cpp, Fernanda diff --git a/fernanda/src/plaintextedit.h b/fernanda/src/plaintextedit.h index 13047a2..821a8cc 100644 --- a/fernanda/src/plaintextedit.h +++ b/fernanda/src/plaintextedit.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // plaintextedit.h, Fernanda diff --git a/fernanda/src/popup.cpp b/fernanda/src/popup.cpp index a8628f7..2d9533f 100644 --- a/fernanda/src/popup.cpp +++ b/fernanda/src/popup.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // popup.cpp, Fernanda diff --git a/fernanda/src/popup.h b/fernanda/src/popup.h index c86a995..db272c2 100644 --- a/fernanda/src/popup.h +++ b/fernanda/src/popup.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // popup.h, Fernanda diff --git a/fernanda/src/resource.h b/fernanda/src/resource.h index 6139896..7493eff 100644 --- a/fernanda/src/resource.h +++ b/fernanda/src/resource.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // resource.h, Fernanda diff --git a/fernanda/src/sample.h b/fernanda/src/sample.h index 959abd9..12bdabc 100644 --- a/fernanda/src/sample.h +++ b/fernanda/src/sample.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // sample.h, Fernanda diff --git a/fernanda/src/splitter.h b/fernanda/src/splitter.h index a50d94c..573c74f 100644 --- a/fernanda/src/splitter.h +++ b/fernanda/src/splitter.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // splitter.h, Fernanda diff --git a/fernanda/src/startcop.h b/fernanda/src/startcop.h index 382c1ce..d3f197a 100644 --- a/fernanda/src/startcop.h +++ b/fernanda/src/startcop.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // startcop.h, Fernanda diff --git a/fernanda/src/story.cpp b/fernanda/src/story.cpp index 25c6204..656fea7 100644 --- a/fernanda/src/story.cpp +++ b/fernanda/src/story.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // story.cpp, Fernanda @@ -135,6 +135,9 @@ void Story::exportTo(StdFsPath path, To type) case To::PDF: toPdf(path); break; + case To::PlainText: + toPlainText(path); + break; } } @@ -304,13 +307,9 @@ void Story::bak() Path::copy(activeArchivePath, bak_path); } -void Story::toPdf(StdFsPath path) +const QString Story::readAllForExport() { - QPrinter printer; - printer.setOutputFormat(QPrinter::PdfFormat); - printer.setOutputFileName(Path::toQString(path)); - QTextDocument doc; - QString content; + QString result; auto elements = dom->elements(); auto& last_element = elements.last(); for (auto& element : elements) @@ -319,12 +318,21 @@ void Story::toPdf(StdFsPath path) auto key = element.attribute(dom->attributeKey); auto temp_path = tempPath(key); (QFile(temp_path).exists()) - ? content = content + Io::readFile(temp_path) - : content = content + archiver->read(activeArchivePath, dom->element(key, Dom::Element::OrigPath)); + ? result = result + Io::readFile(temp_path) + : result = result + archiver->read(activeArchivePath, dom->element(key, Dom::Element::OrigPath)); if (element != last_element) - content = content + Text::newLines(); + result = result + Text::newLines(); } - doc.setPlainText(content); + return result; +} + +void Story::toPdf(StdFsPath path) +{ + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(Path::toQString(path)); + QTextDocument doc; + doc.setPlainText(readAllForExport()); doc.print(&printer); } diff --git a/fernanda/src/story.h b/fernanda/src/story.h index 5d73357..7be2185 100644 --- a/fernanda/src/story.h +++ b/fernanda/src/story.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // story.h, Fernanda @@ -34,7 +34,8 @@ class Story }; enum class To { Directory, - PDF + PDF, + PlainText }; struct TotalCounts { @@ -93,7 +94,10 @@ class Story void amendEditsList(AmendEdits operation, QString key = nullptr); bool isEdited(QString key); void bak(); + const QString readAllForExport(); void toPdf(StdFsPath path); + + void toPlainText(StdFsPath path) { Io::writeFile(path, readAllForExport()); } }; // story.h, Fernanda diff --git a/fernanda/src/style.h b/fernanda/src/style.h index 750d3b7..7fc35c5 100644 --- a/fernanda/src/style.h +++ b/fernanda/src/style.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // style.h, Fernanda @@ -95,6 +95,17 @@ namespace Style else actions.first()->setChecked(true); } + + inline void dump(QActionGroup* group, StdFs::path path) + { + auto dump_directory = path / "__dump"; + Path::makeDirs(dump_directory); + for (auto& action : group->actions()) + { + auto data = action->data(); + Path::copy(Path::toStdFs(data), dump_directory / Path::getName(data, true)); + } + } } // style.h, Fernanda diff --git a/fernanda/src/text.cpp b/fernanda/src/text.cpp index 39fb69d..007da33 100644 --- a/fernanda/src/text.cpp +++ b/fernanda/src/text.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // text.cpp, Fernanda diff --git a/fernanda/src/text.h b/fernanda/src/text.h index 9923e30..e68cb6b 100644 --- a/fernanda/src/text.h +++ b/fernanda/src/text.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // text.h, Fernanda diff --git a/fernanda/src/tool.cpp b/fernanda/src/tool.cpp index 992ddba..e95d2c6 100644 --- a/fernanda/src/tool.cpp +++ b/fernanda/src/tool.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // tool.cpp, Fernanda diff --git a/fernanda/src/tool.h b/fernanda/src/tool.h index eeebdb2..2bf498a 100644 --- a/fernanda/src/tool.h +++ b/fernanda/src/tool.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // tool.h, Fernanda diff --git a/fernanda/src/userdata.cpp b/fernanda/src/userdata.cpp index 7a1f491..1436cf5 100644 --- a/fernanda/src/userdata.cpp +++ b/fernanda/src/userdata.cpp @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // userdata.cpp, Fernanda diff --git a/fernanda/src/userdata.h b/fernanda/src/userdata.h index 8f7e22b..d192278 100644 --- a/fernanda/src/userdata.h +++ b/fernanda/src/userdata.h @@ -1,12 +1,12 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // userdata.h, Fernanda diff --git a/fernanda/src/version.h b/fernanda/src/version.h index d1aefff..1bdb2f2 100644 --- a/fernanda/src/version.h +++ b/fernanda/src/version.h @@ -1,19 +1,19 @@ /* -* Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) -* Copyright(C) 2022 - 2023 @fairybow (https://github.com/fairybow) -* -* https://github.com/fairybow/fernanda -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Fernanda is a plain text editor for drafting long-form fiction. (At least, that's the plan.) + * Copyright (C) 2022-2023 @fairybow + * + * + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ // version.h, Fernanda #pragma once -#define VER_FILEVERSION 0,16,1,35 -#define VER_FILEVERSION_STR "v0.16.1-beta35" +#define VER_FILEVERSION 0,17,0,36 +#define VER_FILEVERSION_STR "v0.17.0-beta36" #define VER_PRODUCTVERSION VER_FILEVERSION #define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR #define VER_COMPANYNAME_STR "@fairybow"