Skip to content

Commit

Permalink
Custom scrollarea style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Denvi committed Sep 20, 2015
1 parent 7b587b3 commit a59dc4c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 173 deletions.
60 changes: 15 additions & 45 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ frmMain::frmMain(QWidget *parent) :
#endif
ui->scrollArea->updateMinimumWidth();

ui->chkHeightMapBorderAuto->hide();

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

m_programLoading = false;
m_currentModel = &m_programModel;

ui->txtJogStep->setLocale(QLocale::C);
Expand All @@ -69,30 +67,18 @@ frmMain::frmMain(QWidget *parent) :
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);
// m_frmSettings.layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(ui->cboCommand, SIGNAL(returnPressed()), this, SLOT(onCboCommandReturnPressed()));

m_originDrawer = new OriginDrawer();

m_codeDrawer = new GcodeDrawer();
m_codeDrawer->setViewParser(&m_viewParser);
// m_codeDrawer->setObjectName("codeDrawer");

m_probeDrawer = new GcodeDrawer();
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));

m_settingsFileName = qApp->applicationDirPath() + "/settings.ini";
loadSettings();

foreach (StyledToolButton* button, ui->grpJog->findChildren<StyledToolButton*>(QRegExp("cmdJogStep\\d")))
{
connect(button, SIGNAL(clicked(bool)), this, SLOT(onCmdJogStepClicked()));
Expand Down Expand Up @@ -126,43 +112,41 @@ frmMain::frmMain(QWidget *parent) :
connect(&m_heightMapModel, SIGNAL(dataChangedByUserInput()), this, SLOT(updateHeightMapInterpolationDrawer()));

ui->tblProgram->setModel(&m_programModel);

ui->tblProgram->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
ui->tblProgram->hideColumn(4);
ui->tblProgram->hideColumn(5);
// ui->tblProgram->showColumn(4);

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

// Loading settings
m_settingsFileName = qApp->applicationDirPath() + "/settings.ini";
loadSettings();

// Setup serial port
m_serialPort.setParity(QSerialPort::NoParity);
m_serialPort.setDataBits(QSerialPort::Data8);
m_serialPort.setFlowControl(QSerialPort::NoFlowControl);
m_serialPort.setStopBits(QSerialPort::OneStop);

if (m_frmSettings.port() != "") {
m_serialPort.setPortName(m_frmSettings.port());
m_serialPort.setBaudRate(m_frmSettings.baud());
}

connect(&m_serialPort, SIGNAL(readyRead()), this, SLOT(onSerialPortReadyRead()));
connect(&m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(onSerialPortError(QSerialPort::SerialPortError)));

connect(&m_timerConnection, SIGNAL(timeout()), this, SLOT(onTimerConnection()));
connect(&m_timerStateQuery, SIGNAL(timeout()), this, SLOT(onTimerStateQuery()));

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

// Apply settings
show(); // Visibility bug workaround
applySettings();
updateControlsState();

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

connect(&m_timerConnection, SIGNAL(timeout()), this, SLOT(onTimerConnection()));
connect(&m_timerStateQuery, SIGNAL(timeout()), this, SLOT(onTimerStateQuery()));
m_timerConnection.start(1000);
m_timerStateQuery.start();

// ui->glwVisualizer->setVisible(false);
}

frmMain::~frmMain()
Expand Down Expand Up @@ -209,7 +193,8 @@ void frmMain::loadSettings()
m_frmSettings.setToolAngle(set.value("toolAngle", 0).toDouble());
m_frmSettings.setToolType(set.value("toolType", 0).toInt());
m_frmSettings.setFps(set.value("fps", 60).toInt());
m_frmSettings.setQueryStateTime(set.value("queryStateTime", 250).toInt());
m_frmSettings.setQueryStateTime(set.value("queryStateTime", 250).toInt());

m_frmSettings.setPanelHeightmap(set.value("panelHeightmapVisible", true).toBool());
m_frmSettings.setPanelSpindle(set.value("panelSpindleVisible", true).toBool());
m_frmSettings.setPanelFeed(set.value("panelFeedVisible", true).toBool());
Expand Down Expand Up @@ -246,6 +231,7 @@ void frmMain::loadSettings()
ui->grpSpindle->setChecked(set.value("spindlePanel", true).toBool());
ui->grpFeed->setChecked(set.value("feedPanel", true).toBool());
ui->grpJog->setChecked(set.value("jogPanel", true).toBool());

m_storedKeyboardControl = set.value("keyboardControl", false).toBool();

ui->cboCommand->addItems(set.value("recentCommands", QStringList()).toStringList());
Expand All @@ -258,7 +244,6 @@ void frmMain::loadSettings()
ui->txtHeightMapBorderY->setValue(set.value("heightmapBorderY", 0).toDouble());
ui->txtHeightMapBorderWidth->setValue(set.value("heightmapBorderWidth", 1).toDouble());
ui->txtHeightMapBorderHeight->setValue(set.value("heightmapBorderHeight", 1).toDouble());
ui->chkHeightMapBorderAuto->setChecked(set.value("heightmapBorderAuto", false).toBool());
ui->chkHeightMapBorderShow->setChecked(set.value("heightmapBorderShow", false).toBool());

ui->txtHeightMapGridX->setValue(set.value("heightmapGridX", 1).toDouble());
Expand Down Expand Up @@ -342,7 +327,6 @@ void frmMain::saveSettings()
set.setValue("heightmapBorderY", ui->txtHeightMapBorderY->value());
set.setValue("heightmapBorderWidth", ui->txtHeightMapBorderWidth->value());
set.setValue("heightmapBorderHeight", ui->txtHeightMapBorderHeight->value());
set.setValue("heightmapBorderAuto", ui->chkHeightMapBorderAuto->isChecked());
set.setValue("heightmapBorderShow", ui->chkHeightMapBorderShow->isChecked());

