- fix: app's title not update when editor closed

- fix: editor's modified status not correctly updated when using new file template
This commit is contained in:
royqh1979@gmail.com 2021-10-22 16:43:53 +08:00
parent 7a5b6b8efc
commit 9d829876b3
7 changed files with 26 additions and 15 deletions

View File

@ -12,6 +12,7 @@ Version 0.7.0
- enhancement: autosave/load breakpoints - enhancement: autosave/load breakpoints
- enhancement: autosave/load watches - enhancement: autosave/load watches
- implement: files view - implement: files view
- fix: app's title not update when editor closed
Version 0.6.8 Version 0.6.8
- enhancement: add link to cppreference in the help menu - enhancement: add link to cppreference in the help menu

View File

@ -77,6 +77,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
mSelectionWord(), mSelectionWord(),
mSaving(false) mSaving(false)
{ {
mFilename.replace("/",QDir::separator());
mUseCppSyntax = pSettings->editor().defaultFileCpp(); mUseCppSyntax = pSettings->editor().defaultFileCpp();
if (mFilename.isEmpty()) { if (mFilename.isEmpty()) {
mFilename = tr("untitled")+QString("%1").arg(getNewFileNumber()); mFilename = tr("untitled")+QString("%1").arg(getNewFileNumber());
@ -97,9 +98,6 @@ Editor::Editor(QWidget *parent, const QString& filename,
else else
mFileEncoding = mEncodingOption; mFileEncoding = mEncodingOption;
highlighter=highlighterManager.getCppHighlighter(); highlighter=highlighterManager.getCppHighlighter();
if (parentPageControl!=nullptr) {
insertCodeSnippet(pMainWindow->codeSnippetManager()->newFileTemplate());
}
} }
if (highlighter) { if (highlighter) {
@ -152,8 +150,16 @@ Editor::Editor(QWidget *parent, const QString& filename,
connect(this, &QWidget::customContextMenuRequested, connect(this, &QWidget::customContextMenuRequested,
pMainWindow, &MainWindow::onEditorContextMenu); pMainWindow, &MainWindow::onEditorContextMenu);
resetBookmarks(); if (isNew && parentPageControl!=nullptr) {
resetBreakpoints(); QString fileTemplate = pMainWindow->codeSnippetManager()->newFileTemplate();
if (!fileTemplate.isEmpty()) {
insertCodeSnippet(fileTemplate);
}
}
if (!isNew && parentPageControl!=nullptr) {
resetBookmarks();
resetBreakpoints();
}
} }
Editor::~Editor() { Editor::~Editor() {

View File

@ -6,6 +6,7 @@
#include <QFileInfo> #include <QFileInfo>
#include "settings.h" #include "settings.h"
#include "project.h" #include "project.h"
#include "systemconsts.h"
EditorList::EditorList(QTabWidget* leftPageWidget, EditorList::EditorList(QTabWidget* leftPageWidget,
QTabWidget* rightPageWidget, QTabWidget* rightPageWidget,
@ -299,15 +300,18 @@ void EditorList::forceCloseEditor(Editor *editor)
endUpdate(); endUpdate();
} }
Editor* EditorList::getOpenedEditorByFilename(const QString &filename) Editor* EditorList::getOpenedEditorByFilename(QString filename)
{ {
if (filename.isEmpty()) if (filename.isEmpty())
return nullptr; return nullptr;
filename.replace("/",QDir::separator());
QFileInfo fileInfo(filename); QFileInfo fileInfo(filename);
QString fullname = fileInfo.absoluteFilePath(); QString fullname = fileInfo.absoluteFilePath();
fullname.replace("/",QDir::separator());
for (int i=0;i<mLeftPageWidget->count();i++) { for (int i=0;i<mLeftPageWidget->count();i++) {
Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i)); Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i));
if (e->filename().compare(filename)==0 || e->filename().compare(fullname)==0) { if (e->filename().compare(filename, PATH_SENSITIVITY)==0 ||
e->filename().compare(fullname, PATH_SENSITIVITY)==0) {
return e; return e;
} }
} }
@ -320,10 +324,11 @@ Editor* EditorList::getOpenedEditorByFilename(const QString &filename)
return nullptr; return nullptr;
} }
Editor *EditorList::getEditorByFilename(const QString &filename) Editor *EditorList::getEditorByFilename(QString filename)
{ {
if (filename.isEmpty()) if (filename.isEmpty())
return nullptr; return nullptr;
filename.replace("/",QDir::separator());
//check if an editor is already openned //check if an editor is already openned
Editor* e=getOpenedEditorByFilename(filename); Editor* e=getOpenedEditorByFilename(filename);
if (e!=nullptr) if (e!=nullptr)
@ -333,6 +338,7 @@ Editor *EditorList::getEditorByFilename(const QString &filename)
//Create a new editor //Create a new editor
QFileInfo fileInfo(filename); QFileInfo fileInfo(filename);
QString fullname = fileInfo.absoluteFilePath(); QString fullname = fileInfo.absoluteFilePath();
fullname.replace("/",QDir::separator());
if (fileInfo.exists()) if (fileInfo.exists())
return newEditor(fullname,ENCODING_AUTO_DETECT,false,false); return newEditor(fullname,ENCODING_AUTO_DETECT,false,false);
return nullptr; return nullptr;

View File

@ -35,9 +35,9 @@ public:
void forceCloseEditor(Editor* editor); void forceCloseEditor(Editor* editor);
Editor* getOpenedEditorByFilename(const QString& filename); Editor* getOpenedEditorByFilename(QString filename);
Editor* getEditorByFilename(const QString& filename); Editor* getEditorByFilename(QString filename);
bool getContentFromOpenedEditor(const QString& filename, QStringList& buffer); bool getContentFromOpenedEditor(const QString& filename, QStringList& buffer);

View File

@ -3,7 +3,7 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "0.6.9" #define DEVCPP_VERSION "0.7.0"
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -188,7 +188,6 @@ void BookmarkModel::removeBookmarkAt(int i)
endRemoveRows(); endRemoveRows();
} }
#ifdef QT_DEBUG
bool BookmarkModel::isBookmarkExists(const QString &filename, int line) bool BookmarkModel::isBookmarkExists(const QString &filename, int line)
{ {
foreach (const PBookmark& bookmark, mBookmarks) { foreach (const PBookmark& bookmark, mBookmarks) {
@ -245,4 +244,4 @@ QVariant BookmarkModel::headerData(int section, Qt::Orientation orientation, int
} }
return QVariant(); return QVariant();
} }
#endif

View File

@ -33,9 +33,8 @@ public slots:
void onFileDeleteLines(const QString& filename, int startLine, int count); void onFileDeleteLines(const QString& filename, int startLine, int count);
void onFileInsertLines(const QString& filename, int startLine, int count); void onFileInsertLines(const QString& filename, int startLine, int count);
private: private:
#ifdef QT_DEBUG
bool isBookmarkExists(const QString&filename, int line); bool isBookmarkExists(const QString&filename, int line);
#endif
private: private:
QList<PBookmark> mBookmarks; QList<PBookmark> mBookmarks;