panel size can be saved

This commit is contained in:
Roy Qu 2022-05-22 14:31:13 +08:00
parent da1647538f
commit d1024e4c9d
10 changed files with 1024 additions and 908 deletions

View File

@ -1749,10 +1749,6 @@
<source>Timeout for Case Valdation</source> <source>Timeout for Case Valdation</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Sec</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Case Editor Font</source> <source>Case Editor Font</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -1769,6 +1765,10 @@
<source>Only Monospaced</source> <source>Only Monospaced</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>ms</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>FileAssociationModel</name> <name>FileAssociationModel</name>
@ -4456,6 +4456,14 @@
<source>Compiler Options...</source> <source>Compiler Options...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Explorer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Messages</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>NewClassDialog</name> <name>NewClassDialog</name>
@ -4643,7 +4651,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Time(sec)</source> <source>Time(ms)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -5621,10 +5629,6 @@
<source>Abort compilation on first error (-Wfatal-errors)</source> <source>Abort compilation on first error (-Wfatal-errors)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Profile</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Generate profiling info for analysis (-pg)</source> <source>Generate profiling info for analysis (-pg)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

File diff suppressed because it is too large Load Diff

View File

@ -1749,10 +1749,6 @@
<source>Timeout for Case Valdation</source> <source>Timeout for Case Valdation</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Sec</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Case Editor Font</source> <source>Case Editor Font</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -1769,6 +1765,10 @@
<source>Only Monospaced</source> <source>Only Monospaced</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>ms</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>FileAssociationModel</name> <name>FileAssociationModel</name>
@ -4456,6 +4456,14 @@
<source>Compiler Options...</source> <source>Compiler Options...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Explorer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Messages</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>NewClassDialog</name> <name>NewClassDialog</name>
@ -4643,7 +4651,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Time(sec)</source> <source>Time(ms)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -5621,10 +5629,6 @@
<source>Abort compilation on first error (-Wfatal-errors)</source> <source>Abort compilation on first error (-Wfatal-errors)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Profile</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Generate profiling info for analysis (-pg)</source> <source>Generate profiling info for analysis (-pg)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View File

@ -352,6 +352,7 @@ MainWindow::MainWindow(QWidget *parent)
updateAppTitle(); updateAppTitle();
//applySettings(); //applySettings();
applyUISettings(); applyUISettings();
initDocks();
updateProjectView(); updateProjectView();
updateEditorActions(); updateEditorActions();
updateCaretActions(); updateCaretActions();
@ -700,6 +701,8 @@ void MainWindow::applySettings()
ui->menuGit->menuAction()->setVisible(pSettings->vcs().gitOk()); ui->menuGit->menuAction()->setVisible(pSettings->vcs().gitOk());
openCloseExplorerPanel(!ui->tabExplorer->isShrinked());
openCloseMessagesPanel(!ui->tabMessages->isShrinked());
} }
void MainWindow::applyUISettings() void MainWindow::applyUISettings()
@ -708,7 +711,7 @@ void MainWindow::applyUISettings()
restoreGeometry(settings.mainWindowGeometry()); restoreGeometry(settings.mainWindowGeometry());
restoreState(settings.mainWindowState()); restoreState(settings.mainWindowState());
ui->actionTool_Window_Bars->setChecked(settings.showToolWindowBars()); ui->actionTool_Window_Bars->setChecked(settings.showToolWindowBars());
ui->tabInfos->setVisible(settings.showToolWindowBars()); ui->tabExplorer->setVisible(settings.showToolWindowBars());
ui->tabMessages->setVisible(settings.showToolWindowBars()); ui->tabMessages->setVisible(settings.showToolWindowBars());
ui->actionStatus_Bar->setChecked(settings.showStatusBar()); ui->actionStatus_Bar->setChecked(settings.showStatusBar());
ui->statusbar->setVisible(settings.showStatusBar()); ui->statusbar->setVisible(settings.showStatusBar());
@ -740,7 +743,13 @@ void MainWindow::applyUISettings()
ui->actionProblem->setChecked(settings.showProblem()); ui->actionProblem->setChecked(settings.showProblem());
showHideMessagesTab(ui->tabProblem,settings.showProblem() showHideMessagesTab(ui->tabProblem,settings.showProblem()
&& pSettings->executor().enableProblemSet()); && pSettings->executor().enableProblemSet());
//we can't show/hide left/bottom panels here, cause mainwindow layout is not calculated
ui->tabMessages->setBeforeShrinkSize(settings.messagesTabsSize());
ui->tabExplorer->setBeforeShrinkSize(settings.explorerTabsSize());
if (settings.shrinkMessagesTabs())
ui->tabMessages->setShrinkedFlag(true);
if (settings.shrinkExplorerTabs())
ui->tabExplorer->setShrinkedFlag(true);
} }
QFileSystemWatcher *MainWindow::fileSystemWatcher() QFileSystemWatcher *MainWindow::fileSystemWatcher()
@ -748,6 +757,14 @@ QFileSystemWatcher *MainWindow::fileSystemWatcher()
return &mFileSystemWatcher; return &mFileSystemWatcher;
} }
void MainWindow::initDocks()
{
ui->dockExplorer->setMinimumSize(0,0);
ui->dockMessages->setMinimumSize(0,0);
setDockExplorerToArea(dockWidgetArea(ui->dockExplorer));
setDockMessagesToArea(dockWidgetArea(ui->dockMessages));
}
void MainWindow::removeActiveBreakpoints() void MainWindow::removeActiveBreakpoints()
{ {
for (int i=0;i<mEditorList->pageCount();i++) { for (int i=0;i<mEditorList->pageCount();i++) {
@ -1139,8 +1156,8 @@ void MainWindow::openProject(const QString &filename, bool openFiles)
} }
} }
ui->tabProject->setVisible(true); ui->tabProject->setVisible(true);
ui->tabInfos->setCurrentWidget(ui->tabProject); ui->tabExplorer->setCurrentWidget(ui->tabProject);
openCloseLeftPanel(true); openCloseExplorerPanel(true);
// { // {
// LeftPageControl.ActivePage := LeftProjectSheet; // LeftPageControl.ActivePage := LeftProjectSheet;
// fLeftPageControlChanged := False; // fLeftPageControlChanged := False;
@ -1272,7 +1289,7 @@ void MainWindow::updateActionIcons()
btn->setIconSize(iconSize); btn->setIconSize(iconSize);
} }
ui->tabInfos->setIconSize(iconSize); ui->tabExplorer->setIconSize(iconSize);
ui->tabMessages->setIconSize(iconSize); ui->tabMessages->setIconSize(iconSize);
ui->EditorTabsLeft->setIconSize(iconSize); ui->EditorTabsLeft->setIconSize(iconSize);
ui->EditorTabsRight->setIconSize(iconSize); ui->EditorTabsRight->setIconSize(iconSize);
@ -1404,21 +1421,21 @@ void MainWindow::updateActionIcons()
mProblem_Properties->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PROPERTIES)); mProblem_Properties->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PROPERTIES));
int idx = ui->tabInfos->indexOf(ui->tabWatch); int idx = ui->tabExplorer->indexOf(ui->tabWatch);
if (idx>=0) if (idx>=0)
ui->tabInfos->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_RUN_ADD_WATCH)); ui->tabExplorer->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_RUN_ADD_WATCH));
idx = ui->tabInfos->indexOf(ui->tabProject); idx = ui->tabExplorer->indexOf(ui->tabProject);
if (idx>=0) if (idx>=0)
ui->tabInfos->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW)); ui->tabExplorer->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW));
idx = ui->tabInfos->indexOf(ui->tabFiles); idx = ui->tabExplorer->indexOf(ui->tabFiles);
if (idx>=0) if (idx>=0)
ui->tabInfos->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_VIEW_FILES)); ui->tabExplorer->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_VIEW_FILES));
idx = ui->tabInfos->indexOf(ui->tabStructure); idx = ui->tabExplorer->indexOf(ui->tabStructure);
if (idx>=0) if (idx>=0)
ui->tabInfos->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_VIEW_CLASSBROWSER)); ui->tabExplorer->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_VIEW_CLASSBROWSER));
idx = ui->tabInfos->indexOf(ui->tabProblemSet); idx = ui->tabExplorer->indexOf(ui->tabProblemSet);
if (idx>=0) if (idx>=0)
ui->tabInfos->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_SET)); ui->tabExplorer->setTabIcon(idx,pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_SET));
idx = ui->tabMessages->indexOf(ui->tabIssues); idx = ui->tabMessages->indexOf(ui->tabIssues);
if (idx>=0) if (idx>=0)
@ -1500,7 +1517,7 @@ bool MainWindow::compile(bool rebuild)
if (mCompileSuccessionTask) { if (mCompileSuccessionTask) {
mCompileSuccessionTask->filename = mProject->executable(); mCompileSuccessionTask->filename = mProject->executable();
} }
openCloseBottomPanel(true); openCloseMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput); ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
mCompilerManager->compileProject(mProject,rebuild); mCompilerManager->compileProject(mProject,rebuild);
updateCompileActions(); updateCompileActions();
@ -1516,7 +1533,7 @@ bool MainWindow::compile(bool rebuild)
if (mCompileSuccessionTask) { if (mCompileSuccessionTask) {
mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename()); mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename());
} }
openCloseBottomPanel(true); openCloseMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput); ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild);
updateCompileActions(); updateCompileActions();
@ -1576,7 +1593,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
if (problem) { if (problem) {
mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(), mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(),
problem->cases); problem->cases);
openCloseBottomPanel(true); openCloseMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabProblem); ui->tabMessages->setCurrentWidget(ui->tabProblem);
} }
} else if (runType == RunType::CurrentProblemCase) { } else if (runType == RunType::CurrentProblemCase) {
@ -1585,7 +1602,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
POJProblemCase problemCase =mOJProblemModel.getCase(index.row()); POJProblemCase problemCase =mOJProblemModel.getCase(index.row());
mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(), mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(),
problemCase); problemCase);
openCloseBottomPanel(true); openCloseMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabProblem); ui->tabMessages->setCurrentWidget(ui->tabProblem);
} }
} }
@ -1850,7 +1867,7 @@ void MainWindow::debug()
void MainWindow::showSearchPanel(bool showReplace) void MainWindow::showSearchPanel(bool showReplace)
{ {
openCloseBottomPanel(true); openCloseMessagesPanel(true);
showSearchReplacePanel(showReplace); showSearchReplacePanel(showReplace);
ui->tabMessages->setCurrentWidget(ui->tabSearch); ui->tabMessages->setCurrentWidget(ui->tabSearch);
} }
@ -1865,77 +1882,36 @@ void MainWindow::showCPUInfoDialog()
mCPUDialog->show(); mCPUDialog->show();
} }
void MainWindow::openCloseBottomPanel(bool open) static void setDockMovable(QDockWidget* dock, bool movable) {
if (movable) {
dock->setFeatures(dock->features() | QDockWidget::DockWidgetMovable);
} else {
dock->setFeatures(dock->features() & ~QDockWidget::DockWidgetMovable);
}
}
void MainWindow::openCloseMessagesPanel(bool open)
{ {
ui->dockMessages->setVisible(open); //ui->dockMessages->setVisible(open);
// if Assigned(fReportToolWindow) then ui->tabMessages->setShrinked(!open);
// Exit; if (open) {
// if (mOpenClosingBottomPanel) resizeDocks({ui->dockMessages},
// return; {ui->tabMessages->beforeShrinkWidthOrHeight()},
// mOpenClosingBottomPanel = true; ui->tabMessages->shrinkOrientation());
// auto action = finally([this]{ }
// mOpenClosingBottomPanel = false; setDockMovable(ui->dockMessages,open);
// });
// // Switch between open and close
// if (open) {
// QList<int> sizes = ui->splitterMessages->sizes();
// int tabHeight = ui->tabMessages->tabBar()->height();
// ui->tabMessages->setMinimumHeight(tabHeight+5);
// if ( mBottomPanelHeight < ui->tabMessages->tabBar()->height() + 5)
// mBottomPanelHeight = ui->tabMessages->tabBar()->height() + 5;
// int totalSize = sizes[0] + sizes[1];
// sizes[1] = mBottomPanelHeight;
// sizes[0] = std::max(1,totalSize - sizes[1]);
// ui->splitterMessages->setSizes(sizes);
// } else {
// QList<int> sizes = ui->splitterMessages->sizes();
// mBottomPanelHeight = sizes[1];
// int totalSize = sizes[0] + sizes[1];
// int tabHeight = ui->tabMessages->tabBar()->height();
// ui->tabMessages->setMinimumHeight(tabHeight);
// sizes[1] = tabHeight;
// sizes[0] = std::max(1,totalSize - sizes[1]);
// ui->splitterMessages->setSizes(sizes);
// }
// mBottomPanelOpenned = open;
// QSplitterHandle* handle = ui->splitterMessages->handle(1);
// handle->setEnabled(mBottomPanelOpenned);
} }
void MainWindow::openCloseLeftPanel(bool open) void MainWindow::openCloseExplorerPanel(bool open)
{ {
ui->dockInfos->setVisible(open); ui->tabExplorer->setShrinked(!open);
// if (mOpenClosingLeftPanel) if (open) {
// return; resizeDocks({ui->dockExplorer},
// mOpenClosingLeftPanel = true; {ui->tabExplorer->beforeShrinkWidthOrHeight()},
// auto action = finally([this]{ ui->tabExplorer->shrinkOrientation());
// mOpenClosingLeftPanel = false; }
// }); setDockMovable(ui->dockExplorer,open);
// // Switch between open and close
// if (open ) {
// QList<int> sizes = ui->splitterInfos->sizes();
// int tabWidth = ui->tabInfos->tabBar()->width();
// ui->tabInfos->setMinimumWidth(tabWidth+5);
// if (mLeftPanelWidth < ui->tabInfos->tabBar()->width() + 5)
// mLeftPanelWidth = ui->tabInfos->tabBar()->width() + 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(mLeftPanelOpenned);
} }
void MainWindow::prepareDebugger() void MainWindow::prepareDebugger()
@ -1950,14 +1926,14 @@ void MainWindow::prepareDebugger()
ui->txtEvalOutput->clear(); ui->txtEvalOutput->clear();
// Restore when no watch vars are shown // Restore when no watch vars are shown
mDebugger->setLeftPageIndexBackup(ui->tabInfos->currentIndex()); mDebugger->setLeftPageIndexBackup(ui->tabExplorer->currentIndex());
// Focus on the debugging buttons // Focus on the debugging buttons
ui->tabInfos->setCurrentWidget(ui->tabWatch); ui->tabExplorer->setCurrentWidget(ui->tabWatch);
ui->tabMessages->setCurrentWidget(ui->tabDebug); ui->tabMessages->setCurrentWidget(ui->tabDebug);
ui->debugViews->setCurrentWidget(ui->tabLocals); ui->debugViews->setCurrentWidget(ui->tabLocals);
openCloseBottomPanel(true); openCloseMessagesPanel(true);
openCloseLeftPanel(true); openCloseExplorerPanel(true);
// Reset watch vars // Reset watch vars
// mDebugger->deleteWatchVars(false); // mDebugger->deleteWatchVars(false);
@ -2713,12 +2689,12 @@ void MainWindow::buildEncodingMenu()
void MainWindow::maximizeEditor() void MainWindow::maximizeEditor()
{ {
if (ui->dockInfos->isVisible() || ui->dockMessages->isVisible()) { if (ui->tabExplorer->isShrinked() && ui->tabExplorer->isShrinked()) {
openCloseBottomPanel(false); openCloseMessagesPanel(true);
openCloseLeftPanel(false); openCloseExplorerPanel(true);
} else { } else {
openCloseBottomPanel(true); openCloseMessagesPanel(false);
openCloseLeftPanel(true); openCloseExplorerPanel(false);
} }
} }
@ -3205,7 +3181,7 @@ void MainWindow::onProblemSetIndexChanged(const QModelIndex &current, const QMod
} else { } else {
onProblemCaseIndexChanged(QModelIndex(),QModelIndex()); onProblemCaseIndexChanged(QModelIndex(),QModelIndex());
} }
openCloseBottomPanel(true); openCloseMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabProblem); ui->tabMessages->setCurrentWidget(ui->tabProblem);
ui->tabProblem->setEnabled(true); ui->tabProblem->setEnabled(true);
ui->btnOpenProblemAnswer->setEnabled(!problem->answerProgram.isEmpty()); ui->btnOpenProblemAnswer->setEnabled(!problem->answerProgram.isEmpty());
@ -3365,7 +3341,7 @@ void MainWindow::onNewProblemConnection()
problem->cases.append(problemCase); problem->cases.append(problemCase);
} }
mOJProblemSetModel.addProblem(problem); mOJProblemSetModel.addProblem(problem);
ui->tabInfos->setCurrentWidget(ui->tabProblemSet); ui->tabExplorer->setCurrentWidget(ui->tabProblemSet);
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index( ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(
mOJProblemSetModel.count()-1 mOJProblemSetModel.count()-1
,0)); ,0));
@ -4128,7 +4104,7 @@ void MainWindow::closeProject(bool refreshEditor)
if (!mQuitting && refreshEditor) { if (!mQuitting && refreshEditor) {
//reset Class browsing //reset Class browsing
ui->tabInfos->setCurrentWidget(ui->tabStructure); ui->tabExplorer->setCurrentWidget(ui->tabStructure);
Editor * e = mEditorList->getEditor(); Editor * e = mEditorList->getEditor();
updateClassBrowserForEditor(e); updateClassBrowserForEditor(e);
} else { } else {
@ -4162,9 +4138,9 @@ void MainWindow::updateProjectView()
} else } else
mProjectProxyModel->invalidate(); mProjectProxyModel->invalidate();
ui->projectView->expandAll(); ui->projectView->expandAll();
openCloseLeftPanel(true); openCloseExplorerPanel(true);
ui->tabProject->setVisible(true); ui->tabProject->setVisible(true);
ui->tabInfos->setCurrentWidget(ui->tabProject); ui->tabExplorer->setCurrentWidget(ui->tabProject);
} else { } else {
// Clear project browser // Clear project browser
mProjectProxyModel->setSourceModel(nullptr); mProjectProxyModel->setSourceModel(nullptr);
@ -4308,7 +4284,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
settings.setMainWindowState(saveState()); settings.setMainWindowState(saveState());
settings.setMainWindowGeometry(saveGeometry()); settings.setMainWindowGeometry(saveGeometry());
settings.setBottomPanelIndex(ui->tabMessages->currentIndex()); settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
settings.setLeftPanelIndex(ui->tabInfos->currentIndex()); settings.setLeftPanelIndex(ui->tabExplorer->currentIndex());
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());
@ -4326,6 +4302,11 @@ void MainWindow::closeEvent(QCloseEvent *event) {
settings.setShowTODO(ui->actionTODO->isChecked()); settings.setShowTODO(ui->actionTODO->isChecked());
settings.setShowBookmark(ui->actionBookmark->isChecked()); settings.setShowBookmark(ui->actionBookmark->isChecked());
settings.setShowProblem(ui->actionProblem->isChecked()); settings.setShowProblem(ui->actionProblem->isChecked());
settings.setMessagesTabsSize(ui->tabMessages->currentSize());
settings.setExplorerTabsSize(ui->tabExplorer->currentSize());
settings.setShrinkExplorerTabs(ui->tabExplorer->isShrinked());
settings.setShrinkMessagesTabs(ui->tabMessages->isShrinked());
settings.save(); settings.save();
//save current folder ( for files view ) //save current folder ( for files view )
@ -4406,14 +4387,14 @@ 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());
ui->tabInfos->setCurrentIndex(settings.leftPanelIndex()); ui->tabExplorer->setCurrentIndex(settings.leftPanelIndex());
} }
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.setLeftPanelIndex(ui->tabInfos->currentIndex()); settings.setLeftPanelIndex(ui->tabExplorer->currentIndex());
} }
bool MainWindow::event(QEvent *event) bool MainWindow::event(QEvent *event)
@ -4586,12 +4567,12 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
} else if (ui->tableIssues->count() == 0) { } else if (ui->tableIssues->count() == 0) {
// Close it if there's nothing to show // Close it if there's nothing to show
if (ui->tabMessages->currentIndex() == i) if (ui->tabMessages->currentIndex() == i)
openCloseBottomPanel(false); openCloseMessagesPanel(false);
} else { } else {
if (ui->tabMessages->currentIndex() != i) { if (ui->tabMessages->currentIndex() != i) {
ui->tabMessages->setCurrentIndex(i); ui->tabMessages->setCurrentIndex(i);
} }
openCloseBottomPanel(true); openCloseMessagesPanel(true);
} }
Editor * e = mEditorList->getEditor(); Editor * e = mEditorList->getEditor();
@ -4933,23 +4914,13 @@ 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() && !ui->tabMessages->isShrinked()) {
ui->tabMessages->toggleShrined(); openCloseMessagesPanel(false);
if (!ui->tabMessages->isShrinked()) { } else {
resizeDocks({ui->dockMessages},{ui->tabMessages->beforeShrinkWidthOrHeight()},ui->tabMessages->shrinkOrientation()); openCloseMessagesPanel(true);
}
} }
} }
void MainWindow::on_tabMessages_currentChanged(int)
{
openCloseBottomPanel(true);
}
void MainWindow::on_tabMessages_tabBarDoubleClicked(int )
{
}
void MainWindow::on_actionCompile_Run_triggered() void MainWindow::on_actionCompile_Run_triggered()
{ {
@ -5366,13 +5337,12 @@ void MainWindow::on_actionForward_triggered()
} }
void MainWindow::on_tabInfos_tabBarClicked(int index) void MainWindow::on_tabExplorer_tabBarClicked(int index)
{ {
if (index == ui->tabInfos->currentIndex()) { if (index == ui->tabExplorer->currentIndex() && !ui->tabExplorer->isShrinked()) {
ui->tabInfos->toggleShrined(); openCloseExplorerPanel(false);
if (!ui->tabInfos->isShrinked()) { } else {
resizeDocks({ui->dockInfos},{ui->tabInfos->beforeShrinkWidthOrHeight()},ui->tabInfos->shrinkOrientation()); openCloseExplorerPanel(true);
}
} }
} }
@ -5884,23 +5854,23 @@ PSymbolUsageManager &MainWindow::symbolUsageManager()
void MainWindow::showHideInfosTab(QWidget *widget, bool show) void MainWindow::showHideInfosTab(QWidget *widget, bool show)
{ {
int idx = findTabIndex(ui->tabInfos,widget); int idx = findTabIndex(ui->tabExplorer,widget);
if (idx>=0) { if (idx>=0) {
if (!show) { if (!show) {
if (mTabInfosData.contains(widget)) { if (mTabInfosData.contains(widget)) {
PTabWidgetInfo info = mTabInfosData[widget]; PTabWidgetInfo info = mTabInfosData[widget];
info->icon = ui->tabInfos->tabIcon(idx); info->icon = ui->tabExplorer->tabIcon(idx);
info->text = ui->tabInfos->tabText(idx); info->text = ui->tabExplorer->tabText(idx);
} }
ui->tabInfos->removeTab(idx); ui->tabExplorer->removeTab(idx);
} }
} else { } else {
if (show && mTabInfosData.contains(widget)) { if (show && mTabInfosData.contains(widget)) {
PTabWidgetInfo info = mTabInfosData[widget]; PTabWidgetInfo info = mTabInfosData[widget];
int insert = -1; int insert = -1;
for (int i=0;i<ui->tabInfos->count();i++) { for (int i=0;i<ui->tabExplorer->count();i++) {
QWidget * w=ui->tabInfos->widget(i); QWidget * w=ui->tabExplorer->widget(i);
PTabWidgetInfo infoW = mTabInfosData[w]; PTabWidgetInfo infoW = mTabInfosData[w];
if (infoW->order>info->order) { if (infoW->order>info->order) {
insert = i; insert = i;
@ -5908,9 +5878,9 @@ void MainWindow::showHideInfosTab(QWidget *widget, bool show)
} }
} }
if (insert>=0) { if (insert>=0) {
ui->tabInfos->insertTab(insert, widget, info->icon, info->text); ui->tabExplorer->insertTab(insert, widget, info->icon, info->text);
} else { } else {
ui->tabInfos->addTab(widget, info->icon, info->text); ui->tabExplorer->addTab(widget, info->icon, info->text);
} }
} }
} }
@ -5952,12 +5922,12 @@ void MainWindow::showHideMessagesTab(QWidget *widget, bool show)
void MainWindow::prepareTabInfosData() void MainWindow::prepareTabInfosData()
{ {
for (int i=0;i<ui->tabInfos->count();i++) { for (int i=0;i<ui->tabExplorer->count();i++) {
QWidget* widget = ui->tabInfos->widget(i); QWidget* widget = ui->tabExplorer->widget(i);
PTabWidgetInfo info = std::make_shared<TabWidgetInfo>(); PTabWidgetInfo info = std::make_shared<TabWidgetInfo>();
info->order =i; info->order =i;
info->text = ui->tabInfos->tabText(i); info->text = ui->tabExplorer->tabText(i);
info->icon = ui->tabInfos->tabIcon(i); info->icon = ui->tabExplorer->tabIcon(i);
mTabInfosData[widget]=info; mTabInfosData[widget]=info;
} }
} }
@ -6129,6 +6099,70 @@ void MainWindow::doFilesViewRemoveFile(const QModelIndex &index)
} }
} }
static void setDockTitlebarLocation(QDockWidget* dock, const Qt::DockWidgetArea &area) {
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
dock->setFeatures(dock->features() | QDockWidget::DockWidgetVerticalTitleBar);
break;
default:
dock->setFeatures(dock->features() & ~QDockWidget::DockWidgetVerticalTitleBar);
}
}
static void setTabsInDockLocation(QTabWidget* tabs, const Qt::DockWidgetArea &area) {
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
tabs->setTabPosition(QTabWidget::TabPosition::South);
break;
case Qt::DockWidgetArea::LeftDockWidgetArea:
tabs->setTabPosition(QTabWidget::TabPosition::West);
break;
case Qt::DockWidgetArea::RightDockWidgetArea:
tabs->setTabPosition(QTabWidget::TabPosition::East);
break;
default:
break;
}
}
static void setSplitterInDockLocation(QSplitter* splitter, const Qt::DockWidgetArea& area) {
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
splitter->setOrientation(Qt::Orientation::Horizontal);
break;
default:
splitter->setOrientation(Qt::Orientation::Vertical);
}
}
void MainWindow::setDockExplorerToArea(const Qt::DockWidgetArea &area)
{
setDockTitlebarLocation(ui->dockExplorer,area);
setTabsInDockLocation(ui->tabExplorer,area);
ui->dockMessages->setAllowedAreas(
(Qt::DockWidgetArea::LeftDockWidgetArea |
Qt::DockWidgetArea::BottomDockWidgetArea |
Qt::DockWidgetArea::RightDockWidgetArea)
& ~area);
}
void MainWindow::setDockMessagesToArea(const Qt::DockWidgetArea &area)
{
setDockTitlebarLocation(ui->dockMessages,area);
setTabsInDockLocation(ui->tabMessages,area);
setSplitterInDockLocation(ui->splitterDebug,area);
setSplitterInDockLocation(ui->splitterProblem,area);
ui->dockExplorer->setAllowedAreas(
(Qt::DockWidgetArea::LeftDockWidgetArea |
Qt::DockWidgetArea::BottomDockWidgetArea |
Qt::DockWidgetArea::RightDockWidgetArea)
& ~area);
}
void MainWindow::updateVCSActions() void MainWindow::updateVCSActions()
{ {
bool hasRepository = false; bool hasRepository = false;
@ -6434,7 +6468,7 @@ void MainWindow::on_btnReplace_clicked()
editor->setSelText(contents.join(editor->lineBreak())); editor->setSelText(contents.join(editor->lineBreak()));
} }
showSearchReplacePanel(false); showSearchReplacePanel(false);
openCloseBottomPanel(false); openCloseMessagesPanel(false);
} }
void MainWindow::on_btnCancelReplace_clicked() void MainWindow::on_btnCancelReplace_clicked()
@ -6630,8 +6664,8 @@ void MainWindow::on_actionLocate_in_Files_View_triggered()
QModelIndex index = mFileSystemModel.index(editor->filename()); QModelIndex index = mFileSystemModel.index(editor->filename());
ui->treeFiles->setCurrentIndex(index); ui->treeFiles->setCurrentIndex(index);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter); ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->tabInfos->setCurrentWidget(ui->tabFiles); ui->tabExplorer->setCurrentWidget(ui->tabFiles);
openCloseLeftPanel(true); openCloseExplorerPanel(true);
} }
} }
@ -6825,9 +6859,9 @@ bool MainWindow::openningFiles() const
void MainWindow::on_actionTool_Window_Bars_triggered() void MainWindow::on_actionTool_Window_Bars_triggered()
{ {
bool state = ui->tabInfos->isVisible(); bool state = ui->tabExplorer->isVisible();
state = !state; state = !state;
ui->tabInfos->setVisible(state); ui->tabExplorer->setVisible(state);
ui->tabMessages->setVisible(state); ui->tabMessages->setVisible(state);
ui->actionTool_Window_Bars->setChecked(state); ui->actionTool_Window_Bars->setChecked(state);
} }
@ -7685,56 +7719,14 @@ void MainWindow::on_actionCompiler_Options_triggered()
); );
} }
void MainWindow::on_dockExplorer_dockLocationChanged(const Qt::DockWidgetArea &area)
void MainWindow::on_dockInfos_dockLocationChanged(const Qt::DockWidgetArea &area)
{ {
switch(area) { setDockExplorerToArea(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) void MainWindow::on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area)
{ {
switch(area) { setDockMessagesToArea(area);
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
ui->splitterDebug->setOrientation(Qt::Orientation::Horizontal);
ui->splitterProblem->setOrientation(Qt::Orientation::Horizontal);
ui->dockMessages->setFeatures( ui->dockMessages->features() | QDockWidget::DockWidgetVerticalTitleBar);
break;
default:
ui->splitterDebug->setOrientation(Qt::Orientation::Vertical);
ui->splitterProblem->setOrientation(Qt::Orientation::Vertical);
ui->dockMessages->setFeatures( ui->dockMessages->features() & ~QDockWidget::DockWidgetVerticalTitleBar);
}
switch(area) {
case Qt::DockWidgetArea::BottomDockWidgetArea:
case Qt::DockWidgetArea::TopDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::South);
ui->debugViews->setTabPosition(QTabWidget::TabPosition::South);
break;
case Qt::DockWidgetArea::LeftDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::West);
ui->debugViews->setTabPosition(QTabWidget::TabPosition::West);
break;
case Qt::DockWidgetArea::RightDockWidgetArea:
ui->tabMessages->setTabPosition(QTabWidget::TabPosition::East);
ui->debugViews->setTabPosition(QTabWidget::TabPosition::East);
break;
default:
break;
}
} }

