Skip to content

Commit

Permalink
Add slot Examples::infiniteButtonClicked.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent b07f62f commit 052166f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
30 changes: 18 additions & 12 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,9 @@ QGroupBox* Examples::wrapProgressBar(const QString& name,

QGroupBox* Examples::createProgressBarInfinite()
{
QObject::connect(
&startStopButtonInfinite_, &QPushButton::clicked, &progressBarInfinite_,
[&bar = progressBarInfinite_, &startStop = startStopButtonInfinite_]()
{
const bool running{bar.isRunning()};
if (running)
bar.stop();
else
bar.start();
startStop.setText(
(running ? QStringLiteral("start") : QStringLiteral("stop")));
});
QObject::connect(&startStopButtonInfinite_, &QPushButton::clicked, this,
&Examples::infiniteButtonClicked);

return wrapProgressBar(QStringLiteral("Infinite progress bar"),
&progressBarInfinite_, &startStopButtonInfinite_);
}
Expand Down Expand Up @@ -208,3 +199,18 @@ void Examples::filterStringsValuesChanged(QStringList bannedItems)
{
info_.setText("Names Filter: " + bannedItems.join(','));
}

void Examples::infiniteButtonClicked()
{
const bool running{progressBarInfinite_.isRunning()};
if (running)
{
progressBarInfinite_.stop();
startStopButtonInfinite_.setText(QStringLiteral("start"));
}
else
{
progressBarInfinite_.start();
startStopButtonInfinite_.setText(QStringLiteral("stop"));
}
}
2 changes: 2 additions & 0 deletions examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ private slots:
void filterDatesValuesChanged(QDate from, QDate to, bool filterEmptyDates);

void filterStringsValuesChanged(QStringList bannedItems);

void infiniteButtonClicked();
};

0 comments on commit 052166f

Please sign in to comment.