diff --git a/CMakeLists.txt b/CMakeLists.txt index c6f9b8c..6fe99a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,8 @@ list(APPEND SRC_FILES src/core/storage src/core/svgiconengine src/editor/doceditor + src/editor/edittoolbar + src/editor/textedit src/gui/maintoolbar src/gui/statusbar src/gui/storytree diff --git a/i18n/collett_en_US.ts b/i18n/collett_en_US.ts index e7862d9..580f23f 100644 --- a/i18n/collett_en_US.ts +++ b/i18n/collett_en_US.ts @@ -1,6 +1,59 @@ + + Collett::GuiEditToolBar + + + Bold + + + + + Italic + + + + + Underline + + + + + Strikethrough + + + + + Align Left + + + + + Align Right + + + + + Align Centre + + + + + Align Justify + + + + + Indent Paragraph + + + + + Outdent Paragraph + + + Collett::GuiMain @@ -133,7 +186,7 @@ Collett::Project - + Unnamed Project @@ -170,32 +223,32 @@ Collett::StoryItem - + Unnamed - + Book - + Partition - + Chapter - + Scene - + Page @@ -203,7 +256,7 @@ Collett::StoryModel - + New %1 diff --git a/i18n/collett_nb_NO.ts b/i18n/collett_nb_NO.ts index f9a1f5f..0e098e6 100644 --- a/i18n/collett_nb_NO.ts +++ b/i18n/collett_nb_NO.ts @@ -1,6 +1,59 @@ + + Collett::GuiEditToolBar + + + Bold + + + + + Italic + + + + + Underline + + + + + Strikethrough + + + + + Align Left + + + + + Align Right + + + + + Align Centre + + + + + Align Justify + + + + + Indent Paragraph + + + + + Outdent Paragraph + + + Collett::GuiMain @@ -133,7 +186,7 @@ Collett::Project - + Unnamed Project @@ -170,32 +223,32 @@ Collett::StoryItem - + Unnamed - + Book - + Partition - + Chapter - + Scene - + Page @@ -203,7 +256,7 @@ Collett::StoryModel - + New %1 diff --git a/sample/project/project.json b/sample/project/project.json index 4710472..4b474fb 100644 --- a/sample/project/project.json +++ b/sample/project/project.json @@ -1,7 +1,7 @@ { "c:meta": { "m:created": "2021-12-14T22:24:25", - "m:updated": "2022-01-23T17:54:31" + "m:updated": "2022-01-23T18:46:08" }, "c:project": { "u:project-name": "Sample Project" diff --git a/src/collett.h b/src/collett.h index 3a031ba..4a22868 100644 --- a/src/collett.h +++ b/src/collett.h @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -26,4 +26,21 @@ #define COL_VERSION_NUM 0x000001a0 #define COL_VERSION_DATE "2021-11-14" +namespace Collett { + +enum DocAction { + FormatBold, + FormatItalic, + FormatUnderline, + FormatStrikethrough, + TextAlignLeft, + TextAlignCentre, + TextAlignRight, + TextAlignJustify, + TextIndent, + TextOutdent, +}; + +} // namespace Collett + #endif // COLLETT_H diff --git a/src/core/data.cpp b/src/core/data.cpp index d878f45..aaade48 100644 --- a/src/core/data.cpp +++ b/src/core/data.cpp @@ -3,7 +3,7 @@ ** ========================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/core/data.h b/src/core/data.h index 1887359..e5d52b9 100644 --- a/src/core/data.h +++ b/src/core/data.h @@ -3,7 +3,7 @@ ** ========================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/core/icons.cpp b/src/core/icons.cpp index 883ce46..b3ad48c 100644 --- a/src/core/icons.cpp +++ b/src/core/icons.cpp @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ #include #include #include +#include namespace Collett { @@ -48,54 +49,113 @@ void CollettIcons::destroy() { /**! * @brief Construct a CollettIcons object. - * - * The icon SVG data is from https://remixicon.com + * + * The icon SVG data is from https://fonts.google.com/icons + * Icon style: Filled */ CollettIcons::CollettIcons() { - // RemixIcon: archive-fill - m_svgData["archive"] = QString( - "" - "" - "" - "" - ); - - // RemixIcon: book-fill - m_svgData["book"] = QString( - "" - "" - "" - "" - ); - - // RemixIcon: more-2-fill - m_svgData["more"] = QString( - "" - "" - "" - ); - - // RemixIcon: settings-5-fill - m_svgData["settings"] = QString( - "" - "" - "" - "" + // format_align_center_black_24dp.svg + m_svgPath["alignCentre"] = QLatin1String( + "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z" + ); + + // format_align_justify_black_24dp.svg + m_svgPath["alignJustify"] = QLatin1String( + "M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z" + ); + + // format_align_left_black_24dp.svg + m_svgPath["alignLeft"] = QLatin1String( + "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z" + ); + + // format_align_right_black_24dp.svg + m_svgPath["alignRight"] = QLatin1String( + "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z" + ); + + // inventory_2_black_24dp.svg + m_svgPath["archive"] = QLatin1String( + "M20,2H4C3,2,2,2.9,2,4v3.01C2,7.73,2.43,8.35,3,8.7V20c0,1.1,1.1,2,2,2h14c0.9,0,2-0.9,2-2V8" + ".7c0.57-0.35,1-0.97,1-1.69V4 C22,2.9,21,2,20,2z M15,14H9v-2h6V14z M20,7H4V4h16V7z" + ); + + // format_bold_black_24dp.svg + m_svgPath["bold"] = QLatin1String( + "M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-" + "3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5" + " 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" + ); + + // auto_stories_black_24dp.svg + m_svgPath["book"] = QLatin1String( + "M19 1l-5 5v11l5-4.5V1zM1 6v14.65c0 .25.25.5.5.5.1 0 .15-.05.25-.05C3.1 20.45 5.05 20 6.5 " + "20c1.95 0 4.05.4 5.5 1.5V6c-1.45-1.1-3.55-1.5-5.5-1.5S2.45 4.9 1 6zm22 13.5V6c-.6-.45-1.2" + "5-.75-2-1v13.5c-1.1-.35-2.3-.5-3.5-.5-1.7 0-4.15.65-5.5 1.5v2c1.35-.85 3.8-1.5 5.5-1.5 1." + "65 0 3.35.3 4.75 1.05.1.05.15.05.25.05.25 0 .5-.25.5-.5v-1.1z" + ); + + // format_indent_increase_black_24dp.svg + m_svgPath["blockIndent"] = QLatin1String( + "M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11" + "v2z" + ); + + // format_indent_decrease_black_24dp.svg + m_svgPath["blockOutdent"] = QLatin1String( + "M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2" + "H11v2z" + ); + + // format_italic_black_24dp.svg + m_svgPath["italic"] = QLatin1String( + "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z" + ); + + // more_vert_black_24dp.svg + m_svgPath["more"] = QLatin1String( + "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-." + "9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" + ); + + // settings_black_24dp.svg + m_svgPath["settings"] = QLatin1String( + "M19.5,12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3,0.51-0.86,0.26-1.3l-1.87-3.23c-0.25" + "-0.44-0.79-0.62-1.25-0.42 l-2.15,0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8,2.38" + ",14.37,2,13.87,2h-3.73C9.63,2,9.2,2.38,9.14,2.88L8.85,5.19 c-0.41,0.19-0.8,0.42-1.17,0.68" + "L5.53,4.96c-0.46-0.2-1-0.02-1.25,0.42L2.41,8.62c-0.25,0.44-0.14,0.99,0.26,1.3l1.86,1.41 C" + "4.51,11.55,4.5,11.77,4.5,12s0.01,0.45,0.03,0.68l-1.86,1.41c-0.4,0.3-0.51,0.86-0.26,1.3l1." + "87,3.23c0.25,0.44,0.79,0.62,1.25,0.42 l2.15-0.91c0.37,0.26,0.76,0.49,1.17,0.68l0.29,2.31C" + "9.2,21.62,9.63,22,10.13,22h3.73c0.5,0,0.93-0.38,0.99-0.88l0.29-2.31 c0.41-0.19,0.8-0.42,1" + ".17-0.68l2.15,0.91c0.46,0.2,1,0.02,1.25-0.42l1.87-3.23c0.25-0.44,0.14-0.99-0.26-1.3l-1.86" + "-1.41 C19.49,12.45,19.5,12.23,19.5,12z M12.04,15.5c-1.93,0-3.5-1.57-3.5-3.5s1.57-3.5,3.5-" + "3.5s3.5,1.57,3.5,3.5S13.97,15.5,12.04,15.5z" + ); + + // format_strikethrough_black_24dp.svg + m_svgPath["strikethrough"] = QLatin1String( + "M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z" + ); + + // subscript_black_24dp.svg + m_svgPath["subscript"] = QLatin1String( + "M22,18h-2v1h3v1h-4v-2c0-0.55,0.45-1,1-1h2v-1h-3v-1h3c0.55,0,1,0.45,1,1v1C23,17.55,22.55,1" + "8,22,18z M5.88,18h2.66 l3.4-5.42h0.12l3.4,5.42h2.66l-4.65-7.27L17.81,4h-2.68l-3.07,4.99h-" + "0.12L8.85,4H6.19l4.32,6.73L5.88,18z" + ); + + // superscript_black_24dp.svg + m_svgPath["superscript"] = QLatin1String( + "M22,7h-2v1h3v1h-4V7c0-0.55,0.45-1,1-1h2V5h-3V4h3c0.55,0,1,0.45,1,1v1C23,6.55,22.55,7,22,7" + "z M5.88,20h2.66l3.4-5.42h0.12 l3.4,5.42h2.66l-4.65-7.27L17.81,6h-2.68l-3.07,4.99h-0.12L8." + "85,6H6.19l4.32,6.73L5.88,20z" + ); + + // format_underlined_black_24dp.svg + m_svgPath["underline"] = QLatin1String( + "M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2" + ".69 6 6 6zm-7 2v2h14" ); } @@ -105,7 +165,10 @@ CollettIcons::~CollettIcons() { QIcon CollettIcons::icon(const QString &name) { QColor col = qApp->palette().buttonText().color(); - QString svg = m_svgData[name].arg(col.name(QColor::HexRgb)).arg("0.8"); + QString svg = QString( + "" + ).arg(col.name(QColor::HexRgb)).arg("0.7").arg(m_svgPath[name]); return QIcon(new SVGIconEngine(svg)); } diff --git a/src/core/icons.h b/src/core/icons.h index c6df814..f389141 100644 --- a/src/core/icons.h +++ b/src/core/icons.h @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include #include #include +#include namespace Collett { @@ -45,7 +46,7 @@ class CollettIcons : public QObject private: static CollettIcons *staticInstance; - QHash m_svgData; + QHash m_svgPath; }; } // namespace Collett diff --git a/src/core/storage.cpp b/src/core/storage.cpp index 0fe3439..2ef1d2f 100644 --- a/src/core/storage.cpp +++ b/src/core/storage.cpp @@ -3,7 +3,7 @@ ** ============================ ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/core/storage.h b/src/core/storage.h index 1613921..57cc20e 100644 --- a/src/core/storage.h +++ b/src/core/storage.h @@ -3,7 +3,7 @@ ** ============================ ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/core/svgiconengine.cpp b/src/core/svgiconengine.cpp index cee4e6c..1dd8ff8 100644 --- a/src/core/svgiconengine.cpp +++ b/src/core/svgiconengine.cpp @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/core/svgiconengine.h b/src/core/svgiconengine.h index 7eb9344..e1ddf82 100644 --- a/src/core/svgiconengine.h +++ b/src/core/svgiconengine.h @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/editor/doceditor.cpp b/src/editor/doceditor.cpp index 2fa7d38..2182afd 100644 --- a/src/editor/doceditor.cpp +++ b/src/editor/doceditor.cpp @@ -1,33 +1,51 @@ /* -Collett – GUI Document Editor Class -=================================== - -This file is a part of Collett -Copyright 2020–2021, Veronica Berglyd Olsen - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +** Collett – GUI Document Editor Class +** =================================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . */ +#include "collett.h" #include "doceditor.h" +#include "textedit.h" +#include "edittoolbar.h" #include -#include +#include +#include namespace Collett { GuiDocEditor::GuiDocEditor(QWidget *parent) - : QTextEdit(parent) -{} + : QWidget(parent) +{ + m_textArea = new GuiTextEdit(this); + m_editToolBar = new GuiEditToolBar(this); + connect(m_editToolBar, SIGNAL(documentAction(DocAction)), m_textArea, SLOT(applyDocAction(DocAction))); + + QVBoxLayout *outerBox = new QVBoxLayout; + outerBox->addWidget(m_editToolBar); + outerBox->addWidget(m_textArea); + outerBox->setContentsMargins(0, 0, 0, 0); + outerBox->setSpacing(0); + + this->setLayout(outerBox); + m_textArea->setHtml("Hello World"); + qDebug() << "QTextDocument:" << sizeof(m_textArea->document()); +} } // namespace Collett diff --git a/src/editor/doceditor.h b/src/editor/doceditor.h index 8b12e19..2d90830 100644 --- a/src/editor/doceditor.h +++ b/src/editor/doceditor.h @@ -1,42 +1,48 @@ /* -Collett – GUI Document Editor Class -=================================== - -This file is a part of Collett -Copyright 2020–2021, Veronica Berglyd Olsen - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +** Collett – GUI Document Editor Class +** =================================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . */ -#ifndef GUIDOCEDITOR_H -#define GUIDOCEDITOR_H +#ifndef GUI_DOCEDITOR_H +#define GUI_DOCEDITOR_H + +#include "textedit.h" +#include "edittoolbar.h" #include -#include +#include namespace Collett { -class GuiDocEditor : public QTextEdit +class GuiDocEditor : public QWidget { Q_OBJECT public: - GuiDocEditor(QWidget *parent=nullptr); ~GuiDocEditor() {}; +private: + GuiTextEdit *m_textArea; + GuiEditToolBar *m_editToolBar; + }; } // namespace Collett -#endif // GUIDOCEDITOR_H +#endif // GUI_DOCEDITOR_H diff --git a/src/editor/edittoolbar.cpp b/src/editor/edittoolbar.cpp new file mode 100644 index 0000000..e08755b --- /dev/null +++ b/src/editor/edittoolbar.cpp @@ -0,0 +1,76 @@ +/* +** Collett – GUI Editor Tool Bar Class +** =================================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#include "collett.h" +#include "edittoolbar.h" +#include "icons.h" + +#include +#include +#include +#include +#include + +namespace Collett { + +GuiEditToolBar::GuiEditToolBar(QWidget *parent) + : QToolBar(parent) +{ + CollettIcons *icons = CollettIcons::instance(); + + this->setIconSize(QSize(20, 20)); + + m_formatBold = this->addAction(icons->icon("bold"), tr("Bold")); + m_formatItalic = this->addAction(icons->icon("italic"), tr("Italic")); + m_formatUnderline = this->addAction(icons->icon("underline"), tr("Underline")); + m_formatStrikethrough = this->addAction(icons->icon("strikethrough"), tr("Strikethrough")); + + connect(m_formatBold, &QAction::triggered, [this]{emitDocumentAction(DocAction::FormatBold);}); + connect(m_formatItalic, &QAction::triggered, [this]{emitDocumentAction(DocAction::FormatItalic);}); + connect(m_formatUnderline, &QAction::triggered, [this]{emitDocumentAction(DocAction::FormatUnderline);}); + connect(m_formatStrikethrough, &QAction::triggered, [this]{emitDocumentAction(DocAction::FormatStrikethrough);}); + + this->addSeparator(); + + m_alignLeft = this->addAction(icons->icon("alignLeft"), tr("Align Left")); + m_alignCentre = this->addAction(icons->icon("alignCentre"), tr("Align Right")); + m_alignRight = this->addAction(icons->icon("alignRight"), tr("Align Centre")); + m_alignJustify = this->addAction(icons->icon("alignJustify"), tr("Align Justify")); + + connect(m_alignLeft, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextAlignLeft);}); + connect(m_alignCentre, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextAlignCentre);}); + connect(m_alignRight, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextAlignRight);}); + connect(m_alignJustify, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextAlignJustify);}); + + this->addSeparator(); + + m_blockIndent = this->addAction(icons->icon("blockIndent"), tr("Indent Paragraph")); + m_blockOutdent = this->addAction(icons->icon("blockOutdent"), tr("Outdent Paragraph")); + + connect(m_blockIndent, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextIndent);}); + connect(m_blockOutdent, &QAction::triggered, [this]{emitDocumentAction(DocAction::TextOutdent);}); +} + +void GuiEditToolBar::emitDocumentAction(DocAction action) { + emit documentAction(action); +} + +} // namespace Collett diff --git a/src/editor/edittoolbar.h b/src/editor/edittoolbar.h new file mode 100644 index 0000000..5c7d2cc --- /dev/null +++ b/src/editor/edittoolbar.h @@ -0,0 +1,64 @@ +/* +** Collett – GUI Editor Tool Bar Class +** =================================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#ifndef GUI_EDITTOOLBAR_H +#define GUI_EDITTOOLBAR_H + +#include "collett.h" + +#include +#include +#include + +namespace Collett { + +class GuiEditToolBar : public QToolBar +{ + Q_OBJECT + +public: + GuiEditToolBar(QWidget *parent=nullptr); + ~GuiEditToolBar() {}; + +signals: + void documentAction(DocAction action); + +private: + QAction *m_formatBold; + QAction *m_formatItalic; + QAction *m_formatUnderline; + QAction *m_formatStrikethrough; + + QAction *m_alignLeft; + QAction *m_alignCentre; + QAction *m_alignRight; + QAction *m_alignJustify; + + QAction *m_blockIndent; + QAction *m_blockOutdent; + +private slots: + void emitDocumentAction(DocAction action); + +}; +} // namespace Collett + +#endif // GUI_EDITTOOLBAR_H diff --git a/src/editor/textedit.cpp b/src/editor/textedit.cpp new file mode 100644 index 0000000..ebd6a03 --- /dev/null +++ b/src/editor/textedit.cpp @@ -0,0 +1,86 @@ +/* +** Collett – GUI Text Editor Class +** =============================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#include "collett.h" +#include "textedit.h" + +#include +#include +#include + +namespace Collett { + +GuiTextEdit::GuiTextEdit(QWidget *parent) + : QTextEdit(parent) +{} + +void GuiTextEdit::applyDocAction(DocAction action) { + + if (action == Collett::FormatBold) { + if (fontWeight() > QFont::Medium) { + setFontWeight(QFont::Normal); + } else { + setFontWeight(QFont::Bold); + } + + } else if (action == Collett::FormatItalic) { + setFontItalic(!fontItalic()); + + } else if (action == Collett::FormatUnderline) { + setFontUnderline(!fontUnderline()); + + } else if (action == Collett::FormatStrikethrough) { + QFont font = currentFont(); + font.setStrikeOut(!font.strikeOut()); + setCurrentFont(font); + + } else if (action == Collett::TextAlignLeft) { + setAlignment(Qt::AlignLeft); + + } else if (action == Collett::TextAlignCentre) { + setAlignment(Qt::AlignHCenter); + + } else if (action == Collett::TextAlignRight) { + setAlignment(Qt::AlignRight); + + } else if (action == Collett::TextAlignJustify) { + setAlignment(Qt::AlignJustify); + + } else if (action == Collett::TextIndent) { + // Indenting is only allowed on text paragraphs (no heading level) that + // are also aligned to the leading edge. + QTextCursor cursor = textCursor(); + QTextBlockFormat format = cursor.blockFormat(); + if (format.headingLevel() == 0 && format.alignment() == Qt::AlignLeading) { + format.setTextIndent(8.0); + cursor.setBlockFormat(format); + } + + } else if (action == Collett::TextOutdent) { + // Text outdent is always allowed as there is no need to restrict it. + QTextCursor cursor = textCursor(); + QTextBlockFormat format = cursor.blockFormat(); + format.setTextIndent(0.0); + cursor.setBlockFormat(format); + } +} + +} // namespace Collett diff --git a/src/editor/textedit.h b/src/editor/textedit.h new file mode 100644 index 0000000..302ebbd --- /dev/null +++ b/src/editor/textedit.h @@ -0,0 +1,47 @@ +/* +** Collett – GUI Text Editor Class +** =============================== +** +** This file is a part of Collett +** Copyright 2020–2022, Veronica Berglyd Olsen +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#ifndef GUI_TEXTEDIT_H +#define GUI_TEXTEDIT_H + +#include "collett.h" + +#include +#include +#include + +namespace Collett { + +class GuiTextEdit : public QTextEdit +{ + Q_OBJECT + +public: + GuiTextEdit(QWidget *parent=nullptr); + ~GuiTextEdit() {}; + +public slots: + void applyDocAction(DocAction action); + +}; +} // namespace Collett + +#endif // GUI_TEXTEDIT_H diff --git a/src/gui/maintoolbar.cpp b/src/gui/maintoolbar.cpp index acf59b1..2989a7d 100644 --- a/src/gui/maintoolbar.cpp +++ b/src/gui/maintoolbar.cpp @@ -3,7 +3,7 @@ ** ================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/maintoolbar.h b/src/gui/maintoolbar.h index 9d6fd03..40bdbd8 100644 --- a/src/gui/maintoolbar.h +++ b/src/gui/maintoolbar.h @@ -3,7 +3,7 @@ ** ================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 9b7e6da..4794ba7 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h index 07b6974..5edea5b 100644 --- a/src/gui/statusbar.h +++ b/src/gui/statusbar.h @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/storytree.cpp b/src/gui/storytree.cpp index 3c4becb..3cdae87 100644 --- a/src/gui/storytree.cpp +++ b/src/gui/storytree.cpp @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/storytree.h b/src/gui/storytree.h index c32268a..adebbe0 100644 --- a/src/gui/storytree.h +++ b/src/gui/storytree.h @@ -3,7 +3,7 @@ ** ============================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/storytreedelegate.cpp b/src/gui/storytreedelegate.cpp index 7fd26da..45fb73f 100644 --- a/src/gui/storytreedelegate.cpp +++ b/src/gui/storytreedelegate.cpp @@ -3,7 +3,7 @@ ** ======================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/storytreedelegate.h b/src/gui/storytreedelegate.h index d0ca4fe..a28fb8e 100644 --- a/src/gui/storytreedelegate.h +++ b/src/gui/storytreedelegate.h @@ -3,7 +3,7 @@ ** ======================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/treetoolbar.cpp b/src/gui/treetoolbar.cpp index 1540d49..c97da39 100644 --- a/src/gui/treetoolbar.cpp +++ b/src/gui/treetoolbar.cpp @@ -3,7 +3,7 @@ ** ================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/gui/treetoolbar.h b/src/gui/treetoolbar.h index dfffaa2..4310c2e 100644 --- a/src/gui/treetoolbar.h +++ b/src/gui/treetoolbar.h @@ -3,7 +3,7 @@ ** ================================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/guimain.cpp b/src/guimain.cpp index 5707de7..03d472d 100644 --- a/src/guimain.cpp +++ b/src/guimain.cpp @@ -3,7 +3,7 @@ ** ======================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -52,7 +52,7 @@ GuiMain::GuiMain(QWidget *parent) : QMainWindow(parent) { // Assemble Main Window m_splitMain = new QSplitter(Qt::Horizontal, this); - m_splitMain->setContentsMargins(4, 4, 4, 4); + m_splitMain->setContentsMargins(0, 0, 0, 0); m_splitMain->setOpaqueResize(false); m_splitMain->addWidget(m_storyTree); m_splitMain->addWidget(m_docEditor); diff --git a/src/guimain.h b/src/guimain.h index 814138f..4b95ab9 100644 --- a/src/guimain.h +++ b/src/guimain.h @@ -3,7 +3,7 @@ ** ======================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/main.cpp b/src/main.cpp index 9771cdb..7372233 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ ** ======================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/project.cpp b/src/project/project.cpp index 84e0012..50ef77b 100644 --- a/src/project/project.cpp +++ b/src/project/project.cpp @@ -3,7 +3,7 @@ ** ======================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/project.h b/src/project/project.h index 9bae56d..c9578d0 100644 --- a/src/project/project.h +++ b/src/project/project.h @@ -3,7 +3,7 @@ ** ======================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/storyitem.cpp b/src/project/storyitem.cpp index 7707fba..88b2d29 100644 --- a/src/project/storyitem.cpp +++ b/src/project/storyitem.cpp @@ -3,7 +3,7 @@ ** ================================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/storyitem.h b/src/project/storyitem.h index 4fa2cb6..8621b06 100644 --- a/src/project/storyitem.h +++ b/src/project/storyitem.h @@ -3,7 +3,7 @@ ** ================================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/storymodel.cpp b/src/project/storymodel.cpp index 6711d59..aa1a985 100644 --- a/src/project/storymodel.cpp +++ b/src/project/storymodel.cpp @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/project/storymodel.h b/src/project/storymodel.h index e485724..c6688f9 100644 --- a/src/project/storymodel.h +++ b/src/project/storymodel.h @@ -3,7 +3,7 @@ ** =================================== ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/settings.cpp b/src/settings.cpp index 717b1eb..78ee1ea 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/src/settings.h b/src/settings.h index 6f452d1..8918d24 100644 --- a/src/settings.h +++ b/src/settings.h @@ -3,7 +3,7 @@ ** ============================= ** ** This file is a part of Collett -** Copyright 2020–2021, Veronica Berglyd Olsen +** Copyright 2020–2022, Veronica Berglyd Olsen ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by