Merge branch 'master' into gdbmi

This commit is contained in:
royqh1979@gmail.com 2021-11-20 07:22:09 +08:00
commit e044bb0703
46 changed files with 1195 additions and 653 deletions

42
NEWS.md
View File

@ -1,3 +1,45 @@
Version 0.9.2 For Dev-C++ 7 Beta
- fix: gutter of the disassembly code control in the cpu info dialog is grayed
- fix: problem set & problem views not correctly hidden when disabled in the executor / problem set options
- fix: executor / problem set options not correctly saved
Version 0.9.1 For Dev-C++ 7 Beta
- enhancement: code completion suggestion for "__func__" variable
- fix: ide failed to start, if there are errors in the compiler set settings
- fix: numpad's enter key doesn't work
- enhancement: code completion suggestion for phrase after long/short/signed/unsigned
- enhancement: save/load default projects folder
- enhancement: add editor general options "highlight current word" and "highlight matching braces"
Version 0.9.0 For Dev-C++ 7 Beta
- fix: control keys in the numpad doesn't work in the editor
- fix: project layout infos are wrongly saved to registry
- fix: project layout infos are not correctly saved/loaded
Version 0.8.11 For Dev-C++ 7 Beta
- fix: text color for cpu info dialog not correctly setted
Version 0.8.10 For Dev-C++ 7 Beta
- fix: Shouldn't update auto link settings, if the header name to be modified is unchanged
- fix: add unit to project not correctly set new unit file's encoding
- fix: correctly set encoding for the new added project unit file
- fix: if there's a project openned, new file should ask user if he want to add the new file to the project
- fix: when adding a file openned in the editor to the project, properties of it are not correctly setted.
- enhancement: when remove a file from the project, also ask if user want to remove it from disk
- fix: double click a project's .dev file in the Files panel should load the project
Version 0.8.9 For Dev-C++ 7 Beta
- fix: text color of labels in statusbar not correctly updated when change theme
Version 0.8.8 For Dev-C++ 7 Beta
- enhancement: drag & drop text in the editor
- enhancement: auto calcuate caret line size basing on font size
- enhancement: shift+mouse wheel to scroll horizontally
- fix: greatly reduces paste time
- fix: auto indent shouldn't use preprocessor's indent to calculate
- fix: option "don't add leading zeros to line numbers" not work
- fix: "collapse all" and "uncollapse all" doesn't work
Version 0.8.7 For Dev-C++ 7 Beta Version 0.8.7 For Dev-C++ 7 Beta
- enhancement: auto indent line to column 1 when enter '#' at beginning of line - enhancement: auto indent line to column 1 when enter '#' at beginning of line
- fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line - fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line

View File

@ -199,6 +199,7 @@ HEADERS += \
thememanager.h \ thememanager.h \
todoparser.h \ todoparser.h \
toolsmanager.h \ toolsmanager.h \
version.h \
widgets/aboutdialog.h \ widgets/aboutdialog.h \
widgets/bookmarkmodel.h \ widgets/bookmarkmodel.h \
widgets/classbrowser.h \ widgets/classbrowser.h \

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
#include "../systemconsts.h" #include "../systemconsts.h"
#include "../platform.h" #include "../platform.h"
#include "../editor.h" #include "../editor.h"
#include "../version.h"
#include <QDir> #include <QDir>
@ -339,14 +340,14 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->editor()->fileEncoding(), .arg(unit->editor()->fileEncoding(),
defaultSystemEncoding); defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_ASCII) { } else if (unit->encoding()==ENCODING_SYSTEM_DEFAULT) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(defaultSystemEncoding, .arg(defaultSystemEncoding,
defaultSystemEncoding); defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_ASCII && !unit->encoding().isEmpty()) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),
defaultSystemEncoding);
} }
} }

View File

