2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Implement SingleChoiceBox using Ui::GenericBox.

This commit is contained in:
John Preston
2021-02-01 17:51:01 +04:00
parent eb11185de7
commit cb2d77d386
4 changed files with 82 additions and 97 deletions

View File

@@ -124,11 +124,14 @@ void Calls::setupContent() {
call->setCurrentVideoDevice(deviceId);
}
});
Ui::show(Box<SingleChoiceBox>(
tr::lng_settings_call_camera(),
options,
currentOption,
save));
Ui::show(Box([=](not_null<Ui::GenericBox*> box) {
SingleChoiceBox(box, {
.title = tr::lng_settings_call_camera(),
.options = options,
.initialSelection = currentOption,
.callback = save,
});
}));
});
const auto bubbleWrap = content->add(object_ptr<Ui::RpWidget>(content));
const auto bubble = content->lifetime().make_state<::Calls::VideoBubble>(
@@ -366,7 +369,7 @@ QString CurrentAudioInputName() {
: tr::lng_settings_call_device_default(tr::now);
}
object_ptr<SingleChoiceBox> ChooseAudioOutputBox(
object_ptr<Ui::GenericBox> ChooseAudioOutputBox(
Fn<void(QString id, QString name)> chosen,
const style::Checkbox *st,
const style::Radio *radioSt) {
@@ -390,16 +393,19 @@ object_ptr<SingleChoiceBox> ChooseAudioOutputBox(
Core::App().calls().setCurrentAudioDevice(false, deviceId);
chosen(deviceId, options[option]);
};
return Box<SingleChoiceBox>(
tr::lng_settings_call_output_device(),
options,
currentOption,
save,
st,
radioSt);
return Box([=](not_null<Ui::GenericBox*> box) {
SingleChoiceBox(box, {
.title = tr::lng_settings_call_output_device(),
.options = options,
.initialSelection = currentOption,
.callback = save,
.st = st,
.radioSt = radioSt,
});
});
}
object_ptr<SingleChoiceBox> ChooseAudioInputBox(
object_ptr<Ui::GenericBox> ChooseAudioInputBox(
Fn<void(QString id, QString name)> chosen,
const style::Checkbox *st,
const style::Radio *radioSt) {
@@ -423,16 +429,19 @@ object_ptr<SingleChoiceBox> ChooseAudioInputBox(
Core::App().calls().setCurrentAudioDevice(true, deviceId);
chosen(deviceId, options[option]);
};
return Box<SingleChoiceBox>(
tr::lng_settings_call_input_device(),
options,
currentOption,
save,
st,
radioSt);
return Box([=](not_null<Ui::GenericBox*> box) {
SingleChoiceBox(box, {
.title = tr::lng_settings_call_input_device(),
.options = options,
.initialSelection = currentOption,
.callback = save,
.st = st,
.radioSt = radioSt,
});
});
}
//object_ptr<SingleChoiceBox> ChooseAudioBackendBox(
//
//object_ptr<Ui::GenericBox> ChooseAudioBackendBox(
// const style::Checkbox *st,
// const style::Radio *radioSt) {
// const auto &settings = Core::App().settings();
@@ -451,13 +460,16 @@ object_ptr<SingleChoiceBox> ChooseAudioInputBox(
// Core::App().saveSettings();
// App::restart();
// };
// return Box<SingleChoiceBox>(
// rpl::single<QString>("Calls audio backend"),
// options,
// currentOption,
// save,
// st,
// radioSt);
// return Box([=](not_null<Ui::GenericBox*> box) {
// SingleChoiceBox(box, {
// .title = rpl::single<QString>("Calls audio backend"),
// .options = options,
// .initialSelection = currentOption,
// .callback = save,
// .st = st,
// .radioSt = radioSt,
// });
// });
//}
} // namespace Settings

View File

@@ -22,14 +22,13 @@ class Call;
namespace Ui {
class LevelMeter;
class GenericBox;
} // namespace Ui
namespace Webrtc {
class AudioInputTester;
} // namespace Webrtc
class SingleChoiceBox;
namespace Settings {
class Calls : public Section {
@@ -61,17 +60,17 @@ inline constexpr auto kMicTestAnimationDuration = crl::time(200);
[[nodiscard]] QString CurrentAudioOutputName();
[[nodiscard]] QString CurrentAudioInputName();
[[nodiscard]] object_ptr<SingleChoiceBox> ChooseAudioOutputBox(
[[nodiscard]] object_ptr<Ui::GenericBox> ChooseAudioOutputBox(
Fn<void(QString id, QString name)> chosen,
const style::Checkbox *st = nullptr,
const style::Radio *radioSt = nullptr);
[[nodiscard]] object_ptr<SingleChoiceBox> ChooseAudioInputBox(
[[nodiscard]] object_ptr<Ui::GenericBox> ChooseAudioInputBox(
Fn<void(QString id, QString name)> chosen,
const style::Checkbox *st = nullptr,
const style::Radio *radioSt = nullptr);
[[nodiscard]] object_ptr<SingleChoiceBox> ChooseAudioBackendBox(
const style::Checkbox *st = nullptr,
const style::Radio *radioSt = nullptr);
//[[nodiscard]] object_ptr<Ui::GenericBox> ChooseAudioBackendBox(
// const style::Checkbox *st = nullptr,
// const style::Radio *radioSt = nullptr);
} // namespace Settings