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
- 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

View File

@ -199,6 +199,7 @@ HEADERS += \
thememanager.h \
todoparser.h \
toolsmanager.h \
version.h \
widgets/aboutdialog.h \
widgets/bookmarkmodel.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 "../platform.h"
#include "../editor.h"
#include "../version.h"
#include <QDir>
@ -339,14 +340,14 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->editor()->fileEncoding(),
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_ASCII) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) {
} else if (unit->encoding()==ENCODING_SYSTEM_DEFAULT) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(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)
{
PCppParser parser;
Editor * editor;
Editor * editor=nullptr;
std::shared_ptr<Project> project;
if (scope == SearchFileScope::currentFile) {
editor = pMainWindow->editorList()->getEditor();

View File

@ -692,6 +692,16 @@ void Editor::keyPressEvent(QKeyEvent *event)
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
if (!lastWord.isEmpty()) {
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
// if devEditor.UseTabnine then
// ShowTabnineCompletion;
@ -713,7 +723,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
}
}
setSelText(ch);
showCompletion(false);
showCompletion("",false);
handled=true;
return;
}
@ -727,7 +737,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
showCompletion("",false);
handled=true;
return;
}
@ -739,7 +749,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
showCompletion("",false);
handled=true;
return;
}
@ -910,7 +920,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid())
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;
if ( (line == mHighlightCharPos1.Line)
&& (aChar == mHighlightCharPos1.Char)) {
@ -1139,7 +1150,7 @@ void Editor::inputMethodEvent(QInputMethodEvent *event)
return;
}
}
showCompletion(false);
showCompletion("",false);
return;
}
}
@ -1398,10 +1409,6 @@ void Editor::onStatusChanged(SynStatusChanges changes)
if (changes.testFlag(SynStatusChange::scCaretX)
|| changes.testFlag(SynStatusChange::scCaretY)) {
invalidateLine(mHighlightCharPos1.Line);
invalidateLine(mHighlightCharPos2.Line);
mHighlightCharPos1 = BufferCoord{0,0};
mHighlightCharPos2 = BufferCoord{0,0};
if (mTabStopBegin >=0) {
if (mTabStopY==caretY()) {
if (mLineAfterTabStop.isEmpty()) {
@ -1427,7 +1434,11 @@ void Editor::onStatusChanged(SynStatusChanges changes)
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?
int lineLength = lineText().length();
int ch = caretX() - 2;
@ -1461,8 +1472,11 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// scSelection includes anything caret related
if (changes.testFlag(SynStatusChange::scSelection)) {
if (!selAvail()) {
if (!selAvail() && pSettings->editor().highlightCurrentWord()) {
mCurrentHighlightedWord = wordAtCursor();
} else if (selAvail() && blockBegin() == wordStart()
&& blockEnd() == wordEnd()){
mCurrentHighlightedWord = selText();
} else {
mCurrentHighlightedWord = "";
}
@ -1904,20 +1918,20 @@ bool Editor::handleCodeCompletion(QChar key)
switch(key.unicode()) {
case '.':
setSelText(key);
showCompletion(false);
showCompletion("",false);
return true;
case '>':
setSelText(key);
if ((caretX() > 2) && (lineText().length() >= 2) &&
(lineText()[caretX() - 3] == '-'))
showCompletion(false);
showCompletion("",false);
return true;
case ':':
ExecuteCommand(SynEditorCommand::ecChar,':',nullptr);
//setSelText(key);
if ((caretX() > 2) && (lineText().length() >= 2) &&
(lineText()[caretX() - 3] == ':'))
showCompletion(false);
showCompletion("",false);
return true;
case '/':
case '\\':
@ -2260,7 +2274,7 @@ void Editor::exportAsHTML(const QString &htmlFilename)
exporter.SaveToFile(htmlFilename);
}
void Editor::showCompletion(bool autoComplete)
void Editor::showCompletion(const QString& preWord,bool autoComplete)
{
if (!pSettings->codeCompletion().enabled())
return;
@ -2337,8 +2351,7 @@ void Editor::showCompletion(bool autoComplete)
if (word.isEmpty())
word=getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion);
//if not fCompletionBox.Visible then
mCompletionPopup->prepareSearch(word, mFilename, pBeginPos.Line);
mCompletionPopup->prepareSearch(preWord, word, mFilename, pBeginPos.Line);
// Filter the whole statement list
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);
QuoteStatus getQuoteStatus();
void showCompletion(bool autoComplete);
void showCompletion(const QString& preWord, bool autoComplete);
void showHeaderCompletion(bool autoComplete);
bool testInFunc(int x,int y);

View File

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
//Translation must be loaded first
QTranslator trans;
QTranslator trans,transQt;
QString settingFilename = getSettingFilename();
if (!isGreenEdition()) {
QDir::setCurrent(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]);
@ -91,8 +91,13 @@ int main(int argc, char *argv[])
QSettings languageSetting(settingFilename,QSettings::IniFormat);
languageSetting.beginGroup(SETTING_ENVIRONMENT);
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");

View File

@ -20,6 +20,7 @@
#include "widgets/darkfusionstyle.h"
#include "problems/problemcasevalidator.h"
#include "widgets/ojproblempropertywidget.h"
#include "version.h"
#include <QCloseEvent>
#include <QComboBox>
@ -511,6 +512,10 @@ void MainWindow::applySettings()
else
QApplication::setStyle("fusion");
qApp->setPalette(appTheme->palette());
//fix for qstatusbar bug
mFileEncodingStatus->setPalette(appTheme->palette());
mFileModeStatus->setPalette(appTheme->palette());
mFileInfoStatus->setPalette(appTheme->palette());
updateEditorColorSchemes();
QFont font(pSettings->environment().interfaceFont(),
@ -529,7 +534,7 @@ void MainWindow::applySettings()
if (!mTcpServer.listen(QHostAddress::LocalHost,pSettings->executor().competivieCompanionPort())) {
// QMessageBox::critical(nullptr,
// 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/>"
// +tr("You can turn off competitive companion support in the Problem Set options.")
// + "<BR/>"
@ -569,7 +574,8 @@ void MainWindow::applyUISettings()
ui->actionFiles->setChecked(settings.showFiles());
showHideInfosTab(ui->tabFiles,settings.showFiles());
ui->actionProblem_Set->setChecked(settings.showProblemSet());
showHideInfosTab(ui->tabProblemSet,settings.showProblemSet());
showHideInfosTab(ui->tabProblemSet,settings.showProblemSet()
&& pSettings->executor().enableProblemSet());
ui->actionIssues->setChecked(settings.showIssues());
showHideMessagesTab(ui->tabIssues,settings.showIssues());
@ -584,7 +590,8 @@ void MainWindow::applyUISettings()
ui->actionBookmark->setChecked(settings.showBookmark());
showHideMessagesTab(ui->tabBookmark,settings.showBookmark());
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
}
@ -2669,12 +2676,14 @@ void MainWindow::onLstProblemSetContextMenu(const QPoint &pos)
QAction * action = new QAction(tr("select other file..."),menuSetAnswer);
connect(action, &QAction::triggered,
[problem,this](){
QFileDialog dialog;
QString filename = QFileDialog::getOpenFileName(
this,
tr("Select Answer Source File"),
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()) {
QDir::setCurrent(extractFileDir(filename));
problem->answerProgram = filename;
@ -3133,7 +3142,7 @@ void MainWindow::onFileChanged(const QString &path)
if (e) {
if (fileExists(path)) {
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?"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::No) == QMessageBox::Yes) {
@ -3144,7 +3153,7 @@ void MainWindow::onFileChanged(const QString &path)
}
}
} 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?"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes) == QMessageBox::No) {
@ -3201,6 +3210,15 @@ CPUDialog *MainWindow::cpuDialog() const
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();
}
@ -3770,7 +3788,7 @@ void MainWindow::on_actionUnfoldAll_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor != NULL ) {
//editor->clearFolds();
editor->unCollpaseAll();
}
}
@ -3778,8 +3796,7 @@ void MainWindow::on_actionFoldAll_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor != NULL ) {
//editor->clearFolds();
//editor->foldAll();
editor->collapseAll();
}
}
@ -4549,6 +4566,10 @@ void MainWindow::on_actionNew_Project_triggered()
{
NewProjectDialog dialog;
if (dialog.exec() == QDialog::Accepted) {
if (dialog.useAsDefaultProjectDir()) {
pSettings->dirs().setProjectDir(dialog.getLocation());
pSettings->dirs().save();
}
// Take care of the currently opened project
QString s;
if (mProject) {
@ -4569,19 +4590,20 @@ void MainWindow::on_actionNew_Project_triggered()
}
//Create the project folder
QDir dir(dialog.getLocation());
QString location = includeTrailingPathDelimiter(dialog.getLocation())+dialog.getProjectName();
QDir dir(location);
if (!dir.exists()) {
if (QMessageBox::question(this,
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::Yes) {
return;
}
if (!dir.mkpath(dialog.getLocation())) {
if (!dir.mkpath(location)) {
QMessageBox::critical(this,
tr("Can't create folder"),
tr("Failed to create folder '%1'.").arg(dialog.getLocation()),
tr("Failed to create folder '%1'.").arg(location),
QMessageBox::Yes);
return;
}
@ -4590,14 +4612,14 @@ void MainWindow::on_actionNew_Project_triggered()
// if cbDefault.Checked then
// devData.DefCpp := rbCpp.Checked;
s = includeTrailingPathDelimiter(dialog.getLocation())
s = includeTrailingPathDelimiter(location)
+ dialog.getProjectName() + "." + DEV_PROJECT_EXT;
if (fileExists(s)) {
QString saveName = QFileDialog::getSaveFileName(
this,
tr("Save new project as"),
dialog.getLocation(),
location,
tr("Red panda Dev-C++ project file (*.dev)"));
if (!saveName.isEmpty()) {
s = saveName;
@ -4645,46 +4667,7 @@ void MainWindow::on_actionSaveAll_triggered()
void MainWindow::on_actionProject_New_File_triggered()
{
int idx = -1;
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();
newProjectUnitFile();
}
@ -4733,9 +4716,14 @@ void MainWindow::on_actionRemove_from_project_triggered()
continue;
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--) {
if (selected.contains(i)) {
mProject->removeEditor(i,true);
mProject->removeUnit(i,true,removeFile);
}
}
@ -4943,6 +4931,50 @@ void MainWindow::prepareTabMessagesData()
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)
{
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
@ -5374,9 +5406,10 @@ void MainWindow::on_treeFiles_doubleClicked(const QModelIndex &index)
QString filepath = mFileSystemModel.filePath(index);
QFileInfo file(filepath);
if (file.isFile()) {
Editor * editor = mEditorList->getEditorByFilename(filepath);
if (editor) {
editor->activate();
if (getFileType(filepath)==FileType::Project) {
openProject(filepath);
} else {
openFile(filepath);
}
}
}

View File

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

View File

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

View File

@ -2153,6 +2153,21 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q
true,
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 {
functionStatement = addStatement(
functionClass,

View File

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

View File

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

View File

@ -148,7 +148,7 @@ public:
const QString& customFileName="");
Editor* openUnit(int index);
void rebuildNodes();
bool removeEditor(int index, bool doClose);
bool removeUnit(int index, bool doClose, bool removeFile = false);
bool removeFolder(PFolderNode node);
void resetParserProjectFiles();
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)
{
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 PSynEditKeyStroke();
@ -118,8 +120,10 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers
int key2, Qt::KeyboardModifiers modifiers2)
{
for (PSynEditKeyStroke& keyStroke:mList) {
if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==key2
&& keyStroke->keyModifiers2() ==modifiers2)
if (keyStroke->key() == key
&& keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier)
&& keyStroke->key2()==key2
&& keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier))
return keyStroke;
}
return PSynEditKeyStroke();
@ -202,8 +206,8 @@ void SynEditKeyStrokes::resetDefaults()
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::ShiftModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier|Qt::ShiftModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier);
add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier);
add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier);
add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier);

View File

@ -95,7 +95,11 @@ QString SynGutter::formatLineNumber(int line)
{
line += (mLineNumberStart - 1);
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)
@ -315,10 +319,9 @@ void SynGutter::setBorderColor(const QColor &value)
}
SynEditMark::SynEditMark(QObject *parent)
SynEditMark::SynEditMark(QObject * /*parent*/)
{
mBookmarkNum = -1;
}
int SynEditMark::Char() const
@ -405,7 +408,7 @@ void SynEditMark::setLine(int line)
}
}
SynBookMarkOpt::SynBookMarkOpt(QObject *parent)
SynBookMarkOpt::SynBookMarkOpt(QObject */*parent*/)
{
mDrawBookmarksFirst = true;
mEnableKeys = true;

View File

@ -19,6 +19,8 @@
#include <QResizeEvent>
#include <QStyleHints>
#include <QMessageBox>
#include <QDrag>
#include <QMimeData>
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);
mOrigRedoList = mRedoList;
mForegroundColor=palette().color(QPalette::Text);
mBackgroundColor=palette().color(QPalette::Base);
mCaretColor = QColorConstants::Red;
mCaretUseTextColor = false;
mActiveLineColor = QColorConstants::Svg::lightblue;
@ -115,7 +119,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mBlockEnd = mBlockBegin;
mOptions = eoAutoIndent
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick
| eoHideShowScrollbars ;
mScrollTimer = new QTimer(this);
mScrollTimer->setInterval(100);
@ -142,6 +147,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
setAttribute(Qt::WA_InputMethodEnabled);
//setMouseTracking(true);
setAcceptDrops(true);
}
int SynEdit::displayLineCount() const
@ -1063,6 +1069,20 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord
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)
{
int X = event->pos().x();
@ -1208,6 +1228,8 @@ void SynEdit::showCaret()
{
if (m_blinkTimerId==0)
m_blinkTimerId = startTimer(500);
m_blinkStatus = 1;
updateCaret();
}
void SynEdit::hideCaret()
@ -1429,7 +1451,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
QString s;
while (startLine>=1) {
s = mLines->getString(startLine-1);
if (!s.trimmed().isEmpty()) {
if (!s.startsWith('#') && !s.trimmed().isEmpty()) {
break;
}
startLine -- ;
@ -3580,25 +3602,40 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
} else {
ct =mOverwriteCaret;
}
QColor caretColor;
if (mCaretUseTextColor) {
painter.setPen(mForegroundColor);
caretColor = mForegroundColor;
} else {
painter.setPen(mCaretColor);
caretColor = mCaretColor;
}
switch(ct) {
case SynEditCaretType::ctVerticalLine:
painter.drawLine(rcClip.left()+1,rcClip.top(),rcClip.left()+1,rcClip.bottom());
case SynEditCaretType::ctVerticalLine: {
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;
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;
}
case SynEditCaretType::ctBlock:
painter.fillRect(rcClip, mCaretColor);
painter.fillRect(rcClip, caretColor);
break;
case SynEditCaretType::ctHalfBlock:
QRect rc=rcClip;
rc.setTop(rcClip.top()+rcClip.height() / 2);
painter.fillRect(rcClip, mCaretColor);
painter.fillRect(rcClip, caretColor);
break;
}
}
@ -4922,12 +4959,13 @@ void SynEdit::doLinesInserted(int firstLine, int count)
// end;
}
void SynEdit::properSetLine(int ALine, const QString &ALineText)
void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify)
{
if (mOptions.testFlag(eoTrimTrailingSpaces))
mLines->putString(ALine,TrimRight(ALineText));
else
mLines->putString(ALine,ALineText);
if (mOptions.testFlag(eoTrimTrailingSpaces)) {
mLines->putString(ALine,TrimRight(ALineText),notify);
} else {
mLines->putString(ALine,ALineText,notify);
}
}
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)
{
mLines->beginUpdate();
auto actionLines = finally([this] {
mLines->endUpdate();
});
QString sLeftSide;
QString sRightSide;
QString Str;
@ -5029,6 +5071,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
bool bChangeScroll;
// int SpaceCount;
int Result = 0;
int startLine = mCaretY;
sLeftSide = lineText().mid(0, mCaretX - 1);
if (mCaretX - 1 > sLeftSide.length()) {
if (StringIsBlank(sLeftSide))
@ -5070,9 +5113,9 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = P;
P = GetEOL(Value,Start);
if (P == Start) {
if (P<Value.length())
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
else
if (P<Value.length())
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
else
Str = sRightSide;
} else {
Str = Value.mid(Start, P-Start);
@ -5083,7 +5126,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str);
}
}
properSetLine(caretY - 1, Str);
properSetLine(caretY - 1, Str,false);
rescanRange(caretY);
Result++;
}
@ -5097,6 +5140,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
internalSetCaretXY(BufferCoord{lineText().length()+1,caretY});
} else
internalSetCaretXY(BufferCoord{Str.length() - sRightSide.length()+1,caretY});
onLinesPutted(startLine-1,Result+1);
return Result;
}
@ -5899,7 +5943,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
&& (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
bStartDrag = true;
bStartDrag = true;
}
if (bStartDrag) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging);
@ -5959,7 +6003,15 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) {
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);
}
// } else if ((buttons == Qt::LeftButton) && (X > mGutterWidth)) {
@ -6017,14 +6069,26 @@ void SynEdit::leaveEvent(QEvent *)
void SynEdit::wheelEvent(QWheelEvent *event)
{
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;
if (event->modifiers() == Qt::ShiftModifier) {
if (event->angleDelta().y()>0) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
event->accept();
return;
} else if (event->angleDelta().y()<0) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
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);
}
@ -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
{
if (mOptions.testFlag(eoScrollPastEof))

View File

@ -219,6 +219,8 @@ public:
const BufferCoord& ptBefore,
const BufferCoord& ptAfter);
void collapseAll();
void unCollpaseAll();
void uncollapseAroundLine(int line);
PSynEditFoldRange foldHidesLine(int line);
void setSelLength(int Value);
@ -504,7 +506,7 @@ private:
const QString& Value, bool AddToUndoList);
void doLinesDeleted(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 insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
int insertTextByNormalMode(const QString& Value);
@ -696,6 +698,10 @@ private:
int mMouseWheelScrollSpeed;
BufferCoord mDragCaretSave;
BufferCoord mDragSelBeginSave;
BufferCoord mDragSelEndSave;
friend class SynEditTextPainter;
// QWidget interface
@ -722,6 +728,13 @@ bool viewportEvent(QEvent * event) override;
// QWidget interface
public:
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

View File

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

View File

@ -67,7 +67,7 @@ public:
void setContents(const QStringList& text);
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 beginUpdate();

View File

@ -234,3 +234,8 @@ void ContentsCoord::setCh(int 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 {
int Char;
int Line;
bool operator==(const BufferCoord& coord);
};
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();
mCodeFormatter.load();
mUI.load();
mDirs.load();
}
Settings::Dirs &Settings::dirs()
@ -161,12 +162,7 @@ QString Settings::Dirs::templateDir() const
QString Settings::Dirs::projectDir() const
{
if (isGreenEdition()) {
return includeTrailingPathDelimiter(app()) + "projects";
} else {
return includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0])
+ "projects";
}
return mProjectDir;
}
QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
@ -205,12 +201,24 @@ QString Settings::Dirs::executable() const
void Settings::Dirs::doSave()
{
saveValue("projectDir",mProjectDir);
}
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):
@ -524,6 +532,26 @@ void Settings::Editor::setUseUTF8ByDefault(bool 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
{
return mEnableTooltips;
@ -994,6 +1022,7 @@ void Settings::Editor::doSave()
saveValue("show_indent_lines", mShowIndentLines);
saveValue("indent_line_color",mIndentLineColor);
saveValue("fill_indents",mfillIndents);
// caret
saveValue("enhance_home_key",mEnhanceHomeKey);
saveValue("enhance_end_key",mEnhanceEndKey);
@ -1003,6 +1032,10 @@ void Settings::Editor::doSave()
saveValue("caret_use_text_color",mCaretUseTextColor);
saveValue("caret_color",mCaretColor);
//highlight
saveValue("highlight_matching_braces",mHighlightMathingBraces);
saveValue("highlight_current_word",mHighlightCurrentWord);
//scroll
saveValue("auto_hide_scroll_bar", mAutoHideScrollbar);
saveValue("scroll_past_eof", mScrollPastEof);
@ -1112,6 +1145,10 @@ void Settings::Editor::doLoad()
mCaretUseTextColor = boolValue("caret_use_text_color",true);
mCaretColor = colorValue("caret_color",QColorConstants::Svg::yellow);
//highlight
mHighlightMathingBraces = boolValue("highlight_matching_braces",true);
mHighlightCurrentWord = boolValue("highlight_current_word",true);
//scroll
mAutoHideScrollbar = boolValue("auto_hide_scroll_bar", false);
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();
int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt();
mSettings->mSettings.endGroup();
bool loadError = false;
for (int i=0;i<listSize;i++) {
PCompilerSet pSet=loadSet(i);
if (!pSet) {
loadError = true;
break;
}
mList.push_back(pSet);
}
if (loadError) {
mList.clear();
mDefaultIndex = -1;
}
PCompilerSet pCurrentSet = defaultSet();
if (pCurrentSet) {
QString msg;
@ -2419,6 +2464,9 @@ void Settings::CompilerSets::loadSets()
mDefaultIndex = mList.size()-1;
pCurrentSet = defaultSet();
if (!pCurrentSet) {
mList.clear();
mDefaultIndex = -1;
saveSets();
return;
}
saveSet(mDefaultIndex);
@ -2442,6 +2490,9 @@ void Settings::CompilerSets::loadSets()
findSets();
pCurrentSet = defaultSet();
if (!pCurrentSet) {
mList.clear();
mDefaultIndex = -1;
saveSets();
return;
}
saveSets();
@ -2641,6 +2692,8 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
mSettings->mSettings.endGroup();
if (pSet->binDirs().isEmpty())
return PCompilerSet();
pSet->setDirectories(pSet->binDirs()[0]);
pSet->setDefines();
return pSet;
@ -2835,6 +2888,9 @@ void Settings::Executor::doSave()
saveValue("redirect_input",mRedirectInput);
saveValue("input_filename",mInputFilename);
//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 executable() const;
// _Base interface
void setProjectDir(const QString &newProjectDir);
protected:
void doSave() override;
void doLoad() override;
private:
QString mProjectDir;
};
class Editor: public _Base {
@ -336,6 +339,12 @@ public:
bool useUTF8ByDefault() const;
void setUseUTF8ByDefault(bool newUseUTF8ByDefault);
bool highlightCurrentWord() const;
void setHighlightCurrentWord(bool newHighlightCurrentWord);
bool highlightMathingBraces() const;
void setHighlightMathingBraces(bool newHighlightMathingBraces);
private:
//General
// indents
@ -354,6 +363,10 @@ public:
bool mCaretUseTextColor;
QColor mCaretColor;
//highlights
bool mHighlightCurrentWord;
bool mHighlightMathingBraces;
//scroll
bool mAutoHideScrollbar;
bool mScrollPastEof;

View File

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

View File

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

View File

@ -228,6 +228,29 @@
</layout>
</widget>
</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>
<widget class="QGroupBox" name="groupBox">
<property name="title">

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
#include "editorlist.h"
#include "editor.h"
#include "project.h"
#include "version.h"
const QByteArray GuessTextEncoding(const QByteArray& text){
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 "ui_aboutdialog.h"
#include "../systemconsts.h"
#include "../version.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
@ -8,9 +10,20 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
ui->setupUi(this);
ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + DEVCPP_VERSION);
#ifdef __GNUC__
ui->lblContent->setText(ui->lblContent->text()
.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()

View File

@ -59,7 +59,7 @@ void CodeCompletionPopup::setKeypressedCallback(const KeyPressedCallback &newKey
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);
if (!isEnabled())
@ -69,19 +69,19 @@ void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &fi
QCursor oldCursor = cursor();
setCursor(Qt::CursorShape::WaitCursor);
mIncludedFiles = mParser->getFileIncludes(filename);
getCompletionFor(filename,phrase,line);
if (preWord.isEmpty()) {
mIncludedFiles = mParser->getFileIncludes(filename);
getCompletionFor(filename,phrase,line);
if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) {
mPhrase = phrase.mid(1);
getCompletionFor(filename,mPhrase,line);
if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) {
mPhrase = phrase.mid(1);
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);
}
@ -453,13 +453,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
if (phrase.startsWith('#')) {
if (mShowKeywords) {
foreach (const QString& keyword, CppDirectives) {
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);
addKeyword(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);
}
}
return;
@ -469,13 +470,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
if (phrase.startsWith('@')) {
if (mShowKeywords) {
foreach (const QString& keyword,JavadocTags) {
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);
addKeyword(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);
}
}
return;
@ -506,23 +508,25 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
//add keywords
if (mUseCppKeyword) {
foreach (const QString& keyword,CppKeywords.keys()) {
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);
addKeyword(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);
}
} else {
foreach (const QString& keyword,CKeywords) {
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);
addKeyword(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);
}
}
}
@ -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)
{
return mIncludedFiles.contains(fileName);

View File

@ -31,7 +31,7 @@ public:
~CodeCompletionPopup();
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);
PStatement selectedStatement();
@ -74,6 +74,8 @@ private:
void addStatement(PStatement statement, const QString& fileName, int line);
void filterList(const QString& member);
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);
private:
CodeCompletionListView * mListView;

View File

@ -13,12 +13,28 @@ CPUDialog::CPUDialog(QWidget *parent) :
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
ui->setupUi(this);
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(),
pSettings->editor().colorScheme());
PColorSchemeItem item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_ACTIVE_LINE);
if (item) {
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->rdIntel->setChecked(pSettings->debugger().useIntelStyle());

View File

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

View File

@ -16,6 +16,11 @@ public:
const QWidget *widget) const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>670</width>
<height>528</height>
<height>546</height>
</rect>
</property>
<property name="windowTitle">
@ -85,6 +85,12 @@
<item>
<widget class="QWidget" name="widget_3" native="true">
<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">
<widget class="QLabel" name="label_2">
<property name="text">
@ -92,16 +98,6 @@
</property>
</widget>
</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">
<widget class="QToolButton" name="btnBrowse">
<property name="text">
@ -114,8 +110,19 @@
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLineEdit" name="txtProjectName"/>
<item row="1" column="0">
<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>
</layout>
</widget>

View File

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