@ -48,7 +48,7 @@ bool CppRefacter::findOccurence(Editor *editor, const BufferCoord &pos)
bool CppRefacter::findOccurence(const QString &statementFullname, SearchFileScope scope) bool CppRefacter::findOccurence(const QString &statementFullname, SearchFileScope scope)
{ {
PCppParser parser; PCppParser parser;
Editor * editor; Editor * editor=nullptr;
std::shared_ptr<Project> project; std::shared_ptr<Project> project;
if (scope == SearchFileScope::currentFile) { if (scope == SearchFileScope::currentFile) {
editor = pMainWindow->editorList()->getEditor(); editor = pMainWindow->editorList()->getEditor();

View File

@ -692,6 +692,16 @@ void Editor::keyPressEvent(QKeyEvent *event)
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
if (!lastWord.isEmpty()) { if (!lastWord.isEmpty()) {
if (CppTypeKeywords.contains(lastWord)) { if (CppTypeKeywords.contains(lastWord)) {
if (lastWord == "long" ||
lastWord == "short" ||
lastWord == "signed" ||
lastWord == "unsigned"
) {
setSelText(ch);
showCompletion(lastWord,false);
handled=true;
return;
}
//last word is a type keyword, this is a var or param define, and dont show suggestion //last word is a type keyword, this is a var or param define, and dont show suggestion
// if devEditor.UseTabnine then // if devEditor.UseTabnine then
// ShowTabnineCompletion; // ShowTabnineCompletion;
@ -713,7 +723,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
} }
} }
setSelText(ch); setSelText(ch);
showCompletion(false); showCompletion("",false);
handled=true; handled=true;
return; return;
} }
@ -727,7 +737,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
&& pSettings->codeCompletion().showCompletionWhileInput() ) { && pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++; mLastIdCharPressed++;
setSelText(ch); setSelText(ch);
showCompletion(false); showCompletion("",false);
handled=true; handled=true;
return; return;
} }
@ -739,7 +749,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
&& pSettings->codeCompletion().showCompletionWhileInput() ) { && pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++; mLastIdCharPressed++;
setSelText(ch); setSelText(ch);
showCompletion(false); showCompletion("",false);
handled=true; handled=true;
return; return;
} }
@ -910,7 +920,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
foreground = mCurrentHighlighWordForeground; foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid()) if (mCurrentHighlighWordBackground.isValid())
background = mCurrentHighlighWordBackground; background = mCurrentHighlighWordBackground;
} else if (!selAvail() && attr->name() == SYNS_AttrSymbol) { } else if (!selAvail() && attr->name() == SYNS_AttrSymbol
&& pSettings->editor().highlightMathingBraces()) {
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char; // qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
if ( (line == mHighlightCharPos1.Line) if ( (line == mHighlightCharPos1.Line)
&& (aChar == mHighlightCharPos1.Char)) { && (aChar == mHighlightCharPos1.Char)) {
@ -1139,7 +1150,7 @@ void Editor::inputMethodEvent(QInputMethodEvent *event)
return; return;
} }
} }
showCompletion(false); showCompletion("",false);
return; return;
} }
} }
@ -1398,10 +1409,6 @@ void Editor::onStatusChanged(SynStatusChanges changes)
if (changes.testFlag(SynStatusChange::scCaretX) if (changes.testFlag(SynStatusChange::scCaretX)
|| changes.testFlag(SynStatusChange::scCaretY)) { || changes.testFlag(SynStatusChange::scCaretY)) {
invalidateLine(mHighlightCharPos1.Line);
invalidateLine(mHighlightCharPos2.Line);
mHighlightCharPos1 = BufferCoord{0,0};
mHighlightCharPos2 = BufferCoord{0,0};
if (mTabStopBegin >=0) { if (mTabStopBegin >=0) {
if (mTabStopY==caretY()) { if (mTabStopY==caretY()) {
if (mLineAfterTabStop.isEmpty()) { if (mLineAfterTabStop.isEmpty()) {
@ -1427,7 +1434,11 @@ void Editor::onStatusChanged(SynStatusChanges changes)
clearUserCodeInTabStops(); clearUserCodeInTabStops();
} }
} }
} else if (!selAvail() && highlighter()){ } else if (!selAvail() && highlighter() && pSettings->editor().highlightMathingBraces()){
invalidateLine(mHighlightCharPos1.Line);
invalidateLine(mHighlightCharPos2.Line);
mHighlightCharPos1 = BufferCoord{0,0};
mHighlightCharPos2 = BufferCoord{0,0};
// Is there a bracket char before us? // Is there a bracket char before us?
int lineLength = lineText().length(); int lineLength = lineText().length();
int ch = caretX() - 2; int ch = caretX() - 2;
@ -1461,8 +1472,11 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// scSelection includes anything caret related // scSelection includes anything caret related
if (changes.testFlag(SynStatusChange::scSelection)) { if (changes.testFlag(SynStatusChange::scSelection)) {
if (!selAvail()) { if (!selAvail() && pSettings->editor().highlightCurrentWord()) {
mCurrentHighlightedWord = wordAtCursor(); mCurrentHighlightedWord = wordAtCursor();
} else if (selAvail() && blockBegin() == wordStart()
&& blockEnd() == wordEnd()){
mCurrentHighlightedWord = selText();
} else { } else {
mCurrentHighlightedWord = ""; mCurrentHighlightedWord = "";
} }
@ -1904,20 +1918,20 @@ bool Editor::handleCodeCompletion(QChar key)
switch(key.unicode()) { switch(key.unicode()) {
case '.': case '.':
setSelText(key); setSelText(key);
showCompletion(false); showCompletion("",false);
return true; return true;
case '>': case '>':
setSelText(key); setSelText(key);
if ((caretX() > 2) && (lineText().length() >= 2) && if ((caretX() > 2) && (lineText().length() >= 2) &&
(lineText()[caretX() - 3] == '-')) (lineText()[caretX() - 3] == '-'))
showCompletion(false); showCompletion("",false);
return true; return true;
case ':': case ':':
ExecuteCommand(SynEditorCommand::ecChar,':',nullptr); ExecuteCommand(SynEditorCommand::ecChar,':',nullptr);
//setSelText(key); //setSelText(key);
if ((caretX() > 2) && (lineText().length() >= 2) && if ((caretX() > 2) && (lineText().length() >= 2) &&
(lineText()[caretX() - 3] == ':')) (lineText()[caretX() - 3] == ':'))
showCompletion(false); showCompletion("",false);
return true; return true;
case '/': case '/':
case '\\': case '\\':
@ -2260,7 +2274,7 @@ void Editor::exportAsHTML(const QString &htmlFilename)
exporter.SaveToFile(htmlFilename); exporter.SaveToFile(htmlFilename);
} }
void Editor::showCompletion(bool autoComplete) void Editor::showCompletion(const QString& preWord,bool autoComplete)
{ {
if (!pSettings->codeCompletion().enabled()) if (!pSettings->codeCompletion().enabled())
return; return;
@ -2337,8 +2351,7 @@ void Editor::showCompletion(bool autoComplete)
if (word.isEmpty()) if (word.isEmpty())
word=getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion); word=getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion);
//if not fCompletionBox.Visible then mCompletionPopup->prepareSearch(preWord, word, mFilename, pBeginPos.Line);
mCompletionPopup->prepareSearch(word, mFilename, pBeginPos.Line);
// Filter the whole statement list // Filter the whole statement list
if (mCompletionPopup->search(word, autoComplete)) { //only one suggestion and it's not input while typing if (mCompletionPopup->search(word, autoComplete)) { //only one suggestion and it's not input while typing

View File

@ -202,7 +202,7 @@ private:
void undoSymbolCompletion(int pos); void undoSymbolCompletion(int pos);
QuoteStatus getQuoteStatus(); QuoteStatus getQuoteStatus();
void showCompletion(bool autoComplete); void showCompletion(const QString& preWord, bool autoComplete);
void showHeaderCompletion(bool autoComplete); void showHeaderCompletion(bool autoComplete);
bool testInFunc(int x,int y); bool testInFunc(int x,int y);

View File

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
//Translation must be loaded first //Translation must be loaded first
QTranslator trans; QTranslator trans,transQt;
QString settingFilename = getSettingFilename(); QString settingFilename = getSettingFilename();
if (!isGreenEdition()) { if (!isGreenEdition()) {
QDir::setCurrent(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]); QDir::setCurrent(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]);
@ -91,8 +91,13 @@ int main(int argc, char *argv[])
QSettings languageSetting(settingFilename,QSettings::IniFormat); QSettings languageSetting(settingFilename,QSettings::IniFormat);
languageSetting.beginGroup(SETTING_ENVIRONMENT); languageSetting.beginGroup(SETTING_ENVIRONMENT);
QString language = languageSetting.value("language",QLocale::system().name()).toString(); QString language = languageSetting.value("language",QLocale::system().name()).toString();
trans.load("RedPandaIDE_"+language,":/translations");
app.installTranslator(&trans); if (trans.load("RedPandaIDE_"+language,":/translations")) {
app.installTranslator(&trans);
}
if (transQt.load("qt_"+language,":/translations")) {
app.installTranslator(&transQt);
}
} }
qRegisterMetaType<PCompileIssue>("PCompileIssue"); qRegisterMetaType<PCompileIssue>("PCompileIssue");

View File

@ -20,6 +20,7 @@
#include "widgets/darkfusionstyle.h" #include "widgets/darkfusionstyle.h"
#include "problems/problemcasevalidator.h" #include "problems/problemcasevalidator.h"
#include "widgets/ojproblempropertywidget.h" #include "widgets/ojproblempropertywidget.h"
#include "version.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QComboBox> #include <QComboBox>
@ -511,6 +512,10 @@ void MainWindow::applySettings()
else else
QApplication::setStyle("fusion"); QApplication::setStyle("fusion");
qApp->setPalette(appTheme->palette()); qApp->setPalette(appTheme->palette());
//fix for qstatusbar bug
mFileEncodingStatus->setPalette(appTheme->palette());
mFileModeStatus->setPalette(appTheme->palette());
mFileInfoStatus->setPalette(appTheme->palette());
updateEditorColorSchemes(); updateEditorColorSchemes();
QFont font(pSettings->environment().interfaceFont(), QFont font(pSettings->environment().interfaceFont(),
@ -529,7 +534,7 @@ void MainWindow::applySettings()
if (!mTcpServer.listen(QHostAddress::LocalHost,pSettings->executor().competivieCompanionPort())) { if (!mTcpServer.listen(QHostAddress::LocalHost,pSettings->executor().competivieCompanionPort())) {
// QMessageBox::critical(nullptr, // QMessageBox::critical(nullptr,
// tr("Listen failed"), // tr("Listen failed"),
// tr("Can't listen to port %1 form Competitve Companion.").arg(10045) // tr("Can't listen to port %1 form Competitive Companion.").arg(10045)
// + "<BR/>" // + "<BR/>"
// +tr("You can turn off competitive companion support in the Problem Set options.") // +tr("You can turn off competitive companion support in the Problem Set options.")
// + "<BR/>" // + "<BR/>"
@ -569,7 +574,8 @@ void MainWindow::applyUISettings()
ui->actionFiles->setChecked(settings.showFiles()); ui->actionFiles->setChecked(settings.showFiles());
showHideInfosTab(ui->tabFiles,settings.showFiles()); showHideInfosTab(ui->tabFiles,settings.showFiles());
ui->actionProblem_Set->setChecked(settings.showProblemSet()); ui->actionProblem_Set->setChecked(settings.showProblemSet());
showHideInfosTab(ui->tabProblemSet,settings.showProblemSet()); showHideInfosTab(ui->tabProblemSet,settings.showProblemSet()
&& pSettings->executor().enableProblemSet());
ui->actionIssues->setChecked(settings.showIssues()); ui->actionIssues->setChecked(settings.showIssues());
showHideMessagesTab(ui->tabIssues,settings.showIssues()); showHideMessagesTab(ui->tabIssues,settings.showIssues());
@ -584,7 +590,8 @@ void MainWindow::applyUISettings()
ui->actionBookmark->setChecked(settings.showBookmark()); ui->actionBookmark->setChecked(settings.showBookmark());
showHideMessagesTab(ui->tabBookmark,settings.showBookmark()); showHideMessagesTab(ui->tabBookmark,settings.showBookmark());
ui->actionProblem->setChecked(settings.showProblem()); ui->actionProblem->setChecked(settings.showProblem());
showHideMessagesTab(ui->tabProblem,settings.showProblem()); showHideMessagesTab(ui->tabProblem,settings.showProblem()
&& pSettings->executor().enableProblemSet());
//we can't show/hide left/bottom panels here, cause mainwindow layout is not calculated //we can't show/hide left/bottom panels here, cause mainwindow layout is not calculated
} }
@ -2669,12 +2676,14 @@ void MainWindow::onLstProblemSetContextMenu(const QPoint &pos)
QAction * action = new QAction(tr("select other file..."),menuSetAnswer); QAction * action = new QAction(tr("select other file..."),menuSetAnswer);
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
[problem,this](){ [problem,this](){
QFileDialog dialog;
QString filename = QFileDialog::getOpenFileName( QString filename = QFileDialog::getOpenFileName(
this, this,
tr("Select Answer Source File"), tr("Select Answer Source File"),
QString(), QString(),
tr("C/C++Source Files (*.c *.cpp *.cc *.cxx)") tr("C/C++Source Files (*.c *.cpp *.cc *.cxx)"),
); nullptr,
dialog.options() | QFileDialog::DontUseNativeDialog);
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
QDir::setCurrent(extractFileDir(filename)); QDir::setCurrent(extractFileDir(filename));
problem->answerProgram = filename; problem->answerProgram = filename;
@ -3133,7 +3142,7 @@ void MainWindow::onFileChanged(const QString &path)
if (e) { if (e) {
if (fileExists(path)) { if (fileExists(path)) {
e->activate(); e->activate();
if (QMessageBox::question(this,tr("Compile"), if (QMessageBox::question(this,tr("File Changed"),
tr("File '%1' was changed.").arg(path)+"<BR /><BR />" + tr("Reload its content from disk?"), tr("File '%1' was changed.").arg(path)+"<BR /><BR />" + tr("Reload its content from disk?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes|QMessageBox::No,
QMessageBox::No) == QMessageBox::Yes) { QMessageBox::No) == QMessageBox::Yes) {
@ -3144,7 +3153,7 @@ void MainWindow::onFileChanged(const QString &path)
} }
} }
} else { } else {
if (QMessageBox::question(this,tr("Compile"), if (QMessageBox::question(this,tr("File Changed"),
tr("File '%1' was removed.").arg(path)+"<BR /><BR />" + tr("Keep it open?"), tr("File '%1' was removed.").arg(path)+"<BR /><BR />" + tr("Keep it open?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes) == QMessageBox::No) { QMessageBox::Yes) == QMessageBox::No) {
@ -3201,6 +3210,15 @@ CPUDialog *MainWindow::cpuDialog() const
void MainWindow::on_actionNew_triggered() void MainWindow::on_actionNew_triggered()
{ {
if (mProject) {
if (QMessageBox::question(this,
tr("New Project File?"),
tr("Do you want to add the new file to the project?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
newProjectUnitFile();
return;
}
}
newEditor(); newEditor();
} }
@ -3770,7 +3788,7 @@ void MainWindow::on_actionUnfoldAll_triggered()
{ {
Editor * editor = mEditorList->getEditor(); Editor * editor = mEditorList->getEditor();
if (editor != NULL ) { if (editor != NULL ) {
//editor->clearFolds(); editor->unCollpaseAll();
} }
} }
@ -3778,8 +3796,7 @@ void MainWindow::on_actionFoldAll_triggered()
{ {
Editor * editor = mEditorList->getEditor(); Editor * editor = mEditorList->getEditor();
if (editor != NULL ) { if (editor != NULL ) {
//editor->clearFolds(); editor->collapseAll();
//editor->foldAll();
} }
} }
@ -4549,6 +4566,10 @@ void MainWindow::on_actionNew_Project_triggered()
{ {
NewProjectDialog dialog; NewProjectDialog dialog;
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
if (dialog.useAsDefaultProjectDir()) {
pSettings->dirs().setProjectDir(dialog.getLocation());
pSettings->dirs().save();
}
// Take care of the currently opened project // Take care of the currently opened project
QString s; QString s;
if (mProject) { if (mProject) {
@ -4569,19 +4590,20 @@ void MainWindow::on_actionNew_Project_triggered()
} }
//Create the project folder //Create the project folder
QDir dir(dialog.getLocation()); QString location = includeTrailingPathDelimiter(dialog.getLocation())+dialog.getProjectName();
QDir dir(location);
if (!dir.exists()) { if (!dir.exists()) {
if (QMessageBox::question(this, if (QMessageBox::question(this,
tr("Folder not exist"), tr("Folder not exist"),
tr("Folder '%1' doesn't exist. Create it now?").arg(dialog.getLocation()), tr("Folder '%1' doesn't exist. Create it now?").arg(location),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes) != QMessageBox::Yes) { QMessageBox::Yes) != QMessageBox::Yes) {
return; return;
} }
if (!dir.mkpath(dialog.getLocation())) { if (!dir.mkpath(location)) {
QMessageBox::critical(this, QMessageBox::critical(this,
tr("Can't create folder"), tr("Can't create folder"),
tr("Failed to create folder '%1'.").arg(dialog.getLocation()), tr("Failed to create folder '%1'.").arg(location),
QMessageBox::Yes); QMessageBox::Yes);
return; return;
} }
@ -4590,14 +4612,14 @@ void MainWindow::on_actionNew_Project_triggered()
// if cbDefault.Checked then // if cbDefault.Checked then
// devData.DefCpp := rbCpp.Checked; // devData.DefCpp := rbCpp.Checked;
s = includeTrailingPathDelimiter(dialog.getLocation()) s = includeTrailingPathDelimiter(location)
+ dialog.getProjectName() + "." + DEV_PROJECT_EXT; + dialog.getProjectName() + "." + DEV_PROJECT_EXT;
if (fileExists(s)) { if (fileExists(s)) {
QString saveName = QFileDialog::getSaveFileName( QString saveName = QFileDialog::getSaveFileName(
this, this,
tr("Save new project as"), tr("Save new project as"),
dialog.getLocation(), location,
tr("Red panda Dev-C++ project file (*.dev)")); tr("Red panda Dev-C++ project file (*.dev)"));
if (!saveName.isEmpty()) { if (!saveName.isEmpty()) {
s = saveName; s = saveName;
@ -4645,46 +4667,7 @@ void MainWindow::on_actionSaveAll_triggered()
void MainWindow::on_actionProject_New_File_triggered() void MainWindow::on_actionProject_New_File_triggered()
{ {
int idx = -1; newProjectUnitFile();
if (!mProject)
return;
QModelIndex current = ui->projectView->currentIndex();
FolderNode * node = nullptr;
if (current.isValid()) {
node = static_cast<FolderNode*>(current.internalPointer());
}
QString newFileName;
do {
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
if (mProject->options().useGPP) {
newFileName+=".cpp";
} else {
newFileName+=".c";
}
} while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
newFileName = QInputDialog::getText(
this,
tr("New Project File Name"),
tr("File Name:"),
QLineEdit::Normal,
newFileName);
if (newFileName.isEmpty())
return;
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
QMessageBox::critical(this,tr("File Already Exists!"),
tr("File '%1' already exists!").arg(newFileName));
return;
}
PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->saveUnits();
updateProjectView();
Editor * editor = mProject->openUnit(idx);
//editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true);
editor->activate();
} }
@ -4733,9 +4716,14 @@ void MainWindow::on_actionRemove_from_project_triggered()
continue; continue;
selected.insert(folderNode->unitIndex); selected.insert(folderNode->unitIndex);
}; };
bool removeFile = (QMessageBox::question(this,tr("Remove file"),
tr("Remove the file from disk?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
for (int i=mProject->units().count()-1;i>=0;i--) { for (int i=mProject->units().count()-1;i>=0;i--) {
if (selected.contains(i)) { if (selected.contains(i)) {
mProject->removeEditor(i,true); mProject->removeUnit(i,true,removeFile);
} }
} }
@ -4943,6 +4931,50 @@ void MainWindow::prepareTabMessagesData()
mTabMessagesData[widget]=info; mTabMessagesData[widget]=info;
} }
} }
void MainWindow::newProjectUnitFile()
{
if (!mProject)
return;
int idx = -1;
QModelIndex current = ui->projectView->currentIndex();
FolderNode * node = nullptr;
if (current.isValid()) {
node = static_cast<FolderNode*>(current.internalPointer());
}
QString newFileName;
do {
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
if (mProject->options().useGPP) {
newFileName+=".cpp";
} else {
newFileName+=".c";
}
} while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
newFileName = QInputDialog::getText(
this,
tr("New Project File Name"),
tr("File Name:"),
QLineEdit::Normal,
newFileName);
if (newFileName.isEmpty())
return;
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
QMessageBox::critical(this,tr("File Already Exists!"),
tr("File '%1' already exists!").arg(newFileName));
return;
}
PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->saveUnits();
updateProjectView();
Editor * editor = mProject->openUnit(idx);
//editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true);
editor->activate();
}
void MainWindow::on_EditorTabsLeft_currentChanged(int) void MainWindow::on_EditorTabsLeft_currentChanged(int)
{ {
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft); Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
@ -5374,9 +5406,10 @@ void MainWindow::on_treeFiles_doubleClicked(const QModelIndex &index)
QString filepath = mFileSystemModel.filePath(index); QString filepath = mFileSystemModel.filePath(index);
QFileInfo file(filepath); QFileInfo file(filepath);
if (file.isFile()) { if (file.isFile()) {
Editor * editor = mEditorList->getEditorByFilename(filepath); if (getFileType(filepath)==FileType::Project) {
if (editor) { openProject(filepath);
editor->activate(); } else {
openFile(filepath);
} }
} }
} }

View File

@ -226,6 +226,7 @@ private:
void showHideMessagesTab(QWidget *widget, bool show); void showHideMessagesTab(QWidget *widget, bool show);
void prepareTabInfosData(); void prepareTabInfosData();
void prepareTabMessagesData(); void prepareTabMessagesData();
void newProjectUnitFile();
private slots: private slots:
void onAutoSaveTimeout(); void onAutoSaveTimeout();

View File

@ -85,7 +85,7 @@
<enum>QTabWidget::West</enum> <enum>QTabWidget::West</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>3</number>
</property> </property>
<property name="usesScrollButtons"> <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>

View File

@ -2153,6 +2153,21 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
true, true,
false); false);
} }
// add "__func__ variable"
addStatement(
functionStatement,
mCurrentFile,
"", //dont override hint
"static const char ",
"__func__",
"[]",
"\""+scopelessName+"\"",
startLine+1,
StatementKind::skVariable,
StatementScope::ssLocal,
StatementClassScope::scsNone,
true,
false);
} else { } else {
functionStatement = addStatement( functionStatement = addStatement(
functionClass, functionClass,

View File

@ -154,6 +154,8 @@ void initParser()
//CppTypeKeywords.insert("unsigned"); //CppTypeKeywords.insert("unsigned");
CppTypeKeywords.insert("void"); CppTypeKeywords.insert("void");
CppTypeKeywords.insert("wchar_t"); CppTypeKeywords.insert("wchar_t");
CppTypeKeywords.insert("signed");
CppTypeKeywords.insert("unsigned");
// it's part of type info // it's part of type info
CppKeywords.insert("const",SkipType::skNone); CppKeywords.insert("const",SkipType::skNone);

View File

@ -260,7 +260,7 @@ PProjectUnit Project::newUnit(PFolderNode parentNode, const QString& customFileN
newUnit->setOverrideBuildCmd(false); newUnit->setOverrideBuildCmd(false);
newUnit->setBuildCmd(""); newUnit->setBuildCmd("");
newUnit->setModified(true); newUnit->setModified(true);
newUnit->setEncoding(toByteArray(options().encoding)); newUnit->setEncoding(toByteArray(mOptions.encoding));
return newUnit; return newUnit;
} }
@ -285,7 +285,7 @@ Editor *Project::openUnit(int index)
editor = pMainWindow->editorList()->newEditor(fullPath, encoding, true, unit->isNew()); editor = pMainWindow->editorList()->newEditor(fullPath, encoding, true, unit->isNew());
editor->setInProject(true); editor->setInProject(true);
unit->setEditor(editor); unit->setEditor(editor);
unit->setEncoding(encoding); //unit->setEncoding(encoding);
editor->activate(); editor->activate();
loadUnitLayout(editor,index); loadUnitLayout(editor,index);
return editor; return editor;
@ -340,7 +340,7 @@ void Project::rebuildNodes()
emit nodesChanged(); emit nodesChanged();
} }
bool Project::removeEditor(int index, bool doClose) bool Project::removeUnit(int index, bool doClose , bool removeFile)
{ {
mModel.beginUpdate(); mModel.beginUpdate();
auto action = finally([this]{ auto action = finally([this]{
@ -357,6 +357,10 @@ bool Project::removeEditor(int index, bool doClose)
return false; return false;
} }
if (removeFile) {
QFile::remove(unit->fileName());
}
//if not fUnits.GetItem(index).fNew then //if not fUnits.GetItem(index).fNew then
PFolderNode node = unit->node(); PFolderNode node = unit->node();
PFolderNode parent = node->parent.lock(); PFolderNode parent = node->parent.lock();
@ -416,7 +420,7 @@ void Project::saveAll()
void Project::saveLayout() void Project::saveLayout()
{ {
QSettings layIni(changeFileExt(mFilename, "layout"),QSettings::IniFormat); SimpleIni layIni;
QStringList sl; QStringList sl;
// Write list of open project files // Write list of open project files
for (int i=0;i<pMainWindow->editorList()->pageCount();i++) { for (int i=0;i<pMainWindow->editorList()->pageCount();i++) {
@ -424,39 +428,37 @@ void Project::saveLayout()
if (e && e->inProject()) if (e && e->inProject())
sl.append(QString("%1").arg(indexInUnits(e))); sl.append(QString("%1").arg(indexInUnits(e)));
} }
layIni.beginGroup("Editors"); layIni.SetValue("Editors","Order",sl.join(",").toUtf8());
layIni.setValue("Order",sl.join(","));
Editor *e, *e2; Editor *e, *e2;
// Remember what files were visible // Remember what files were visible
pMainWindow->editorList()->getVisibleEditors(e, e2); pMainWindow->editorList()->getVisibleEditors(e, e2);
if (e) if (e)
layIni.setValue("Focused", indexInUnits(e)); layIni.SetLongValue("Editors","Focused", indexInUnits(e));
layIni.endGroup();
// save editor info // save editor info
for (int i=0;i<mUnits.count();i++) { for (int i=0;i<mUnits.count();i++) {
layIni.beginGroup(QString("Editor_%1").arg(i)); QByteArray groupName = QString("Editor_%1").arg(i).toUtf8();
PProjectUnit unit = mUnits[i]; PProjectUnit unit = mUnits[i];
Editor* editor = unit->editor(); Editor* editor = unit->editor();
if (editor) { if (editor) {
layIni.setValue("CursorCol", editor->caretX()); layIni.SetLongValue(groupName,"CursorCol", editor->caretX());
layIni.setValue("CursorRow", editor->caretY()); layIni.SetLongValue(groupName,"CursorRow", editor->caretY());
layIni.setValue("TopLine", editor->topLine()); layIni.SetLongValue(groupName,"TopLine", editor->topLine());
layIni.setValue("LeftChar", editor->leftChar()); layIni.SetLongValue(groupName,"LeftChar", editor->leftChar());
} }
layIni.endGroup();
// remove old data from project file // remove old data from project file
SimpleIni ini; SimpleIni ini;
ini.LoadFile(mFilename.toLocal8Bit()); ini.LoadFile(filename().toLocal8Bit());
QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1)); groupName = toByteArray(QString("Unit%1").arg(i+1));
ini.Delete(groupName,"Open"); ini.Delete(groupName,"Open");
ini.Delete(groupName,"Top"); ini.Delete(groupName,"Top");
ini.Delete(groupName,"CursorCol"); ini.Delete(groupName,"CursorCol");
ini.Delete(groupName,"CursorRow"); ini.Delete(groupName,"CursorRow");
ini.Delete(groupName,"TopLine"); ini.Delete(groupName,"TopLine");
ini.Delete(groupName,"LeftChar"); ini.Delete(groupName,"LeftChar");
ini.SaveFile(mFilename.toLocal8Bit()); ini.SaveFile(filename().toLocal8Bit());
} }
layIni.SaveFile(changeFileExt(filename(), "layout").toLocal8Bit());
} }
void Project::saveUnitAs(int i, const QString &sFileName, bool syncEditor) void Project::saveUnitAs(int i, const QString &sFileName, bool syncEditor)
@ -496,20 +498,22 @@ void Project::saveUnitLayout(Editor *e, int index)
{ {
if (!e) if (!e)
return; return;
QSettings layIni = QSettings(changeFileExt(filename(), "layout")); SimpleIni layIni;
layIni.beginGroup(QString("Editor_%1").arg(index)); QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8();
layIni.setValue("CursorCol", e->caretX()); layIni.SetLongValue(groupName,"CursorCol", e->caretX());
layIni.setValue("CursorRow", e->caretY()); layIni.SetLongValue(groupName,"CursorRow", e->caretY());
layIni.setValue("TopLine", e->topLine()); layIni.SetLongValue(groupName,"TopLine", e->topLine());
layIni.setValue("LeftChar", e->leftChar()); layIni.SetLongValue(groupName,"LeftChar", e->leftChar());
layIni.endGroup(); layIni.SaveFile((changeFileExt(filename(), "layout")).toLocal8Bit());
} }
bool Project::saveUnits() bool Project::saveUnits()
{ {
int count = 0; int count = 0;
SimpleIni ini; SimpleIni ini;
ini.LoadFile(mFilename.toLocal8Bit()); SI_Error error = ini.LoadFile(mFilename.toLocal8Bit());
if (error != SI_Error::SI_OK)
return false;
for (int idx = 0; idx < mUnits.count(); idx++) { for (int idx = 0; idx < mUnits.count(); idx++) {
PProjectUnit unit = mUnits[idx]; PProjectUnit unit = mUnits[idx];
bool rd_only = false; bool rd_only = false;
@ -790,7 +794,15 @@ PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode,
// Set all properties // Set all properties
newUnit->setFileName(QDir(directory()).filePath(inFileName)); newUnit->setFileName(QDir(directory()).filePath(inFileName));
newUnit->setNew(false); newUnit->setNew(false);
newUnit->setEditor(nullptr); Editor * e= pMainWindow->editorList()->getOpenedEditorByFilename(newUnit->fileName());
if (e) {
newUnit->setEditor(e);
newUnit->setEncoding(e->encodingOption());
e->setInProject(true);
} else {
newUnit->setEditor(nullptr);
newUnit->setEncoding(ENCODING_AUTO_DETECT);
}
newUnit->setFolder(getFolderPath(parentNode)); newUnit->setFolder(getFolderPath(parentNode));
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode)); newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode));
newUnit->node()->unitIndex = mUnits.count(); newUnit->node()->unitIndex = mUnits.count();
@ -1290,12 +1302,13 @@ QString Project::listUnitStr(const QChar &separator)
void Project::loadLayout() void Project::loadLayout()
{ {
QSettings layIni = QSettings(changeFileExt(filename(), "layout"),QSettings::IniFormat); SimpleIni layIni;
layIni.beginGroup("Editors"); SI_Error error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit());
int topLeft = layIni.value("Focused", -1).toInt(); if (error!=SI_OK)
return;
int topLeft = layIni.GetLongValue("Editors","Focused",1);
//TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1); //TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1);
QString temp =layIni.value("Order", "").toString(); QString temp =layIni.GetValue("Editors","Order", "");
layIni.endGroup();
QStringList sl = temp.split(",",Qt::SkipEmptyParts); QStringList sl = temp.split(",",Qt::SkipEmptyParts);
foreach (const QString& s,sl) { foreach (const QString& s,sl) {
@ -1308,7 +1321,6 @@ void Project::loadLayout()
if (topLeft>=0 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) { if (topLeft>=0 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) {
mUnits[topLeft]->editor()->activate(); mUnits[topLeft]->editor()->activate();
} }
} }
void Project::loadOptions(SimpleIni& ini) void Project::loadOptions(SimpleIni& ini)
@ -1444,13 +1456,16 @@ void Project::loadUnitLayout(Editor *e, int index)
{ {
if (!e) if (!e)
return; return;
QSettings layIni(changeFileExt(filename(), "layout"), QSettings::IniFormat); SimpleIni layIni;
layIni.beginGroup(QString("Editor_%1").arg(index)); SI_Error error;
e->setCaretY(layIni.value("CursorRow",1).toInt()); error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit());
e->setCaretX(layIni.value("CursorCol",1).toInt()); if (error != SI_Error::SI_OK)
e->setTopLine(layIni.value("TopLine",1).toInt()); return;
e->setLeftChar(layIni.value("LeftChar",1).toInt()); QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8();
layIni.endGroup(); e->setCaretY(layIni.GetLongValue(groupName,"CursorRow",1));
e->setCaretX(layIni.GetLongValue(groupName,"CursorCol",1));
e->setTopLine(layIni.GetLongValue(groupName,"TopLine",1));
e->setLeftChar(layIni.GetLongValue(groupName,"LeftChar",1));
} }
PCppParser Project::cppParser() PCppParser Project::cppParser()
@ -1514,7 +1529,7 @@ void Project::removeFolderRecurse(PFolderNode node)
} else if (childNode->unitIndex >= 0 && childNode->level > 0) { } else if (childNode->unitIndex >= 0 && childNode->level > 0) {
// Remove editor in folder from project // Remove editor in folder from project
int editorIndex = childNode->unitIndex; int editorIndex = childNode->unitIndex;
if (!removeEditor(editorIndex,true)) if (!removeUnit(editorIndex,true))
return; return;
} }
} }
@ -1919,7 +1934,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
// Remove it from the current project... // Remove it from the current project...
int projindex = mProject->indexInUnits(newName); int projindex = mProject->indexInUnits(newName);
if (projindex>=0) { if (projindex>=0) {
mProject->removeEditor(projindex,false); mProject->removeUnit(projindex,false);
} }
// All references to the file are removed. Delete the file from disk // All references to the file are removed. Delete the file from disk
@ -1954,7 +1969,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
} }
// Add new filename to file minitor // Add new filename to file minitor
pMainWindow->fileSystemWatcher()->removePath(oldName); pMainWindow->fileSystemWatcher()->addPath(newName);
return true; return true;
} else { } else {
//change folder name //change folder name

View File

@ -148,7 +148,7 @@ public:
const QString& customFileName=""); const QString& customFileName="");
Editor* openUnit(int index); Editor* openUnit(int index);
void rebuildNodes(); void rebuildNodes();
bool removeEditor(int index, bool doClose); bool removeUnit(int index, bool doClose, bool removeFile = false);
bool removeFolder(PFolderNode node); bool removeFolder(PFolderNode node);
void resetParserProjectFiles(); void resetParserProjectFiles();
void saveAll(); // save [Project] and all [UnitX] void saveAll(); // save [Project] and all [UnitX]

View File

@ -108,7 +108,9 @@ PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command)
PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers)
{ {
for (PSynEditKeyStroke& keyStroke:mList) { for (PSynEditKeyStroke& keyStroke:mList) {
if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==0) if (keyStroke->key() == key
&& keyStroke->keyModifiers() == (modifiers & ~ Qt::KeypadModifier)
&& keyStroke->key2()==0)
return keyStroke; return keyStroke;
} }
return PSynEditKeyStroke(); return PSynEditKeyStroke();
@ -118,8 +120,10 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers
int key2, Qt::KeyboardModifiers modifiers2) int key2, Qt::KeyboardModifiers modifiers2)
{ {
for (PSynEditKeyStroke& keyStroke:mList) { for (PSynEditKeyStroke& keyStroke:mList) {
if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==key2 if (keyStroke->key() == key
&& keyStroke->keyModifiers2() ==modifiers2) && keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier)
&& keyStroke->key2()==key2
&& keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier))
return keyStroke; return keyStroke;
} }
return PSynEditKeyStroke(); return PSynEditKeyStroke();
@ -202,8 +206,8 @@ void SynEditKeyStrokes::resetDefaults()
add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier); add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier|Qt::ShiftModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier);
add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier); add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier);
add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier);
add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier);

View File

@ -95,7 +95,11 @@ QString SynGutter::formatLineNumber(int line)
{ {
line += (mLineNumberStart - 1); line += (mLineNumberStart - 1);
QString result = QString::number(line); QString result = QString::number(line);
return QString(mAutoSizeDigitCount - result.length(),'0') + result; if (mLeadingZeros) {
return QString(mAutoSizeDigitCount - result.length(),'0') + result;
} else {
return result;
}
} }
int SynGutter::realGutterWidth(int charWidth) int SynGutter::realGutterWidth(int charWidth)
@ -315,10 +319,9 @@ void SynGutter::setBorderColor(const QColor &value)
} }
SynEditMark::SynEditMark(QObject *parent) SynEditMark::SynEditMark(QObject * /*parent*/)
{ {
mBookmarkNum = -1; mBookmarkNum = -1;
} }
int SynEditMark::Char() const int SynEditMark::Char() const
@ -405,7 +408,7 @@ void SynEditMark::setLine(int line)
} }
} }
SynBookMarkOpt::SynBookMarkOpt(QObject *parent) SynBookMarkOpt::SynBookMarkOpt(QObject */*parent*/)
{ {
mDrawBookmarksFirst = true; mDrawBookmarksFirst = true;
mEnableKeys = true; mEnableKeys = true;

View File

@ -19,6 +19,8 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QStyleHints> #include <QStyleHints>
#include <QMessageBox> #include <QMessageBox>
#include <QDrag>
#include <QMimeData>
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
{ {
@ -57,6 +59,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onRedoAdded); mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onRedoAdded);
mOrigRedoList = mRedoList; mOrigRedoList = mRedoList;
mForegroundColor=palette().color(QPalette::Text);
mBackgroundColor=palette().color(QPalette::Base);
mCaretColor = QColorConstants::Red; mCaretColor = QColorConstants::Red;
mCaretUseTextColor = false; mCaretUseTextColor = false;
mActiveLineColor = QColorConstants::Svg::lightblue; mActiveLineColor = QColorConstants::Svg::lightblue;
@ -115,7 +119,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mBlockEnd = mBlockBegin; mBlockEnd = mBlockBegin;
mOptions = eoAutoIndent mOptions = eoAutoIndent
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent | | eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick; eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick
| eoHideShowScrollbars ;
mScrollTimer = new QTimer(this); mScrollTimer = new QTimer(this);
mScrollTimer->setInterval(100); mScrollTimer->setInterval(100);
@ -142,6 +147,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
setAttribute(Qt::WA_InputMethodEnabled); setAttribute(Qt::WA_InputMethodEnabled);
//setMouseTracking(true); //setMouseTracking(true);
setAcceptDrops(true);
} }
int SynEdit::displayLineCount() const int SynEdit::displayLineCount() const
@ -1063,6 +1069,20 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord
setBlockEnd(ptAfter); setBlockEnd(ptAfter);
} }
void SynEdit::collapseAll()
{
for (int i = mAllFoldRanges.count()-1;i>=0;i--){
collapse(mAllFoldRanges[i]);
}
}
void SynEdit::unCollpaseAll()
{
for (int i = mAllFoldRanges.count()-1;i>=0;i--){
uncollapse(mAllFoldRanges[i]);
}
}
void SynEdit::processGutterClick(QMouseEvent *event) void SynEdit::processGutterClick(QMouseEvent *event)
{ {
int X = event->pos().x(); int X = event->pos().x();
@ -1208,6 +1228,8 @@ void SynEdit::showCaret()
{ {
if (m_blinkTimerId==0) if (m_blinkTimerId==0)
m_blinkTimerId = startTimer(500); m_blinkTimerId = startTimer(500);
m_blinkStatus = 1;
updateCaret();
} }
void SynEdit::hideCaret() void SynEdit::hideCaret()
@ -1429,7 +1451,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
QString s; QString s;
while (startLine>=1) { while (startLine>=1) {
s = mLines->getString(startLine-1); s = mLines->getString(startLine-1);
if (!s.trimmed().isEmpty()) { if (!s.startsWith('#') && !s.trimmed().isEmpty()) {
break; break;
} }
startLine -- ; startLine -- ;
@ -3580,25 +3602,40 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
} else { } else {
ct =mOverwriteCaret; ct =mOverwriteCaret;
} }
QColor caretColor;
if (mCaretUseTextColor) { if (mCaretUseTextColor) {
painter.setPen(mForegroundColor); caretColor = mForegroundColor;
} else { } else {
painter.setPen(mCaretColor); caretColor = mCaretColor;
} }
switch(ct) { switch(ct) {
case SynEditCaretType::ctVerticalLine: case SynEditCaretType::ctVerticalLine: {
painter.drawLine(rcClip.left()+1,rcClip.top(),rcClip.left()+1,rcClip.bottom()); QRect caretRC;
int size = std::max(1,(rcClip.bottom()-rcClip.top())/15);
caretRC.setLeft(rcClip.left()+1);
caretRC.setTop(rcClip.top());
caretRC.setBottom(rcClip.bottom());
caretRC.setRight(rcClip.left()+1+size);
painter.fillRect(caretRC,caretColor);
break; break;
case SynEditCaretType::ctHorizontalLine: }
painter.drawLine(rcClip.left(),rcClip.bottom()-1,rcClip.right(),rcClip.bottom()-1); case SynEditCaretType::ctHorizontalLine: {
QRect caretRC;
int size = std::max(1,(rcClip.bottom()-rcClip.top())/15);
caretRC.setLeft(rcClip.left());
caretRC.setTop(rcClip.bottom()-1+size);
caretRC.setBottom(rcClip.bottom()-1);
caretRC.setRight(rcClip.right());
painter.fillRect(caretRC,caretColor);
break; break;
}
case SynEditCaretType::ctBlock: case SynEditCaretType::ctBlock:
painter.fillRect(rcClip, mCaretColor); painter.fillRect(rcClip, caretColor);
break; break;
case SynEditCaretType::ctHalfBlock: case SynEditCaretType::ctHalfBlock:
QRect rc=rcClip; QRect rc=rcClip;
rc.setTop(rcClip.top()+rcClip.height() / 2); rc.setTop(rcClip.top()+rcClip.height() / 2);
painter.fillRect(rcClip, mCaretColor); painter.fillRect(rcClip, caretColor);
break; break;
} }
} }
@ -4922,12 +4959,13 @@ void SynEdit::doLinesInserted(int firstLine, int count)
// end; // end;
} }
void SynEdit::properSetLine(int ALine, const QString &ALineText) void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify)
{ {
if (mOptions.testFlag(eoTrimTrailingSpaces)) if (mOptions.testFlag(eoTrimTrailingSpaces)) {
mLines->putString(ALine,TrimRight(ALineText)); mLines->putString(ALine,TrimRight(ALineText),notify);
else } else {
mLines->putString(ALine,ALineText); mLines->putString(ALine,ALineText,notify);
}
} }
void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE) void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE)
@ -5021,6 +5059,10 @@ void SynEdit::insertText(const QString &Value, SynSelectionMode PasteMode,bool A
int SynEdit::insertTextByNormalMode(const QString &Value) int SynEdit::insertTextByNormalMode(const QString &Value)
{ {
mLines->beginUpdate();
auto actionLines = finally([this] {
mLines->endUpdate();
});
QString sLeftSide; QString sLeftSide;
QString sRightSide; QString sRightSide;
QString Str; QString Str;
@ -5029,6 +5071,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
bool bChangeScroll; bool bChangeScroll;
// int SpaceCount; // int SpaceCount;
int Result = 0; int Result = 0;
int startLine = mCaretY;
sLeftSide = lineText().mid(0, mCaretX - 1); sLeftSide = lineText().mid(0, mCaretX - 1);
if (mCaretX - 1 > sLeftSide.length()) { if (mCaretX - 1 > sLeftSide.length()) {
if (StringIsBlank(sLeftSide)) if (StringIsBlank(sLeftSide))
@ -5070,9 +5113,9 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = P; Start = P;
P = GetEOL(Value,Start); P = GetEOL(Value,Start);
if (P == Start) { if (P == Start) {
if (P<Value.length()) if (P<Value.length())
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true); Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
else else
Str = sRightSide; Str = sRightSide;
} else { } else {
Str = Value.mid(Start, P-Start); Str = Value.mid(Start, P-Start);
@ -5083,7 +5126,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str); Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str);
} }
} }
properSetLine(caretY - 1, Str); properSetLine(caretY - 1, Str,false);
rescanRange(caretY); rescanRange(caretY);
Result++; Result++;
} }
@ -5097,6 +5140,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
internalSetCaretXY(BufferCoord{lineText().length()+1,caretY}); internalSetCaretXY(BufferCoord{lineText().length()+1,caretY});
} else } else
internalSetCaretXY(BufferCoord{Str.length() - sRightSide.length()+1,caretY}); internalSetCaretXY(BufferCoord{Str.length() - sRightSide.length()+1,caretY});
onLinesPutted(startLine-1,Result+1);
return Result; return Result;
} }
@ -5899,7 +5943,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2) if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
&& (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { && (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
bStartDrag = true; bStartDrag = true;
} }
if (bStartDrag) { if (bStartDrag) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging);
@ -5959,7 +6003,15 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) {
if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setText(selText());
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction);
//drag->setPixmap(iconPixmap);
//BeginDrag(false); //BeginDrag(false);
} }
// } else if ((buttons == Qt::LeftButton) && (X > mGutterWidth)) { // } else if ((buttons == Qt::LeftButton) && (X > mGutterWidth)) {
@ -6017,14 +6069,26 @@ void SynEdit::leaveEvent(QEvent *)
void SynEdit::wheelEvent(QWheelEvent *event) void SynEdit::wheelEvent(QWheelEvent *event)
{ {
if (event->angleDelta().y()>0) { if (event->modifiers() == Qt::ShiftModifier) {
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); if (event->angleDelta().y()>0) {
event->accept(); horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
return; event->accept();
} else if (event->angleDelta().y()<0) { return;
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); } else if (event->angleDelta().y()<0) {
event->accept(); horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
return; event->accept();
return;
}
} else {
if (event->angleDelta().y()>0) {
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed);
event->accept();
return;
} else if (event->angleDelta().y()<0) {
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed);
event->accept();
return;
}
} }
QAbstractScrollArea::wheelEvent(event); QAbstractScrollArea::wheelEvent(event);
} }
@ -6052,6 +6116,63 @@ QVariant SynEdit::inputMethodQuery(Qt::InputMethodQuery property) const
} }
void SynEdit::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/plain")) {
event->acceptProposedAction();
mDragCaretSave = caretXY();
mDragSelBeginSave = blockBegin();
mDragSelEndSave = blockEnd();
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
event->pos().y()));
setCaretXY(coord);
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
showCaret();
}
}
void SynEdit::dropEvent(QDropEvent *event)
{
mUndoList->BeginBlock();
auto action = finally([this] {
mUndoList->EndBlock();
});
if (event->proposedAction() == Qt::DropAction::MoveAction) {
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
setSelText("");
}
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
event->pos().y()));
setCaretXY(coord);
setSelText(event->mimeData()->text());
event->acceptProposedAction();
}
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
{
if (event->keyboardModifiers() == Qt::ControlModifier) {
event->setDropAction(Qt::CopyAction);
} else {
event->setDropAction(Qt::MoveAction);
}
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
event->pos().y()));
setCaretXY(coord);
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
showCaret();
}
void SynEdit::dragLeaveEvent(QDragLeaveEvent *)
{
setCaretXY(mDragCaretSave);
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
showCaret();
}
int SynEdit::maxScrollHeight() const int SynEdit::maxScrollHeight() const
{ {
if (mOptions.testFlag(eoScrollPastEof)) if (mOptions.testFlag(eoScrollPastEof))

View File

@ -219,6 +219,8 @@ public:
const BufferCoord& ptBefore, const BufferCoord& ptBefore,
const BufferCoord& ptAfter); const BufferCoord& ptAfter);
void collapseAll();
void unCollpaseAll();
void uncollapseAroundLine(int line); void uncollapseAroundLine(int line);
PSynEditFoldRange foldHidesLine(int line); PSynEditFoldRange foldHidesLine(int line);
void setSelLength(int Value); void setSelLength(int Value);
@ -504,7 +506,7 @@ private:
const QString& Value, bool AddToUndoList); const QString& Value, bool AddToUndoList);
void doLinesDeleted(int FirstLine, int Count); void doLinesDeleted(int FirstLine, int Count);
void doLinesInserted(int FirstLine, int Count); void doLinesInserted(int FirstLine, int Count);
void properSetLine(int ALine, const QString& ALineText); void properSetLine(int ALine, const QString& ALineText, bool notify = true);
void deleteSelection(const BufferCoord& BB, const BufferCoord& BE); void deleteSelection(const BufferCoord& BB, const BufferCoord& BE);
void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList); void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
int insertTextByNormalMode(const QString& Value); int insertTextByNormalMode(const QString& Value);
@ -696,6 +698,10 @@ private:
int mMouseWheelScrollSpeed; int mMouseWheelScrollSpeed;
BufferCoord mDragCaretSave;
BufferCoord mDragSelBeginSave;
BufferCoord mDragSelEndSave;
friend class SynEditTextPainter; friend class SynEditTextPainter;
// QWidget interface // QWidget interface
@ -722,6 +728,13 @@ bool viewportEvent(QEvent * event) override;
// QWidget interface // QWidget interface
public: public:
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
// QWidget interface
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
}; };
#endif // SYNEDIT_H #endif // SYNEDIT_H

