- feature: save/restore main window layout
- feature: hide/show left panel - feature: double click editor title to maximize/restore it - fix: editor not updated when parser done
This commit is contained in:
parent
9ee608891c
commit
805533664f
|
@ -382,6 +382,12 @@ void Editor::wheelEvent(QWheelEvent *event) {
|
|||
void Editor::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
SynEdit::focusInEvent(event);
|
||||
if (mParser) {
|
||||
connect(mParser.get(),
|
||||
&CppParser::onEndParsing,
|
||||
this,
|
||||
&SynEdit::invalidate);
|
||||
}
|
||||
pMainWindow->updateEditorActions();
|
||||
pMainWindow->updateStatusbarForLineCol();
|
||||
pMainWindow->updateForStatusbarModeInfo();
|
||||
|
@ -391,6 +397,13 @@ void Editor::focusInEvent(QFocusEvent *event)
|
|||
void Editor::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
SynEdit::focusOutEvent(event);
|
||||
if (mParser) {
|
||||
disconnect(mParser.get(),
|
||||
&CppParser::onEndParsing,
|
||||
this,
|
||||
&SynEdit::invalidate);
|
||||
}
|
||||
pMainWindow->updateClassBrowserForEditor(nullptr);
|
||||
pMainWindow->updateEditorActions();
|
||||
pMainWindow->updateStatusbarForLineCol();
|
||||
pMainWindow->updateForStatusbarModeInfo();
|
||||
|
|
|
@ -34,9 +34,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui(new Ui::MainWindow),
|
||||
mSearchDialog(nullptr),
|
||||
mQuitting(false),
|
||||
mMessageControlChanged(false),
|
||||
mTabMessagesTogglingState(false),
|
||||
mCheckSyntaxInBack(false)
|
||||
mOpenClosingBottomPanel(false),
|
||||
mOpenClosingLeftPanel(false),
|
||||
mCheckSyntaxInBack(false),
|
||||
mClosing(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
// status bar
|
||||
|
@ -288,11 +289,26 @@ void MainWindow::applySettings()
|
|||
|
||||
void MainWindow::applyUISettings()
|
||||
{
|
||||
openCloseMessageSheet(false);
|
||||
mPreviousHeight = 250;
|
||||
const Settings::UI& settings = pSettings->ui();
|
||||
restoreGeometry(settings.mainWindowGeometry());
|
||||
restoreState(settings.mainWindowState());
|
||||
//we can show/hide left/bottom panels here, cause mainwindow layout is not calculated
|
||||
// ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex());
|
||||
// if (settings.bottomPanelOpenned()) {
|
||||
// mBottomPanelHeight = settings.bottomPanelHeight();
|
||||
// openCloseBottomPanel(true);
|
||||
// } else {
|
||||
// openCloseBottomPanel(false);
|
||||
// mBottomPanelHeight = settings.bottomPanelHeight();
|
||||
// }
|
||||
// ui->tabInfos->setCurrentIndex(settings.leftPanelIndex());
|
||||
// if (settings.leftPanelOpenned()) {
|
||||
// mLeftPanelWidth = settings.leftPanelWidth();
|
||||
// openCloseLeftPanel(true);
|
||||
// } else {
|
||||
// openCloseLeftPanel(false);
|
||||
// mLeftPanelWidth = settings.leftPanelWidth();
|
||||
// }
|
||||
}
|
||||
|
||||
QFileSystemWatcher *MainWindow::fileSystemWatcher()
|
||||
|
@ -612,7 +628,7 @@ bool MainWindow::compile(bool rebuild)
|
|||
mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename());
|
||||
}
|
||||
updateCompileActions();
|
||||
openCloseMessageSheet(true);
|
||||
openCloseBottomPanel(true);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabCompilerOutput);
|
||||
updateAppTitle();
|
||||
mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild);
|
||||
|
@ -929,19 +945,19 @@ void MainWindow::debug()
|
|||
|
||||
void MainWindow::showSearchPanel()
|
||||
{
|
||||
openCloseMessageSheet(true);
|
||||
openCloseBottomPanel(true);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabSearch);
|
||||
}
|
||||
|
||||
void MainWindow::openCloseMessageSheet(bool open)
|
||||
void MainWindow::openCloseBottomPanel(bool open)
|
||||
{
|
||||
// if Assigned(fReportToolWindow) then
|
||||
// Exit;
|
||||
if (mTabMessagesTogglingState)
|
||||
if (mOpenClosingBottomPanel)
|
||||
return;
|
||||
mTabMessagesTogglingState = true;
|
||||
mOpenClosingBottomPanel = true;
|
||||
auto action = finally([this]{
|
||||
mTabMessagesTogglingState = false;
|
||||
mOpenClosingBottomPanel = false;
|
||||
});
|
||||
// Switch between open and close
|
||||
if (open) {
|
||||
|
@ -949,12 +965,12 @@ void MainWindow::openCloseMessageSheet(bool open)
|
|||
int tabHeight = ui->tabMessages->tabBar()->height();
|
||||
ui->tabMessages->setMinimumHeight(tabHeight+5);
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
sizes[1] = mPreviousHeight;
|
||||
sizes[1] = mBottomPanelHeight;
|
||||
sizes[0] = std::max(1,totalSize - sizes[1]);
|
||||
ui->splitterMessages->setSizes(sizes);
|
||||
} else {
|
||||
QList<int> sizes = ui->splitterMessages->sizes();
|
||||
mPreviousHeight = sizes[1];
|
||||
mBottomPanelHeight = sizes[1];
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
int tabHeight = ui->tabMessages->tabBar()->height();
|
||||
ui->tabMessages->setMinimumHeight(tabHeight);
|
||||
|
@ -962,11 +978,43 @@ void MainWindow::openCloseMessageSheet(bool open)
|
|||
sizes[0] = std::max(1,totalSize - sizes[1]);
|
||||
ui->splitterMessages->setSizes(sizes);
|
||||
}
|
||||
mBottomPanelOpenned = open;
|
||||
QSplitterHandle* handle = ui->splitterMessages->handle(1);
|
||||
handle->setEnabled(open);
|
||||
int idxClose = ui->tabMessages->indexOf(ui->tabClose);
|
||||
ui->tabMessages->setTabVisible(idxClose,open);
|
||||
mTabMessagesTogglingState = false;
|
||||
}
|
||||
|
||||
void MainWindow::openCloseLeftPanel(bool open)
|
||||
{
|
||||
if (mOpenClosingLeftPanel)
|
||||
return;
|
||||
mOpenClosingLeftPanel = true;
|
||||
auto action = finally([this]{
|
||||
mOpenClosingLeftPanel = false;
|
||||
});
|
||||
// Switch between open and close
|
||||
if (open) {
|
||||
QList<int> sizes = ui->splitterInfos->sizes();
|
||||
int tabWidth = ui->tabInfos->tabBar()->width();
|
||||
ui->tabInfos->setMinimumWidth(tabWidth+5);
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
sizes[0] = mLeftPanelWidth;
|
||||
sizes[1] = std::max(1,totalSize - sizes[0]);
|
||||
ui->splitterInfos->setSizes(sizes);
|
||||
} else {
|
||||
QList<int> sizes = ui->splitterInfos->sizes();
|
||||
mLeftPanelWidth = sizes[0];
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
int tabWidth = ui->tabInfos->tabBar()->width();
|
||||
ui->tabInfos->setMinimumWidth(tabWidth);
|
||||
sizes[0] = tabWidth;
|
||||
sizes[1] = std::max(1,totalSize - sizes[0]);
|
||||
ui->splitterInfos->setSizes(sizes);
|
||||
}
|
||||
mLeftPanelOpenned = open;
|
||||
QSplitterHandle* handle = ui->splitterInfos->handle(1);
|
||||
handle->setEnabled(open);
|
||||
}
|
||||
|
||||
void MainWindow::prepareDebugger()
|
||||
|
@ -984,7 +1032,8 @@ void MainWindow::prepareDebugger()
|
|||
ui->tabInfos->setCurrentWidget(ui->tabWatch);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabDebug);
|
||||
ui->debugViews->setCurrentWidget(ui->tabDebugConsole);
|
||||
openCloseMessageSheet(true);
|
||||
openCloseBottomPanel(true);
|
||||
openCloseLeftPanel(true);
|
||||
|
||||
|
||||
// Reset watch vars
|
||||
|
@ -1138,7 +1187,7 @@ void MainWindow::on_actionNew_triggered()
|
|||
|
||||
void MainWindow::on_EditorTabsLeft_tabCloseRequested(int index)
|
||||
{
|
||||
Editor* editor = mEditorList->getEditor(index);
|
||||
Editor* editor = mEditorList->getEditor(index,ui->EditorTabsLeft);
|
||||
mEditorList->closeEditor(editor);
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1213,14 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||
Settings::UI& settings = pSettings->ui();
|
||||
settings.setMainWindowState(saveState());
|
||||
settings.setMainWindowGeometry(saveGeometry());
|
||||
pSettings->ui().save();
|
||||
settings.setBottomPanelHeight(mBottomPanelHeight);
|
||||
settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
|
||||
settings.setBottomPanelOpenned(mBottomPanelOpenned);
|
||||
settings.setLeftPanelWidth(mLeftPanelWidth);
|
||||
settings.setLeftPanelIndex(ui->tabInfos->currentIndex());
|
||||
settings.setLeftPanelOpenned(mLeftPanelOpenned);
|
||||
settings.save();
|
||||
|
||||
if (!mEditorList->closeAll(false)) {
|
||||
event->ignore();
|
||||
return ;
|
||||
|
@ -1175,6 +1231,27 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||
return;
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
const Settings::UI& settings = pSettings->ui();
|
||||
ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex());
|
||||
if (settings.bottomPanelOpenned()) {
|
||||
mBottomPanelHeight = settings.bottomPanelHeight();
|
||||
openCloseBottomPanel(true);
|
||||
} else {
|
||||
openCloseBottomPanel(false);
|
||||
mBottomPanelHeight = settings.bottomPanelHeight();
|
||||
}
|
||||
ui->tabInfos->setCurrentIndex(settings.leftPanelIndex());
|
||||
if (settings.leftPanelOpenned()) {
|
||||
mLeftPanelWidth = settings.leftPanelWidth();
|
||||
openCloseLeftPanel(true);
|
||||
} else {
|
||||
openCloseLeftPanel(false);
|
||||
mLeftPanelWidth = settings.leftPanelWidth();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_triggered()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
|
@ -1258,13 +1335,12 @@ void MainWindow::onCompileFinished()
|
|||
// and (ResourceOutput.Items.Count = 0)
|
||||
// and devData.AutoCloseProgress
|
||||
) {
|
||||
openCloseMessageSheet(false);
|
||||
openCloseBottomPanel(false);
|
||||
// Or open it if there is anything to show
|
||||
} else {
|
||||
if (ui->tableIssues->count() > 0) {
|
||||
if (ui->tabMessages->currentIndex() != i) {
|
||||
ui->tabMessages->setCurrentIndex(i);
|
||||
mMessageControlChanged = false;
|
||||
}
|
||||
// end else if (ResourceOutput.Items.Count > 0) then begin
|
||||
// if MessageControl.ActivePage <> ResSheet then begin
|
||||
|
@ -1272,7 +1348,7 @@ void MainWindow::onCompileFinished()
|
|||
// fMessageControlChanged := False;
|
||||
// end;
|
||||
// end;
|
||||
openCloseMessageSheet(true);
|
||||
openCloseBottomPanel(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1544,7 +1620,7 @@ void MainWindow::on_actionConvert_to_UTF_8_triggered()
|
|||
void MainWindow::on_tabMessages_tabBarClicked(int index)
|
||||
{
|
||||
if (index == ui->tabMessages->currentIndex()) {
|
||||
openCloseMessageSheet(!ui->splitterMessages->handle(1)->isEnabled());
|
||||
openCloseBottomPanel(!mBottomPanelOpenned);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1552,9 +1628,9 @@ void MainWindow::on_tabMessages_currentChanged(int index)
|
|||
{
|
||||
int idxClose = ui->tabMessages->indexOf(ui->tabClose);
|
||||
if (index == idxClose) {
|
||||
openCloseMessageSheet(false);
|
||||
openCloseBottomPanel(false);
|
||||
} else {
|
||||
openCloseMessageSheet(true);
|
||||
openCloseBottomPanel(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1949,3 +2025,47 @@ void MainWindow::on_actionForward_triggered()
|
|||
updateCaretActions();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_tabInfos_tabBarClicked(int index)
|
||||
{
|
||||
if (index == ui->tabInfos->currentIndex()) {
|
||||
openCloseLeftPanel(!mLeftPanelOpenned);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_splitterInfos_splitterMoved(int, int)
|
||||
{
|
||||
QList<int> sizes = ui->splitterMessages->sizes();
|
||||
mLeftPanelWidth = sizes[0];
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_splitterMessages_splitterMoved(int, int)
|
||||
{
|
||||
QList<int> sizes = ui->splitterMessages->sizes();
|
||||
mBottomPanelHeight = sizes[1];
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_EditorTabsLeft_tabBarDoubleClicked(int index)
|
||||
{
|
||||
if (mLeftPanelOpenned || mBottomPanelOpenned ) {
|
||||
openCloseBottomPanel(false);
|
||||
openCloseLeftPanel(false);
|
||||
} else {
|
||||
openCloseBottomPanel(true);
|
||||
openCloseLeftPanel(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionClose_triggered()
|
||||
{
|
||||
mClosing = true;
|
||||
Editor* e = mEditorList->getEditor();
|
||||
if (e) {
|
||||
mEditorList->closeEditor(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,8 @@ private:
|
|||
CompileTarget getCompileTarget();
|
||||
bool debugInferiorhasBreakpoint();
|
||||
void setupActions();
|
||||
void openCloseMessageSheet(bool open);
|
||||
void openCloseBottomPanel(bool open);
|
||||
void openCloseLeftPanel(bool open);
|
||||
void prepareDebugger();
|
||||
void doAutoSave(Editor *e);
|
||||
void buildContextMenus();
|
||||
|
@ -244,6 +245,16 @@ private slots:
|
|||
|
||||
void on_actionForward_triggered();
|
||||
|
||||
void on_tabInfos_tabBarClicked(int index);
|
||||
|
||||
void on_splitterInfos_splitterMoved(int pos, int index);
|
||||
|
||||
void on_splitterMessages_splitterMoved(int pos, int index);
|
||||
|
||||
void on_EditorTabsLeft_tabBarDoubleClicked(int index);
|
||||
|
||||
void on_actionClose_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
@ -272,20 +283,26 @@ private:
|
|||
PSearchResultTreeViewDelegate mSearchViewDelegate;
|
||||
ClassBrowserModel mClassBrowserModel;
|
||||
|
||||
bool mMessageControlChanged;
|
||||
bool mTabMessagesTogglingState;
|
||||
bool mCheckSyntaxInBack;
|
||||
int mPreviousHeight;
|
||||
bool mOpenClosingBottomPanel;
|
||||
int mBottomPanelHeight;
|
||||
bool mBottomPanelOpenned;
|
||||
bool mOpenClosingLeftPanel;
|
||||
int mLeftPanelWidth;
|
||||
bool mLeftPanelOpenned;
|
||||
PCompileSuccessionTask mCompileSuccessionTask;
|
||||
|
||||
QTimer mAutoSaveTimer;
|
||||
|
||||
CaretList mCaretList;
|
||||
|
||||
bool mClosing = false;
|
||||
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
};
|
||||
|
||||
extern MainWindow* pMainWindow;
|
||||
|
|
|
@ -751,7 +751,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>25</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -765,6 +765,9 @@
|
|||
<addaction name="actionSaveAs"/>
|
||||
<addaction name="actionSaveAll"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClose"/>
|
||||
<addaction name="actionClose_All"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
|
@ -834,12 +837,18 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="actionReformat_Code"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
<string>Window</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuSearch"/>
|
||||
<addaction name="menuCode"/>
|
||||
<addaction name="menuExecute"/>
|
||||
<addaction name="menuTools"/>
|
||||
<addaction name="menuWindow"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolbarMain">
|
||||
|
@ -1426,6 +1435,32 @@
|
|||
<string>Ctrl+Alt+Right</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/010-closefl.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose_All">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/009-closeall.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close All</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+W</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -3663,9 +3663,10 @@ void Settings::UI::doSave()
|
|||
saveValue("main_window_geometry",mMainWindowGeometry);
|
||||
saveValue("bottom_panel_openned",mBottomPanelOpenned);
|
||||
saveValue("bottom_panel_height",mBottomPanelHeight);
|
||||
saveValue()
|
||||
saveValue("bottom_panel_index",mBottomPanelIndex);
|
||||
saveValue("left_panel_openned",mLeftPanelOpenned);
|
||||
saveValue("left_panel_width",mLeftPanelWidth);
|
||||
saveValue("left_panel_index",mLeftPanelIndex);
|
||||
}
|
||||
|
||||
void Settings::UI::doLoad()
|
||||
|
@ -3674,6 +3675,8 @@ void Settings::UI::doLoad()
|
|||
mMainWindowGeometry = value("main_window_geometry",QByteArray()).toByteArray();
|
||||
mBottomPanelOpenned = boolValue("bottom_panel_openned",false);
|
||||
mBottomPanelHeight = intValue("bottom_panel_height",220);
|
||||
mBottomPanelIndex = intValue("bottom_panel_index",0);
|
||||
mLeftPanelOpenned = boolValue("left_panel_openned",true);
|
||||
mLeftPanelWidth = intValue("left_panel_width",250);
|
||||
mLeftPanelIndex = intValue("left_panel_index",2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue