Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquetc committed Nov 16, 2022
2 parents 0ad1c33 + 4769838 commit 74d9d01
Show file tree
Hide file tree
Showing 30 changed files with 601 additions and 73 deletions.
7 changes: 7 additions & 0 deletions NEWS.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version: 2.0.2
Date: 2022-11-17
Type: stable
Description:
- "Add spellchecking suggestions"
- "Add quick note creation"
---
Version: 2.0.1
Date: 2022-11-15
Type: stable
Expand Down
7 changes: 5 additions & 2 deletions eu.skribisto.skribisto.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
</screenshot>
</screenshots>
<releases>
<release type="stable" version="2.0.1" date="2022-11-15T00:00:00Z">
<release type="stable" version="2.0.2" date="2022-11-17T00:00:00Z">
<description>
<p>Fix Theme creation dialog</p>
<ul>
<li>Add spellchecking suggestions</li>
<li>Add quick note creation</li>
</ul>
</description>
</release>
</releases>
Expand Down
11 changes: 11 additions & 0 deletions src/desktopapp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "backupmanager.h"
#include "commands.h"
#include "desktopapplication.h"
#include "dictcommands.h"
#include "interfaces/newprojectformatinterface.h"
#include "interfaces/pagetypeiconinterface.h"
#include "projectcommands.h"
Expand Down Expand Up @@ -84,8 +85,10 @@ int main(int argc, char *argv[]) {
new ProjectTreeModel(skrData);
new Commands(skrData, undoStack);
new ProjectCommands(skrData, undoStack);
commands->subscribe(projectCommands);
new ProjectTreeCommands(skrData, undoStack, projectTreeModel);
new TagCommands(skrData, undoStack);
new DictCommands(skrData, undoStack);
new BackupManager(skrData);
QObject::connect(&app, &DesktopApplication::settingsChanged, backupManager, &BackupManager::settingsChanged);

Expand All @@ -96,6 +99,14 @@ int main(int argc, char *argv[]) {

QMainWindow *window = windowManager->restoreWindows();

if(!args.empty() && QUrl::fromLocalFile(args.first()).isValid()){
QFileInfo fileInfo(args.first());
if(fileInfo.exists() && fileInfo.isReadable()){
projectCommands->loadProject(QUrl::fromLocalFile(args.first()));
}

}


if (parser.isSet("testProject")) {
projectCommands->loadProject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void OutlineItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde
int treeItemId = index.data(ProjectTreeItem::TreeItemIdRole).toInt();

TextEdit * textEdit = qobject_cast<TextEdit*>(editor);
textEdit->setProjectId(projectId);

MarkdownTextDocument *document = new MarkdownTextDocument(editor);
document->setSkribistoMarkdown(index.data(ProjectTreeItem::SecondaryContentRole).toString());
Expand Down
13 changes: 5 additions & 8 deletions src/desktopapp/plugins/textPage/textview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ QList<Toolbox *> TextView::toolboxes()

void TextView::initialize()
{
centralWidgetUi->textEdit->setProjectId(this->projectId());

MarkdownTextDocument *document = new MarkdownTextDocument(this);

m_isSecondaryContent = parameters().value("is_secondary_content", false).toBool();
Expand Down Expand Up @@ -192,13 +194,8 @@ void TextView::initialize()
QSettings settings;

// spellchecker :

m_highlighter = new Highlighter(document);
m_highlighter->setProjectId(this->projectId());
m_highlighter->getSpellChecker()->setLangCode(skrdata->projectHub()->getLangCode(this->projectId()));
m_highlighter->setSpellCheckHighlightColor("#FF0000");
m_highlighter->getSpellChecker()->activate(settings.value("common/spellChecker", true).toBool());

centralWidgetUi->textEdit->setupHighlighter();
centralWidgetUi->textEdit->setSpellcheckerEnabled(settings.value("common/spellChecker", true).toBool());

// restore font size and family:

Expand Down Expand Up @@ -419,7 +416,7 @@ void TextView::settingsChanged(const QHash<QString, QVariant> &newSettings)
}

if(newSettings.contains("common/spellChecker")){
m_highlighter->getSpellChecker()->activate(newSettings.value("common/spellChecker").toBool());
centralWidgetUi->textEdit->setSpellcheckerEnabled(newSettings.value("common/spellChecker").toBool());
}


Expand Down
1 change: 0 additions & 1 deletion src/desktopapp/plugins/textPage/textview.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public slots:
QMetaObject::Connection m_saveConnection;
QTimer *m_saveTimer, *m_historyTimer;
bool m_wasModified;
Highlighter *m_highlighter;
int m_oldCursorPosition;

void saveTextState();
Expand Down
12 changes: 11 additions & 1 deletion src/desktopapp/themewizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
ui->typeComboBox->addItem(tr("Light"), "light");
ui->typeComboBox->addItem(tr("Dark"), "dark");

this->setButtonText(WizardButton::FinishButton, tr("Save"));


resetThemeList();
themeManager->scanChildrenAndAddWidgetsHoldingIcons(this);


QTimer::singleShot(0, this, [this](){
this->button(QWizard::NextButton)->setEnabled(false);
});

connect(ui->themeTreeWidget, &QTreeWidget::currentItemChanged, this, [this](QTreeWidgetItem *current, QTreeWidgetItem *previous){
if(!current->data(0, Qt::UserRole).toString().isEmpty()){
m_selectedTheme = current->text(0);
Expand All @@ -35,7 +42,7 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
ui->duplicateAndModifyRadioButton->setChecked(!isEditable);

if(ui->duplicateAndModifyRadioButton->isChecked()){
ui->nameLineEdit->setText(m_selectedTheme + " " + tr("(Copy)"));
ui->nameLineEdit->setText(tr("%1 (Copy)").arg(m_selectedTheme));
}
else{
ui->nameLineEdit->setText(m_selectedTheme);
Expand Down Expand Up @@ -68,6 +75,9 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
QTimer::singleShot(0, this, [this](){
ui->comboBoxExample_2->shakePalette();
});

this->button(QWizard::NextButton)->setEnabled(true );

}

});
Expand Down
2 changes: 1 addition & 1 deletion src/desktopapp/themewizard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<enum>QWizard::ModernStyle</enum>
</property>
<property name="options">
<set>QWizard::NoCancelButton|QWizard::NoDefaultButton</set>
<set>QWizard::NoDefaultButton</set>
</property>
<widget class="QWizardPage" name="wizardPage1">
<property name="title">
Expand Down
1 change: 1 addition & 0 deletions src/libskribisto-backend/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(backend_SRCS
text/highlighter.h text/highlighter.cpp
text/spellchecker.h text/spellchecker.cpp
backupmanager.h backupmanager.cpp
dictcommands.h dictcommands.cpp
)

set(backend_MODELS
Expand Down
4 changes: 2 additions & 2 deletions src/libskribisto-backend/src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ return m_undoStack;

}

void Commands::subscribe(InvokableCommandGroupInterface &object)
void Commands::subscribe(InvokableCommandGroupInterface *object)
{

m_addressWithObjectHash.insert(object.address() , &object);
m_addressWithObjectHash.insert(object->address() , object);
}

void Commands::invoke(const QString &address, const QString &action, const QVariantMap &parameters)
Expand Down
2 changes: 1 addition & 1 deletion src/libskribisto-backend/src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SKRBACKENDEXPORT Commands : public QObject
}
QUndoStack *undoStack() const;

void subscribe(InvokableCommandGroupInterface &object);
void subscribe(InvokableCommandGroupInterface *object);

void invoke(const QString &address, const QString &action, const QVariantMap &parameters);

Expand Down
64 changes: 64 additions & 0 deletions src/libskribisto-backend/src/dictcommands.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "dictcommands.h"
#include "commands.h"
#include "skrdata.h"

DictCommands::DictCommands(QObject *parent, QUndoStack *undoStack)
: QObject{parent}, m_undoStack(undoStack)
{
m_instance = this;
commands->subscribe(this);
}
// ----------------------------------------------------------------------------


DictCommands *DictCommands::m_instance = nullptr;


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



QUndoStack *DictCommands::undoStack() const
{
return m_undoStack;
}

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


void DictCommands::addWordToProjectDict(int projectId, const QString &word)
{
m_undoStack->push(new AddWordToProjectDictCommand(projectId, word));

}

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



Command *DictCommands::getCommand(const QString &action, const QVariantMap &parameters)
{
//TODO: fill
}


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

AddWordToProjectDictCommand::AddWordToProjectDictCommand(int projectId, const QString &word) : Command("Add word to project dictionary"),
m_projectId(projectId), m_word(word)
{

}

void AddWordToProjectDictCommand::undo()
{
skrdata->projectDictHub()->removeWordFromProjectDict(m_projectId, m_word);
}

void AddWordToProjectDictCommand::redo()
{
skrdata->projectDictHub()->addWordToProjectDict(m_projectId, m_word);
}
54 changes: 54 additions & 0 deletions src/libskribisto-backend/src/dictcommands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef DICTCOMMANDS_H
#define DICTCOMMANDS_H

#include <QObject>
#include <QUndoCommand>
#include "skribisto_backend_global.h"
#include "interfaces/invokablecommandgroupinterface.h"

#define dictCommands DictCommands::instance()

class SKRBACKENDEXPORT DictCommands : public QObject, public InvokableCommandGroupInterface
{
Q_OBJECT
public:
explicit DictCommands(QObject *parent, QUndoStack *undoStack);

static DictCommands* instance()
{
return m_instance;
}
QUndoStack *undoStack() const;
void addWordToProjectDict(int projectId, const QString &word);

signals:
private:
static DictCommands *m_instance;
QUndoStack *m_undoStack;

// InvokableCommandGroupInterface interface
public:
Command *getCommand(const QString &action, const QVariantMap &parameters) override;
QString address() const override
{
return "dict";
}

};


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

class AddWordToProjectDictCommand : public Command
{
public:
AddWordToProjectDictCommand(int projectId, const QString &word);
void undo();
void redo();
private:
QString m_word;
int m_projectId;
};

#endif // DICTCOMMANDS_H
2 changes: 2 additions & 0 deletions src/libskribisto-backend/src/projectcommands.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "projectcommands.h"
#include "commands.h"
#include "skrdata.h"
#include "project/plmprojectmanager.h"
#include "project/plmproject.h"
Expand All @@ -9,6 +10,7 @@ ProjectCommands::ProjectCommands(QObject *parent, QUndoStack *undoStack)
: QObject{parent}, m_undoStack(undoStack)
{
m_instance = this;
commands->subscribe(this);

Exporter::init();
Importer::init();
Expand Down
3 changes: 0 additions & 3 deletions src/libskribisto-backend/src/projectcommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class SKRBACKENDEXPORT ProjectCommands : public QObject, public InvokableCommand
{
return "project";
}

// InvokableCommandGroupInterface interface
public:
Command *getCommand(const QString &action, const QVariantMap &parameters) override;
};

Expand Down
45 changes: 45 additions & 0 deletions src/libskribisto-backend/src/projecttreecommands.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "projecttreecommands.h"
#include "commands.h"
#include "interfaces/newprojecttemplateinterface.h"
#include "interfaces/pageinterface.h"

ProjectTreeCommands::ProjectTreeCommands(QObject *parent, QUndoStack *undoStack, ProjectTreeModel *treeModel)
: QObject{parent}, m_undoStack(undoStack), m_treeModel(treeModel)
{
m_instance = this;
commands->subscribe(this);
skrpluginhub->addPluginType<NewProjectTemplateInterface>();

}
Expand Down Expand Up @@ -213,6 +215,40 @@ void ProjectTreeCommands::moveItemsAsChildOf(int sourceProjectId, QList<int> sou

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


int ProjectTreeCommands::addNote(int projectId, const QString &name, int targetFolderId)
{
m_undoStack->beginMacro("Add note");

int noteFolder = -1;
if(targetFolderId == -1){
QList<int> folders = skrdata->treeHub()->getIdsWithInternalTitle(projectId, "note_folder");

if(folders.isEmpty()){
noteFolder = this->addSubItem(projectId, 0, "FOLDER", tr("Notes"));
}
else {
noteFolder = folders.first();
}


}
else {
noteFolder = targetFolderId;
}


int newId = this->addSubItem(projectId, noteFolder, "TEXT", name);



m_undoStack->endMacro();

return newId;
}

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

void ProjectTreeCommands::sendItemToTrash(int projectId, int targetId)
{
m_undoStack->push(new TrashItemCommand(projectId, targetId, true));
Expand Down Expand Up @@ -358,3 +394,12 @@ QUndoStack *ProjectTreeCommands::undoStack() const
{
return m_undoStack;
}

Command *ProjectTreeCommands::getCommand(const QString &action, const QVariantMap &parameters)
{
if(action == "rename"){
return new RenameItemCommand(parameters.value("projectId").toInt(), parameters.value("treeItemId").toInt(), parameters.value("name").toString());
}
return nullptr;

}
Loading

0 comments on commit 74d9d01

Please sign in to comment.