View File

@ -125,6 +125,7 @@ public:
void applySettings(); void applySettings();
void applyUISettings(); void applyUISettings();
QFileSystemWatcher* fileSystemWatcher(); QFileSystemWatcher* fileSystemWatcher();
void initDocks();
void removeActiveBreakpoints(); void removeActiveBreakpoints();
void updateAppTitle(); void updateAppTitle();
@ -231,8 +232,8 @@ private:
void updateProjectView(); void updateProjectView();
CompileTarget getCompileTarget(); CompileTarget getCompileTarget();
bool debugInferiorhasBreakpoint(); bool debugInferiorhasBreakpoint();
void openCloseBottomPanel(bool open); void openCloseMessagesPanel(bool open);
void openCloseLeftPanel(bool open); void openCloseExplorerPanel(bool open);
void prepareDebugger(); void prepareDebugger();
void doAutoSave(Editor *e); void doAutoSave(Editor *e);
void buildContextMenus(); void buildContextMenus();
@ -259,6 +260,8 @@ private:
void doFilesViewRemoveFile(const QModelIndex& index); void doFilesViewRemoveFile(const QModelIndex& index);
private slots: private slots:
void setDockExplorerToArea(const Qt::DockWidgetArea &area);
void setDockMessagesToArea(const Qt::DockWidgetArea &area);
void updateVCSActions(); void updateVCSActions();
void invalidateProjectProxyModel(); void invalidateProjectProxyModel();
void onEditorRenamed(const QString& oldFilename, const QString& newFilename, bool firstSave); void onEditorRenamed(const QString& oldFilename, const QString& newFilename, bool firstSave);
@ -387,10 +390,6 @@ private slots:
void on_tabMessages_tabBarClicked(int index); void on_tabMessages_tabBarClicked(int index);
void on_tabMessages_currentChanged(int index);
void on_tabMessages_tabBarDoubleClicked(int index);
void on_actionCompile_Run_triggered(); void on_actionCompile_Run_triggered();
void on_actionRebuild_triggered(); void on_actionRebuild_triggered();
@ -440,7 +439,7 @@ private slots:
void on_actionForward_triggered(); void on_actionForward_triggered();
void on_tabInfos_tabBarClicked(int index); void on_tabExplorer_tabBarClicked(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);
@ -670,7 +669,7 @@ private slots:
void on_actionCompiler_Options_triggered(); void on_actionCompiler_Options_triggered();
void on_dockInfos_dockLocationChanged(const Qt::DockWidgetArea &area); void on_dockExplorer_dockLocationChanged(const Qt::DockWidgetArea &area);
void on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area); void on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area);