View File

@ -397,7 +397,7 @@ QString SynEditStringList::getTextStr() const
return result; return result;
} }
void SynEditStringList::putString(int Index, const QString &s) { void SynEditStringList::putString(int Index, const QString &s, bool notify) {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
if (Index == mList.count()) { if (Index == mList.count()) {
add(s); add(s);
@ -409,7 +409,8 @@ void SynEditStringList::putString(int Index, const QString &s) {
mIndexOfLongestLine = -1; mIndexOfLongestLine = -1;
mList[Index]->fString = s; mList[Index]->fString = s;
mList[Index]->fColumns = -1; mList[Index]->fColumns = -1;
emit putted(Index,1); if (notify)
emit putted(Index,1);
endUpdate(); endUpdate();
} }
} }

View File

@ -67,7 +67,7 @@ public:
void setContents(const QStringList& text); void setContents(const QStringList& text);
QStringList contents(); QStringList contents();
void putString(int Index, const QString& s); void putString(int Index, const QString& s, bool notify=true);
void putObject(int Index, void * AObject); void putObject(int Index, void * AObject);
void beginUpdate(); void beginUpdate();

View File

@ -234,3 +234,8 @@ void ContentsCoord::setCh(int newChar)
{ {
mChar = newChar; mChar = newChar;
} }
bool BufferCoord::operator==(const BufferCoord &coord)
{
return coord.Char == Char && coord.Line == Line;
}

View File

@ -10,6 +10,7 @@ enum class SynSelectionMode {smNormal, smLine, smColumn};
struct BufferCoord { struct BufferCoord {
int Char; int Char;
int Line; int Line;
bool operator==(const BufferCoord& coord);
}; };
class SynEdit; class SynEdit;

BIN
RedPandaIDE/qt_zh_CN.qm Normal file

Binary file not shown.

View File

@ -87,6 +87,7 @@ void Settings::load()
mCodeCompletion.load(); mCodeCompletion.load();
mCodeFormatter.load(); mCodeFormatter.load();
mUI.load(); mUI.load();
mDirs.load();
} }
Settings::Dirs &Settings::dirs() Settings::Dirs &Settings::dirs()
@ -161,12 +162,7 @@ QString Settings::Dirs::templateDir() const
QString Settings::Dirs::projectDir() const QString Settings::Dirs::projectDir() const
{ {
if (isGreenEdition()) { return mProjectDir;
return includeTrailingPathDelimiter(app()) + "projects";
} else {
return includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0])
+ "projects";
}
} }
QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
@ -205,12 +201,24 @@ QString Settings::Dirs::executable() const
void Settings::Dirs::doSave() void Settings::Dirs::doSave()
{ {
saveValue("projectDir",mProjectDir);
} }
void Settings::Dirs::doLoad() void Settings::Dirs::doLoad()
{ {
QString defaultProjectDir;
if (isGreenEdition()) {
defaultProjectDir = includeTrailingPathDelimiter(app()) + "projects";
} else {
defaultProjectDir = includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0])
+ "projects";
}
mProjectDir = stringValue("projectDir",defaultProjectDir);
}
void Settings::Dirs::setProjectDir(const QString &newProjectDir)
{
mProjectDir = newProjectDir;
} }
Settings::_Base::_Base(Settings *settings, const QString &groupName): Settings::_Base::_Base(Settings *settings, const QString &groupName):
@ -524,6 +532,26 @@ void Settings::Editor::setUseUTF8ByDefault(bool newUseUTF8ByDefault)
mUseUTF8ByDefault = newUseUTF8ByDefault; mUseUTF8ByDefault = newUseUTF8ByDefault;
} }
bool Settings::Editor::highlightMathingBraces() const
{
return mHighlightMathingBraces;
}
void Settings::Editor::setHighlightMathingBraces(bool newHighlightMathingBraces)
{
mHighlightMathingBraces = newHighlightMathingBraces;
}
bool Settings::Editor::highlightCurrentWord() const
{
return mHighlightCurrentWord;
}
void Settings::Editor::setHighlightCurrentWord(bool newHighlightCurrentWord)
{
mHighlightCurrentWord = newHighlightCurrentWord;
}
bool Settings::Editor::enableTooltips() const bool Settings::Editor::enableTooltips() const
{ {
return mEnableTooltips; return mEnableTooltips;
@ -994,6 +1022,7 @@ void Settings::Editor::doSave()
saveValue("show_indent_lines", mShowIndentLines); saveValue("show_indent_lines", mShowIndentLines);
saveValue("indent_line_color",mIndentLineColor); saveValue("indent_line_color",mIndentLineColor);
saveValue("fill_indents",mfillIndents); saveValue("fill_indents",mfillIndents);
// caret // caret
saveValue("enhance_home_key",mEnhanceHomeKey); saveValue("enhance_home_key",mEnhanceHomeKey);
saveValue("enhance_end_key",mEnhanceEndKey); saveValue("enhance_end_key",mEnhanceEndKey);
@ -1003,6 +1032,10 @@ void Settings::Editor::doSave()
saveValue("caret_use_text_color",mCaretUseTextColor); saveValue("caret_use_text_color",mCaretUseTextColor);
saveValue("caret_color",mCaretColor); saveValue("caret_color",mCaretColor);
//highlight
saveValue("highlight_matching_braces",mHighlightMathingBraces);
saveValue("highlight_current_word",mHighlightCurrentWord);
//scroll //scroll
saveValue("auto_hide_scroll_bar", mAutoHideScrollbar); saveValue("auto_hide_scroll_bar", mAutoHideScrollbar);
saveValue("scroll_past_eof", mScrollPastEof); saveValue("scroll_past_eof", mScrollPastEof);
@ -1112,6 +1145,10 @@ void Settings::Editor::doLoad()
mCaretUseTextColor = boolValue("caret_use_text_color",true); mCaretUseTextColor = boolValue("caret_use_text_color",true);
mCaretColor = colorValue("caret_color",QColorConstants::Svg::yellow); mCaretColor = colorValue("caret_color",QColorConstants::Svg::yellow);
//highlight
mHighlightMathingBraces = boolValue("highlight_matching_braces",true);
mHighlightCurrentWord = boolValue("highlight_current_word",true);
//scroll //scroll
mAutoHideScrollbar = boolValue("auto_hide_scroll_bar", false); mAutoHideScrollbar = boolValue("auto_hide_scroll_bar", false);
mScrollPastEof = boolValue("scroll_past_eof", true); mScrollPastEof = boolValue("scroll_past_eof", true);
@ -2393,11 +2430,19 @@ void Settings::CompilerSets::loadSets()
mDefaultIndex =mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX,-1).toInt(); mDefaultIndex =mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX,-1).toInt();
int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt(); int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt();
mSettings->mSettings.endGroup(); mSettings->mSettings.endGroup();
bool loadError = false;
for (int i=0;i<listSize;i++) { for (int i=0;i<listSize;i++) {
PCompilerSet pSet=loadSet(i); PCompilerSet pSet=loadSet(i);
if (!pSet) {
loadError = true;
break;
}
mList.push_back(pSet); mList.push_back(pSet);
} }
if (loadError) {
mList.clear();
mDefaultIndex = -1;
}
PCompilerSet pCurrentSet = defaultSet(); PCompilerSet pCurrentSet = defaultSet();
if (pCurrentSet) { if (pCurrentSet) {
QString msg; QString msg;
@ -2419,6 +2464,9 @@ void Settings::CompilerSets::loadSets()
mDefaultIndex = mList.size()-1; mDefaultIndex = mList.size()-1;
pCurrentSet = defaultSet(); pCurrentSet = defaultSet();
if (!pCurrentSet) { if (!pCurrentSet) {
mList.clear();
mDefaultIndex = -1;
saveSets();
return; return;
} }
saveSet(mDefaultIndex); saveSet(mDefaultIndex);
@ -2442,6 +2490,9 @@ void Settings::CompilerSets::loadSets()
findSets(); findSets();
pCurrentSet = defaultSet(); pCurrentSet = defaultSet();
if (!pCurrentSet) { if (!pCurrentSet) {
mList.clear();
mDefaultIndex = -1;
saveSets();
return; return;
} }
saveSets(); saveSets();
@ -2641,6 +2692,8 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
mSettings->mSettings.endGroup(); mSettings->mSettings.endGroup();
if (pSet->binDirs().isEmpty())
return PCompilerSet();
pSet->setDirectories(pSet->binDirs()[0]); pSet->setDirectories(pSet->binDirs()[0]);
pSet->setDefines(); pSet->setDefines();
return pSet; return pSet;
@ -2835,6 +2888,9 @@ void Settings::Executor::doSave()
saveValue("redirect_input",mRedirectInput); saveValue("redirect_input",mRedirectInput);
saveValue("input_filename",mInputFilename); saveValue("input_filename",mInputFilename);
//problem set //problem set
saveValue("enable_proble_set", mEnableProblemSet);
saveValue("enable_competivie_companion", mEnableCompetitiveCompanion);
saveValue("competitive_companion_port", mCompetivieCompanionPort);
} }

