Skip to content

Commit

Permalink
Brightness range adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
breakingspell committed May 10, 2024
1 parent 6c09cd5 commit 364e29f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/arbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ void Arbiter::set_brightness(uint8_t brightness)

void Arbiter::decrease_brightness(uint8_t val)
{
this->set_brightness(std::min(std::max(76, this->system().brightness.value - val), 255));
this->set_brightness(std::min(std::max(20, this->system().brightness.value - val), 180));
}

void Arbiter::increase_brightness(uint8_t val)
{
this->set_brightness(std::min(std::max(76, this->system().brightness.value + val), 255));
this->set_brightness(std::min(std::max(20, this->system().brightness.value + val), 180));
}

void Arbiter::set_volume(uint8_t volume)
Expand Down
10 changes: 5 additions & 5 deletions src/app/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const char *Session::System::Brightness::AUTO_PLUGIN = "auto";

Session::System::Brightness::Brightness(QSettings &settings)
: plugin(settings.value("System/Brightness/plugin", Session::System::Brightness::AUTO_PLUGIN).toString())
, value(settings.value("System/Brightness/value", 255).toUInt())
, value(settings.value("System/Brightness/value", 180).toUInt())
, loader_()
{
for (const auto file : Session::plugin_dir("brightness").entryInfoList(QDir::Files)) {
Expand Down Expand Up @@ -206,7 +206,7 @@ void Session::System::Brightness::set()
void Session::System::Brightness::reset()
{
if (auto plugin = qobject_cast<BrightnessPlugin *>(this->loader_.instance()))
plugin->set(255);
plugin->set(180);
}

const QList<QString> &Session::System::Brightness::plugins() const
Expand Down Expand Up @@ -313,7 +313,7 @@ QWidget *Session::Forge::brightness_slider(bool buttons) const

auto slider = new QSlider(Qt::Orientation::Horizontal);
slider->setTracking(false);
slider->setRange(76, 255);
slider->setRange(20, 180);
slider->setValue(this->arbiter_.system().brightness.value);
QObject::connect(slider, &QSlider::sliderReleased, [this, slider]{
this->arbiter_.set_brightness(slider->sliderPosition());
Expand All @@ -324,12 +324,12 @@ QWidget *Session::Forge::brightness_slider(bool buttons) const
auto dim_button = new QPushButton();
dim_button->setFlat(true);
this->iconize("brightness_low", dim_button, 26);
QObject::connect(dim_button, &QPushButton::clicked, [this]{ this->arbiter_.decrease_brightness(18); });
QObject::connect(dim_button, &QPushButton::clicked, [this]{ this->arbiter_.decrease_brightness(20); });

auto brighten_button = new QPushButton();
brighten_button->setFlat(true);
this->iconize("brightness_high", brighten_button, 26);
QObject::connect(brighten_button, &QPushButton::clicked, [this]{ this->arbiter_.increase_brightness(18); });
QObject::connect(brighten_button, &QPushButton::clicked, [this]{ this->arbiter_.increase_brightness(20); });

layout->addWidget(dim_button);
layout->addWidget(brighten_button);
Expand Down

0 comments on commit 364e29f

Please sign in to comment.