Skip to content

Commit

Permalink
Adjusted PDF export 🌺
Browse files Browse the repository at this point in the history
- Updated copyright year in version.h
- Added license info to source files
- Moved single-line implementations to headers, just above templates (per-section for class)
- Adjusted PDF export to exclude new lines after last file
  • Loading branch information
fairybow committed Jan 30, 2023
1 parent d3afba2 commit 37d0ba5
Show file tree
Hide file tree
Showing 42 changed files with 511 additions and 299 deletions.
12 changes: 9 additions & 3 deletions fernanda/docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
- [ ] Move the startup `ColorBar` singleshot to a different window event? `showEvent` doesn't seem to be working for this
- [ ] Move the `nullptr` checks closer to the functions that create the `nullptr`, if possible (viz., don't wait till the info is sent to `Story` to cancel a nullptr from `Pane renameItem()`)
- [ ] Replace certain bool args with enums for descriptive actions taken (like "finalize" in `dom->renames()`)
- [ ] Alphabetize enums and generally clean up headers
- [ ] Custom highlight colors for line highlight and `Delegate` highlight (like with cursor)?
- [ ] Add border variables to stylesheets--for the most part, these can just be `transparent`, but allows for user to decide in customs
- [ ] Hold current story file from being edited while Fernanda is open? (Not sure this is possible. Plus, will need a way to temporarily request access for `Archiver` for editing)
- [ ] Export to PDF using Markdown or Fountain
- [ ] Is there a way to link swatches?
- [ ] Implement QStringLiterals where possible
- [ ] Temp save before cut?
- [ ] Delete trailing spaces on save
- [x] ~~Export selected / all, partly done~~
- [x] ~~Total word count (export-marked or all) - partly done~~
- [x] ~~Remove all non-standard abbreviations (like "cur" for current)~~
- [x] ~~Combine all the messagebox functions into something that generates most of it as a default config~~
- [x] ~~Keep screen awake?~~
- [x] ~~Mutex for running only one instance (sorta)~~
Expand All @@ -36,6 +33,15 @@
- [x] ~~Activate dev menu via command arg~~
- [x] ~~Redo Dependency Tree~~

## Code Guidelines
- [ ] One-line implementations to headers, bottom of proper class section namespace (before templates) (if header-only, bottom of section/namespace if possible)
- [ ] Header-onlys =< 100 lines
- [ ] `pascalCase`: member/global variables, function names and parameters
- [ ] `snake_case`: local-variables
- [ ] `CamelCase`: enums, classes, structs
- [ ] No uncommon/unhelpful abbreviations
- [ ] Names functionally descriptive, e.g. `editor->toggle(checked, Editor::Has::Scrolls);` or `pane->navigate(Pane::Go::Next);`

### Known issues
- [ ] Windows scale > 100% negates the effects of `setTextCursor(0)`
- [ ] AOT toggling affects stored window position setting (which, when toggled while maximized makes unmaximizing not change the window size)
Expand Down
10 changes: 10 additions & 0 deletions fernanda/src/archiver.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// archiver.cpp, Fernanda

#include "archiver.h"
Expand Down
15 changes: 11 additions & 4 deletions fernanda/src/archiver.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// archiver.h, Fernanda

#pragma once
Expand All @@ -13,10 +23,7 @@

#include <QTemporaryDir>

inline void operator<<(std::vector<std::string>& lhs, const std::string& rhs)
{
return lhs.push_back(rhs);
}
inline void operator<<(std::vector<std::string>& lhs, const std::string& rhs) { return lhs.push_back(rhs); }

class Archiver
{
Expand Down
20 changes: 10 additions & 10 deletions fernanda/src/colorbar.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// colorbar.cpp, Fernanda

#include "colorbar.h"
Expand Down Expand Up @@ -48,11 +58,6 @@ void ColorBar::run(Run theme)
bar_fill->start();
}

void ColorBar::delayedStartUp()
{
QTimer::singleShot(1500, this, [&]() { run(Run::Pastels); });
}

void ColorBar::setAlignment(QString alignment)
{
(alignment == "Bottom")
Expand All @@ -61,11 +66,6 @@ void ColorBar::setAlignment(QString alignment)
UserData::saveConfig(UserData::IniGroup::Window, UserData::IniValue::ColorBarAlignment, alignment);
}

bool ColorBar::hasStartUp()
{
return hasRunOnStartUp;
}

void ColorBar::style(Run theme)
{
QString style_sheet;
Expand Down
16 changes: 14 additions & 2 deletions fernanda/src/colorbar.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// colorbar.h, Fernanda

#pragma once
Expand Down Expand Up @@ -31,11 +41,13 @@ class ColorBar : public QWidget

void toggle(bool checked, Has has);
void run(Run theme = Run::None);
void delayedStartUp();

void delayedStartUp() { QTimer::singleShot(1500, this, [&]() { run(Run::Pastels); }); }

public slots:
void setAlignment(QString alignment);
bool hasStartUp();

bool hasStartUp() { return hasRunOnStartUp; }

private:
QProgressBar* bar = new QProgressBar(this);
Expand Down
17 changes: 12 additions & 5 deletions fernanda/src/delegate.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// delegate.h, Fernanda

#pragma once
Expand Down Expand Up @@ -65,11 +75,6 @@ class PaneDelegate : public QStyledItemDelegate
return false;
}

const QColor highlight() const
{
return QColor(0, 0, 0, 33);
}

void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
auto geometry = getRectSizes(option);
Expand Down Expand Up @@ -113,6 +118,8 @@ class PaneDelegate : public QStyledItemDelegate
painter->drawText(geometry.text, name);
painter->restore();
}