View File

@ -96,10 +96,13 @@ public:
QString config(DataType dataType = DataType::None) const; QString config(DataType dataType = DataType::None) const;
QString executable() const; QString executable() const;
// _Base interface void setProjectDir(const QString &newProjectDir);
protected: protected:
void doSave() override; void doSave() override;
void doLoad() override; void doLoad() override;
private:
QString mProjectDir;
}; };
class Editor: public _Base { class Editor: public _Base {
@ -336,6 +339,12 @@ public:
bool useUTF8ByDefault() const; bool useUTF8ByDefault() const;
void setUseUTF8ByDefault(bool newUseUTF8ByDefault); void setUseUTF8ByDefault(bool newUseUTF8ByDefault);
bool highlightCurrentWord() const;
void setHighlightCurrentWord(bool newHighlightCurrentWord);
bool highlightMathingBraces() const;
void setHighlightMathingBraces(bool newHighlightMathingBraces);
private: private:
//General //General
// indents // indents
@ -354,6 +363,10 @@ public:
bool mCaretUseTextColor; bool mCaretUseTextColor;
QColor mCaretColor; QColor mCaretColor;
//highlights
bool mHighlightCurrentWord;
bool mHighlightMathingBraces;
//scroll //scroll
bool mAutoHideScrollbar; bool mAutoHideScrollbar;
bool mScrollPastEof; bool mScrollPastEof;

View File

@ -110,6 +110,8 @@ bool AutolinkModel::setData(const QModelIndex &index, const QVariant &value, int
if (index.column() == 0) { if (index.column() == 0) {
if (s.isEmpty()) if (s.isEmpty())
return false; return false;
if (link->header == s)
return false;
if (findLink(s)>=0) { if (findLink(s)>=0) {
QMessageBox::warning(pMainWindow, QMessageBox::warning(pMainWindow,
tr("Header exists"), tr("Header exists"),

View File

@ -52,6 +52,9 @@ void EditorGeneralWidget::doLoad()
setCaretTypeIndex(ui->cbCaretForOverwrite,pSettings->editor().caretForOverwrite()); setCaretTypeIndex(ui->cbCaretForOverwrite,pSettings->editor().caretForOverwrite());
ui->chkCaretUseTextColor->setChecked(pSettings->editor().caretUseTextColor()); ui->chkCaretUseTextColor->setChecked(pSettings->editor().caretUseTextColor());
ui->colorCaret->setColor(pSettings->editor().caretColor()); ui->colorCaret->setColor(pSettings->editor().caretColor());
//highlight
ui->chkHighlightCurrentWord->setChecked(pSettings->editor().highlightCurrentWord());
ui->chkHighlightMatchingBraces->setChecked(pSettings->editor().highlightMathingBraces());
//scrolls; //scrolls;
ui->chkAutoHideScrollBars->setChecked(pSettings->editor().autoHideScrollbar()); ui->chkAutoHideScrollBars->setChecked(pSettings->editor().autoHideScrollbar());
ui->chkScrollPastEOF->setChecked(pSettings->editor().scrollPastEof()); ui->chkScrollPastEOF->setChecked(pSettings->editor().scrollPastEof());
@ -84,6 +87,10 @@ void EditorGeneralWidget::doSave()
pSettings->editor().setCaretForOverwrite(getCaretTypeIndex(ui->cbCaretForOverwrite)); pSettings->editor().setCaretForOverwrite(getCaretTypeIndex(ui->cbCaretForOverwrite));
pSettings->editor().setCaretUseTextColor(ui->chkCaretUseTextColor->isChecked()); pSettings->editor().setCaretUseTextColor(ui->chkCaretUseTextColor->isChecked());
pSettings->editor().setCaretColor(ui->colorCaret->color()); pSettings->editor().setCaretColor(ui->colorCaret->color());
//highlight
pSettings->editor().setHighlightCurrentWord(ui->chkHighlightCurrentWord->isChecked());
pSettings->editor().setHighlightMathingBraces(ui->chkHighlightMatchingBraces->isChecked());
//scrolls; //scrolls;
pSettings->editor().setAutoHideScrollbar(ui->chkAutoHideScrollBars->isChecked()); pSettings->editor().setAutoHideScrollbar(ui->chkAutoHideScrollBars->isChecked());
pSettings->editor().setScrollPastEof(ui->chkScrollPastEOF->isChecked()); pSettings->editor().setScrollPastEof(ui->chkScrollPastEOF->isChecked());

View File

@ -228,6 +228,29 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Highlight</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="chkHighlightMatchingBraces">
<property name="text">
<string>Highlight matching braces</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkHighlightCurrentWord">
<property name="text">
<string>Highlight current word</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">

View File

@ -58,6 +58,7 @@ void EnvironmentAppearenceWidget::doSave()
pSettings->environment().setInterfaceFontSize(ui->spinFontSize->value()); pSettings->environment().setInterfaceFontSize(ui->spinFontSize->value());
pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString()); pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString());
pSettings->editor().save();
pSettings->environment().save(); pSettings->environment().save();
pMainWindow->applySettings(); pMainWindow->applySettings();
} }

View File

@ -99,6 +99,8 @@ PSettingsDialog SettingsDialog::optionDialog()
{ {
PSettingsDialog dialog = std::make_shared<SettingsDialog>(); PSettingsDialog dialog = std::make_shared<SettingsDialog>();
dialog->setWindowTitle(tr("Options"));
SettingsWidget* widget = new EnvironmentAppearenceWidget(tr("Appearence"),tr("Environment")); SettingsWidget* widget = new EnvironmentAppearenceWidget(tr("Appearence"),tr("Environment"));
widget->init(); widget->init();
dialog->addWidget(widget); dialog->addWidget(widget);
@ -206,6 +208,8 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
{ {
PSettingsDialog dialog = std::make_shared<SettingsDialog>(); PSettingsDialog dialog = std::make_shared<SettingsDialog>();
dialog->setWindowTitle(tr("Project Options"));
SettingsWidget* widget = new ProjectGeneralWidget(tr("General"),tr("Project")); SettingsWidget* widget = new ProjectGeneralWidget(tr("General"),tr("Project"));
widget->init(); widget->init();
dialog->addWidget(widget); dialog->addWidget(widget);

View File

@ -3,8 +3,6 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "beta.0.8.6"
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#define GCC_PROGRAM "gcc.exe" #define GCC_PROGRAM "gcc.exe"

View File

@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="/translations"> <qresource prefix="/translations">
<file>RedPandaIDE_zh_CN.qm</file> <file>RedPandaIDE_zh_CN.qm</file>
<file>qt_zh_CN.qm</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -22,6 +22,7 @@
#include "editorlist.h" #include "editorlist.h"
#include "editor.h" #include "editor.h"
#include "project.h" #include "project.h"
#include "version.h"
const QByteArray GuessTextEncoding(const QByteArray& text){ const QByteArray GuessTextEncoding(const QByteArray& text){
bool allAscii; bool allAscii;

7
RedPandaIDE/version.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef VERSION_H
#define VERSION_H
#include <QObject>
#define DEVCPP_VERSION "beta.0.9.2"
#endif // VERSION_H

View File

@ -1,6 +1,8 @@
#include "aboutdialog.h" #include "aboutdialog.h"
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include "../systemconsts.h" #include "../systemconsts.h"
#include "../version.h"
AboutDialog::AboutDialog(QWidget *parent) : AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -8,9 +10,20 @@ AboutDialog::AboutDialog(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + DEVCPP_VERSION); ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + DEVCPP_VERSION);
#ifdef __GNUC__
ui->lblContent->setText(ui->lblContent->text() ui->lblContent->setText(ui->lblContent->text()
.arg(qVersion()) .arg(qVersion())
.arg("GCC 10.3.0",__DATE__, __TIME__)); .arg(QString("GCC %1.%2")
.arg(__GNUC__)
.arg(__GNUC_MINOR__)
,__DATE__, __TIME__));
#else
ui->lblContent->setText(ui->lblContent->text()
.arg(qVersion())
.arg("Non-GCC Compiler"
,__DATE__, __TIME__));
#endif
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

View File

@ -59,7 +59,7 @@ void CodeCompletionPopup::setKeypressedCallback(const KeyPressedCallback &newKey
mListView->setKeypressedCallback(newKeypressedCallback); mListView->setKeypressedCallback(newKeypressedCallback);
} }
void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &filename, int line) void CodeCompletionPopup::prepareSearch(const QString& preWord,const QString &phrase, const QString &filename, int line)
{ {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
if (!isEnabled()) if (!isEnabled())
@ -69,19 +69,19 @@ void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &fi
QCursor oldCursor = cursor(); QCursor oldCursor = cursor();
setCursor(Qt::CursorShape::WaitCursor); setCursor(Qt::CursorShape::WaitCursor);
mIncludedFiles = mParser->getFileIncludes(filename); if (preWord.isEmpty()) {
getCompletionFor(filename,phrase,line); mIncludedFiles = mParser->getFileIncludes(filename);
getCompletionFor(filename,phrase,line);
if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) { if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) {
mPhrase = phrase.mid(1); mPhrase = phrase.mid(1);
getCompletionFor(filename,mPhrase,line); getCompletionFor(filename,mPhrase,line);
}
} else {
mPhrase = phrase;
getFullCompletionListFor(preWord);
} }
//todo: notify model
//CodeComplForm.lbCompletion.Font.Size := FontSize;
//CodeComplForm.lbCompletion.ItemHeight := CodeComplForm.lbCompletion.Canvas.TextHeight('F')+6;
// Round(2 * FontSize);
//CodeComplForm.Update;
setCursor(oldCursor); setCursor(oldCursor);
} }
@ -453,13 +453,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
if (phrase.startsWith('#')) { if (phrase.startsWith('#')) {
if (mShowKeywords) { if (mShowKeywords) {
foreach (const QString& keyword, CppDirectives) { foreach (const QString& keyword, CppDirectives) {
PStatement statement = std::make_shared<Statement>(); addKeyword(keyword);
statement->command = keyword; // PStatement statement = std::make_shared<Statement>();
statement->kind = StatementKind::skKeyword; // statement->command = keyword;
statement->fullName = keyword; // statement->kind = StatementKind::skKeyword;
statement->usageCount = 0; // statement->fullName = keyword;
statement->freqTop = 0; // statement->usageCount = 0;
mFullCompletionStatementList.append(statement); // statement->freqTop = 0;
// mFullCompletionStatementList.append(statement);
} }
} }
return; return;
@ -469,13 +470,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
if (phrase.startsWith('@')) { if (phrase.startsWith('@')) {
if (mShowKeywords) { if (mShowKeywords) {
foreach (const QString& keyword,JavadocTags) { foreach (const QString& keyword,JavadocTags) {
PStatement statement = std::make_shared<Statement>(); addKeyword(keyword);
statement->command = keyword; // PStatement statement = std::make_shared<Statement>();
statement->kind = StatementKind::skKeyword; // statement->command = keyword;
statement->fullName = keyword; // statement->kind = StatementKind::skKeyword;
statement->usageCount = 0; // statement->fullName = keyword;
statement->freqTop = 0; // statement->usageCount = 0;
mFullCompletionStatementList.append(statement); // statement->freqTop = 0;
// mFullCompletionStatementList.append(statement);
} }
} }
return; return;
@ -506,23 +508,25 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
//add keywords //add keywords
if (mUseCppKeyword) { if (mUseCppKeyword) {
foreach (const QString& keyword,CppKeywords.keys()) { foreach (const QString& keyword,CppKeywords.keys()) {
PStatement statement = std::make_shared<Statement>(); addKeyword(keyword);
statement->command = keyword; // PStatement statement = std::make_shared<Statement>();
statement->kind = StatementKind::skKeyword; // statement->command = keyword;
statement->fullName = keyword; // statement->kind = StatementKind::skKeyword;
statement->usageCount = 0; // statement->fullName = keyword;
statement->freqTop = 0; // statement->usageCount = 0;
mFullCompletionStatementList.append(statement); // statement->freqTop = 0;
// mFullCompletionStatementList.append(statement);
} }
} else { } else {
foreach (const QString& keyword,CKeywords) { foreach (const QString& keyword,CKeywords) {
PStatement statement = std::make_shared<Statement>(); addKeyword(keyword);
statement->command = keyword; // PStatement statement = std::make_shared<Statement>();
statement->kind = StatementKind::skKeyword; // statement->command = keyword;
statement->fullName = keyword; // statement->kind = StatementKind::skKeyword;
statement->usageCount = 0; // statement->fullName = keyword;
statement->freqTop = 0; // statement->usageCount = 0;
mFullCompletionStatementList.append(statement); // statement->freqTop = 0;
// mFullCompletionStatementList.append(statement);
} }
} }
} }
@ -750,6 +754,39 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
} }
} }
void CodeCompletionPopup::getFullCompletionListFor(const QString &preWord)
{
mFullCompletionStatementList.clear();
if (preWord == "long") {
addKeyword("long");
addKeyword("double");
addKeyword("int");
} else if (preWord == "short") {
addKeyword("int");
} else if (preWord == "signed") {
addKeyword("long");
addKeyword("short");
addKeyword("int");
addKeyword("char");
} else if (preWord == "unsigned") {
addKeyword("long");
addKeyword("short");
addKeyword("int");
addKeyword("char");
}
}
void CodeCompletionPopup::addKeyword(const QString &keyword)
{
PStatement statement = std::make_shared<Statement>();
statement->command = keyword;
statement->kind = StatementKind::skKeyword;
statement->fullName = keyword;
statement->usageCount = 0;
statement->freqTop = 0;
mFullCompletionStatementList.append(statement);
}
bool CodeCompletionPopup::isIncluded(const QString &fileName) bool CodeCompletionPopup::isIncluded(const QString &fileName)
{ {
return mIncludedFiles.contains(fileName); return mIncludedFiles.contains(fileName);

View File

@ -31,7 +31,7 @@ public:
~CodeCompletionPopup(); ~CodeCompletionPopup();
void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback); void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback);
void prepareSearch(const QString& phrase, const QString& filename, int line); void prepareSearch(const QString& preWord, const QString& phrase, const QString& filename, int line);
bool search(const QString& phrase, bool autoHideOnSingleResult); bool search(const QString& phrase, bool autoHideOnSingleResult);
PStatement selectedStatement(); PStatement selectedStatement();
@ -74,6 +74,8 @@ private:
void addStatement(PStatement statement, const QString& fileName, int line); void addStatement(PStatement statement, const QString& fileName, int line);
void filterList(const QString& member); void filterList(const QString& member);
void getCompletionFor(const QString& fileName,const QString& phrase, int line); void getCompletionFor(const QString& fileName,const QString& phrase, int line);
void getFullCompletionListFor(const QString& preWord);
void addKeyword(const QString& keyword);
bool isIncluded(const QString& fileName); bool isIncluded(const QString& fileName);
private: private:
CodeCompletionListView * mListView; CodeCompletionListView * mListView;

View File

@ -13,12 +13,28 @@ CPUDialog::CPUDialog(QWidget *parent) :
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
ui->setupUi(this); ui->setupUi(this);
ui->txtCode->setHighlighter(highlighterManager.getCppHighlighter()); ui->txtCode->setHighlighter(highlighterManager.getCppHighlighter());
ui->txtCode->setReadOnly(true);
ui->txtCode->gutter().setShowLineNumbers(false);
ui->txtCode->setCaretUseTextColor(true);
ui->txtCode->codeFolding().indentGuides = false;
ui->txtCode->codeFolding().fillIndents = false;
ui->txtCode->setGutterWidth(0);
ui->txtCode->setUseCodeFolding(false);
highlighterManager.applyColorScheme(ui->txtCode->highlighter(), highlighterManager.applyColorScheme(ui->txtCode->highlighter(),
pSettings->editor().colorScheme()); pSettings->editor().colorScheme());
PColorSchemeItem item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_ACTIVE_LINE); PColorSchemeItem item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_ACTIVE_LINE);
if (item) { if (item) {
ui->txtCode->setActiveLineColor(item->background()); ui->txtCode->setActiveLineColor(item->background());
} }
item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_TEXT);
if (item) {
ui->txtCode->setForegroundColor(item->foreground());
ui->txtCode->setBackgroundColor(item->background());
} else {
ui->txtCode->setForegroundColor(palette().color(QPalette::Text));
ui->txtCode->setBackgroundColor(palette().color(QPalette::Base));
}
ui->lstRegister->setModel(pMainWindow->debugger()->registerModel()); ui->lstRegister->setModel(pMainWindow->debugger()->registerModel());
ui->rdIntel->setChecked(pSettings->debugger().useIntelStyle()); ui->rdIntel->setChecked(pSettings->debugger().useIntelStyle());

View File

@ -794,6 +794,11 @@ QIcon DarkFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOpt
return QProxyStyle::standardIcon(standardIcon, option, widget); return QProxyStyle::standardIcon(standardIcon, option, widget);
} }
void DarkFusionStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
{
QProxyStyle::drawComplexControl(control,option,painter,widget);
}
void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
const QWidget *widget) const const QWidget *widget) const
{ {
@ -807,8 +812,8 @@ void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *op
case CE_MenuItem: case CE_MenuItem:
// Draws one item in a popup menu. // Draws one item in a popup menu.
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
QColor highlightOutline = highlightedOutline; //QColor highlightOutline = highlightedOutline;
QColor highlight = option->palette.highlight().color(); //QColor highlight = option->palette.highlight().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
painter->save(); painter->save();
int w = 0; int w = 0;

View File

@ -16,6 +16,11 @@ public:
const QWidget *widget) const override; const QWidget *widget) const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
const QWidget *widget = nullptr) const override; const QWidget *widget = nullptr) const override;
// QStyle interface
public:
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
QPainter *painter, const QWidget *widget) const override;
}; };
#endif // DARKFUSIONSTYLE_H #endif // DARKFUSIONSTYLE_H

