Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
File save confirmation dialog on app close in heightmap mode fix.
  • Loading branch information
Denvi committed Sep 6, 2015
1 parent 1dc5c32 commit b747ad3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 31 deletions.
34 changes: 18 additions & 16 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QScrollBar>
#include <QShortcut>
#include <QAction>
#include <QLayout>
#include "frmmain.h"
#include "ui_frmmain.h"

Expand All @@ -31,8 +32,11 @@ frmMain::frmMain(QWidget *parent) :
m_taskBarProgress = NULL;
ui->cboCommand->setStyleSheet("QComboBox {padding: 2 2;} QComboBox::drop-down {width: 0; border-style: none;} QComboBox::down-arrow {image: url(noimg); border-width: 0;}");
#endif
ui->chkHeightMapBorderAuto->hide();

m_heightMapMode = false;
m_lastDrawnLineIndex = 0;
m_fileProcessedCommandIndex = 0;

m_currentModel = &m_programModel;

Expand All @@ -58,7 +62,8 @@ frmMain::frmMain(QWidget *parent) :

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

m_frmSettings.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
// m_frmSettings.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
m_frmSettings.layout()->setSizeConstraint(QLayout::SetFixedSize);

m_codeDrawer = new GcodeDrawer(this);
m_codeDrawer->setViewParser(&m_viewParser);
Expand All @@ -68,6 +73,8 @@ frmMain::frmMain(QWidget *parent) :
m_probeDrawer->setViewParser(&m_probeParser);
m_probeDrawer->setVisible(false);

m_heightMapGridDrawer.setModel(&m_heightMapModel);

m_currentDrawer = m_codeDrawer;

m_toolDrawer.setToolPosition(QVector3D(0, 0, 0));
Expand Down Expand Up @@ -131,25 +138,16 @@ frmMain::frmMain(QWidget *parent) :
connect(&m_timerConnection, SIGNAL(timeout()), this, SLOT(onTimerConnection()));
connect(&m_timerStateQuery, SIGNAL(timeout()), this, SLOT(onTimerStateQuery()));

updateControlsState();
applySettings();

m_lastDrawnLineIndex = 0;
m_fileProcessedCommandIndex = 0;

m_timerConnection.start(1000);
m_timerStateQuery.start();

connect(ui->cboCommand, SIGNAL(returnPressed()), this, SLOT(onCboCommandReturnPressed()));

// m_heightMapModel.resize(1, 1);

m_heightMapGridDrawer.setModel(&m_heightMapModel);
applySettings();
updateControlsState();

this->installEventFilter(this);
ui->tblProgram->installEventFilter(this);

ui->chkHeightMapBorderAuto->hide();
m_timerConnection.start(1000);
m_timerStateQuery.start();
}

frmMain::~frmMain()
Expand Down Expand Up @@ -359,8 +357,6 @@ bool frmMain::saveChanges(bool heightMapMode)
void frmMain::updateControlsState() {
bool portOpened = m_serialPort.isOpen();

// this->setUpdatesEnabled(false);

ui->grpState->setEnabled(portOpened);
ui->grpControl->setEnabled(portOpened);
ui->widgetSpindle->setEnabled(portOpened);
Expand Down Expand Up @@ -434,6 +430,7 @@ void frmMain::updateControlsState() {

ui->grpHeightMapSettings->setVisible(m_heightMapMode);
ui->grpHeightMapSettings->setEnabled(!m_transferringFile);

ui->chkTestMode->setVisible(!m_heightMapMode);
ui->chkAutoScroll->setVisible(!m_heightMapMode);

Expand Down Expand Up @@ -1143,14 +1140,19 @@ void frmMain::timerEvent(QTimerEvent *te)

void frmMain::closeEvent(QCloseEvent *ce)
{
bool mode = m_heightMapMode;
m_heightMapMode = false;

if (!saveChanges(m_heightMapMode)) {
ce->ignore();
m_heightMapMode = mode;
return;
}

if (m_transferringFile && QMessageBox::warning(this, this->windowTitle(), tr("File sending in progress. Terminate and exit?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
ce->ignore();
m_heightMapMode = mode;
return;
}

Expand Down
16 changes: 8 additions & 8 deletions frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>921</width>
<height>889</height>
<width>839</width>
<height>788</height>
</rect>
</property>
<property name="palette">
Expand Down Expand Up @@ -161,11 +161,11 @@ QSplitter::handle {
QSplitter::handle:vertical {
background-image: url(&quot;:/images/handle_horizontal.png&quot;);
}

/*
QSplitter::handle:horizontal {
background-image: url(&quot;:/images/handle_vertical.png&quot;);
}

*/
QTableView {
selection-background-color: #cdcdff;
selection-color: rgb(0, 0, 0);
Expand Down Expand Up @@ -1678,8 +1678,8 @@ color: black;</string>
<rect>
<x>0</x>
<y>0</y>
<width>245</width>
<height>662</height>
<width>237</width>
<height>612</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -2727,8 +2727,8 @@ QDoubleSpinBox:focus {
<rect>
<x>0</x>
<y>0</y>
<width>921</width>
<height>26</height>
<width>839</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="mnuFile">
Expand Down
4 changes: 2 additions & 2 deletions frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>697</height>
<width>304</width>
<height>403</height>
</rect>
</property>
<property name="windowTitle">
Expand Down
2 changes: 1 addition & 1 deletion gcodetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public slots:

private:
QList<GCodeItem*> m_data;
QStringList m_headers;
QList<QString> m_headers;
};

#endif // GCODETABLEMODEL_H
2 changes: 1 addition & 1 deletion grbl_control.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ unix: {

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

VERSION = 0.5
VERSION = 0.5.2

DEFINES += APP_VERSION=\\\"$$VERSION\\\"

Expand Down
2 changes: 1 addition & 1 deletion heightmaptablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool HeightMapTableModel::insertRow(int row, const QModelIndex &parent)

bool HeightMapTableModel::removeRow(int row, const QModelIndex &parent)
{
m_data.removeAt(row);
m_data.remove(row);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion heightmaptablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HeightMapTableModel : public QAbstractTableModel
private:
// QList<QList<double>> m_data;
QVector<QVector<double>> m_data;
QStringList m_headers;
QList<QString> m_headers;
};

#endif // HEIGHTMAPTABLEMODEL_H
2 changes: 1 addition & 1 deletion scrollarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ScrollArea::setWidget(QWidget *widget)
foreach (GroupBox *box, list) {
connect(box, SIGNAL(mouseMoved(int,int)), this, SLOT(onScroll(int,int)));
connect(box, SIGNAL(mousePressed()), this, SLOT(onPressed()));
m_width = qMax<int>(m_width, box->sizeHint().width() + box->layout()->contentsMargins().left()); // 1 * margin
m_width = qMax<int>(m_width, box->sizeHint().width() + box->layout()->contentsMargins().left() + 4); // 1 * margin
}

QScrollArea::setWidget(widget);
Expand Down

0 comments on commit b747ad3

Please sign in to comment.