Compare commits
2 Commits
v3.0.1-rc1
...
v3.0.0-rc2
| Author | SHA1 | Date | |
|---|---|---|---|
| c4d74bb22b | |||
| f99ab4741b |
@@ -7,7 +7,7 @@ CONFIG += c++17
|
|||||||
win32:VERSION = 3.0.0.0 # major.minor.patch.build
|
win32:VERSION = 3.0.0.0 # major.minor.patch.build
|
||||||
else:VERSION = 3.0.0 # major.minor.patch
|
else:VERSION = 3.0.0 # major.minor.patch
|
||||||
|
|
||||||
DEFINES += APP_VERSION=\"\\\"$${VERSION}-rc1\\\"\"
|
DEFINES += APP_VERSION=\"\\\"$${VERSION}-rc2\\\"\"
|
||||||
DEFINES += APP_NAME=\"\\\"WorkPad\\\"\"
|
DEFINES += APP_NAME=\"\\\"WorkPad\\\"\"
|
||||||
|
|
||||||
# remove possible other optimization flags
|
# remove possible other optimization flags
|
||||||
@@ -111,4 +111,5 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
icons.qrc
|
icons.qrc \
|
||||||
|
static.qrc
|
||||||
|
|||||||
1105
resources/style.css
Normal file
1105
resources/style.css
Normal file
File diff suppressed because it is too large
Load Diff
@@ -19,5 +19,9 @@ int ExportDialog::getResult()
|
|||||||
{
|
{
|
||||||
return MARKDOWN;
|
return MARKDOWN;
|
||||||
}
|
}
|
||||||
|
else if (ui->pdfRadio->isChecked())
|
||||||
|
{
|
||||||
|
return PDF;
|
||||||
|
}
|
||||||
return PLAIN;
|
return PLAIN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define MARKDOWN 1
|
#define MARKDOWN 1
|
||||||
#define PLAIN 2
|
#define PLAIN 2
|
||||||
|
#define PDF 3
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ExportDialog;
|
class ExportDialog;
|
||||||
|
|||||||
@@ -35,10 +35,10 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QRadioButton" name="markdownButton">
|
<widget class="QRadioButton" name="markdownButton">
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
<y>60</y>
|
<y>40</y>
|
||||||
<width>92</width>
|
<width>92</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -70,6 +70,19 @@
|
|||||||
<string>Text file</string>
|
<string>Text file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QRadioButton" name="pdfRadio">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>60</y>
|
||||||
|
<width>92</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PDF file</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
@@ -7,14 +7,22 @@
|
|||||||
#include "renamedialog.h"
|
#include "renamedialog.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
updateViewThread = nullptr;
|
|
||||||
parser = std::make_shared<maddy::Parser>();
|
parser = std::make_shared<maddy::Parser>();
|
||||||
|
|
||||||
|
// open stylesheet resource
|
||||||
|
QFile f(":/css/resources/style.css");
|
||||||
|
f.open(QFile::OpenModeFlag::ReadOnly);
|
||||||
|
style = f.readAll();
|
||||||
|
f.close();
|
||||||
|
|
||||||
connect(ui->actionAdd_folder, &QAction::triggered, this, &MainWindow::createFolder);
|
connect(ui->actionAdd_folder, &QAction::triggered, this, &MainWindow::createFolder);
|
||||||
connect(ui->actionAdd, &QAction::triggered, this, &MainWindow::createNote);
|
connect(ui->actionAdd, &QAction::triggered, this, &MainWindow::createNote);
|
||||||
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::save);
|
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::save);
|
||||||
@@ -32,10 +40,39 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
this->cfgmng = new ConfigManager();
|
this->cfgmng = new ConfigManager();
|
||||||
updateListView();
|
updateListView();
|
||||||
connect(timer, &QTimer::timeout, this, &MainWindow::save);
|
connect(timer, &QTimer::timeout, this, &MainWindow::save);
|
||||||
|
|
||||||
|
// start render thread
|
||||||
|
threaddone = new bool(false);
|
||||||
|
queue = new QVector<QString>;
|
||||||
|
queueMutex = new QMutex();
|
||||||
|
updateViewThread = new std::thread([this](){
|
||||||
|
while (!*threaddone) {
|
||||||
|
queueMutex->lock();
|
||||||
|
if (queue->count() == 0) {
|
||||||
|
queueMutex->unlock();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString content = (*queue)[0];
|
||||||
|
queue->pop_front();
|
||||||
|
queueMutex->unlock();
|
||||||
|
std::stringstream markdownInput(content.toStdString());
|
||||||
|
QString htmlOutput = "<html><body class='markdown-body'>";
|
||||||
|
htmlOutput += QString::fromStdString(parser->Parse(markdownInput));
|
||||||
|
htmlOutput += "</body><style>" + style + "</style></html>";
|
||||||
|
emit updateViewers(htmlOutput);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
*threaddone = true;
|
||||||
|
updateViewThread->join();
|
||||||
|
delete queue;
|
||||||
|
delete queueMutex;
|
||||||
|
delete threaddone;
|
||||||
|
delete updateViewThread;
|
||||||
delete timer;
|
delete timer;
|
||||||
delete savemng;
|
delete savemng;
|
||||||
delete ui;
|
delete ui;
|
||||||
@@ -309,6 +346,10 @@ void MainWindow::exportNote()
|
|||||||
{
|
{
|
||||||
filter = "Markdown file (*.md)";
|
filter = "Markdown file (*.md)";
|
||||||
}
|
}
|
||||||
|
else if (fileType == PDF)
|
||||||
|
{
|
||||||
|
filter = "PDF file (*.pdf)";
|
||||||
|
}
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export note"), "", filter);
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Export note"), "", filter);
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -320,13 +361,27 @@ void MainWindow::exportNote()
|
|||||||
{
|
{
|
||||||
fileName += ".txt";
|
fileName += ".txt";
|
||||||
}
|
}
|
||||||
QFile *f = new QFile(fileName);
|
else if (fileType == PDF && !fileName.endsWith(".pdf", Qt::CaseInsensitive))
|
||||||
if (f->open(QIODevice::WriteOnly))
|
|
||||||
{
|
{
|
||||||
f->write(n->getContent().toUtf8());
|
fileName += ".pdf";
|
||||||
f->close();
|
|
||||||
}
|
}
|
||||||
delete f;
|
|
||||||
|
if (fileType == PDF)
|
||||||
|
{
|
||||||
|
ui->webEngineViewer->printToPdf(fileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QFile *f = new QFile(fileName);
|
||||||
|
if (f->open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
|
||||||
|
f->write(n->getContent().toUtf8());
|
||||||
|
f->close();
|
||||||
|
}
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,19 +468,12 @@ void MainWindow::updateListView()
|
|||||||
|
|
||||||
void MainWindow::updateHTMLView()
|
void MainWindow::updateHTMLView()
|
||||||
{
|
{
|
||||||
if (threadLock.tryLock()) {
|
queueMutex->lock();
|
||||||
updateViewThread = new std::thread([this](){
|
if (queue->count() > 4) {
|
||||||
QString content = ui->plainTextEdit->toPlainText();
|
queue->pop_front();
|
||||||
std::stringstream markdownInput(content.toStdString());
|
|
||||||
QString htmlOutput = QString::fromStdString(parser->Parse(markdownInput));
|
|
||||||
emit updateViewers(htmlOutput);
|
|
||||||
threadLock.unlock();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
QTimer::singleShot(200, [this]() {
|
|
||||||
updateHTMLView();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
queue->append(ui->plainTextEdit->toPlainText());
|
||||||
|
queueMutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearAndDisableFields()
|
void MainWindow::clearAndDisableFields()
|
||||||
|
|||||||
@@ -61,9 +61,15 @@ private:
|
|||||||
SaveManager *savemng;
|
SaveManager *savemng;
|
||||||
ConfigManager *cfgmng;
|
ConfigManager *cfgmng;
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
std::thread *updateViewThread;
|
|
||||||
std::shared_ptr<maddy::Parser> parser;
|
std::shared_ptr<maddy::Parser> parser;
|
||||||
QMutex threadLock;
|
|
||||||
|
QString style;
|
||||||
|
|
||||||
|
//shared between threads
|
||||||
|
QVector<QString>* queue;
|
||||||
|
QMutex* queueMutex;
|
||||||
|
bool* threaddone;
|
||||||
|
std::thread *updateViewThread;
|
||||||
|
|
||||||
void updateListView();
|
void updateListView();
|
||||||
void clearAndDisableFields();
|
void clearAndDisableFields();
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="contentEdit">
|
<widget class="QPlainTextEdit" name="contentEdit">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@@ -125,8 +125,8 @@
|
|||||||
<widget class="QWebEngineView" name="webEngineEditor" native="true">
|
<widget class="QWebEngineView" name="webEngineEditor" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>400</width>
|
||||||
<height>200</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
5
static.qrc
Normal file
5
static.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/css">
|
||||||
|
<file>resources/style.css</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
Reference in New Issue
Block a user