Skip to content

Commit 71061a1

Browse files
committed
add an option
Allow users to choose whether to create a new file when launching the software.
1 parent f3b1e91 commit 71061a1

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

RedPandaIDE/settings.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,16 @@ void Settings::Editor::setSyntaxCheckWhenLineChanged(bool syntaxCheckWhenLineCha
529529
mSyntaxCheckWhenLineChanged = syntaxCheckWhenLineChanged;
530530
}
531531

532+
bool Settings::Editor::createFileAfterStartup() const
533+
{
534+
return mCreateFileAfterStartup;
535+
}
536+
537+
void Settings::Editor::setCreateFileAfterStartup(bool newCreateFileAfterStartup)
538+
{
539+
mCreateFileAfterStartup = newCreateFileAfterStartup;
540+
}
541+
532542
bool Settings::Editor::readOnlySytemHeader() const
533543
{
534544
return mReadOnlySytemHeader;
@@ -1400,6 +1410,7 @@ void Settings::Editor::doSave()
14001410

14011411
//misc
14021412
saveValue("default_encoding",mDefaultEncoding);
1413+
saveValue("create_file_after_startup",mCreateFileAfterStartup);
14031414
saveValue("readonly_system_header",mReadOnlySytemHeader);
14041415
saveValue("auto_load_last_files",mAutoLoadLastFiles);
14051416
saveValue("default_file_cpp",mDefaultFileCpp);
@@ -1558,6 +1569,7 @@ void Settings::Editor::doLoad()
15581569
mEnableAutolink = boolValue("enable_autolink",true);
15591570

15601571
//misc
1572+
mCreateFileAfterStartup = boolValue("create_file_after_startup", true);
15611573
mReadOnlySytemHeader = boolValue("readonly_system_header",true);
15621574
mAutoLoadLastFiles = boolValue("auto_load_last_files",true);
15631575
mDefaultFileCpp = boolValue("default_file_cpp",true);

RedPandaIDE/settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ class Settings
272272
bool syntaxCheckWhenLineChanged() const;
273273
void setSyntaxCheckWhenLineChanged(bool syntaxCheckWhenLineChanged);
274274

275+
bool createFileAfterStartup() const;
276+
void setCreateFileAfterStartup(bool newCreateFileAfterStartup);
277+
275278
bool readOnlySytemHeader() const;
276279
void setReadOnlySytemHeader(bool newReadOnlySytemHeader);
277280

@@ -510,6 +513,7 @@ class Settings
510513
//Misc
511514
QByteArray mDefaultEncoding;
512515
bool mAutoDetectFileEncoding;
516+
bool mCreateFileAfterStartup;
513517
bool mReadOnlySytemHeader;
514518
bool mAutoLoadLastFiles;
515519
bool mDefaultFileCpp;

RedPandaIDE/settingsdialog/editormiscwidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ EditorMiscWidget::~EditorMiscWidget()
3535

3636
void EditorMiscWidget::doLoad()
3737
{
38+
ui->chkCreateFileAfterStartup->setChecked(pSettings->editor().createFileAfterStartup());
3839
ui->chkReadonlySystemHeaders->setChecked(pSettings->editor().readOnlySytemHeader());
3940
ui->chkLoadLastFiles->setChecked(pSettings->editor().autoLoadLastFiles());
4041
if (pSettings->editor().defaultFileCpp()) {
@@ -76,6 +77,7 @@ void EditorMiscWidget::doLoad()
7677

7778
void EditorMiscWidget::doSave()
7879
{
80+
pSettings->editor().setCreateFileAfterStartup(ui->chkCreateFileAfterStartup->isChecked());
7981
pSettings->editor().setReadOnlySytemHeader(ui->chkReadonlySystemHeaders->isChecked());
8082
pSettings->editor().setAutoLoadLastFiles(ui->chkLoadLastFiles->isChecked());
8183
pSettings->editor().setDefaultFileCpp(ui->rbCppFile->isChecked());

RedPandaIDE/settingsdialog/editormiscwidget.ui

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
</property>
3636
</widget>
3737
</item>
38+
<item>
39+
<widget class="QCheckBox" name="chkCreateFileAfterStartup">
40+
<property name="text">
41+
<string>Create a new file after startup</string>
42+
</property>
43+
</widget>
44+
</item>
3845
<item>
3946
<widget class="QWidget" name="widget" native="true">
4047
<layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -101,7 +108,7 @@
101108
<item row="0" column="3">
102109
<spacer name="horizontalSpacer_2">
103110
<property name="orientation">
104-
<enum>Qt::Horizontal</enum>
111+
<enum>Qt::Orientation::Horizontal</enum>
105112
</property>
106113
<property name="sizeHint" stdset="0">
107114
<size>
@@ -136,7 +143,7 @@
136143
<item>
137144
<spacer name="horizontalSpacer">
138145
<property name="orientation">
139-
<enum>Qt::Horizontal</enum>
146+
<enum>Qt::Orientation::Horizontal</enum>
140147
</property>
141148
<property name="sizeHint" stdset="0">
142149
<size>
@@ -172,7 +179,7 @@
172179
<item>
173180
<spacer name="horizontalSpacer_3">
174181
<property name="orientation">
175-
<enum>Qt::Horizontal</enum>
182+
<enum>Qt::Orientation::Horizontal</enum>
176183
</property>
177184
<property name="sizeHint" stdset="0">
178185
<size>
@@ -188,7 +195,7 @@
188195
<item>
189196
<spacer name="verticalSpacer">
190197
<property name="orientation">
191-
<enum>Qt::Vertical</enum>
198+
<enum>Qt::Orientation::Vertical</enum>
192199
</property>
193200
<property name="sizeHint" stdset="0">
194201
<size>

0 commit comments

Comments
 (0)