Commit 54f35d69 authored by Nikita Sirgienko's avatar Nikita Sirgienko
Browse files

[GSoC 2020] Realisation of T12844

Added new type of entries - Hierarchy Entry. This type of entry used for creating structure of worksheet.
The entry type also support some additiona stuff - like hiding all subentries and custom style for each level of structure deapth in Settings.
Also have been added new Panel Plugin - Table of Content plugin, which show hierarchy structure and allow to move over it
parent 2459ea59
Pipeline #30639 passed with stage
in 20 minutes and 19 seconds
......@@ -31,6 +31,7 @@ set(cantor_SRCS
install(FILES cantor.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
ki18n_wrap_ui(cantor_SRCS settings.ui)
ki18n_wrap_ui(cantor_SRCS formating.ui)
ki18n_wrap_ui(cantor_SRCS backendchooser.ui)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/*-apps-cantor.png")
......@@ -65,6 +66,7 @@ set(cantor_PART_SRCS
latexentry.cpp
placeholderentry.cpp
horizontalruleentry.cpp
hierarchyentry.cpp
worksheetcursor.cpp
searchbar.cpp
actionbar.cpp
......
......@@ -49,6 +49,7 @@
#include "settings.h"
#include "ui_settings.h"
#include "ui_formating.h"
#include "backendchoosedialog.h"
#include <QMetaObject>
......@@ -366,6 +367,11 @@ void CantorShell::addWorksheet(const QString& backendName)
connect(part, SIGNAL(setCaption(QString,QIcon)), this, SLOT(setTabCaption(QString,QIcon)));
connect(part, SIGNAL(worksheetSave(QUrl)), this, SLOT(onWorksheetSave(QUrl)));
connect(part, SIGNAL(showHelp(QString)), this, SIGNAL(showHelp(QString)));
connect(part, SIGNAL(hierarchyChanged(QStringList, QStringList, QList<int>)), this, SIGNAL(hierarchyChanged(QStringList, QStringList, QList<int>)));
connect(part, SIGNAL(hierarhyEntryNameChange(QString, QString, int)), this, SIGNAL(hierarhyEntryNameChange(QString, QString, int)));
connect(this, SIGNAL(requestScrollToHierarchyEntry(QString)), part, SIGNAL(requestScrollToHierarchyEntry(QString)));
connect(this, SIGNAL(settingsChanges()), part, SIGNAL(settingsChanges()));
m_parts.append(part);
if (backend) // If backend empty (loading worksheet from file), then we connect to signal and wait
m_parts2Backends[part] = backend->id();
......@@ -583,12 +589,19 @@ void CantorShell::closeEvent(QCloseEvent* event) {
void CantorShell::showSettings()
{
KConfigDialog *dialog = new KConfigDialog(this, QLatin1String("settings"), Settings::self());
QWidget *generalSettings = new QWidget;
Ui::SettingsBase base;
base.setupUi(generalSettings);
QWidget *formattingSettings = new QWidget;
Ui::SettingsFormatting formatting;
formatting.setupUi(formattingSettings);
base.kcfg_DefaultBackend->addItems(Cantor::Backend::listAvailableBackends());
dialog->addPage(generalSettings, i18n("General"), QLatin1String("preferences-other"));
dialog->addPage(formattingSettings, i18n("Formatting"), QLatin1String("preferences-other"));
for (auto* backend : Cantor::Backend::availableBackends())
{
if (backend->config()) //It has something to configure, so add it to the dialog
......@@ -596,6 +609,7 @@ void CantorShell::showSettings()
}
dialog->show();
connect(dialog, &KConfigDialog::settingsChanged, this, &CantorShell::settingsChanges);
}
void CantorShell::downloadExamples()
......
......@@ -80,6 +80,10 @@ protected:
Q_SIGNALS:
void showHelp(QString);
void hierarchyChanged(QStringList, QStringList, QList<int>);
void hierarhyEntryNameChange(QString, QString, int);
void requestScrollToHierarchyEntry(QString);
void settingsChanges();
public Q_SLOTS:
void addWorksheet(const QString& backendName);
......
......@@ -6,6 +6,7 @@
<include>cantor_export.h</include>
<include>config-cantor.h</include>
<include>QUrl</include>
<include>QApplication</include>
<kcfgfile/>
<group name="Cantor">
<entry name="DefaultBackend" type="String">
......@@ -64,6 +65,102 @@
<label>Path to directory, which contains Cantor plugins (cantorpart and all backends)</label>
<default code="true">QUrl::fromLocalFile(QString::fromLocal8Bit(PATH_TO_CANTOR_PLUGINS))</default>
</entry>
<entry name="ChapterFontFamily" type="Font">
<label>Hierarchy font for chapter</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="ChapterFontSize" type="Int">
<label>Hierarchy font size for chapter</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="ChapterFontItalic" type="Bool">
<label>Hierarchy font italic for chapter</label>
<default>false</default>
</entry>
<entry name="ChapterFontBold" type="Bool">
<label>Hierarchy font bold for chapter</label>
<default>false</default>
</entry>
<entry name="SubchapterFontFamily" type="Font">
<label>Hierarchy font for subchapter</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="SubchapterFontSize" type="Int">
<label>Hierarchy font size for subchapter</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="SubchapterFontItalic" type="Bool">
<label>Hierarchy font italic for subchapter</label>
<default>false</default>
</entry>
<entry name="SubchapterFontBold" type="Bool">
<label>Hierarchy font bold for subchapter</label>
<default>false</default>
</entry>
<entry name="SectionFontFamily" type="Font">
<label>Hierarchy font for section</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="SectionFontSize" type="Int">
<label>Hierarchy font for section</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="SectionFontItalic" type="Bool">
<label>Hierarchy font italic for section</label>
<default>false</default>
</entry>
<entry name="SectionFontBold" type="Bool">
<label>Hierarchy font bold for section</label>
<default>false</default>
</entry>
<entry name="SubsectionFontFamily" type="Font">
<label>Hierarchy font for subsection</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="SubsectionFontSize" type="Int">
<label>Hierarchy font for subsection</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="SubsectionFontItalic" type="Bool">
<label>Hierarchy font italic for subsection</label>
<default>false</default>
</entry>
<entry name="SubsectionFontBold" type="Bool">
<label>Hierarchy font bold for subsection</label>
<default>false</default>
</entry>
<entry name="ParagraphFontFamily" type="Font">
<label>Hierarchy font for paragraph</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="ParagraphFontSize" type="Int">
<label>Hierarchy font for paragraph</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="ParagraphFontItalic" type="Bool">
<label>Hierarchy font italic for paragraph</label>
<default>false</default>
</entry>
<entry name="ParagraphFontBold" type="Bool">
<label>Hierarchy font bold for paragraph</label>
<default>false</default>
</entry>
<entry name="SubparagraphFontFamily" type="Font">
<label>Hierarchy font for subparagraph</label>
<default code="true">QApplication::font()</default>
</entry>
<entry name="SubparagraphFontSize" type="Int">
<label>Hierarchy font for subparagraph</label>
<default code="true">QApplication::font().pointSize()</default>
</entry>
<entry name="SubparagraphFontItalic" type="Bool">
<label>Hierarchy font italic for subparagraph</label>
<default>false</default>
</entry>
<entry name="SubparagraphFontBold" type="Bool">
<label>Hierarchy font bold for subparagraph</label>
<default>false</default>
</entry>
</group>
</kcfg>
......@@ -146,6 +146,10 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
connect(m_worksheet, &Worksheet::modified, this, static_cast<void (KParts::ReadWritePart::*)()>(&KParts::ReadWritePart::setModified));
connect(m_worksheet, &Worksheet::showHelp, this, &CantorPart::showHelp);
connect(m_worksheet, &Worksheet::loaded, this, &CantorPart::initialized);
connect(m_worksheet, &Worksheet::hierarchyChanged, this, &CantorPart::hierarchyChanged);
connect(m_worksheet, &Worksheet::hierarhyEntryNameChange, this, &CantorPart::hierarhyEntryNameChange);
connect(this, &CantorPart::requestScrollToHierarchyEntry, m_worksheet, &Worksheet::requestScrollToHierarchyEntry);
connect(this, &CantorPart::settingsChanges, m_worksheet, &Worksheet::handleSettingsChanges);
layout->addWidget(m_worksheetview);
setWidget(widget);
......
......@@ -83,8 +83,12 @@ public:
Q_SIGNALS:
void setCaption(const QString& caption, const QIcon& icon);
void showHelp(const QString& help);
void hierarchyChanged(QStringList, QStringList, QList<int>);
void hierarhyEntryNameChange(QString name, QString searchName, int depth);
void worksheetSave(const QUrl& url);
void setBackendName(const QString& name);
void requestScrollToHierarchyEntry(QString);
void settingsChanges();
public Q_SLOTS:
void updateCaption();
......
......@@ -50,7 +50,6 @@
const QString CommandEntry::Prompt = QLatin1String(">>> ");
const QString CommandEntry::MidPrompt = QLatin1String(">> ");
const QString CommandEntry::HidePrompt = QLatin1String("> ");
const double CommandEntry::HorizontalSpacing = 4;
const double CommandEntry::VerticalSpacing = 4;
......
......@@ -167,7 +167,6 @@ class CommandEntry : public WorksheetEntry
private:
static const double HorizontalSpacing;
static const double VerticalSpacing;
WorksheetTextItem* m_promptItem;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsFormatting</class>
<widget class="QWidget" name="SettingsFormatting">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>511</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Hierarchy Fonts</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="ChapterTab">
<attribute name="title">
<string>Chapter Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_ChapterFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_ChapterFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ChapterFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ChapterFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="SubchapterTab">
<attribute name="title">
<string>Subchapter Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_SubchapterFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_SubchapterFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubchapterFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubchapterFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="SectionTab">
<attribute name="title">
<string>Section Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_SectionFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_SectionFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SectionFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SectionFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="SubsectionTab">
<attribute name="title">
<string>Subsection Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_SubsectionFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_SubsectionFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubsectionFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubsectionFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="ParagraphTab">
<attribute name="title">
<string>Paragraph Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_ParagraphFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_ParagraphFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ParagraphFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ParagraphFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="SubparagraphTab">
<attribute name="title">
<string>Subparagraph Font</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Font Family:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="kcfg_SubparagraphFontFamily"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_SubparagraphFontSize">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubparagraphFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_SubparagraphFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>