set.setValue("heightmapGridX", ui->txtHeightMapGridX->value());
Expand Down Expand Up @@ -2337,20 +2321,6 @@ QRectF frmMain::borderRectFromExtremes()
return rect;
}

void frmMain::on_chkHeightMapBorderAuto_toggled(bool checked)
{
if (checked) {
// QRectF rect = borderRectFromExtremes();

// if (!std::isnan(rect.width()) && !std::isnan(rect.height())) {
// ui->txtHeightMapBorderX->setValue(rect.x());
// ui->txtHeightMapBorderY->setValue(rect.y());
// ui->txtHeightMapBorderWidth->setValue(rect.width());
// ui->txtHeightMapBorderHeight->setValue(rect.height());
// }
}
}

void frmMain::updateHeightMapBorderDrawer()
{
if (m_settingsLoading) return;
Expand Down
1 change: 0 additions & 1 deletion frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private slots:
void on_actRecentClear_triggered();
void on_sliSpindleSpeed_sliderReleased();
void on_grpHeightMap_toggled(bool arg1);
void on_chkHeightMapBorderAuto_toggled(bool checked);
void on_chkHeightMapBorderShow_toggled(bool checked);
void on_txtHeightMapBorderX_valueChanged(double arg1);
void on_txtHeightMapBorderWidth_valueChanged(double arg1);
Expand Down
98 changes: 3 additions & 95 deletions frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,6 @@
font-size: 9pt;
}

QScrollArea#scrollArea QScrollBar:vertical {
/* background-color: transparent;*/
border: none;
width: 2px;
padding-top: 8px;
}
QScrollArea#scrollArea QScrollBar::handle:vertical {
background: darkgray;
}
QScrollArea#scrollArea QScrollBar::add-line:vertical {
border: none;
background: none;
height: 0px;
}
QScrollArea#scrollArea QScrollBar::sub-line:vertical {
border: none;
background: none;
height: 0px;
}

QSpinBox, QDoubleSpinBox {
padding-top: 1px;
padding-bottom: 1px;
Expand Down Expand Up @@ -669,16 +649,6 @@ QToolButton:checked { /* all types of tool button */
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QCheckBox" name="chkHeightMapBorderAuto">
<property name="text">
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkHeightMapBorderShow">
<property name="text">
Expand Down Expand Up @@ -1588,6 +1558,9 @@ color: black;</string>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -2778,7 +2751,6 @@ QDoubleSpinBox:focus {
<tabstop>txtHeightMapBorderY</tabstop>
<tabstop>txtHeightMapBorderWidth</tabstop>
<tabstop>txtHeightMapBorderHeight</tabstop>
<tabstop>chkHeightMapBorderAuto</tabstop>
<tabstop>chkHeightMapBorderShow</tabstop>
<tabstop>cmdHeightMapBorderAuto</tabstop>
<tabstop>txtHeightMapGridX</tabstop>
Expand Down Expand Up @@ -2837,70 +2809,6 @@ QDoubleSpinBox:focus {
<include location="images.qrc"/>
</resources>
<connections>
<connection>
<sender>chkHeightMapBorderAuto</sender>
<signal>toggled(bool)</signal>
<receiver>txtHeightMapBorderX</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>79</x>
<y>1080</y>
</hint>
<hint type="destinationlabel">
<x>129</x>
<y>1027</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkHeightMapBorderAuto</sender>
<signal>toggled(bool)</signal>
<receiver>txtHeightMapBorderY</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>79</x>
<y>1080</y>
</hint>
<hint type="destinationlabel">
<x>230</x>
<y>1027</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkHeightMapBorderAuto</sender>
<signal>toggled(bool)</signal>
<receiver>txtHeightMapBorderWidth</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>79</x>
<y>1080</y>
</hint>
<hint type="destinationlabel">
<x>129</x>
<y>1053</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkHeightMapBorderAuto</sender>
<signal>toggled(bool)</signal>
<receiver>txtHeightMapBorderHeight</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>79</x>
<y>1080</y>
</hint>
<hint type="destinationlabel">
<x>230</x>
<y>1053</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkKeyboardControl</sender>
<signal>toggled(bool)</signal>
Expand Down
25 changes: 4 additions & 21 deletions frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@ QGroupBox {
border: none;
padding-top: 16;
font-weight: bold;
}

QScrollArea QScrollBar:vertical {
/* background-color: transparent;*/
border: none;
width: 2px;
padding-top: 8px;
}
QScrollArea QScrollBar::handle:vertical {
background: darkgray;
}
QScrollArea QScrollBar::add-line:vertical {
border: none;
background: none;
height: 0px;
}
QScrollArea QScrollBar::sub-line:vertical {
border: none;
background: none;
height: 0px;
}</string>
</property>
<property name="modal">
Expand Down Expand Up @@ -90,6 +70,9 @@ QScrollArea QScrollBar::sub-line:vertical {
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
Expand All @@ -100,7 +83,7 @@ QScrollArea QScrollBar::sub-line:vertical {
<property name="geometry">
<rect>
<x>0</x>
<y>-528</y>
<y>0</y>
<width>344</width>
<height>986</height>
</rect>
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char *argv[])
foreach (QString str, QStyleFactory::keys()) {
qDebug() << str;
if (str.contains("GTK+")) {
a.setStyle(QStyleFactory::create(str));
// a.setStyle(QStyleFactory::create(str));
break;
}
}
Expand Down
Loading

0 comments on commit a59dc4c

Please sign in to comment.