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_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;
|
||||
|
||||
updateEditorActions();
|
||||
|
@ -330,6 +336,30 @@ void MainWindow::updateDebugEval(const QString &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()
|
||||
{
|
||||
return ui->txtLocals;
|
||||
|
@ -1456,3 +1486,8 @@ void MainWindow::on_txtEvaludate_returnPressed()
|
|||
mDebugger->sendCommand("print",s,false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -68,13 +68,14 @@ public:
|
|||
void changeDebugOutputLastline(const QString& text);
|
||||
void updateDebugEval(const QString& value);
|
||||
|
||||
void rebuildOpenedFileHisotryMenu();
|
||||
|
||||
QPlainTextEdit* txtLocals();
|
||||
|
||||
CPUDialog *cpuDialog() const;
|
||||
|
||||
Debugger *debugger() const;
|
||||
|
||||
|
||||
protected:
|
||||
void openFiles(const QStringList& files);
|
||||
void openFile(const QString& filename);
|
||||
|
@ -165,6 +166,8 @@ private slots:
|
|||
|
||||
void on_txtEvaludate_returnPressed();
|
||||
|
||||
void on_actionExit_triggered();
|
||||
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
|
@ -188,10 +191,12 @@ private:
|
|||
QLabel *mFileModeStatus;
|
||||
QMenu *mMenuEncoding;
|
||||
QMenu *mMenuEncodingList;
|
||||
QMenu *mMenuRecentFiles;
|
||||
QComboBox *mCompilerSet;
|
||||
CompilerManager *mCompilerManager;
|
||||
Debugger *mDebugger;
|
||||
CPUDialog *mCPUDialog;
|
||||
QList<QAction *> mRecentFileActions;
|
||||
|
||||
bool mMessageControlChanged;
|
||||
bool mTabMessagesTogglingState;
|
||||
|
|
|
@ -566,6 +566,8 @@
|
|||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSaveAs"/>
|
||||
<addaction name="actionSaveAll"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
|
@ -573,9 +575,9 @@
|
|||
</property>
|
||||
<addaction name="actionOptions"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuRun">
|
||||
<widget class="QMenu" name="menuExecute">
|
||||
<property name="title">
|
||||
<string>Run</string>
|
||||
<string>Execute</string>
|
||||
</property>
|
||||
<addaction name="actionCompile"/>
|
||||
<addaction name="actionRun"/>
|
||||
|
@ -614,7 +616,7 @@
|
|||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuRun"/>
|
||||
<addaction name="menuExecute"/>
|
||||
<addaction name="menuTools"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
|
@ -1078,6 +1080,11 @@
|
|||
<string>View CPU Window...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -22,7 +22,8 @@ Settings::Settings(const QString &filename):
|
|||
mEnvironment(this),
|
||||
mCompilerSets(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)
|
||||
{
|
||||
if (!QFile(filename).exists())
|
||||
return false;
|
||||
if (openedFiles().indexOf(filename)>=0)
|
||||
return false;
|
||||
if (openedFiles().size()>=15) {
|
||||
openedFiles().pop_front();
|
||||
int index = mOpenedFiles.indexOf(filename);
|
||||
if (index>=0) {
|
||||
mOpenedFiles.removeAt(index);
|
||||
}
|
||||
openedFiles().append(filename);
|
||||
if (mOpenedFiles.size()>=15) {
|
||||
mOpenedFiles.pop_back();
|
||||
}
|
||||
mOpenedFiles.push_front(filename);
|
||||
save();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
@ -75,9 +75,13 @@ void CPUDialog::closeEvent(QCloseEvent *event)
|
|||
void CPUDialog::on_rdIntel_toggled(bool)
|
||||
{
|
||||
sendSyntaxCommand();
|
||||
pSettings->debugger().setUseIntelStyle(ui->rdIntel->isChecked());
|
||||
pSettings->debugger().save();
|
||||
}
|
||||
|
||||
void CPUDialog::on_rdATT_toggled(bool)
|
||||
{
|
||||
sendSyntaxCommand();
|
||||
pSettings->debugger().setUseIntelStyle(ui->rdIntel->isChecked());
|
||||
pSettings->debugger().save();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue