- menu item for close / close all / maximize editor

This commit is contained in:
royqh1979 2021-09-02 20:12:16 +08:00
parent 805533664f
commit 9fa098960b
5 changed files with 319 additions and 226 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,8 @@ MainWindow::MainWindow(QWidget *parent)
mOpenClosingBottomPanel(false), mOpenClosingBottomPanel(false),
mOpenClosingLeftPanel(false), mOpenClosingLeftPanel(false),
mCheckSyntaxInBack(false), mCheckSyntaxInBack(false),
mClosing(false) mClosing(false),
mSystemTurnedOff(false)
{ {
ui->setupUi(this); ui->setupUi(this);
// status bar // status bar
@ -210,6 +211,9 @@ void MainWindow::updateEditorActions()
//code //code
ui->actionReformat_Code->setEnabled(false); ui->actionReformat_Code->setEnabled(false);
ui->actionClose->setEnabled(false);
ui->actionClose_All->setEnabled(false);
} else { } else {
ui->actionAuto_Detect->setEnabled(true); ui->actionAuto_Detect->setEnabled(true);
ui->actionEncode_in_ANSI->setEnabled(true); ui->actionEncode_in_ANSI->setEnabled(true);
@ -241,6 +245,9 @@ void MainWindow::updateEditorActions()
//code //code
ui->actionReformat_Code->setEnabled(true); ui->actionReformat_Code->setEnabled(true);
ui->actionClose->setEnabled(true);
ui->actionClose_All->setEnabled(true);
updateCompileActions(); updateCompileActions();
} }
@ -1082,6 +1089,17 @@ void MainWindow::buildContextMenus()
ui->watchView->addAction(ui->actionModify_Watch); ui->watchView->addAction(ui->actionModify_Watch);
} }
void MainWindow::maximizeEditor()
{
if (mLeftPanelOpenned || mBottomPanelOpenned) {
openCloseBottomPanel(false);
openCloseLeftPanel(false);
} else {
openCloseBottomPanel(true);
openCloseLeftPanel(true);
}
}
void MainWindow::onAutoSaveTimeout() void MainWindow::onAutoSaveTimeout()
{ {
if (!pSettings->editor().enableAutoSave()) if (!pSettings->editor().enableAutoSave())
@ -2050,13 +2068,7 @@ void MainWindow::on_splitterMessages_splitterMoved(int, int)
void MainWindow::on_EditorTabsLeft_tabBarDoubleClicked(int index) void MainWindow::on_EditorTabsLeft_tabBarDoubleClicked(int index)
{ {
if (mLeftPanelOpenned || mBottomPanelOpenned ) { maximizeEditor();
openCloseBottomPanel(false);
openCloseLeftPanel(false);
} else {
openCloseBottomPanel(true);
openCloseLeftPanel(true);
}
} }
@ -2067,5 +2079,20 @@ void MainWindow::on_actionClose_triggered()
if (e) { if (e) {
mEditorList->closeEditor(e); mEditorList->closeEditor(e);
} }
mClosing = false;
}
void MainWindow::on_actionClose_All_triggered()
{
mClosing = true;
mEditorList->closeAll(mSystemTurnedOff);
mClosing = false;
}
void MainWindow::on_actionMaximize_Editor_triggered()
{
maximizeEditor();
} }

View File

@ -119,11 +119,9 @@ public slots:
void onEndParsing(int total, int updateView); void onEndParsing(int total, int updateView);
void onEvalValueReady(const QString& value); void onEvalValueReady(const QString& value);
protected: private:
void openFiles(const QStringList& files); void openFiles(const QStringList& files);
void openFile(const QString& filename); void openFile(const QString& filename);
private:
CompileTarget getCompileTarget(); CompileTarget getCompileTarget();
bool debugInferiorhasBreakpoint(); bool debugInferiorhasBreakpoint();
void setupActions(); void setupActions();
@ -132,6 +130,7 @@ private:
void prepareDebugger(); void prepareDebugger();
void doAutoSave(Editor *e); void doAutoSave(Editor *e);
void buildContextMenus(); void buildContextMenus();
void maximizeEditor();
private slots: private slots:
void onAutoSaveTimeout(); void onAutoSaveTimeout();
@ -255,6 +254,10 @@ private slots:
void on_actionClose_triggered(); void on_actionClose_triggered();
void on_actionClose_All_triggered();
void on_actionMaximize_Editor_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;
@ -296,7 +299,8 @@ private:
CaretList mCaretList; CaretList mCaretList;
bool mClosing = false; bool mClosing;
bool mSystemTurnedOff;
// QWidget interface // QWidget interface

View File

@ -841,6 +841,8 @@
<property name="title"> <property name="title">
<string>Window</string> <string>Window</string>
</property> </property>
<addaction name="actionClose_All"/>
<addaction name="actionMaximize_Editor"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuEdit"/> <addaction name="menuEdit"/>
@ -1461,6 +1463,19 @@
<string>Ctrl+Shift+W</string> <string>Ctrl+Shift+W</string>
</property> </property>
</action> </action>
<action name="actionMaximize_Editor">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/030-dos.png</normalon>
</iconset>
</property>
<property name="text">
<string>Maximize Editor</string>
</property>
<property name="shortcut">
<string>Ctrl+F11</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>