maybe fix toggle work in code

This commit is contained in:
kirillpt 2020-11-25 18:57:54 +03:00
parent b9dcdbcb81
commit 46605d86f2
2 changed files with 26 additions and 26 deletions

View file

@ -870,18 +870,18 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
[this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); }); [this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); });
connect(trayToggle_, &Toggle::toggled, this, [this](bool disabled) { connect(trayToggle_, &Toggle::toggled, this, [this](bool enabled) {
settings_->setTray(!disabled); settings_->setTray(enabled);
if (disabled) { if (enabled) {
startInTrayToggle_->setDisabled(true);
} else {
startInTrayToggle_->setEnabled(true); startInTrayToggle_->setEnabled(true);
} else {
startInTrayToggle_->setDisabled(true);
} }
emit trayOptionChanged(!disabled); emit trayOptionChanged(enabled);
}); });
connect(startInTrayToggle_, &Toggle::toggled, this, [this](bool disabled) { connect(startInTrayToggle_, &Toggle::toggled, this, [this](bool enabled) {
settings_->setStartInTray(!disabled); settings_->setStartInTray(enabled);
}); });
connect(mobileMode_, &Toggle::toggled, this, [this](bool disabled) { connect(mobileMode_, &Toggle::toggled, this, [this](bool disabled) {
@ -972,22 +972,22 @@ UserSettingsPage::showEvent(QShowEvent *)
utils::restoreCombobox(ringtoneCombo_, settings_->ringtone()); utils::restoreCombobox(ringtoneCombo_, settings_->ringtone());
// FIXME: Toggle treats true as "off" // FIXME: Toggle treats true as "off"
trayToggle_->setState(!settings_->tray()); trayToggle_->setState(settings_->tray());
startInTrayToggle_->setState(!settings_->startInTray()); startInTrayToggle_->setState(settings_->startInTray());
groupViewToggle_->setState(!settings_->groupView()); groupViewToggle_->setState(settings_->groupView());
decryptSidebar_->setState(!settings_->decryptSidebar()); decryptSidebar_->setState(settings_->decryptSidebar());
shareKeysWithTrustedUsers_->setState(!settings_->shareKeysWithTrustedUsers()); shareKeysWithTrustedUsers_->setState(settings_->shareKeysWithTrustedUsers());
avatarCircles_->setState(!settings_->avatarCircles()); avatarCircles_->setState(settings_->avatarCircles());
typingNotifications_->setState(!settings_->typingNotifications()); typingNotifications_->setState(settings_->typingNotifications());
sortByImportance_->setState(!settings_->sortByImportance()); sortByImportance_->setState(settings_->sortByImportance());
timelineButtonsToggle_->setState(!settings_->buttonsInTimeline()); timelineButtonsToggle_->setState(settings_->buttonsInTimeline());
mobileMode_->setState(!settings_->mobileMode()); mobileMode_->setState(settings_->mobileMode());
readReceipts_->setState(!settings_->readReceipts()); readReceipts_->setState(settings_->readReceipts());
markdown_->setState(!settings_->markdown()); markdown_->setState(settings_->markdown());
desktopNotifications_->setState(!settings_->hasDesktopNotifications()); desktopNotifications_->setState(settings_->hasDesktopNotifications());
alertOnNotification_->setState(!settings_->hasAlertOnNotification()); alertOnNotification_->setState(settings_->hasAlertOnNotification());
messageHoverHighlight_->setState(!settings_->messageHoverHighlight()); messageHoverHighlight_->setState(settings_->messageHoverHighlight());
enlargeEmojiOnlyMessages_->setState(!settings_->enlargeEmojiOnlyMessages()); enlargeEmojiOnlyMessages_->setState(settings_->enlargeEmojiOnlyMessages());
deviceIdValue_->setText(QString::fromStdString(http::client()->device_id())); deviceIdValue_->setText(QString::fromStdString(http::client()->device_id()));
timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth()); timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth());
@ -1010,7 +1010,7 @@ UserSettingsPage::showEvent(QShowEvent *)
utils::restoreCombobox(cameraResolutionCombo_, cameraResolution); utils::restoreCombobox(cameraResolutionCombo_, cameraResolution);
utils::restoreCombobox(cameraFrameRateCombo_, cameraFrameRate); utils::restoreCombobox(cameraFrameRateCombo_, cameraFrameRate);
useStunServer_->setState(!settings_->useStunServer()); useStunServer_->setState(settings_->useStunServer());
deviceFingerprintValue_->setText( deviceFingerprintValue_->setText(
utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519)); utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519));

View file

@ -22,7 +22,7 @@ Toggle::Toggle(QWidget *parent)
void void
Toggle::setState(bool isEnabled) Toggle::setState(bool isEnabled)
{ {
thumb_->setShift(isEnabled ? Position::Right : Position::Left); thumb_->setShift(isEnabled ? Position::Left : Position::Right);
setupProperties(); setupProperties();
} }