Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquetc committed Jan 21, 2023
2 parents 29d4e9a + 75f5957 commit 8a7e9e8
Show file tree
Hide file tree
Showing 35 changed files with 469 additions and 351 deletions.
6 changes: 6 additions & 0 deletions NEWS.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version: 2.0.4
Date: 2023-01-21
Type: stable
Description:
- "Fix crash when clicking on a list item when exporting a book"
---
Version: 2.0.3
Date: 2022-11-19
Type: stable
Expand Down
26 changes: 10 additions & 16 deletions eu.skribisto.skribisto.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
<description>
<p>Skribisto is geared toward helping anyone write anything, be it a novel or course notes. The user is free to use tags to define texts or write hundreds of notes. The tools are designed to be most unobstrusive, so you can write, write and write a bit more without too much distraction.</p>
</description>
<categories>
<category>Office</category>
</categories>
<launchable type="desktop-id">eu.skribisto.skribisto.desktop</launchable>
<url type="homepage">https://github.com/jacquetc/skribisto</url>
<url type="bugtracker">https://github.com/jacquetc/skribisto/issues</url>
<url type="faq">https://manual.skribisto.eu/faq/</url>
<url type="help">https://manual.skribisto.eu/manual/</url>
<url type="translate">https://github.com/jacquetc/skribisto#translation</url>
<url type="contact">https://github.com/jacquetc/skribisto#to-contact-me</url>
<launchable type="desktop-id">eu.skribisto.skribisto.desktop</launchable>
<categories>
<category>Office</category>
</categories>
<provides>
<mediatype>application/x-skribisto</mediatype>
<binary>SkribistoDesktop</binary>
</provides>
<screenshots>
<screenshot type="default">
<image type="source">https://raw.githubusercontent.com/jacquetc/skribisto/master/resources/skribisto_screenshot1.png</image>
Expand All @@ -28,21 +32,11 @@
</screenshot>
</screenshots>
<releases>
<release type="stable" version="2.0.3" date="2022-11-19T00:00:00Z">
<release type="stable" version="2.0.4" date="2023-01-21T00:00:00Z">
<description>
<ul>
<li>Fix path creation in theme creator dialog</li>
<li>Word count in Text view</li>
<li>Speed optimizations</li>
</ul>
<p>Fix crash when clicking on a list item when exporting a book</p>
</description>
</release>
</releases>
<mimetypes>
<mimetype>application/x-skribisto</mimetype>
</mimetypes>
<provides>
<binary>SkribistoDesktop</binary>
</provides>
<content_rating type="oars-1.1"/>
</component>
14 changes: 10 additions & 4 deletions src/desktopapp/export/bookexportwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ BookExportWizard::BookExportWizard(QWidget *parent, int projectId, bool enablePr
m_selectedBookId = item->data(Qt::UserRole).value<TreeItemAddress>();
this->fillChapterListWidget(m_selectedBookId);
});
connect(ui->bookListWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *item){
m_selectedBookId = item->data(Qt::UserRole).value<TreeItemAddress>();
connect(ui->bookListWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous){
if(!current){
return;
}
m_selectedBookId = current->data(Qt::UserRole).value<TreeItemAddress>();
this->fillChapterListWidget(m_selectedBookId);
});

Expand All @@ -135,8 +138,11 @@ BookExportWizard::BookExportWizard(QWidget *parent, int projectId, bool enablePr
connect(ui->chapterListWidget, &QListWidget::itemClicked, this, [this](QListWidgetItem *item){
m_selectedChapterId = item->data(Qt::UserRole).value<TreeItemAddress>();
});
connect(ui->chapterListWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *item){
m_selectedChapterId = item->data(Qt::UserRole).value<TreeItemAddress>();
connect(ui->chapterListWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous){
if(!current){
return;
}
m_selectedChapterId = current->data(Qt::UserRole).value<TreeItemAddress>();
});

if(ui->chapterListWidget->count() > 0){
Expand Down
5 changes: 0 additions & 5 deletions src/desktopapp/plugins/folderPage/folderpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ QVariantMap FolderPage::propertiesForCreationOfTreeItem(const QVariantMap &custo
{
return QVariantMap();
}
// ---------------------------------------------------

void FolderPage::updateCharAndWordCount(const TreeItemAddress &treeItemAddress, bool sameThread)
{
}

// ---------------------------------------------------
QTextDocumentFragment FolderPage::generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
Expand Down
2 changes: 0 additions & 2 deletions src/desktopapp/plugins/folderPage/folderpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class FolderPage : public QObject,

QVariantMap propertiesForCreationOfTreeItem(const QVariantMap &customProperties = QVariantMap()) const override;

void updateCharAndWordCount(const TreeItemAddress &treeItemAddress,
bool sameThread = false) override;

// exporter
QTextDocumentFragment generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
Expand Down
30 changes: 17 additions & 13 deletions src/desktopapp/plugins/overviewPage/outlineitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QTreeView>
#include <QHeaderView>
#include <skrdata.h>
#include <QVBoxLayout>

OutlineItemDelegate::OutlineItemDelegate(QObject *parent)
: QStyledItemDelegate{parent}
Expand All @@ -23,35 +24,27 @@ void OutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
// timer.start();
// qDebug() << "!" << timer.elapsed();


//QString content = skrdata->treeHub()->getSecondaryContent(projectId, treeItemId);
// qDebug() << "(!)(" << timer.elapsed();
QString content = index.data(ProjectTreeItem::SecondaryContentRole).toString();
// qDebug() << "(!)((" << timer.elapsed();

if(content.isEmpty()){
return QStyledItemDelegate::paint(painter, option, index);
}
// qDebug() << "a" << timer.elapsed();

MarkdownTextDocument document;
document.setSkribistoMarkdown(content);
// qDebug() << "b" <<timer.elapsed();


TextEdit textEdit;
textEdit.setDocument(&document);
// qDebug() << "bb" <<timer.elapsed();
textEdit.document()->setDocumentMargin(0);
textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textEdit.setFrameShape(QFrame::Shape::NoFrame);
textEdit.setFrameShadow(QFrame::Shadow::Plain);
textEdit.setLineWidth(0);
//initStyleOption(&option, index);

// qDebug() << "c" <<timer.elapsed();

painter->save();
//qDebug() << option.rect;

option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
textEdit.setGeometry(option.rect);
Expand All @@ -60,7 +53,6 @@ void OutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
painter->restore();
//QStyledItemDelegate::paint(painter, option, index);

// qDebug() << "d" <<timer.elapsed();


}
Expand Down Expand Up @@ -100,8 +92,8 @@ QSize OutlineItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QM

QWidget *OutlineItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
TextEdit *textEdit = new TextEdit(parent);

TextEdit *textEdit = new TextEdit(parent);
//textEdit->document()->setDocumentMargin(0);
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textEdit->setFrameShape(QFrame::Shape::NoFrame);
Expand All @@ -110,6 +102,8 @@ QWidget *OutlineItemDelegate::createEditor(QWidget *parent, const QStyleOptionVi
textEdit->setFocusPolicy(Qt::FocusPolicy::StrongFocus);
textEdit->setParent(parent);



return textEdit;
}

Expand Down Expand Up @@ -137,6 +131,17 @@ void OutlineItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde
QTextCursor textCursor = textEdit->textCursor();
textCursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(textCursor);



QSettings settings;

// spellchecker :
int projectId = index.data(ProjectTreeItem::ProjectIdRole).toInt();
textEdit->setProjectId(projectId);
textEdit->setupHighlighter();
textEdit->setSpellcheckerEnabled(settings.value("common/spellChecker", true).toBool());

}

//---------------------------------------------------------------------------
Expand All @@ -157,7 +162,6 @@ void OutlineItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *mode
textEditor->uuid(),
document);


emit editFinished(index);
}

Expand Down Expand Up @@ -192,6 +196,6 @@ bool OutlineItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,

void OutlineItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{

//qDebug() << "updateEditorGeometry";
editor->setGeometry(option.rect);
}
19 changes: 19 additions & 0 deletions src/desktopapp/plugins/overviewPage/overviewview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "outlineitemdelegate.h"
#include "ui_overviewview.h"
#include "viewmanager.h"
#include "thememanager.h"

#include <QKeyEvent>
#include <QMenu>
Expand Down Expand Up @@ -35,9 +36,27 @@ OverviewView::OverviewView(QWidget *parent) :

centralWidgetUi->treeView->setModel(m_overviewProxyModel);

centralWidgetUi->treeView->setStyleSheet(R"""(QTreeView::item {
border: 1px solid #d9d9d9;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
})""");

connect(themeManager, &ThemeManager::currentThemeTypeChanged, this, [this](){

centralWidgetUi->treeView->setStyleSheet(R"""(QTreeView::item {
border: 1px solid #d9d9d9;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
})""");
});

OutlineItemDelegate *outlineItemDelegate = new OutlineItemDelegate(centralWidgetUi->treeView);
centralWidgetUi->treeView->setItemDelegateForColumn(1, outlineItemDelegate);


