work save
This commit is contained in:
parent
62527a04ae
commit
813bacebfb
|
@ -87,6 +87,12 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->actionEncode_in_ANSI->setCheckable(true);
|
ui->actionEncode_in_ANSI->setCheckable(true);
|
||||||
ui->actionEncode_in_UTF_8->setCheckable(true);
|
ui->actionEncode_in_UTF_8->setCheckable(true);
|
||||||
|
|
||||||
|
mMenuRecentFiles = new QMenu();
|
||||||
|
mMenuRecentFiles->setTitle(tr("Recent Files"));
|
||||||
|
ui->menuFile->insertMenu(ui->actionExit, mMenuRecentFiles);
|
||||||
|
ui->menuFile->insertSeparator(ui->actionExit);
|
||||||
|
rebuildOpenedFileHisotryMenu();
|
||||||
|
|
||||||
mCPUDialog = nullptr;
|
mCPUDialog = nullptr;
|
||||||
|
|
||||||
updateEditorActions();
|
updateEditorActions();
|
||||||
|
@ -330,6 +336,30 @@ void MainWindow::updateDebugEval(const QString &value)
|
||||||
ui->txtEvalOutput->appendPlainText(value);
|
ui->txtEvalOutput->appendPlainText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::rebuildOpenedFileHisotryMenu()
|
||||||
|
{
|
||||||
|
mMenuRecentFiles->clear();
|
||||||
|
for (QAction* action:mRecentFileActions) {
|
||||||
|
action->setParent(nullptr);
|
||||||
|
action->deleteLater();
|
||||||
|
}
|
||||||
|
mRecentFileActions.clear();
|
||||||
|
if (pSettings->history().openedFiles().size()==0) {
|
||||||
|
mMenuRecentFiles->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
mMenuRecentFiles->setEnabled(true);
|
||||||
|
for (QString filename: pSettings->history().openedFiles()) {
|
||||||
|
QAction* action = new QAction();
|
||||||
|
action->setText(filename);
|
||||||
|
connect(action, &QAction::triggered, [=,this](bool checked = false){
|
||||||
|
this->openFile(filename);
|
||||||
|
});
|
||||||
|
mRecentFileActions.append(action);
|
||||||
|
}
|
||||||
|
mMenuRecentFiles->addActions(mRecentFileActions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QPlainTextEdit *MainWindow::txtLocals()
|
QPlainTextEdit *MainWindow::txtLocals()
|
||||||
{
|
{
|
||||||
return ui->txtLocals;
|
return ui->txtLocals;
|
||||||
|
@ -1456,3 +1486,8 @@ void MainWindow::on_txtEvaludate_returnPressed()
|
||||||
mDebugger->sendCommand("print",s,false);
|
mDebugger->sendCommand("print",s,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionExit_triggered()
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
|
@ -68,13 +68,14 @@ public:
|
||||||
void changeDebugOutputLastline(const QString& text);
|
void changeDebugOutputLastline(const QString& text);
|
||||||
void updateDebugEval(const QString& value);
|
void updateDebugEval(const QString& value);
|
||||||
|
|
||||||
|
void rebuildOpenedFileHisotryMenu();
|
||||||
|
|
||||||
QPlainTextEdit* txtLocals();
|
QPlainTextEdit* txtLocals();
|
||||||
|
|
||||||
CPUDialog *cpuDialog() const;
|
CPUDialog *cpuDialog() const;
|
||||||
|
|
||||||
Debugger *debugger() const;
|
Debugger *debugger() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void openFiles(const QStringList& files);
|
void openFiles(const QStringList& files);
|
||||||
void openFile(const QString& filename);
|
void openFile(const QString& filename);
|
||||||
|
@ -165,6 +166,8 @@ private slots:
|
||||||
|
|
||||||
void on_txtEvaludate_returnPressed();
|
void on_txtEvaludate_returnPressed();
|
||||||
|
|
||||||
|
void on_actionExit_triggered();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onCompileLog(const QString& msg);
|
void onCompileLog(const QString& msg);
|
||||||
void onCompileIssue(PCompileIssue issue);
|
void onCompileIssue(PCompileIssue issue);
|
||||||
|
@ -188,10 +191,12 @@ private:
|
||||||
QLabel *mFileModeStatus;
|
QLabel *mFileModeStatus;
|
||||||
QMenu *mMenuEncoding;
|
QMenu *mMenuEncoding;
|
||||||
QMenu *mMenuEncodingList;
|
QMenu *mMenuEncodingList;
|
||||||
|
QMenu *mMenuRecentFiles;
|
||||||
QComboBox *mCompilerSet;
|
QComboBox *mCompilerSet;
|
||||||
CompilerManager *mCompilerManager;
|
CompilerManager *mCompilerManager;
|
||||||
Debugger *mDebugger;
|
Debugger *mDebugger;
|
||||||
CPUDialog *mCPUDialog;
|
CPUDialog *mCPUDialog;
|
||||||
|
QList<QAction *> mRecentFileActions;
|
||||||
|
|
||||||
bool mMessageControlChanged;
|
bool mMessageControlChanged;
|
||||||
bool mTabMessagesTogglingState;
|
bool mTabMessagesTogglingState;
|
||||||
|
|
|
@ -566,6 +566,8 @@
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionSaveAs"/>
|
<addaction name="actionSaveAs"/>
|
||||||
<addaction name="actionSaveAll"/>
|
<addaction name="actionSaveAll"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuTools">
|
<widget class="QMenu" name="menuTools">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -573,9 +575,9 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionOptions"/>
|
<addaction name="actionOptions"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuRun">
|
<widget class="QMenu" name="menuExecute">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Run</string>
|
<string>Execute</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionCompile"/>
|
<addaction name="actionCompile"/>
|
||||||
<addaction name="actionRun"/>
|
<addaction name="actionRun"/>
|
||||||
|
@ -614,7 +616,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuEdit"/>
|
<addaction name="menuEdit"/>
|
||||||
<addaction name="menuRun"/>
|
<addaction name="menuExecute"/>
|
||||||
<addaction name="menuTools"/>
|
<addaction name="menuTools"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
@ -1078,6 +1080,11 @@
|
||||||
<string>View CPU Window...</string>
|
<string>View CPU Window...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Exit</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -22,7 +22,8 @@ Settings::Settings(const QString &filename):
|
||||||
mEnvironment(this),
|
mEnvironment(this),
|
||||||
mCompilerSets(this),
|
mCompilerSets(this),
|
||||||
mExecutor(this),
|
mExecutor(this),
|
||||||
mDebugger(this)
|
mDebugger(this),
|
||||||
|
mHistory(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2350,16 +2351,29 @@ Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList &Settings::History::openedFiles()
|
||||||
|
{
|
||||||
|
return mOpenedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList &Settings::History::openedProjects()
|
||||||
|
{
|
||||||
|
return mOpenedProjects;
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::History::addToOpenedFiles(const QString &filename)
|
bool Settings::History::addToOpenedFiles(const QString &filename)
|
||||||
{
|
{
|
||||||
if (!QFile(filename).exists())
|
if (!QFile(filename).exists())
|
||||||
return false;
|
return false;
|
||||||
if (openedFiles().indexOf(filename)>=0)
|
int index = mOpenedFiles.indexOf(filename);
|
||||||
return false;
|
if (index>=0) {
|
||||||
if (openedFiles().size()>=15) {
|
mOpenedFiles.removeAt(index);
|
||||||
openedFiles().pop_front();
|
|
||||||
}
|
}
|
||||||
openedFiles().append(filename);
|
if (mOpenedFiles.size()>=15) {
|
||||||
|
mOpenedFiles.pop_back();
|
||||||
|
}
|
||||||
|
mOpenedFiles.push_front(filename);
|
||||||
|
save();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,13 @@ void CPUDialog::closeEvent(QCloseEvent *event)
|
||||||
void CPUDialog::on_rdIntel_toggled(bool)
|
void CPUDialog::on_rdIntel_toggled(bool)
|
||||||
{
|
{
|
||||||
sendSyntaxCommand();
|
sendSyntaxCommand();
|
||||||
|
pSettings->debugger().setUseIntelStyle(ui->rdIntel->isChecked());
|
||||||
|
pSettings->debugger().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUDialog::on_rdATT_toggled(bool)
|
void CPUDialog::on_rdATT_toggled(bool)
|
||||||
{
|
{
|
||||||
sendSyntaxCommand();
|
sendSyntaxCommand();
|
||||||
|
pSettings->debugger().setUseIntelStyle(ui->rdIntel->isChecked());
|
||||||
|
pSettings->debugger().save();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue