Skip to content

Commit ba5819b

Browse files
Merge branch 'dail8859:master' into master
2 parents 32a6be7 + ebabc63 commit ba5819b

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,28 @@ jobs:
104104
make appimage
105105
106106
- name: Upload Windows zip Package
107-
uses: actions/upload-artifact@v4
107+
uses: actions/upload-artifact@v5
108108
if: runner.os == 'Windows'
109109
with:
110110
name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Zip
111111
path: ${{ github.workspace }}/build/package/
112112

113113
- name: Upload Windows Installer
114-
uses: actions/upload-artifact@v4
114+
uses: actions/upload-artifact@v5
115115
if: runner.os == 'Windows'
116116
with:
117117
name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Installer
118118
path: ${{ github.workspace }}/installer/NotepadNext*.exe
119119

120120
- name: Upload macOS dmg
121-
uses: actions/upload-artifact@v4
121+
uses: actions/upload-artifact@v5
122122
if: runner.os == 'macOS'
123123
with:
124124
name: NotepadNext-macOS-Qt${{ matrix.qt_version }}
125125
path: ${{ github.workspace }}/build/NotepadNext/NotepadNext*.dmg
126126

127127
- name: Upload Linux AppImage
128-
uses: actions/upload-artifact@v4
128+
uses: actions/upload-artifact@v5
129129
if: runner.os == 'Linux'
130130
with:
131131
name: NotepadNext-Linux-Qt${{ matrix.qt_version }}-AppImage
@@ -150,7 +150,7 @@ jobs:
150150
gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --generate-notes --draft
151151
152152
- name: Download all artifacts
153-
uses: actions/download-artifact@v5
153+
uses: actions/download-artifact@v6
154154

155155
- name: Upload Windows Installer
156156
run: |

src/NotepadNext/NotepadNextApplication.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,19 @@ void NotepadNextApplication::saveSettings()
440440
getSettings()->setValue("App/RecentFilesList", recentFilesListManager->fileList());
441441
}
442442

443+
void NotepadNextApplication::saveSession()
444+
{
445+
// Iterate all the opened editors and add them to the recent file list
446+
for (const auto &editor : window->editors()) {
447+
if (editor->isFile()) {
448+
recentFilesListManager->addFile(editor->getFilePath());
449+
}
450+
}
451+
saveSettings();
452+
453+
getSessionManager()->saveSession(window);
454+
}
455+
443456
MainWindow *NotepadNextApplication::createNewWindow()
444457
{
445458
Q_ASSERT(window == Q_NULLPTR);
@@ -451,16 +464,14 @@ MainWindow *NotepadNextApplication::createNewWindow()
451464
LuaExtension::Instance().setEditor(editor);
452465
});
453466

454-
// Since these editors don't actually get "closed" go ahead and add them to the recent file list
455-
connect(window, &MainWindow::aboutToClose, this, [=]() {
456-
for (const auto &editor : window->editors()) {
457-
if (editor->isFile()) {
458-
recentFilesListManager->addFile(editor->getFilePath());
459-
}
460-
}
467+
// TODO: this shouldn't be dependent on a MainWindow closing, but this works for now
468+
// since the assumption is MainWindow::aboutToClose() infers the application is shutting
469+
// down but the editors are still active.
470+
connect(window, &MainWindow::aboutToClose, this, &NotepadNextApplication::saveSession);
461471

462-
getSessionManager()->saveSession(window);
463-
});
472+
// Timer to autosave the session
473+
connect(&autoSaveTimer, &QTimer::timeout, this, &NotepadNextApplication::saveSession);
474+
autoSaveTimer.start(60 * 1000);
464475

465476
return window;
466477
}

src/NotepadNext/NotepadNextApplication.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <QCommandLineParser>
2828
#include <QPointer>
29+
#include <QTimer>
2930

3031

3132
class MainWindow;
@@ -75,6 +76,7 @@ class NotepadNextApplication : public SingleApplication
7576
private slots:
7677
void saveSettings();
7778
void receiveInfoFromSecondaryInstance(quint32 instanceId, QByteArray message);
79+
void saveSession();
7880

7981
private:
8082
void openFiles(const QStringList &files);
@@ -95,6 +97,8 @@ private slots:
9597
MainWindow *createNewWindow();
9698

9799
QCommandLineParser parser;
100+
101+
QTimer autoSaveTimer; //save automatically the session
98102
};
99103

100104
#endif // NOTEPADNEXTAPPLICATION_H

src/NotepadNext/SessionManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ ScintillaNext *SessionManager::loadUnsavedFileDetails(QSettings &settings)
316316
editor->setFileInfo(filePath);
317317
editor->setTemporary(true);
318318

319-
loadEditorViewDetails(editor, settings);
320-
321319
app->getEditorManager()->manageEditor(editor);
322320

321+
loadEditorViewDetails(editor, settings);
322+
323323
return editor;
324324
}
325325
else {

0 commit comments

Comments
 (0)