- change: panels can be relocated

This commit is contained in:
Roy Qu 2022-05-20 18:43:01 +08:00
parent c3db151c2c
commit 964909a31e
4 changed files with 1615 additions and 1636 deletions

View File

@ -4,6 +4,7 @@ Red Panda C++ Version 1.0.9
- fix: input with ime in column mode not correctly handled - fix: input with ime in column mode not correctly handled
- fix: copy & paste in column mode not correctly handled - fix: copy & paste in column mode not correctly handled
- fix: crash when project name is selected in the project view and try create new project file - fix: crash when project name is selected in the project view and try create new project file
- change: panels can be relocated
Red Panda C++ Version 1.0.8 Red Panda C++ Version 1.0.8
- enhancement: auto complete '#undef' - enhancement: auto complete '#undef'

View File

@ -103,8 +103,6 @@ MainWindow::MainWindow(QWidget *parent)
mSearchDialog(nullptr), mSearchDialog(nullptr),
mQuitting(false), mQuitting(false),
mCheckSyntaxInBack(false), mCheckSyntaxInBack(false),
mOpenClosingBottomPanel(false),
mOpenClosingLeftPanel(false),
mShouldRemoveAllSettings(false), mShouldRemoveAllSettings(false),
mClosing(false), mClosing(false),
mOpenningFiles(false), mOpenningFiles(false),
@ -327,9 +325,6 @@ MainWindow::MainWindow(QWidget *parent)
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>(); mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
mFunctionTip = std::make_shared<FunctionTooltipWidget>(); mFunctionTip = std::make_shared<FunctionTooltipWidget>();
mBottomPanelHeight = 0;
mLeftPanelWidth = 0;
mClassBrowserModel.setColors(mStatementColors); mClassBrowserModel.setColors(mStatementColors);
connect(&mAutoSaveTimer, &QTimer::timeout, connect(&mAutoSaveTimer, &QTimer::timeout,
@ -779,8 +774,6 @@ void MainWindow::updateDPI(int oldDPI, int newDPI)
//applySettings(); //applySettings();
if (oldDPI<1) if (oldDPI<1)
oldDPI = 1; oldDPI = 1;
mBottomPanelHeight = mBottomPanelHeight * newDPI / oldDPI ;
mLeftPanelWidth = mLeftPanelWidth * newDPI / oldDPI ;
} }
void MainWindow::onFileSaved(const QString &path, bool inProject) void MainWindow::onFileSaved(const QString &path, bool inProject)
@ -1874,72 +1867,74 @@ void MainWindow::showCPUInfoDialog()
void MainWindow::openCloseBottomPanel(bool open) void MainWindow::openCloseBottomPanel(bool open)
{ {
ui->dockMessages->setVisible(open);
// if Assigned(fReportToolWindow) then // if Assigned(fReportToolWindow) then
// Exit; // Exit;
if (mOpenClosingBottomPanel) // if (mOpenClosingBottomPanel)
return; // return;
mOpenClosingBottomPanel = true; // mOpenClosingBottomPanel = true;
auto action = finally([this]{ // auto action = finally([this]{
mOpenClosingBottomPanel = false; // mOpenClosingBottomPanel = false;
}); // });
// Switch between open and close // // Switch between open and close
if (open) { // if (open) {
QList<int> sizes = ui->splitterMessages->sizes(); // QList<int> sizes = ui->splitterMessages->sizes();
int tabHeight = ui->tabMessages->tabBar()->height(); // int tabHeight = ui->tabMessages->tabBar()->height();
ui->tabMessages->setMinimumHeight(tabHeight+5); // ui->tabMessages->setMinimumHeight(tabHeight+5);
if ( mBottomPanelHeight < ui->tabMessages->tabBar()->height() + 5) // if ( mBottomPanelHeight < ui->tabMessages->tabBar()->height() + 5)
mBottomPanelHeight = ui->tabMessages->tabBar()->height() + 5; // mBottomPanelHeight = ui->tabMessages->tabBar()->height() + 5;
int totalSize = sizes[0] + sizes[1]; // int totalSize = sizes[0] + sizes[1];
sizes[1] = mBottomPanelHeight; // sizes[1] = mBottomPanelHeight;
sizes[0] = std::max(1,totalSize - sizes[1]); // sizes[0] = std::max(1,totalSize - sizes[1]);
ui->splitterMessages->setSizes(sizes); // ui->splitterMessages->setSizes(sizes);
} else { // } else {
QList<int> sizes = ui->splitterMessages->sizes(); // QList<int> sizes = ui->splitterMessages->sizes();
mBottomPanelHeight = sizes[1]; // mBottomPanelHeight = sizes[1];
int totalSize = sizes[0] + sizes[1]; // int totalSize = sizes[0] + sizes[1];
int tabHeight = ui->tabMessages->tabBar()->height(); // int tabHeight = ui->tabMessages->tabBar()->height();
ui->tabMessages->setMinimumHeight(tabHeight); // ui->tabMessages->setMinimumHeight(tabHeight);
sizes[1] = tabHeight; // sizes[1] = tabHeight;
sizes[0] = std::max(1,totalSize - sizes[1]); // sizes[0] = std::max(1,totalSize - sizes[1]);
ui->splitterMessages->setSizes(sizes); // ui->splitterMessages->setSizes(sizes);
} // }
mBottomPanelOpenned = open; // mBottomPanelOpenned = open;
QSplitterHandle* handle = ui->splitterMessages->handle(1); // QSplitterHandle* handle = ui->splitterMessages->handle(1);
handle->setEnabled(mBottomPanelOpenned); // handle->setEnabled(mBottomPanelOpenned);
} }
void MainWindow::openCloseLeftPanel(bool open) void MainWindow::openCloseLeftPanel(bool open)
{ {
if (mOpenClosingLeftPanel) ui->dockFiles->setVisible(open);
return; // if (mOpenClosingLeftPanel)
mOpenClosingLeftPanel = true; // return;
auto action = finally([this]{ // mOpenClosingLeftPanel = true;
mOpenClosingLeftPanel = false; // auto action = finally([this]{
}); // mOpenClosingLeftPanel = false;
// Switch between open and close // });
if (open ) { // // Switch between open and close
QList<int> sizes = ui->splitterInfos->sizes(); // if (open ) {
int tabWidth = ui->tabInfos->tabBar()->width(); // QList<int> sizes = ui->splitterInfos->sizes();
ui->tabInfos->setMinimumWidth(tabWidth+5); // int tabWidth = ui->tabInfos->tabBar()->width();
if (mLeftPanelWidth < ui->tabInfos->tabBar()->width() + 5) // ui->tabInfos->setMinimumWidth(tabWidth+5);
mLeftPanelWidth = ui->tabInfos->tabBar()->width() + 5; // if (mLeftPanelWidth < ui->tabInfos->tabBar()->width() + 5)
int totalSize = sizes[0] + sizes[1]; // mLeftPanelWidth = ui->tabInfos->tabBar()->width() + 5;
sizes[0] = mLeftPanelWidth; // int totalSize = sizes[0] + sizes[1];
sizes[1] = std::max(1,totalSize - sizes[0]); // sizes[0] = mLeftPanelWidth;
ui->splitterInfos->setSizes(sizes); // sizes[1] = std::max(1,totalSize - sizes[0]);
} else { // ui->splitterInfos->setSizes(sizes);
QList<int> sizes = ui->splitterInfos->sizes(); // } else {
mLeftPanelWidth = sizes[0]; // QList<int> sizes = ui->splitterInfos->sizes();
int totalSize = sizes[0] + sizes[1]; // mLeftPanelWidth = sizes[0];
int tabWidth = ui->tabInfos->tabBar()->width(); // int totalSize = sizes[0] + sizes[1];
ui->tabInfos->setMinimumWidth(tabWidth); // int tabWidth = ui->tabInfos->tabBar()->width();
sizes[0] = tabWidth; // ui->tabInfos->setMinimumWidth(tabWidth);
sizes[1] = std::max(1,totalSize - sizes[0]); // sizes[0] = tabWidth;
ui->splitterInfos->setSizes(sizes); // sizes[1] = std::max(1,totalSize - sizes[0]);
} // ui->splitterInfos->setSizes(sizes);
mLeftPanelOpenned = open; // }
QSplitterHandle* handle = ui->splitterInfos->handle(1); // mLeftPanelOpenned = open;
handle->setEnabled(mLeftPanelOpenned); // QSplitterHandle* handle = ui->splitterInfos->handle(1);
// handle->setEnabled(mLeftPanelOpenned);
} }
void MainWindow::prepareDebugger() void MainWindow::prepareDebugger()
@ -2717,7 +2712,7 @@ void MainWindow::buildEncodingMenu()
void MainWindow::maximizeEditor() void MainWindow::maximizeEditor()
{ {
if (mLeftPanelOpenned || mBottomPanelOpenned) { if (ui->dockFiles->isVisible() || ui->dockMessages->isVisible()) {
openCloseBottomPanel(false); openCloseBottomPanel(false);
openCloseLeftPanel(false); openCloseLeftPanel(false);
} else { } else {
@ -4311,12 +4306,8 @@ void MainWindow::closeEvent(QCloseEvent *event) {
Settings::UI& settings = pSettings->ui(); Settings::UI& settings = pSettings->ui();
settings.setMainWindowState(saveState()); settings.setMainWindowState(saveState());
settings.setMainWindowGeometry(saveGeometry()); settings.setMainWindowGeometry(saveGeometry());
settings.setBottomPanelHeight(mBottomPanelHeight);
settings.setBottomPanelIndex(ui->tabMessages->currentIndex()); settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
settings.setBottomPanelOpenned(mBottomPanelOpenned);
settings.setLeftPanelWidth(mLeftPanelWidth);
settings.setLeftPanelIndex(ui->tabInfos->currentIndex()); settings.setLeftPanelIndex(ui->tabInfos->currentIndex());
settings.setLeftPanelOpenned(mLeftPanelOpenned);
settings.setShowStatusBar(ui->actionStatus_Bar->isChecked()); settings.setShowStatusBar(ui->actionStatus_Bar->isChecked());
settings.setShowToolWindowBars(ui->actionTool_Window_Bars->isChecked()); settings.setShowToolWindowBars(ui->actionTool_Window_Bars->isChecked());
@ -4413,44 +4404,20 @@ void MainWindow::showEvent(QShowEvent *)
applySettings(); applySettings();
const Settings::UI& settings = pSettings->ui(); const Settings::UI& settings = pSettings->ui();
ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex()); ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex());
if (settings.bottomPanelOpenned()) {
mBottomPanelHeight = settings.bottomPanelHeight();
openCloseBottomPanel(true);
} else {
openCloseBottomPanel(false);
mBottomPanelHeight = settings.bottomPanelHeight();
}
ui->tabInfos->setCurrentIndex(settings.leftPanelIndex()); ui->tabInfos->setCurrentIndex(settings.leftPanelIndex());
if (settings.leftPanelOpenned()) {
mLeftPanelWidth = settings.leftPanelWidth();
openCloseLeftPanel(true);
} else {
openCloseLeftPanel(false);
mLeftPanelWidth = settings.leftPanelWidth();
}
} }
void MainWindow::hideEvent(QHideEvent *) void MainWindow::hideEvent(QHideEvent *)
{ {
Settings::UI& settings = pSettings->ui(); Settings::UI& settings = pSettings->ui();
settings.setBottomPanelIndex(ui->tabMessages->currentIndex()); settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
settings.setBottomPanelOpenned(mBottomPanelOpenned);
settings.setBottomPanelHeight(mBottomPanelHeight);
settings.setLeftPanelIndex(ui->tabInfos->currentIndex()); settings.setLeftPanelIndex(ui->tabInfos->currentIndex());
settings.setLeftPanelOpenned(mLeftPanelOpenned);
settings.setLeftPanelWidth(mLeftPanelWidth);
} }
bool MainWindow::event(QEvent *event) bool MainWindow::event(QEvent *event)
{ {
if (event->type()==DPI_CHANGED_EVENT) { if (event->type()==DPI_CHANGED_EVENT) {
applySettings(); applySettings();
int saveHeight = mBottomPanelHeight ;
int saveWidth = mLeftPanelWidth;
openCloseBottomPanel(mBottomPanelOpenned);
openCloseLeftPanel(mLeftPanelOpenned);
mBottomPanelHeight = saveHeight;
mLeftPanelWidth = saveWidth;
event->accept(); event->accept();
return true; return true;
} }
@ -4965,7 +4932,7 @@ void MainWindow::on_actionConvert_to_UTF_8_triggered()
void MainWindow::on_tabMessages_tabBarClicked(int index) void MainWindow::on_tabMessages_tabBarClicked(int index)
{ {
if (index == ui->tabMessages->currentIndex()) { if (index == ui->tabMessages->currentIndex()) {
openCloseBottomPanel(!mBottomPanelOpenned); // openCloseBottomPanel(!mBottomPanelOpenned);
} }
} }
@ -5397,25 +5364,11 @@ void MainWindow::on_actionForward_triggered()
void MainWindow::on_tabInfos_tabBarClicked(int index) void MainWindow::on_tabInfos_tabBarClicked(int index)
{ {
if (index == ui->tabInfos->currentIndex()) { if (index == ui->tabInfos->currentIndex()) {
openCloseLeftPanel(!mLeftPanelOpenned); // openCloseLeftPanel(!mLeftPanelOpenned);
} }
} }
void MainWindow::on_splitterInfos_splitterMoved(int, int)
{
QList<int> sizes = ui->splitterInfos->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) void MainWindow::on_EditorTabsLeft_tabBarDoubleClicked(int)
{ {
maximizeEditor(); maximizeEditor();
@ -7713,3 +7666,52 @@ void MainWindow::on_actionCompiler_Options_triggered()
); );
} }
void MainWindow::on_dockFiles_dockLocationChanged(const Qt::DockWidgetArea &area)
{
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
ui->tabInfos->setTabPosition(QTabWidget::TabPosition::South);
break;
case Qt::DockWidgetArea::LeftDockWidgetArea:
ui->tabInfos->setTabPosition(QTabWidget::TabPosition::West);
break;
case Qt::DockWidgetArea::RightDockWidgetArea:
ui->tabInfos->setTabPosition(QTabWidget::TabPosition::East);
break;
default:
break;
}
}
void MainWindow::on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area)
{
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
ui->splitterDebug->setOrientation(Qt::Orientation::Horizontal);
ui->splitterProblem->setOrientation(Qt::Orientation::Horizontal);
break;
default:
ui->splitterDebug->setOrientation(Qt::Orientation::Vertical);
ui->splitterProblem->setOrientation(Qt::Orientation::Vertical);
}
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::South);
break;
case Qt::DockWidgetArea::LeftDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::West);
break;
case Qt::DockWidgetArea::RightDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::East);
break;
default:
break;
}
}

View File

@ -442,10 +442,6 @@ private slots:
void on_tabInfos_tabBarClicked(int index); 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_EditorTabsLeft_tabBarDoubleClicked(int index);
void on_EditorTabsRight_tabBarDoubleClicked(int index); void on_EditorTabsRight_tabBarDoubleClicked(int index);
@ -674,6 +670,10 @@ private slots:
void on_actionCompiler_Options_triggered(); void on_actionCompiler_Options_triggered();
void on_dockFiles_dockLocationChanged(const Qt::DockWidgetArea &area);
void on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;
@ -720,12 +720,6 @@ private:
int mOJProblemSetNameCounter; int mOJProblemSetNameCounter;
bool mCheckSyntaxInBack; bool mCheckSyntaxInBack;
bool mOpenClosingBottomPanel;
int mBottomPanelHeight;
bool mBottomPanelOpenned;
bool mOpenClosingLeftPanel;
int mLeftPanelWidth;
bool mLeftPanelOpenned;
bool mShouldRemoveAllSettings; bool mShouldRemoveAllSettings;
PCompileSuccessionTask mCompileSuccessionTask; PCompileSuccessionTask mCompileSuccessionTask;

File diff suppressed because it is too large Load Diff