connect(outlineItemDelegate, &OutlineItemDelegate::editFinished, this, [this](const QModelIndex &index){
centralWidgetUi->treeView->dataChanged(index, index, QList<int>() << Qt::ItemDataRole::SizeHintRole);
});
Expand Down
8 changes: 8 additions & 0 deletions src/desktopapp/plugins/overviewPage/overviewview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@
</property>
<item>
<widget class="QTreeView" name="treeView">
<property name="font">
<font>
<family>.AppleSystemUIFont</family>
</font>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
Expand Down
5 changes: 0 additions & 5 deletions src/desktopapp/plugins/projectPage/projectpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ QVariantMap ProjectPage::propertiesForCreationOfTreeItem(const QVariantMap &cust
return QVariantMap();
}

// ---------------------------------------------------

void ProjectPage::updateCharAndWordCount(const TreeItemAddress &treeItemAddress, bool sameThread)
{}

// ---------------------------------------------------
QTextDocumentFragment ProjectPage::generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
const QVariantMap& exportProperties,
Expand Down
3 changes: 0 additions & 3 deletions src/desktopapp/plugins/projectPage/projectpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ class ProjectPage : public QObject,

QVariantMap propertiesForCreationOfTreeItem(const QVariantMap &customProperties = QVariantMap()) const override;

void updateCharAndWordCount(const TreeItemAddress &treeItemAddress,
bool sameThread = false) override;

// exporter
QTextDocumentFragment
generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
Expand Down
5 changes: 0 additions & 5 deletions src/desktopapp/plugins/sectionPage/sectionpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ QVariantMap SectionPage::propertiesForCreationOfTreeItem(const QVariantMap &cust
return properties;
}

// ---------------------------------------------------

void SectionPage::updateCharAndWordCount(const TreeItemAddress &treeItemAddress, bool sameThread)
{}

// ---------------------------------------------------
QTextDocumentFragment SectionPage::generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
const QVariantMap& exportProperties,
Expand Down
2 changes: 0 additions & 2 deletions src/desktopapp/plugins/sectionPage/sectionpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class SectionPage : public QObject,

QVariantMap propertiesForCreationOfTreeItem(const QVariantMap &customProperties = QVariantMap()) const override;

void updateCharAndWordCount(const TreeItemAddress &treeItemAddress,
bool sameThread = false) override;

// exporter
QTextDocumentFragment generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
Expand Down
25 changes: 18 additions & 7 deletions src/desktopapp/plugins/textPage/textpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ TextPage::TextPage(QObject *parent) : QObject(parent)
{
m_wordMeter = new SKRWordMeter(this);

connect(m_wordMeter, &SKRWordMeter::characterCountCalculated, skrdata->statHub(),
&SKRStatHub::updateCharacterStats);
connect(m_wordMeter, &SKRWordMeter::characterCountCalculated, this , [](const TreeItemAddress &treeItemAddress,
int charCount,
bool triggerProjectModifiedSignal){
skrdata->statHub()->updateStats(treeItemAddress, SKRStatHub::Character ,charCount, triggerProjectModifiedSignal);
});

connect(m_wordMeter,
&SKRWordMeter::wordCountCalculated,
skrdata->statHub(),
&SKRStatHub::updateWordStats);
&SKRWordMeter::wordCountCalculated, this , [](const TreeItemAddress &treeItemAddress,
int wordCount,
bool triggerProjectModifiedSignal){
skrdata->statHub()->updateStats(treeItemAddress, SKRStatHub::Word ,wordCount, triggerProjectModifiedSignal);
});
}

// ---------------------------------------------------
Expand Down Expand Up @@ -64,11 +70,16 @@ QVariantMap TextPage::propertiesForCreationOfTreeItem(const QVariantMap &customP
}
// ---------------------------------------------------

void TextPage::updateCharAndWordCount(const TreeItemAddress &treeItemAddress, bool sameThread)
void TextPage::updateCharAndWordCount(const TreeItemAddress &treeItemAddress, bool sameThread, bool triggerProjectModifiedSignal)
{
const QString &primaryContent = skrdata->treeHub()->getPrimaryContent(treeItemAddress);

m_wordMeter->countText(treeItemAddress, std::move(primaryContent), sameThread, false);
MarkdownTextDocument textDocument;

textDocument.setSkribistoMarkdown(primaryContent);
const QString &plainText = textDocument.toPlainText();

m_wordMeter->countText(treeItemAddress, std::move(plainText), sameThread, triggerProjectModifiedSignal);
}

// ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/desktopapp/plugins/textPage/textpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TextPage : public QObject,
QVariantMap propertiesForCreationOfTreeItem(const QVariantMap &customProperties = QVariantMap()) const override;

void updateCharAndWordCount(const TreeItemAddress &treeItemAddress,
bool sameThread = false) override;
bool sameThread = false, bool triggerProjectModifiedSignal = true) override;

// exporter
QTextDocumentFragment generateExporterTextFragment(const TreeItemAddress &treeItemAddress,
Expand Down
Loading

0 comments on commit 8a7e9e8

Please sign in to comment.