View File

@ -20,11 +20,12 @@ NewProjectDialog::NewProjectDialog(QWidget *parent) :
int i=0; int i=0;
QString projectName; QString projectName;
QString location; QString location;
location = excludeTrailingPathDelimiter(pSettings->dirs().projectDir());
while (true) { while (true) {
i++; i++;
projectName = tr("Project%1").arg(i); projectName = tr("Project%1").arg(i);
location = includeTrailingPathDelimiter(pSettings->dirs().projectDir()) + projectName; QString tempLocation = includeTrailingPathDelimiter(location)+projectName;
if (!QDir(location).exists()) if (!QDir(tempLocation).exists())
break; break;
} }
ui->txtProjectName->setText(projectName); ui->txtProjectName->setText(projectName);
@ -65,6 +66,11 @@ QString NewProjectDialog::getProjectName()
return ui->txtProjectName->text(); return ui->txtProjectName->text();
} }
bool NewProjectDialog::useAsDefaultProjectDir()
{
return ui->chkAsDefaultLocation->isChecked();
}
bool NewProjectDialog::isCProject() bool NewProjectDialog::isCProject()
{ {
return ui->rdCProject->isChecked(); return ui->rdCProject->isChecked();
@ -159,12 +165,7 @@ void NewProjectDialog::updateView()
void NewProjectDialog::updateProjectLocation() void NewProjectDialog::updateProjectLocation()
{ {
ui->txtLocation->setText( QString newLocation = ui->txtLocation->text();
includeTrailingPathDelimiter(
extractFilePath(
ui->txtLocation->text()))
+ ui->txtProjectName->text()
);
QListWidgetItem * current = ui->lstTemplates->currentItem(); QListWidgetItem * current = ui->lstTemplates->currentItem();
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled( ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
@ -210,7 +211,7 @@ void NewProjectDialog::on_btnBrowse_clicked()
} }
QString dir = QFileDialog::getExistingDirectory( QString dir = QFileDialog::getExistingDirectory(
this, this,
"Project directory", "Choose directory",
dirPath dirPath
); );
if (!dir.isEmpty()) { if (!dir.isEmpty()) {

View File

@ -20,6 +20,7 @@ public:
PProjectTemplate getTemplate(); PProjectTemplate getTemplate();
QString getLocation(); QString getLocation();
QString getProjectName(); QString getProjectName();
bool useAsDefaultProjectDir();
bool isCProject(); bool isCProject();
bool isCppProject(); bool isCppProject();
bool makeProjectDefault(); bool makeProjectDefault();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>670</width> <width>670</width>
<height>528</height> <height>546</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -85,6 +85,12 @@
<item> <item>
<widget class="QWidget" name="widget_3" native="true"> <widget class="QWidget" name="widget_3" native="true">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="2">
<widget class="QLineEdit" name="txtLocation"/>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLineEdit" name="txtProjectName"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -92,16 +98,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="txtLocation"/>
</item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QToolButton" name="btnBrowse"> <widget class="QToolButton" name="btnBrowse">
<property name="text"> <property name="text">
@ -114,8 +110,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2" colspan="2"> <item row="1" column="0">
<widget class="QLineEdit" name="txtProjectName"/> <widget class="QLabel" name="label_3">
<property name="text">
<string>Create in</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<widget class="QCheckBox" name="chkAsDefaultLocation">
<property name="text">
<string>Use as the default project location</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -184,6 +184,8 @@ int main(int argc, char** argv) {
SetStdHandle(STD_ERROR_HANDLE, hOutput); SetStdHandle(STD_ERROR_HANDLE, hOutput);
freopen("CONOUT$","w+",stdout); freopen("CONOUT$","w+",stdout);
freopen("CONOUT$","w+",stderr); freopen("CONOUT$","w+",stderr);
} else {
FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
} }
// Save starting timestamp // Save starting timestamp