- fix: Wrong compiler settings if xcode is not installed in mac os.

- enhancement: Name for new files will not be different from files openned.
This commit is contained in:
Roy Qu 2023-08-11 17:09:30 +08:00
parent 12f4b3ee9c
commit 496421e97d
5 changed files with 48 additions and 22 deletions

View File

@ -25,6 +25,7 @@ Red Panda C++ Version 2.24
- change: Remove option "clear all symbols when current editor is hidden". - change: Remove option "clear all symbols when current editor is hidden".
- fix: When opening multiple files, only the active file should be parsed. - fix: When opening multiple files, only the active file should be parsed.
- fix: Wrong compiler settings if xcode is not installed in mac os. - fix: Wrong compiler settings if xcode is not installed in mac os.
- enhancement: Name for new files will not be different from files openned.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -315,24 +315,43 @@ void EditorList::applyColorSchemes(const QString& name)
} }
} }
bool EditorList::isFileOpened(const QString &name) bool EditorList::isFileOpened(const QString &fullfilepath) const
{ {
QFileInfo fileInfo(name); QFileInfo fileInfo(fullfilepath);
QString filename = fileInfo.absoluteFilePath(); QString filename = fileInfo.absoluteFilePath();
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(name)==0) if (e->filename().compare(filename)==0 || e->filename().compare(fullfilepath)==0)
return true; return true;
} }
for (int i=0;i<mRightPageWidget->count();i++) { for (int i=0;i<mRightPageWidget->count();i++) {
Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i)); Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i));
if (e->filename().compare(filename)==0 || e->filename().compare(name)==0) if (e->filename().compare(filename)==0 || e->filename().compare(fullfilepath)==0)
return true; return true;
} }
return false; return false;
} }
int EditorList::pageCount() bool EditorList::hasFilename(const QString &filename) const
{
for (int i=0;i<mLeftPageWidget->count();i++) {
Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i));
QFileInfo fileInfo(e->filename());
QString name = fileInfo.fileName();
if (name.compare(filename, PATH_SENSITIVITY)==0 )
return true;
}
for (int i=0;i<mRightPageWidget->count();i++) {
Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i));
QFileInfo fileInfo(e->filename());
QString name = fileInfo.fileName();
if (name.compare(filename, PATH_SENSITIVITY)==0 )
return true;
}
return false;
}
int EditorList::pageCount() const
{ {
return mLeftPageWidget->count()+mRightPageWidget->count(); return mLeftPageWidget->count()+mRightPageWidget->count();
} }
@ -416,7 +435,7 @@ void EditorList::forceCloseEditor(Editor *editor)
emit editorClosed(); emit editorClosed();
} }
Editor* EditorList::getOpenedEditorByFilename(QString filename) Editor* EditorList::getOpenedEditorByFilename(QString filename) const
{ {
if (filename.isEmpty()) if (filename.isEmpty())
return nullptr; return nullptr;
@ -439,7 +458,7 @@ Editor* EditorList::getOpenedEditorByFilename(QString filename)
return nullptr; return nullptr;
} }
bool EditorList::getContentFromOpenedEditor(const QString &filename, QStringList &buffer) bool EditorList::getContentFromOpenedEditor(const QString &filename, QStringList &buffer) const
{ {
if (pMainWindow->isQuitting()) if (pMainWindow->isQuitting())
return false; return false;
@ -450,7 +469,7 @@ bool EditorList::getContentFromOpenedEditor(const QString &filename, QStringList
return true; return true;
} }
void EditorList::getVisibleEditors(Editor *&left, Editor *&right) void EditorList::getVisibleEditors(Editor *&left, Editor *&right) const
{ {
switch(mLayout) { switch(mLayout) {
case LayoutShowType::lstLeft: case LayoutShowType::lstLeft:

View File

@ -60,19 +60,20 @@ public:
void forceCloseEditor(Editor* editor); void forceCloseEditor(Editor* editor);
Editor* getOpenedEditorByFilename(QString filename); Editor* getOpenedEditorByFilename(QString filename) const;
bool getContentFromOpenedEditor(const QString& filename, QStringList& buffer); bool getContentFromOpenedEditor(const QString& filename, QStringList& buffer) const;
void getVisibleEditors(Editor*& left, Editor*& right); void getVisibleEditors(Editor*& left, Editor*& right) const;
void updateLayout(); void updateLayout();
void beginUpdate(); void beginUpdate();
void endUpdate(); void endUpdate();
void applySettings(); void applySettings();
void applyColorSchemes(const QString& name); void applyColorSchemes(const QString& name);
bool isFileOpened(const QString& name); bool isFileOpened(const QString& fullfilepath) const;
int pageCount(); bool hasFilename(const QString& filename) const;
int pageCount() const;
void selectNextPage(); void selectNextPage();
void selectPreviousPage(); void selectPreviousPage();

View File

@ -3362,14 +3362,19 @@ void MainWindow::updateTools()
void MainWindow::newEditor(const QString& suffix) void MainWindow::newEditor(const QString& suffix)
{ {
try { try {
QString filename=QString("untitled%1").arg(getNewFileNumber()); QString filename;
if (suffix.isEmpty()) {
if (pSettings->editor().defaultFileCpp()) do {
filename+=".cpp"; filename = QString("untitled%1").arg(getNewFileNumber());
else if (suffix.isEmpty()) {
filename+=".c"; if (pSettings->editor().defaultFileCpp())
} else filename+=".cpp";
filename+= "." + suffix; else
filename+=".c";
} else
filename+= "." + suffix;
} while(mEditorList->hasFilename(filename));
Editor * editor=mEditorList->newEditor(filename, Editor * editor=mEditorList->newEditor(filename,
pSettings->editor().defaultEncoding(), pSettings->editor().defaultEncoding(),
nullptr,true); nullptr,true);

View File

@ -4385,7 +4385,7 @@ void Settings::CodeCompletion::doLoad()
mHideSymbolsStartsWithUnderLine = boolValue("hide_symbols_start_with_underline", false); mHideSymbolsStartsWithUnderLine = boolValue("hide_symbols_start_with_underline", false);
bool shouldShare= true; bool shouldShare= true;
bool doClear = false; // bool doClear = false;
//#ifdef Q_OS_WIN //#ifdef Q_OS_WIN
// MEMORYSTATUSEX statex; // MEMORYSTATUSEX statex;