Skip to content

Commit

Permalink
Dbl click on console handle switch it to max/min size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denvi committed Nov 30, 2015
1 parent 7192d7e commit 13a6dfc
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
Binary file modified bin/grblControl
Binary file not shown.
Binary file modified bin/grblControl.exe
Binary file not shown.
12 changes: 12 additions & 0 deletions frmabout.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1">
<property name="spacing">
Expand Down
30 changes: 23 additions & 7 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,10 +2438,8 @@ bool frmMain::eventFilter(QObject *obj, QEvent *event)
ui->splitPanels->setSizes(QList<int>() << ui->scrollArea->height() << ui->grpConsole->height());

// Set new console mimimum height
int pureHeight = ui->grpConsole->height() - ui->grpConsole->contentsRect().height()
+ ui->spacerConsole->geometry().height() + ui->grpConsole->layout()->margin() * 2
+ ui->cboCommand->height();
ui->grpConsole->setMinimumHeight(qMax(pureHeight, ui->splitPanels->height()
int minHeight = getConsoleMinHeight();
ui->grpConsole->setMinimumHeight(qMax(minHeight, ui->splitPanels->height()
- ui->scrollAreaWidgetContents->sizeHint().height() - ui->splitPanels->handleWidth() - 4));
}
} else if (event->type() == QEvent::MouseButtonRelease) {
Expand All @@ -2458,16 +2456,34 @@ bool frmMain::eventFilter(QObject *obj, QEvent *event)
// Resize splited widgets
onPanelsSizeChanged(ui->scrollAreaWidgetContents->sizeHint());
}
} else if (event->type() == QEvent::MouseButtonDblClick) {
if (obj == ui->splitPanels->handle(1)) {
// Switch to min/max console size
int minHeight = getConsoleMinHeight();
if (ui->grpConsole->height() == minHeight || !ui->scrollArea->verticalScrollBar()->isVisible()) {
ui->splitPanels->setSizes(QList<int>() << ui->scrollArea->minimumHeight()
<< ui->splitPanels->height() - ui->splitPanels->handleWidth() - ui->scrollArea->minimumHeight());
} else {
ui->grpConsole->setMinimumHeight(minHeight);
onPanelsSizeChanged(ui->scrollAreaWidgetContents->sizeHint());
}
}
}

return QMainWindow::eventFilter(obj, event);
}

void frmMain::onConsoleResized(QSize size)
int frmMain::getConsoleMinHeight()
{
int pureHeight = ui->spacerConsole->geometry().height() + ui->grpConsole->layout()->margin() * 2
return ui->grpConsole->height() - ui->grpConsole->contentsRect().height()
+ ui->spacerConsole->geometry().height() + ui->grpConsole->layout()->margin() * 2
+ ui->cboCommand->height();
bool visible = ui->grpConsole->contentsRect().height() > pureHeight;
}

void frmMain::onConsoleResized(QSize size)
{
int minHeight = getConsoleMinHeight();
bool visible = ui->grpConsole->height() > minHeight;
if (ui->txtConsole->isVisible() != visible) {
ui->txtConsole->setVisible(visible);
}
Expand Down
1 change: 1 addition & 0 deletions frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ private slots:
bool isGCodeFile(QString fileName);
bool isHeightmapFile(QString fileName);
bool compareCoordinates(double x, double y, double z);
int getConsoleMinHeight();
};

#endif // FRMMAIN_H
12 changes: 6 additions & 6 deletions frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ QGroupBox {
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>8</number>
<number>9</number>
</property>
<property name="topMargin">
<number>8</number>
<number>9</number>
</property>
<property name="rightMargin">
<number>8</number>
<number>9</number>
</property>
<property name="bottomMargin">
<number>8</number>
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
Expand Down Expand Up @@ -84,8 +84,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>1186</height>
<width>399</width>
<height>1183</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down

0 comments on commit 13a6dfc

Please sign in to comment.