wip: bad build config, unnecesary reimpl. Step by step
This commit is contained in:
parent
0e123f886d
commit
f8171f12f3
5 changed files with 640 additions and 135 deletions
|
|
@ -34,6 +34,7 @@ bool MeterSlider::event(QEvent* ev) {
|
|||
void MeterSlider::paintEvent(QPaintEvent *event) {
|
||||
QStyleOptionSlider sliderComplex = QStyleOptionSlider();
|
||||
sliderComplex.initFrom(this);
|
||||
|
||||
/*
|
||||
* sliderComplex.initFrom(this);
|
||||
* sliderComplex.subControls = QStyle::SC_None;
|
||||
|
|
@ -64,36 +65,46 @@ void MeterSlider::paintEvent(QPaintEvent *event) {
|
|||
* //sliderComplex.subControls = QStyle::SC_SliderGroove;
|
||||
* if (this->tickPosition() != NoTicks) sliderComplex.subControls |= QStyle::SC_SliderTickmarks;
|
||||
* QStylePainter p(this);
|
||||
* p.drawComplexControl(QStyle::CC_Slider, sliderComplex);
|
||||
*/
|
||||
//p.drawComplexControl(QStyle::CC_Slider, sliderComplex);
|
||||
|
||||
|
||||
/*
|
||||
* QStyleOptionSlider sliderComplex2 = QStyleOptionSlider();
|
||||
* sliderComplex2.initFrom(this);
|
||||
* sliderComplex2.orientation = this->orientation();
|
||||
* sliderComplex2.maximum = this->maximum();
|
||||
* sliderComplex2.minimum = this->minimum();
|
||||
* sliderComplex2.tickPosition = (QSlider::TickPosition)this->tickPosition();
|
||||
* sliderComplex2.tickInterval = this->tickInterval();
|
||||
* sliderComplex2.upsideDown = (this->orientation() == Qt::Horizontal) ?
|
||||
* (this->invertedAppearance() != (sliderComplex2.direction == Qt::RightToLeft))
|
||||
* : (!this->invertedAppearance());
|
||||
* sliderComplex2.subControls = QStyle::SC_SliderHandle;
|
||||
* sliderComplex2.direction = Qt::LeftToRight; // we use the upsideDown option instead
|
||||
* sliderComplex2.sliderPosition = this->sliderPosition();
|
||||
* sliderComplex2.sliderValue = this->value();
|
||||
* sliderComplex2.singleStep = this->singleStep();
|
||||
* sliderComplex2.pageStep = this->pageStep();
|
||||
* if (this->orientation() == Qt::Horizontal)
|
||||
* sliderComplex2.state |= QStyle::State_Horizontal;
|
||||
*
|
||||
* if (this->isSliderDown()) {
|
||||
* sliderComplex2.activeSubControls = QStyle::SC_SliderHandle;
|
||||
* sliderComplex2.state |= QStyle::State_Sunken;
|
||||
* } else {
|
||||
* sliderComplex2.activeSubControls = QStyle::SC_SliderHandle;
|
||||
* }
|
||||
*/
|
||||
|
||||
QStyleOptionSlider sliderComplex2 = QStyleOptionSlider();
|
||||
sliderComplex2.initFrom(this);
|
||||
sliderComplex2.orientation = this->orientation();
|
||||
sliderComplex2.maximum = this->maximum();
|
||||
sliderComplex2.minimum = this->minimum();
|
||||
sliderComplex2.tickPosition = (QSlider::TickPosition)this->tickPosition();
|
||||
sliderComplex2.tickInterval = this->tickInterval();
|
||||
sliderComplex2.upsideDown = (this->orientation() == Qt::Horizontal) ?
|
||||
(this->invertedAppearance() != (sliderComplex2.direction == Qt::RightToLeft))
|
||||
: (!this->invertedAppearance());
|
||||
sliderComplex2.subControls = QStyle::SC_SliderHandle;
|
||||
sliderComplex2.direction = Qt::LeftToRight; // we use the upsideDown option instead
|
||||
sliderComplex2.sliderPosition = this->sliderPosition();
|
||||
sliderComplex2.sliderValue = this->value();
|
||||
sliderComplex2.singleStep = this->singleStep();
|
||||
sliderComplex2.pageStep = this->pageStep();
|
||||
if (this->orientation() == Qt::Horizontal)
|
||||
sliderComplex2.state |= QStyle::State_Horizontal;
|
||||
|
||||
if (this->isSliderDown()) {
|
||||
sliderComplex2.activeSubControls = QStyle::SC_SliderHandle;
|
||||
sliderComplex2.state |= QStyle::State_Sunken;
|
||||
} else {
|
||||
sliderComplex2.activeSubControls = QStyle::SC_SliderHandle;
|
||||
}
|
||||
|
||||
sliderComplex2.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
|
||||
if ((QSlider::TickPosition)this->tickPosition() != NoTicks)
|
||||
sliderComplex2.subControls |= QStyle::SC_SliderTickmarks;
|
||||
|
||||
QPainter painter(this);
|
||||
QStyle* stle = QApplication::style();
|
||||
stle->drawComplexControl((QStyle::ComplexControl)CC_MeterSlider, &sliderComplex2, &painter, this);
|
||||
|
||||
|
||||
|
||||
//Q_D(QSlider);
|
||||
/*
|
||||
|
|
@ -108,39 +119,43 @@ void MeterSlider::paintEvent(QPaintEvent *event) {
|
|||
* //p.drawComplexControl(QStyle::CC_Slider, opt);
|
||||
*/
|
||||
//QSlider::paintEvent(event);
|
||||
int left = 0, top = 0, right = 0, bottom = 0;
|
||||
((QWidget*)parent())->layout()->getContentsMargins(&left, &top, &right, &bottom);
|
||||
|
||||
QStyle *style = QApplication::style();
|
||||
//int lol = style->pixelMetric(QStyle::PM_SliderSpaceAvailable);
|
||||
QPainter painter(this);
|
||||
//painter.setPen(Qt::blue);
|
||||
painter.setOpacity(1.0);
|
||||
painter.setClipping(false);
|
||||
painter.setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
|
||||
float peakLength = (this->width() * (this->peakValue));
|
||||
double stepWidth = (double)this->width() * ((double)this->singleStep() / (this->maximum() - this->minimum()));
|
||||
//Fusion seems to fuck around with bar's height and width
|
||||
//const qreal dpr = painter->device()->devicePixelRatio();
|
||||
//QStyleOptionSlider sliderComplex = QStyleOptionSlider(); //slider.initFrom(this);
|
||||
QRect sliderSize = style->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&sliderComplex, QStyle::SC_SliderHandle);
|
||||
int handleCenterPos = QStyle::sliderPositionFromValue(this->minimum(), this->maximum(), this->value(), this->width());
|
||||
int unattenuatedPeakMeter = ((this->width() * this->peakValue) >= handleCenterPos - (sliderSize.width() / 2))
|
||||
? this->width() - (sliderSize.width() / 2)
|
||||
: this->width() * this->peakValue;
|
||||
//QApplication::style()->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&slider, QStyle::SC_SliderHandle);
|
||||
painter.fillRect(0, (this->height() / 2) - 3, this->width(),
|
||||
4, Qt::white);
|
||||
painter.fillRect(0, (this->height() / 2) - 3, this->width() * this->peakValue,
|
||||
4, Qt::gray);
|
||||
painter.fillRect(0, (this->height() / 2) - 3, (this->width() - ((this->maximum() - this->value()) * stepWidth)) * this->peakValue,
|
||||
4, Qt::green);
|
||||
// - ((this->maximum() - this->value()) * stepWidth))
|
||||
//double ratio = ;
|
||||
double handleShift = (double)((sliderSize.width() * ((double)(this->maximum() - this->value()) / 100)));
|
||||
painter.fillRect((this->width() - ((this->maximum() - this->value()) * stepWidth)) - (sliderSize.width()) + handleShift, top / 2, sliderSize.width(), sliderSize.height() - bottom, Qt::magenta);
|
||||
//sliderComplex.subControls = QStyle::SC_SliderHandle;
|
||||
//p.drawComplexControl(QStyle::CC_Slider, sliderComplex);
|
||||
//IL CODE WENO lbockomet
|
||||
/*
|
||||
* int left = 0, top = 0, right = 0, bottom = 0;
|
||||
* ((QWidget*)parent())->layout()->getContentsMargins(&left, &top, &right, &bottom);
|
||||
*
|
||||
* QStyle *style = QApplication::style();
|
||||
* //int lol = style->pixelMetric(QStyle::PM_SliderSpaceAvailable);
|
||||
* QPainter painter(this);
|
||||
* //painter.setPen(Qt::blue);
|
||||
* painter.setOpacity(1.0);
|
||||
* painter.setClipping(false);
|
||||
* painter.setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
|
||||
* float peakLength = (this->width() * (this->peakValue));
|
||||
* double stepWidth = (double)this->width() * ((double)this->singleStep() / (this->maximum() - this->minimum()));
|
||||
* //Fusion seems to fuck around with bar's height and width
|
||||
* //const qreal dpr = painter->device()->devicePixelRatio();
|
||||
* //QStyleOptionSlider sliderComplex = QStyleOptionSlider(); //slider.initFrom(this);
|
||||
* QRect sliderSize = style->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&sliderComplex, QStyle::SC_SliderHandle);
|
||||
* int handleCenterPos = QStyle::sliderPositionFromValue(this->minimum(), this->maximum(), this->value(), this->width());
|
||||
* int unattenuatedPeakMeter = ((this->width() * this->peakValue) >= handleCenterPos - (sliderSize.width() / 2))
|
||||
* ? this->width() - (sliderSize.width() / 2)
|
||||
* : this->width() * this->peakValue;
|
||||
* //QApplication::style()->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&slider, QStyle::SC_SliderHandle);
|
||||
* painter.fillRect(0, (this->height() / 2) - 3, this->width(),
|
||||
* 4, Qt::white);
|
||||
* painter.fillRect(0, (this->height() / 2) - 3, this->width() * this->peakValue,
|
||||
* 4, Qt::gray);
|
||||
* painter.fillRect(0, (this->height() / 2) - 3, (this->width() - ((this->maximum() - this->value()) * stepWidth)) * this->peakValue,
|
||||
* 4, Qt::green);
|
||||
* // - ((this->maximum() - this->value()) * stepWidth))
|
||||
* //double ratio = ;
|
||||
* double handleShift = (double)((sliderSize.width() * ((double)(this->maximum() - this->value()) / 100)));
|
||||
* painter.fillRect((this->width() - ((this->maximum() - this->value()) * stepWidth)) - (sliderSize.width()) + handleShift, top / 2, sliderSize.width(), sliderSize.height() - bottom, Qt::magenta);
|
||||
* //sliderComplex.subControls = QStyle::SC_SliderHandle;
|
||||
* //p.drawComplexControl(QStyle::CC_Slider, sliderComplex);
|
||||
*/
|
||||
}
|
||||
|
||||
void ExtendedCheckBox::customEvent(QEvent* ev) {
|
||||
|
|
@ -317,8 +332,8 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
|||
mainSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
//mainSlider->setMinimumWidth(120 /*1/16 1080p*/);
|
||||
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
mainSlider->setTickInterval(5);
|
||||
//mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
//mainSlider->setTickInterval(5);
|
||||
mainSlider->setSingleStep(1);
|
||||
mainSlider->setRange(0,100);
|
||||
|
||||
|
|
@ -428,7 +443,7 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
|||
for(uint64_t channel = 0, col = 0, row = 0; channel < channelCount && channelCount > 1; channel++){
|
||||
MeterSlider* tmp = new MeterSlider(Qt::Horizontal);
|
||||
QLabel* tmpLb = new QLabel("");
|
||||
tmp->setTickInterval(5);
|
||||
//tmp->setTickInterval(5);
|
||||
tmp->setSingleStep(1);
|
||||
tmp->setRange(0,100);
|
||||
|
||||
|
|
@ -520,8 +535,8 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
//muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
|
||||
mainSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
mainSlider->setTickInterval(5);
|
||||
//mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
//mainSlider->setTickInterval(5);
|
||||
mainSlider->setSingleStep(1);
|
||||
mainSlider->setRange(0,100);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue