mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-04 00:25:17 +00:00
Possibility to add description to radio options
This commit is contained in:
@@ -53,6 +53,44 @@ RadioBox::RadioBox(
|
|||||||
, _warnRestart(warnRestart) {
|
, _warnRestart(warnRestart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RadioBox::RadioBox(
|
||||||
|
QWidget*,
|
||||||
|
const QString &title,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<QString(int)> descriptionGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart)
|
||||||
|
: _title(title)
|
||||||
|
, _startValue(currentValue)
|
||||||
|
, _valueCount(valueCount)
|
||||||
|
, _labelGetter(labelGetter)
|
||||||
|
, _descriptionGetter(descriptionGetter)
|
||||||
|
, _saveCallback(std::move(saveCallback))
|
||||||
|
, _warnRestart(warnRestart) {
|
||||||
|
}
|
||||||
|
|
||||||
|
RadioBox::RadioBox(
|
||||||
|
QWidget*,
|
||||||
|
const QString &title,
|
||||||
|
const QString &description,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<QString(int)> descriptionGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart)
|
||||||
|
: _title(title)
|
||||||
|
, _description(description)
|
||||||
|
, _startValue(currentValue)
|
||||||
|
, _valueCount(valueCount)
|
||||||
|
, _labelGetter(labelGetter)
|
||||||
|
, _descriptionGetter(descriptionGetter)
|
||||||
|
, _saveCallback(std::move(saveCallback))
|
||||||
|
, _warnRestart(warnRestart) {
|
||||||
|
}
|
||||||
|
|
||||||
void RadioBox::prepare() {
|
void RadioBox::prepare() {
|
||||||
setTitle(rpl::single(_title));
|
setTitle(rpl::single(_title));
|
||||||
|
|
||||||
@@ -74,6 +112,10 @@ void RadioBox::prepare() {
|
|||||||
_group = std::make_shared<Ui::RadiobuttonGroup>(_startValue);
|
_group = std::make_shared<Ui::RadiobuttonGroup>(_startValue);
|
||||||
|
|
||||||
for (auto i = 0; i != _valueCount; ++i) {
|
for (auto i = 0; i != _valueCount; ++i) {
|
||||||
|
const auto description = _descriptionGetter
|
||||||
|
? _descriptionGetter(i)
|
||||||
|
: QString();
|
||||||
|
|
||||||
content->add(
|
content->add(
|
||||||
object_ptr<Ui::Radiobutton>(
|
object_ptr<Ui::Radiobutton>(
|
||||||
this,
|
this,
|
||||||
@@ -85,7 +127,20 @@ void RadioBox::prepare() {
|
|||||||
st::boxPadding.left(),
|
st::boxPadding.left(),
|
||||||
st::boxPadding.bottom(),
|
st::boxPadding.bottom(),
|
||||||
st::boxPadding.right(),
|
st::boxPadding.right(),
|
||||||
st::boxPadding.bottom()));
|
description.isEmpty() ? st::boxPadding.bottom() : 0));
|
||||||
|
if (!description.isEmpty()) {
|
||||||
|
content->add(
|
||||||
|
object_ptr<Ui::FlatLabel>(this, description, st::boxDividerLabel),
|
||||||
|
style::margins(
|
||||||
|
st::boxPadding.left()
|
||||||
|
+ st::autolockButton.margin.left()
|
||||||
|
+ st::autolockButton.margin.right()
|
||||||
|
+ st::defaultToggle.width
|
||||||
|
+ st::defaultToggle.border * 2,
|
||||||
|
0,
|
||||||
|
st::boxPadding.right(),
|
||||||
|
st::boxPadding.bottom()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDimensionsToContent(st::boxWidth, content);
|
setDimensionsToContent(st::boxWidth, content);
|
||||||
|
@@ -19,8 +19,42 @@ namespace Kotato {
|
|||||||
|
|
||||||
class RadioBox : public Ui::BoxContent {
|
class RadioBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
RadioBox(QWidget* parent, const QString &title, int currentValue, int valueCount, Fn<QString(int)> labelGetter, Fn<void(int)> saveCallback, bool warnRestart = false);
|
RadioBox(
|
||||||
RadioBox(QWidget* parent, const QString &title, const QString &description, int currentValue, int valueCount, Fn<QString(int)> labelGetter, Fn<void(int)> saveCallback, bool warnRestart = false);
|
QWidget* parent,
|
||||||
|
const QString &title,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart = false);
|
||||||
|
RadioBox(
|
||||||
|
QWidget* parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &description,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart = false);
|
||||||
|
RadioBox(
|
||||||
|
QWidget* parent,
|
||||||
|
const QString &title,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<QString(int)> descriptionGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart = false);
|
||||||
|
RadioBox(
|
||||||
|
QWidget* parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &description,
|
||||||
|
int currentValue,
|
||||||
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
|
Fn<QString(int)> descriptionGetter,
|
||||||
|
Fn<void(int)> saveCallback,
|
||||||
|
bool warnRestart = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
@@ -33,6 +67,7 @@ private:
|
|||||||
int _startValue;
|
int _startValue;
|
||||||
int _valueCount;
|
int _valueCount;
|
||||||
Fn<QString(int)> _labelGetter;
|
Fn<QString(int)> _labelGetter;
|
||||||
|
Fn<QString(int)> _descriptionGetter;
|
||||||
Fn<void(int)> _saveCallback;
|
Fn<void(int)> _saveCallback;
|
||||||
bool _warnRestart = false;
|
bool _warnRestart = false;
|
||||||
std::shared_ptr<Ui::RadiobuttonGroup> _group;
|
std::shared_ptr<Ui::RadiobuttonGroup> _group;
|
||||||
|
Reference in New Issue
Block a user