Skip to content

Commit

Permalink
Panels width fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denvi committed Sep 3, 2015
1 parent c54fdc3 commit 65f87e7
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 18 deletions.
31 changes: 18 additions & 13 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ frmMain::frmMain(QWidget *parent) :

ui->setupUi(this);

ui->cmdHeightMapBorderAuto->setMinimumHeight(ui->chkHeightMapBorderShow->sizeHint().height());

connect(ui->glwVisualizer, SIGNAL(resized()), this, SLOT(placeVisualizerButtons()));

m_taskBarButton = NULL;
m_taskBarProgress = NULL;
m_currentModel = &m_programModel;
Expand All @@ -49,6 +45,11 @@ frmMain::frmMain(QWidget *parent) :
ui->cmdFront->setParent(ui->glwVisualizer);
ui->cmdLeft->setParent(ui->glwVisualizer);

ui->cmdHeightMapBorderAuto->setMinimumHeight(ui->chkHeightMapBorderShow->sizeHint().height());
ui->cmdHeightMapCreate->setMinimumHeight(ui->cmdFileOpen->sizeHint().height());
ui->cmdHeightMapLoad->setMinimumHeight(ui->cmdFileOpen->sizeHint().height());
ui->cmdHeightMapMode->setMinimumHeight(ui->cmdFileOpen->sizeHint().height());

connect(ui->tblProgram->verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(onScroolBarAction(int)));

m_frmSettings.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
Expand Down Expand Up @@ -93,6 +94,7 @@ frmMain::frmMain(QWidget *parent) :
ui->glwVisualizer->fitDrawable();

connect(ui->glwVisualizer, SIGNAL(rotationChanged()), this, SLOT(onVisualizatorRotationChanged()));
connect(ui->glwVisualizer, SIGNAL(resized()), this, SLOT(placeVisualizerButtons()));
connect(&m_programModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_tblProgram_cellChanged(QModelIndex,QModelIndex)));
connect(&m_programHeightmapModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_tblProgram_cellChanged(QModelIndex,QModelIndex)));
connect(&m_probeModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_tblProgram_cellChanged(QModelIndex,QModelIndex)));
Expand Down Expand Up @@ -777,7 +779,7 @@ void frmMain::onSerialPortReadyRead()
double z = std::numeric_limits<double>::quiet_NaN();
if (rx.indexIn(response) != -1) {
qDebug() << "probing coordinates:" << rx.cap(1) << rx.cap(2) << rx.cap(3);
z = rx.cap(3).toDouble();
z = toMetric(rx.cap(3).toDouble());
}

// z = 23 + (double)m_probeIndex / 10;
Expand Down Expand Up @@ -1003,6 +1005,7 @@ void frmMain::onTableInsertLine()
// ui->tblProgram->edit(m_currentModel->index(row, 1));

updateParser();
ui->tblProgram->selectRow(row);
}

void frmMain::onTableDeleteLines()
Expand All @@ -1017,9 +1020,8 @@ void frmMain::onTableDeleteLines()
m_currentModel->removeRow(firstRow.row());
}

ui->tblProgram->selectRow(firstRow.row());

updateParser();
ui->tblProgram->selectRow(firstRow.row());
}

void frmMain::placeVisualizerButtons()
Expand Down Expand Up @@ -1895,35 +1897,38 @@ void frmMain::on_chkFeedOverride_toggled(bool checked)

void frmMain::on_grpFeed_toggled(bool checked)
{
ui->widgetFeed->setVisible(checked);

if (checked) {
ui->grpFeed->setTitle(tr("Feed"));
} else if (ui->chkFeedOverride->isChecked()) {
ui->grpFeed->setTitle(tr("Feed") + QString(tr(" (%1)")).arg(ui->txtFeed->text()));
}
updateLayouts();

ui->widgetFeed->setVisible(checked);
}

void frmMain::on_grpSpindle_toggled(bool checked)
{
ui->widgetSpindle->setVisible(checked);

if (checked) {
ui->grpSpindle->setTitle(tr("Spindle"));
} else if (ui->cmdSpindle->isChecked()) {
ui->grpSpindle->setTitle(tr("Spindle") + QString(tr(" (%1)")).arg(ui->txtSpindleSpeed->text()));
}
updateLayouts();

ui->widgetSpindle->setVisible(checked);
}

void frmMain::on_grpJog_toggled(bool checked)
{
ui->widgetJog->setVisible(checked);

if (checked) {
ui->grpJog->setTitle(tr("Jog"));
} else if (ui->chkKeyboardControl->isChecked()) {
ui->grpJog->setTitle(tr("Jog") + QString(tr(" (%1)")).arg(ui->txtJogStep->text()));
}
updateLayouts();

ui->widgetJog->setVisible(checked);
}

void frmMain::blockJogForRapidMovement() {
Expand Down
3 changes: 3 additions & 0 deletions groupbox.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include <QMouseEvent>
#include <QDebug>
#include "groupbox.h"
Expand Down
3 changes: 3 additions & 0 deletions groupbox.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef GROUPBOX_H
#define GROUPBOX_H

Expand Down
3 changes: 3 additions & 0 deletions heightmapborderdrawer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include "heightmapborderdrawer.h"

HeightMapBorderDrawer::HeightMapBorderDrawer(QObject *parent) : GLDrawable(parent)
Expand Down
3 changes: 3 additions & 0 deletions heightmapborderdrawer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef HEIGHTMAPBORDERDRAWER_H
#define HEIGHTMAPBORDERDRAWER_H

Expand Down
3 changes: 3 additions & 0 deletions heightmapgriddrawer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include "heightmapgriddrawer.h"

HeightMapGridDrawer::HeightMapGridDrawer(QObject *parent) : GLDrawable(parent)
Expand Down
3 changes: 3 additions & 0 deletions heightmapgriddrawer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef HEIGHTMAPGRIDDRAWER_H
#define HEIGHTMAPGRIDDRAWER_H

Expand Down
3 changes: 3 additions & 0 deletions heightmapinterpolationdrawer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include "heightmapinterpolationdrawer.h"

HeightMapInterpolationDrawer::HeightMapInterpolationDrawer(QObject *parent) : GLDrawable(parent)
Expand Down
3 changes: 3 additions & 0 deletions heightmapinterpolationdrawer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef HEIGHTMAPINTERPOLATIONDRAWER_H
#define HEIGHTMAPINTERPOLATIONDRAWER_H

Expand Down
3 changes: 3 additions & 0 deletions heightmaptablemodel.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include "heightmaptablemodel.h"

HeightMapTableModel::HeightMapTableModel(QObject *parent) : QAbstractTableModel(parent)
Expand Down
3 changes: 3 additions & 0 deletions heightmaptablemodel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef HEIGHTMAPTABLEMODEL_H
#define HEIGHTMAPTABLEMODEL_H

Expand Down
3 changes: 3 additions & 0 deletions interpolation.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef INTERPOLATION
#define INTERPOLATION

Expand Down
19 changes: 14 additions & 5 deletions scrollarea.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include <QDebug>
#include <QLayout>
#include <QScrollBar>
Expand All @@ -8,6 +11,7 @@
ScrollArea::ScrollArea(QWidget *parent) : QScrollArea(parent)
{
m_update = false;
m_width = 0;

connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVerticalScrollBarValueChanged(int)));
connect(this->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onVerticalScrollBarRangeChanged(int,int)));
Expand All @@ -18,7 +22,8 @@ ScrollArea::ScrollArea(QWidget *parent) : QScrollArea(parent)
QSize ScrollArea::sizeHint() const
{
QSize hint = widget()->sizeHint();
hint.setHeight(hint.height() + 2);
hint.setHeight(hint.height() + 4); // top + bottom border width
hint.setWidth(m_width);

return hint;
}
Expand All @@ -30,7 +35,8 @@ void ScrollArea::setWidget(QWidget *widget)
QList<GroupBox*> list = widget->findChildren<GroupBox*>();
foreach (GroupBox *box, list) {
connect(box, SIGNAL(mouseMoved(int,int)), this, SLOT(onScroll(int,int)));
}
m_width = qMax<int>(m_width, box->sizeHint().width() + box->layout()->contentsMargins().left()); // 1 * margin
}

QScrollArea::setWidget(widget);
}
Expand All @@ -55,6 +61,7 @@ void ScrollArea::mousePressEvent(QMouseEvent *me)

void ScrollArea::onContentSizeChanged(QSize newSize)
{
this->widget()->setMinimumWidth(m_width);
this->updateGeometry();
}

Expand All @@ -78,9 +85,11 @@ void ScrollArea::updateBorders()

this->styleSheet().clear();

QString style = QString("QScrollArea {border-top: 1px solid %1; border-bottom: 1px solid %2;}")
.arg(bar->value() > bar->minimum() && !fitted ? "palette(midlight)" : "transparent")
.arg(bar->value() < bar->maximum() && !fitted ? "palette(midlight)" : "transparent");
QString style = QString("QScrollArea {border-top: 2px solid %1; border-bottom: 2px solid %2;}")
.arg(bar->value() > bar->minimum() && !fitted ? "qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:1 #D5DFE5, stop:0 white)"
: "transparent")
.arg(bar->value() < bar->maximum() && !fitted ? "qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:1 #D5DFE5, stop:0 white)"
: "transparent");

this->setStyleSheet(style);
}
4 changes: 4 additions & 0 deletions scrollarea.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef SCROLLAREA_H
#define SCROLLAREA_H

Expand Down Expand Up @@ -34,6 +37,7 @@ private slots:
private:
bool m_update;
QPoint m_previousPos;
int m_width;

void updateBorders();
};
Expand Down
3 changes: 3 additions & 0 deletions util.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef UTIL
#define UTIL

Expand Down
3 changes: 3 additions & 0 deletions widget.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#include <QResizeEvent>
#include "widget.h"

Expand Down
3 changes: 3 additions & 0 deletions widget.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich

#ifndef WIDGET_H
#define WIDGET_H

Expand Down

0 comments on commit 65f87e7

Please sign in to comment.