View File

@ -18,6 +18,9 @@
<normalon>:/icons/images/devcpp.ico</normalon> <normalon>:/icons/images/devcpp.ico</normalon>
</iconset> </iconset>
</property> </property>
<property name="dockOptions">
<set>QMainWindow::AnimatedDocks</set>
</property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="leftMargin">
@ -117,7 +120,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>945</width> <width>945</width>
<height>26</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -433,7 +436,7 @@
</attribute> </attribute>
<addaction name="actionCompiler_Options"/> <addaction name="actionCompiler_Options"/>
</widget> </widget>
<widget class="QDockWidget" name="dockInfos"> <widget class="QDockWidget" name="dockExplorer">
<property name="features"> <property name="features">
<set>QDockWidget::DockWidgetMovable</set> <set>QDockWidget::DockWidgetMovable</set>
</property> </property>
@ -441,12 +444,12 @@
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set> <set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Infos</string> <string>Explorer</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="ShrinkableTabWidget" name="tabInfos"> <widget class="ShrinkableTabWidget" name="tabExplorer">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View File

@ -313,6 +313,11 @@ bool Settings::_Base::boolValue(const QString &key, bool defaultValue)
return value(key,defaultValue).toBool(); return value(key,defaultValue).toBool();
} }
QSize Settings::_Base::sizeValue(const QString &key)
{
return value(key,QSize()).toSize();
}
int Settings::_Base::intValue(const QString &key, int defaultValue) int Settings::_Base::intValue(const QString &key, int defaultValue)
{ {
return value(key,defaultValue).toInt(); return value(key,defaultValue).toInt();
@ -4742,6 +4747,46 @@ void Settings::UI::setNewHeaderDialogHeight(int newNewFileDialogHeight)
mNewHeaderDialogHeight = newNewFileDialogHeight; mNewHeaderDialogHeight = newNewFileDialogHeight;
} }
const QSize &Settings::UI::messagesTabsSize() const
{
return mMessagesTabsSize;
}
void Settings::UI::setMessagesTabsSize(const QSize &newMessagesTabsSize)
{
mMessagesTabsSize = newMessagesTabsSize;
}
const QSize &Settings::UI::explorerTabsSize() const
{
return mExplorerTabsSize;
}
void Settings::UI::setExplorerTabsSize(const QSize &newExplorerTabsSize)
{
mExplorerTabsSize = newExplorerTabsSize;
}
bool Settings::UI::shrinkMessagesTabs() const
{
return mShrinkMessagesTabs;
}
void Settings::UI::setShrinkMessagesTabs(bool newShrinkMessagesTabs)
{
mShrinkMessagesTabs = newShrinkMessagesTabs;
}
bool Settings::UI::shrinkExplorerTabs() const
{
return mShrinkExplorerTabs;
}
void Settings::UI::setShrinkExplorerTabs(bool newShrinkExplorerTabs)
{
mShrinkExplorerTabs = newShrinkExplorerTabs;
}
int Settings::UI::newHeaderDialogWidth() const int Settings::UI::newHeaderDialogWidth() const
{ {
return mNewHeaderDialogWidth; return mNewHeaderDialogWidth;
@ -4982,6 +5027,11 @@ void Settings::UI::doSave()
saveValue("class_browser_sort_by_type",mClassBrowserSortType); saveValue("class_browser_sort_by_type",mClassBrowserSortType);
saveValue("class_browser_show_inherited",mClassBrowserShowInherited); saveValue("class_browser_show_inherited",mClassBrowserShowInherited);
saveValue("shrink_explorer_tabs",mShrinkExplorerTabs);
saveValue("shrink_messages_tabs",mShrinkMessagesTabs);
saveValue("explorer_tabs_size", mExplorerTabsSize);
saveValue("messages_tabs_size",mMessagesTabsSize);
//view //view
saveValue("show_toolbar", mShowToolbar); saveValue("show_toolbar", mShowToolbar);
saveValue("show_statusbar", mShowStatusBar); saveValue("show_statusbar", mShowStatusBar);
@ -5026,6 +5076,11 @@ void Settings::UI::doLoad()
mClassBrowserSortType = boolValue("class_browser_sort_by_type",true); mClassBrowserSortType = boolValue("class_browser_sort_by_type",true);
mClassBrowserShowInherited = boolValue("class_browser_show_inherited",true); mClassBrowserShowInherited = boolValue("class_browser_show_inherited",true);
mShrinkExplorerTabs = boolValue("shrink_explorer_tabs",false);
mShrinkMessagesTabs = boolValue("shrink_messages_tabs",false);
mExplorerTabsSize = sizeValue("explorer_tabs_size");
mMessagesTabsSize = sizeValue("messages_tabs_size");
//view //view
mShowToolbar = boolValue("show_toolbar",true); mShowToolbar = boolValue("show_toolbar",true);
mShowStatusBar = boolValue("show_statusbar",true); mShowStatusBar = boolValue("show_statusbar",true);

View File

@ -71,6 +71,7 @@ private:
void saveValue(const QString &key, const QVariant &value); void saveValue(const QString &key, const QVariant &value);
QVariant value(const QString &key, const QVariant& defaultValue); QVariant value(const QString &key, const QVariant& defaultValue);
bool boolValue(const QString &key, bool defaultValue); bool boolValue(const QString &key, bool defaultValue);
QSize sizeValue(const QString &key);
int intValue(const QString &key, int defaultValue); int intValue(const QString &key, int defaultValue);
QStringList stringListValue(const QString &key, const QStringList& defaultValue=QStringList()); QStringList stringListValue(const QString &key, const QStringList& defaultValue=QStringList());
QColor colorValue(const QString &key, const QColor& defaultValue); QColor colorValue(const QString &key, const QColor& defaultValue);
@ -1026,6 +1027,18 @@ public:
int newHeaderDialogHeight() const; int newHeaderDialogHeight() const;
void setNewHeaderDialogHeight(int newNewFileDialogHeight); void setNewHeaderDialogHeight(int newNewFileDialogHeight);
bool shrinkExplorerTabs() const;
void setShrinkExplorerTabs(bool newShrinkExplorerTabs);
bool shrinkMessagesTabs() const;
void setShrinkMessagesTabs(bool newShrinkMessagesTabs);
const QSize &explorerTabsSize() const;
void setExplorerTabsSize(const QSize &newExplorerTabsSize);
const QSize &messagesTabsSize() const;
void setMessagesTabsSize(const QSize &newMessagesTabsSize);
private: private:
QByteArray mMainWindowState; QByteArray mMainWindowState;
QByteArray mMainWindowGeometry; QByteArray mMainWindowGeometry;
@ -1035,6 +1048,10 @@ public:
bool mClassBrowserSortType; bool mClassBrowserSortType;
bool mClassBrowserShowInherited; bool mClassBrowserShowInherited;
bool mShrinkExplorerTabs;
bool mShrinkMessagesTabs;
QSize mExplorerTabsSize;
QSize mMessagesTabsSize;
//view //view
bool mShowToolbar; bool mShowToolbar;
bool mShowStatusBar; bool mShowStatusBar;

View File

@ -26,10 +26,15 @@ ShrinkableTabWidget::ShrinkableTabWidget(QWidget *parent):QTabWidget(parent),
} }
void ShrinkableTabWidget::setShrinkedFlag(bool shrinked)
{
mShrinked = shrinked;
}
void ShrinkableTabWidget::setShrinked(bool shrinked) void ShrinkableTabWidget::setShrinked(bool shrinked)
{ {
if (!mShrinked && shrinked) { if (!mShrinked && shrinked) {
BeforeShrinkSizes.insert(this, size()); setBeforeShrinkSize(size());
} }
mShrinked = shrinked; mShrinked = shrinked;
switch(this->tabPosition()) { switch(this->tabPosition()) {
@ -61,14 +66,28 @@ void ShrinkableTabWidget::toggleShrined()
setShrinked(!mShrinked); setShrinked(!mShrinked);
} }
void ShrinkableTabWidget::setBeforeShrinkSize(const QSize &size)
{
BeforeShrinkSizes.insert(this,size);
}
QSize ShrinkableTabWidget::beforeShrinkSize() QSize ShrinkableTabWidget::beforeShrinkSize()
{ {
QSize size = BeforeShrinkSizes.value(this,QSize()); QSize size = BeforeShrinkSizes.value(this,QSize());
if (!size.isValid()) if (!size.isValid() || size.isNull()) {
size = QSize(width(),height()); size = QTabWidget::size();
}
return size; return size;
} }
QSize ShrinkableTabWidget::currentSize()
{
if (isShrinked())
return beforeShrinkSize();
else
return size();
}
int ShrinkableTabWidget::beforeShrinkWidthOrHeight() int ShrinkableTabWidget::beforeShrinkWidthOrHeight()
{ {
if (shrinkOrientation()==Qt::Vertical) if (shrinkOrientation()==Qt::Vertical)
@ -99,11 +118,17 @@ QSize ShrinkableTabWidget::minimumSizeHint() const
switch(this->tabPosition()) { switch(this->tabPosition()) {
case QTabWidget::East: case QTabWidget::East:
case QTabWidget::West: case QTabWidget::West:
size.setWidth(tabBar()->width()); if (isShrinked())
size.setWidth(tabBar()->width());
else
size.setWidth(tabBar()->width()*2);
break; break;
case QTabWidget::North: case QTabWidget::North:
case QTabWidget::South: case QTabWidget::South:
size.setHeight(tabBar()->height()); if (isShrinked())
size.setHeight(tabBar()->height());
else
size.setHeight(tabBar()->height()*2);
} }
return size; return size;
} }

View File

@ -25,10 +25,13 @@ class ShrinkableTabWidget : public QTabWidget
public: public:
ShrinkableTabWidget(QWidget* parent=nullptr); ShrinkableTabWidget(QWidget* parent=nullptr);
void setShrinkedFlag(bool shrinked);
void setShrinked(bool shrinked); void setShrinked(bool shrinked);
bool isShrinked() const; bool isShrinked() const;
void toggleShrined(); void toggleShrined();
void setBeforeShrinkSize(const QSize& size);
QSize beforeShrinkSize(); QSize beforeShrinkSize();
QSize currentSize();
int beforeShrinkWidthOrHeight(); int beforeShrinkWidthOrHeight();
Qt::Orientation shrinkOrientation(); Qt::Orientation shrinkOrientation();