mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
speed up start
This commit is contained in:
parent
d683afa271
commit
d917c942d9
@ -223,13 +223,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
w.checkNotebooks();
|
w.kickOffStartUpTimer(filePaths);
|
||||||
|
|
||||||
w.promptNewNotebookIfEmpty();
|
|
||||||
|
|
||||||
w.openStartupPages();
|
|
||||||
|
|
||||||
w.openFiles(filePaths);
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ bool VEditArea::handleKeyNavigation(int p_key, bool &p_succeed)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VEditArea::openFiles(const QVector<VFileSessionInfo> &p_files)
|
int VEditArea::openFiles(const QVector<VFileSessionInfo> &p_files, bool p_oneByOne)
|
||||||
{
|
{
|
||||||
VFile *curFile = NULL;
|
VFile *curFile = NULL;
|
||||||
int nrOpened = 0;
|
int nrOpened = 0;
|
||||||
@ -838,6 +838,10 @@ int VEditArea::openFiles(const QVector<VFileSessionInfo> &p_files)
|
|||||||
info.toEditTabInfo(&tabInfo);
|
info.toEditTabInfo(&tabInfo);
|
||||||
|
|
||||||
tab->tryRestoreFromTabInfo(tabInfo);
|
tab->tryRestoreFromTabInfo(tabInfo);
|
||||||
|
|
||||||
|
if (p_oneByOne) {
|
||||||
|
QCoreApplication::sendPostedEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curFile) {
|
if (curFile) {
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
|
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
// Open files @p_files.
|
// Open files @p_files.
|
||||||
int openFiles(const QVector<VFileSessionInfo> &p_files);
|
int openFiles(const QVector<VFileSessionInfo> &p_files, bool p_oneByOne = false);
|
||||||
|
|
||||||
// Record a closed file in the stack.
|
// Record a closed file in the stack.
|
||||||
void recordClosedFile(const VFileSessionInfo &p_file);
|
void recordClosedFile(const VFileSessionInfo &p_file);
|
||||||
|
@ -2637,7 +2637,8 @@ bool VMainWindow::tryOpenInternalFile(const QString &p_filePath)
|
|||||||
void VMainWindow::openFiles(const QStringList &p_files,
|
void VMainWindow::openFiles(const QStringList &p_files,
|
||||||
bool p_forceOrphan,
|
bool p_forceOrphan,
|
||||||
OpenFileMode p_mode,
|
OpenFileMode p_mode,
|
||||||
bool p_forceMode)
|
bool p_forceMode,
|
||||||
|
bool p_oneByOne)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < p_files.size(); ++i) {
|
for (int i = 0; i < p_files.size(); ++i) {
|
||||||
VFile *file = NULL;
|
VFile *file = NULL;
|
||||||
@ -2650,6 +2651,9 @@ void VMainWindow::openFiles(const QStringList &p_files,
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_editArea->openFile(file, p_mode, p_forceMode);
|
m_editArea->openFile(file, p_mode, p_forceMode);
|
||||||
|
if (p_oneByOne) {
|
||||||
|
QCoreApplication::sendPostedEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2744,7 +2748,7 @@ void VMainWindow::openStartupPages()
|
|||||||
{
|
{
|
||||||
QVector<VFileSessionInfo> files = g_config->getLastOpenedFiles();
|
QVector<VFileSessionInfo> files = g_config->getLastOpenedFiles();
|
||||||
qDebug() << "open" << files.size() << "last opened files";
|
qDebug() << "open" << files.size() << "last opened files";
|
||||||
m_editArea->openFiles(files);
|
m_editArea->openFiles(files, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2752,7 +2756,7 @@ void VMainWindow::openStartupPages()
|
|||||||
{
|
{
|
||||||
QStringList pagesToOpen = VUtils::filterFilePathsToOpen(g_config->getStartupPages());
|
QStringList pagesToOpen = VUtils::filterFilePathsToOpen(g_config->getStartupPages());
|
||||||
qDebug() << "open startup pages" << pagesToOpen;
|
qDebug() << "open startup pages" << pagesToOpen;
|
||||||
openFiles(pagesToOpen);
|
openFiles(pagesToOpen, false, OpenFileMode::Read, false, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3403,3 +3407,15 @@ void VMainWindow::postChangePanelView()
|
|||||||
m_mainSplitter->setSizes(sizes);
|
m_mainSplitter->setSizes(sizes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
||||||
|
{
|
||||||
|
QTimer::singleShot(300, [this, p_files]() {
|
||||||
|
checkNotebooks();
|
||||||
|
QCoreApplication::sendPostedEvents();
|
||||||
|
promptNewNotebookIfEmpty();
|
||||||
|
QCoreApplication::sendPostedEvents();
|
||||||
|
openStartupPages();
|
||||||
|
openFiles(p_files, false, OpenFileMode::Read, false, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -89,7 +89,8 @@ public:
|
|||||||
void openFiles(const QStringList &p_files,
|
void openFiles(const QStringList &p_files,
|
||||||
bool p_forceOrphan = false,
|
bool p_forceOrphan = false,
|
||||||
OpenFileMode p_mode = OpenFileMode::Read,
|
OpenFileMode p_mode = OpenFileMode::Read,
|
||||||
bool p_forceMode = false);
|
bool p_forceMode = false,
|
||||||
|
bool p_oneByOne = false);
|
||||||
|
|
||||||
// Try to open @p_filePath as internal note.
|
// Try to open @p_filePath as internal note.
|
||||||
bool tryOpenInternalFile(const QString &p_filePath);
|
bool tryOpenInternalFile(const QString &p_filePath);
|
||||||
@ -114,6 +115,9 @@ public:
|
|||||||
|
|
||||||
VNotebook *getCurrentNotebook() const;
|
VNotebook *getCurrentNotebook() const;
|
||||||
|
|
||||||
|
// Kick off timer to do things after start.
|
||||||
|
void kickOffStartUpTimer(const QStringList &p_files);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Emit when editor related configurations were changed by user.
|
// Emit when editor related configurations were changed by user.
|
||||||
void editorConfigUpdated();
|
void editorConfigUpdated();
|
||||||
|
@ -153,27 +153,23 @@ void VMathJaxInplacePreviewHelper::processForInplacePreview(int p_idx)
|
|||||||
if (vmb.m_text.isEmpty()) {
|
if (vmb.m_text.isEmpty()) {
|
||||||
updateInplacePreview();
|
updateInplacePreview();
|
||||||
} else {
|
} else {
|
||||||
textToHtmlViaWebView(vmb.m_text, p_idx, m_timeStamp);
|
if (!textToHtmlViaWebView(vmb.m_text, p_idx, m_timeStamp)) {
|
||||||
|
updateInplacePreview();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMathJaxInplacePreviewHelper::textToHtmlViaWebView(const QString &p_text,
|
bool VMathJaxInplacePreviewHelper::textToHtmlViaWebView(const QString &p_text,
|
||||||
int p_id,
|
int p_id,
|
||||||
int p_timeStamp)
|
int p_timeStamp)
|
||||||
{
|
{
|
||||||
int maxRetry = 50;
|
if (!m_document->isReadyToTextToHtml()) {
|
||||||
while (!m_document->isReadyToTextToHtml() && maxRetry > 0) {
|
qDebug() << "web side is not ready to convert text to HTML";
|
||||||
qDebug() << "wait for web side ready to convert text to HTML";
|
return false;
|
||||||
VUtils::sleepWait(100);
|
|
||||||
--maxRetry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxRetry == 0) {
|
|
||||||
qWarning() << "web side is not ready to convert text to HTML";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_document->textToHtmlAsync(m_documentID, p_id, p_timeStamp, p_text, false);
|
m_document->textToHtmlAsync(m_documentID, p_id, p_timeStamp, p_text, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMathJaxInplacePreviewHelper::updateInplacePreview()
|
void VMathJaxInplacePreviewHelper::updateInplacePreview()
|
||||||
|
@ -118,7 +118,7 @@ private:
|
|||||||
// Emit signal to update inplace preview.
|
// Emit signal to update inplace preview.
|
||||||
void updateInplacePreview();
|
void updateInplacePreview();
|
||||||
|
|
||||||
void textToHtmlViaWebView(const QString &p_text,
|
bool textToHtmlViaWebView(const QString &p_text,
|
||||||
int p_id,
|
int p_id,
|
||||||
int p_timeStamp);
|
int p_timeStamp);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user