const QColor highlight() const { return QColor(0, 0, 0, 33); }
};

// delegate.h, Fernanda
10 changes: 10 additions & 0 deletions fernanda/src/dom.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// dom.cpp, Fernanda

#include "dom.h"
Expand Down
25 changes: 13 additions & 12 deletions fernanda/src/dom.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// dom.h, Fernanda

#pragma once
Expand Down Expand Up @@ -169,22 +179,13 @@ class Dom
}

template<typename T>
inline bool isDir(T nodeOrElement)
{
return isThis(nodeOrElement, tagDir);
}
inline bool isDir(T nodeOrElement) { return isThis(nodeOrElement, tagDir); }

template<typename T>
inline bool isFile(T nodeOrElement)
{
return isThis(nodeOrElement, tagFile);
}
inline bool isFile(T nodeOrElement) { return isThis(nodeOrElement, tagFile); }

template<typename T>
inline bool isRoot(T nodeOrElement)
{
return isThis(nodeOrElement, tagRoot);
}
inline bool isRoot(T nodeOrElement) { return isThis(nodeOrElement, tagRoot); }
};

// dom.h, Fernanda
10 changes: 10 additions & 0 deletions fernanda/src/editor.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// editor.cpp, Fernanda

#include "editor.h"
Expand Down
10 changes: 10 additions & 0 deletions fernanda/src/editor.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// editor.h, Fernanda

#pragma once
Expand Down
21 changes: 11 additions & 10 deletions fernanda/src/fernanda.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// fernanda.cpp, Fernanda

#include "fernanda.h"
Expand Down Expand Up @@ -70,11 +80,6 @@ bool Fernanda::confirmStoryClose(bool isQuit)
return result;
}

void Fernanda::openLocalFolder(StdFsPath path)
{
QDesktopServices::openUrl(QUrl::fromLocalFile(Path::toQString(path)));
}

const QStringList Fernanda::devPrintRenames(QVector<Io::ArchiveRename> renames)
{
QStringList result;
Expand Down Expand Up @@ -258,6 +263,7 @@ void Fernanda::makeStoryMenu()
story->addSeparator();
for (const auto& action : { total_counts })
story->addAction(action);
story->addSeparator();
auto exporting = story->addMenu(tr("&Export"));
for (const auto& action : { export_directory, export_PDF })
exporting->addAction(action);
Expand Down Expand Up @@ -778,11 +784,6 @@ void Fernanda::helpMenuUpdate()
});
}

void Fernanda::devMenuWrite(QString name, QString value)
{
Io::writeFile(UserData::doThis(UserData::Operation::GetDocuments) / name.toStdString(), value);
}

void Fernanda::handleEditorOpen(QString key)
{
QString old_key = nullptr;
Expand Down
16 changes: 14 additions & 2 deletions fernanda/src/fernanda.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// fernanda.h, Fernanda

#pragma once
Expand Down Expand Up @@ -71,7 +81,6 @@ class Fernanda : public QMainWindow
bool hasTheme = true;

bool confirmStoryClose(bool isQuit = false);
void openLocalFolder(StdFsPath path);
const QStringList devPrintRenames(QVector<Io::ArchiveRename> renames);
const QString name();
void addWidgets();
Expand All @@ -91,6 +100,8 @@ class Fernanda : public QMainWindow
void openStory(StdFsPath fileName, Story::Mode mode = Story::Mode::Normal);
void toggleWidget(QWidget* widget, UserData::IniGroup group, UserData::IniValue valueType, bool value);

void openLocalFolder(StdFsPath path) { QDesktopServices::openUrl(QUrl::fromLocalFile(Path::toQString(path))); }

template<typename T>
inline QActionGroup* makeViewToggles(QVector<Resource::DataPair>& dataLabelPairs, T slot)
{
Expand Down Expand Up @@ -136,7 +147,6 @@ private slots:
void helpMenuMakeSampleProject();
void helpMenuMakeSampleRes();
void helpMenuUpdate();
void devMenuWrite(QString name, QString value);
void handleEditorOpen(QString key = nullptr);
void sendEditedText();
bool replyHasProject();
Expand All @@ -145,6 +155,8 @@ private slots:
void domRename(QString newName, QString key);
void domCut(QString key);

void devMenuWrite(QString name, QString value) { Io::writeFile(UserData::doThis(UserData::Operation::GetDocuments) / name.toStdString(), value); }

signals:
void askSetBarAlignment(QString alignment);
void askSetCountdown(int seconds);
Expand Down
10 changes: 10 additions & 0 deletions fernanda/src/icon.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// icon.h, Fernanda

#pragma once
Expand Down
12 changes: 12 additions & 0 deletions fernanda/src/index.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

// index.h, Fernanda

#pragma once
Expand Down Expand Up @@ -29,6 +39,7 @@ namespace Index
}
return result;
}

inline const QString type(QModelIndex index) { return getData<QString>(index); }
inline const QString key(QModelIndex index) { return getData<QString>(index, 1); }
inline const QString name(QModelIndex index) { return getData<QString>(index, 2); }
Expand All @@ -40,6 +51,7 @@ namespace Index
if (type(index) == indexType) return true;
return false;
}

inline bool isDir(QModelIndex index) { return isThis(index, "directory"); }
inline bool isFile(QModelIndex index) { return isThis(index, "file"); }
}
Expand Down
Loading

0 comments on commit 37d0ba5

Please sign in to comment.