Commit c9da580c984ae46c8581cd6fae1bdc456a1b550f
Committed by
David Gräff
1 parent
9676c169
Fix settings loader, change LevelSlider needle shape
Showing
6 changed files
with
37 additions
and
34 deletions
openhantek/src/dsowidget.cpp
| ... | ... | @@ -217,6 +217,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla |
| 217 | 217 | mainScope->update(); |
| 218 | 218 | zoomScope->update(); |
| 219 | 219 | }); |
| 220 | + updateTriggerSource(); | |
| 220 | 221 | } |
| 221 | 222 | |
| 222 | 223 | void DsoWidget::showNewData(std::unique_ptr<DataAnalyzerResult> data) { | ... | ... |
openhantek/src/hantek/hantekdsocontrol.cpp
| ... | ... | @@ -220,7 +220,6 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) : device(device) { |
| 220 | 220 | break; |
| 221 | 221 | |
| 222 | 222 | case MODEL_DSO5200A: |
| 223 | - [[clang::fallthrough]]; | |
| 224 | 223 | case MODEL_DSO5200: |
| 225 | 224 | // Instantiate additional commands for the DSO-5200 |
| 226 | 225 | command[BULK_CSETTRIGGERORSAMPLERATE] = new BulkSetSamplerate5200(); | ... | ... |
openhantek/src/main.cpp
| ... | ... | @@ -162,8 +162,7 @@ int main(int argc, char *argv[]) { |
| 162 | 162 | QObject::connect(&dsoControl, &HantekDsoControl::samplesAvailable, &dataAnalyser, &DataAnalyzer::samplesAvailable); |
| 163 | 163 | |
| 164 | 164 | //////// Create settings object //////// |
| 165 | - DsoSettings settings; | |
| 166 | - settings.setChannelCount(dsoControl.getChannelCount()); | |
| 165 | + DsoSettings settings(dsoControl.getChannelCount()); | |
| 167 | 166 | dataAnalyser.applySettings(&settings.scope); |
| 168 | 167 | |
| 169 | 168 | //////// Create main window //////// | ... | ... |
openhantek/src/settings.cpp
| ... | ... | @@ -33,7 +33,10 @@ |
| 33 | 33 | |
| 34 | 34 | /// \brief Set the number of channels. |
| 35 | 35 | /// \param channels The new channel count, that will be applied to lists. |
| 36 | -DsoSettings::DsoSettings() { load(); } | |
| 36 | +DsoSettings::DsoSettings(unsigned int channels) { | |
| 37 | + setChannelCount(channels); | |
| 38 | + load(); | |
| 39 | +} | |
| 37 | 40 | |
| 38 | 41 | bool DsoSettings::setFilename(const QString &filename) { |
| 39 | 42 | std::unique_ptr<QSettings> local = std::unique_ptr<QSettings>(new QSettings(filename, QSettings::IniFormat)); | ... | ... |
openhantek/src/settings.h
| ... | ... | @@ -23,7 +23,7 @@ struct DsoSettingsOptions { |
| 23 | 23 | /// \brief Holds the settings of the program. |
| 24 | 24 | class DsoSettings { |
| 25 | 25 | public: |
| 26 | - DsoSettings(); | |
| 26 | + explicit DsoSettings(unsigned int channels); | |
| 27 | 27 | bool setFilename(const QString &filename); |
| 28 | 28 | |
| 29 | 29 | void setChannelCount(unsigned int channels); | ... | ... |
openhantek/src/widgets/levelslider.cpp
| ... | ... | @@ -40,7 +40,7 @@ LevelSlider::LevelSlider(Qt::ArrowType direction, QWidget *parent) : QWidget(par |
| 40 | 40 | this->setFont(font); |
| 41 | 41 | |
| 42 | 42 | this->pressedSlider = -1; |
| 43 | - this->sliderWidth = 8; | |
| 43 | + this->sliderWidth = 12; | |
| 44 | 44 | |
| 45 | 45 | this->setDirection(direction); |
| 46 | 46 | } |
| ... | ... | @@ -381,44 +381,45 @@ void LevelSlider::paintEvent(QPaintEvent *event) { |
| 381 | 381 | painter.setPen((*slider)->color); |
| 382 | 382 | |
| 383 | 383 | if ((*slider)->text.isEmpty()) { |
| 384 | - int needlePoints[6]; | |
| 384 | + QVector<QPoint> needlePoints; | |
| 385 | + QRect& sRect = (*slider)->rect; | |
| 386 | + const int W = this->sliderWidth; | |
| 385 | 387 | |
| 386 | 388 | switch (this->_direction) { |
| 387 | 389 | case Qt::LeftArrow: |
| 388 | - needlePoints[0] = (*slider)->rect.left() + 4; | |
| 389 | - needlePoints[1] = (*slider)->rect.top(); | |
| 390 | - needlePoints[2] = (*slider)->rect.left() + 1; | |
| 391 | - needlePoints[3] = (*slider)->rect.top() + 3; | |
| 392 | - needlePoints[4] = (*slider)->rect.left() + 4; | |
| 393 | - needlePoints[5] = (*slider)->rect.top() + 6; | |
| 390 | + needlePoints << QPoint(sRect.left() + 4, sRect.top() ) | |
| 391 | + << QPoint(sRect.left() + 1, sRect.top() + 3) | |
| 392 | + << QPoint(sRect.left() + 4, sRect.top() + 6) | |
| 393 | + << QPoint(sRect.left() + W, sRect.top() + 6) | |
| 394 | + << QPoint(sRect.left() + W, sRect.top() ); | |
| 394 | 395 | break; |
| 395 | 396 | case Qt::UpArrow: |
| 396 | - needlePoints[0] = (*slider)->rect.left(); | |
| 397 | - needlePoints[1] = (*slider)->rect.top() + 4; | |
| 398 | - needlePoints[2] = (*slider)->rect.left() + 3; | |
| 399 | - needlePoints[3] = (*slider)->rect.top() + 1; | |
| 400 | - needlePoints[4] = (*slider)->rect.left() + 6; | |
| 401 | - needlePoints[5] = (*slider)->rect.top() + 4; | |
| 397 | + needlePoints << QPoint(sRect.left(), sRect.top() + 4) | |
| 398 | + << QPoint(sRect.left() + 3, sRect.top() + 1) | |
| 399 | + << QPoint(sRect.left() + 6, sRect.top() + 4) | |
| 400 | + << QPoint(sRect.left() + 6, sRect.top() + W) | |
| 401 | + << QPoint(sRect.left(), sRect.top() + W); | |
| 402 | 402 | break; |
| 403 | 403 | case Qt::DownArrow: |
| 404 | - needlePoints[0] = (*slider)->rect.left(); | |
| 405 | - needlePoints[1] = (*slider)->rect.top() + this->sliderWidth - 5; | |
| 406 | - needlePoints[2] = (*slider)->rect.left() + 3; | |
| 407 | - needlePoints[3] = (*slider)->rect.top() + this->sliderWidth - 2; | |
| 408 | - needlePoints[4] = (*slider)->rect.left() + 6; | |
| 409 | - needlePoints[5] = (*slider)->rect.top() + this->sliderWidth - 5; | |
| 404 | + needlePoints << QPoint(sRect.left(), sRect.top() + W - 5) | |
| 405 | + << QPoint(sRect.left() + 3, sRect.top() + W - 2) | |
| 406 | + << QPoint(sRect.left() + 6, sRect.top() + W - 5) | |
| 407 | + << QPoint(sRect.left() + 6, sRect.top() ) | |
| 408 | + << QPoint(sRect.left(), sRect.top() ); | |
| 409 | + break; | |
| 410 | + case Qt::RightArrow: | |
| 411 | + needlePoints << QPoint(sRect.left() + W - 5, sRect.top() ) | |
| 412 | + << QPoint(sRect.left() + W - 2, sRect.top() + 3) | |
| 413 | + << QPoint(sRect.left() + W - 5, sRect.top() + 6) | |
| 414 | + << QPoint(sRect.left(), sRect.top() + 6) | |
| 415 | + << QPoint(sRect.left(), sRect.top() ); | |
| 410 | 416 | break; |
| 411 | 417 | default: |
| 412 | - needlePoints[0] = (*slider)->rect.left() + this->sliderWidth - 5; | |
| 413 | - needlePoints[1] = (*slider)->rect.top(); | |
| 414 | - needlePoints[2] = (*slider)->rect.left() + this->sliderWidth - 2; | |
| 415 | - needlePoints[3] = (*slider)->rect.top() + 3; | |
| 416 | - needlePoints[4] = (*slider)->rect.left() + this->sliderWidth - 5; | |
| 417 | - needlePoints[5] = (*slider)->rect.top() + 6; | |
| 418 | + break; | |
| 418 | 419 | } |
| 419 | 420 | |
| 420 | 421 | painter.setBrush(QBrush((*slider)->color, Qt::SolidPattern)); |
| 421 | - painter.drawPolygon(QPolygon(3, needlePoints)); | |
| 422 | + painter.drawPolygon(QPolygon(needlePoints)); | |
| 422 | 423 | painter.setBrush(Qt::NoBrush); |
| 423 | 424 | } else { |
| 424 | 425 | // Get rect for text and draw needle |
| ... | ... | @@ -539,8 +540,8 @@ QRect LevelSlider::calculateRect(int sliderId) { |
| 539 | 540 | /// \brief Search for the widest slider element. |
| 540 | 541 | /// \return The calculated width of the slider. |
| 541 | 542 | int LevelSlider::calculateWidth() { |
| 542 | - // At least 8 px for the needles | |
| 543 | - this->sliderWidth = 8; | |
| 543 | + // At least 12 px for the needles | |
| 544 | + this->sliderWidth = 12; | |
| 544 | 545 | |
| 545 | 546 | // Is it a vertical slider? |
| 546 | 547 | if (this->_direction == Qt::RightArrow || this->_direction == Qt::LeftArrow) { | ... | ... |