Compare commits
2 commits
dc8951776f
...
c7d77c30ab
| Author | SHA1 | Date | |
|---|---|---|---|
| c7d77c30ab | |||
| 75fdfaa095 |
3 changed files with 92 additions and 8 deletions
|
|
@ -104,7 +104,6 @@ Session::Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx
|
|||
if (FAILED(sessionControl->QueryInterface(__uuidof(IAudioMeterInformation), (void**)&meterInformation))) { log_wdebugcpp(L"sPeakbros......"); };
|
||||
//meterInformation = (IAudioMeterInformation*)sessionControl;
|
||||
|
||||
|
||||
AudioSessionState msState;
|
||||
sessionControl->GetState(&msState);
|
||||
switch (msState) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "qtclasses.h"
|
||||
#define POLLING_RATE 2
|
||||
|
||||
template <typename T>
|
||||
CustomWidgetEvent<T>::CustomWidgetEvent(QEvent::Type type, T payload) : QEvent(type){
|
||||
|
|
@ -10,6 +11,69 @@ void MeterSlider::setPeakValue(float peakValue) {
|
|||
}
|
||||
|
||||
void MeterSlider::paintEvent(QPaintEvent *event) {
|
||||
QStyleOptionSlider sliderComplex = QStyleOptionSlider();
|
||||
sliderComplex.initFrom(this);
|
||||
/*
|
||||
* sliderComplex.initFrom(this);
|
||||
* sliderComplex.subControls = QStyle::SC_None;
|
||||
* sliderComplex.activeSubControls = QStyle::SC_None;
|
||||
* sliderComplex.orientation = this->orientation();
|
||||
* sliderComplex.maximum = this->maximum();
|
||||
* sliderComplex.minimum = this->minimum();
|
||||
* sliderComplex.tickPosition = (QSlider::TickPosition)this->tickPosition();
|
||||
* sliderComplex.tickInterval = this->tickInterval();
|
||||
* sliderComplex.upsideDown = (this->orientation() == Qt::Horizontal) ?
|
||||
* (this->invertedAppearance() != (sliderComplex.direction == Qt::RightToLeft))
|
||||
* : (!this->invertedAppearance());
|
||||
* sliderComplex.direction = Qt::LeftToRight; // we use the upsideDown option instead
|
||||
* sliderComplex.sliderPosition = this->sliderPosition();
|
||||
* sliderComplex.sliderValue = this->value();
|
||||
* sliderComplex.singleStep = this->singleStep();
|
||||
* sliderComplex.pageStep = this->pageStep();
|
||||
* if (this->orientation() == Qt::Horizontal)
|
||||
* sliderComplex.state |= QStyle::State_Horizontal;
|
||||
*
|
||||
* if (this->isSliderDown()) {
|
||||
* sliderComplex.activeSubControls = QStyle::SC_SliderHandle;
|
||||
* sliderComplex.state |= QStyle::State_Sunken;
|
||||
* } else {
|
||||
* sliderComplex.activeSubControls = QStyle::SC_SliderHandle;
|
||||
* }
|
||||
*
|
||||
* //sliderComplex.subControls = QStyle::SC_SliderGroove;
|
||||
* if (this->tickPosition() != NoTicks) sliderComplex.subControls |= QStyle::SC_SliderTickmarks;
|
||||
* QStylePainter p(this);
|
||||
* 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;
|
||||
* }
|
||||
*/
|
||||
|
||||
//Q_D(QSlider);
|
||||
/*
|
||||
* QStylePainter p(this);
|
||||
|
|
@ -22,7 +86,9 @@ void MeterSlider::paintEvent(QPaintEvent *event) {
|
|||
*
|
||||
* //p.drawComplexControl(QStyle::CC_Slider, opt);
|
||||
*/
|
||||
QSlider::paintEvent(event);
|
||||
//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);
|
||||
|
|
@ -32,10 +98,29 @@ void MeterSlider::paintEvent(QPaintEvent *event) {
|
|||
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 slider = QStyleOptionSlider();
|
||||
QRect test = QApplication::style()->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&slider, QStyle::SC_SliderHandle);
|
||||
painter.fillRect(0, (this->height() / 2) - 3, (this->width() * (this->peakValue)), 4, Qt::green);
|
||||
//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) {
|
||||
|
|
@ -260,7 +345,7 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
|||
mainSlider->blockSignals(false);
|
||||
muteButton->blockSignals(false);
|
||||
});
|
||||
volumePoller->start(2);
|
||||
volumePoller->start(POLLING_RATE);
|
||||
}
|
||||
|
||||
void SessionWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||
|
|
@ -507,7 +592,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
mainSlider->blockSignals(false);
|
||||
muteButton->blockSignals(false);
|
||||
});
|
||||
timer->start(2);
|
||||
timer->start(POLLING_RATE);
|
||||
|
||||
/* First Widget batch */
|
||||
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ int main (int argc, char* argv[]) {
|
|||
* log_debugcpp(a.toStdString());
|
||||
* }
|
||||
*/
|
||||
QApplication::setStyle("Fusion");
|
||||
//QApplication::setStyle("Fusion");
|
||||
//Check if running
|
||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||
initialize_file_log();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue