diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index eba8acf2a..2622dff47 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -96,7 +96,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent) connect(splitter, &QSplitter::splitterMoved, this, &ContentDialog::saveSplitterState); - connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, this, &ContentDialog::onGroupchatPositionChanged); + const Settings& s = Settings::getInstance(); + connect(&s, &Settings::groupchatPositionChanged, this, &ContentDialog::onGroupchatPositionChanged); setMinimumSize(500, 220); setAttribute(Qt::WA_DeleteOnClose); @@ -167,9 +168,10 @@ FriendWidget* ContentDialog::addFriend(int friendId, QString id) friendLayout->addFriendWidget(friendWidget, FriendList::findFriend(friendId)->getStatus()); Friend* frnd = friendWidget->getFriend(); + const Settings& s = Settings::getInstance(); connect(frnd, &Friend::displayedNameChanged, this, &ContentDialog::updateFriendWidget); - connect(settingsWidget, &SettingsWidget::compactToggled, friendWidget, &FriendWidget::compactChange); + connect(&s, &Settings::compactLayoutChanged, friendWidget, &FriendWidget::compactChange); connect(friendWidget, &FriendWidget::chatroomWidgetClicked, this, &ContentDialog::onChatroomWidgetClicked); connect(friendWidget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), frnd->getChatForm(), SLOT(focusInput())); connect(Core::getInstance(), &Core::friendAvatarChanged, friendWidget, &FriendWidget::onAvatarChange); @@ -191,10 +193,11 @@ GroupWidget* ContentDialog::addGroup(int groupId, const QString& name) GroupWidget* groupWidget = new GroupWidget(groupId, name); groupLayout.addSortedWidget(groupWidget); + const Settings& s = Settings::getInstance(); Group* group = groupWidget->getGroup(); connect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget); connect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget); - connect(settingsWidget, &SettingsWidget::compactToggled, groupWidget, &GroupWidget::compactChange); + connect(&s, &Settings::compactLayoutChanged, groupWidget, &GroupWidget::compactChange); connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::onChatroomWidgetClicked); ContentDialog* lastDialog = getGroupDialog(groupId); diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 1d201914c..7445d5fb2 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -321,7 +321,6 @@ void GeneralForm::onAutorunUpdated() void GeneralForm::onSetShowSystemTray() { Settings::getInstance().setShowSystemTray(bodyUI->showSystemTray->isChecked()); - emit parent->setShowSystemTray(bodyUI->showSystemTray->isChecked()); Settings::getInstance().saveGlobal(); } @@ -534,14 +533,12 @@ void GeneralForm::onFauxOfflineMessaging() void GeneralForm::onCompactLayout() { Settings::getInstance().setCompactLayout(bodyUI->cbCompactLayout->isChecked()); - emit parent->compactToggled(bodyUI->cbCompactLayout->isChecked()); } void GeneralForm::onSeparateWindowChanged() { bodyUI->cbDontGroupWindows->setEnabled(bodyUI->cbSeparateWindow->isChecked()); Settings::getInstance().setSeparateWindow(bodyUI->cbSeparateWindow->isChecked()); - emit parent->separateWindowToggled(bodyUI->cbSeparateWindow->isChecked()); } void GeneralForm::onDontGroupWindowsChanged() @@ -552,7 +549,6 @@ void GeneralForm::onDontGroupWindowsChanged() void GeneralForm::onGroupchatPositionChanged() { Settings::getInstance().setGroupchatPosition(bodyUI->cbGroupchatPosition->isChecked()); - emit parent->groupchatPositionToggled(bodyUI->cbGroupchatPosition->isChecked()); } void GeneralForm::onThemeColorChanged(int) diff --git a/src/widget/form/settingswidget.h b/src/widget/form/settingswidget.h index 997355efc..316c1baab 100644 --- a/src/widget/form/settingswidget.h +++ b/src/widget/form/settingswidget.h @@ -47,12 +47,6 @@ public: void showAbout(); -signals: - void setShowSystemTray(bool newValue); - void compactToggled(bool compact); - void separateWindowToggled(bool separateWindow); - void groupchatPositionToggled(bool groupchatPosition); - private slots: void onTabChanged(int); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 1b0445bd5..db16c51a9 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -240,10 +240,11 @@ void Widget::init() //connect logout tray menu action connect(actionLogout, &QAction::triggered, profileForm, &ProfileForm::onLogoutClicked); + const Settings& s = Settings::getInstance(); Core* core = Nexus::getCore(); connect(core, &Core::fileDownloadFinished, filesForm, &FilesForm::onFileDownloadComplete); connect(core, &Core::fileUploadFinished, filesForm, &FilesForm::onFileUploadComplete); - connect(settingsWidget, &SettingsWidget::setShowSystemTray, this, &Widget::onSetShowSystemTray); + connect(&s, &Settings::showSystemTrayChanged, this, &Widget::onSetShowSystemTray); connect(core, &Core::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded); connect(ui->addButton, &QPushButton::clicked, this, &Widget::onAddClicked); connect(ui->groupButton, &QPushButton::clicked, this, &Widget::onGroupClicked); @@ -380,9 +381,9 @@ void Widget::init() ui->mainSplitter->setSizes(sizes); } - connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged); - connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged); - connect(settingsWidget, &SettingsWidget::separateWindowToggled, this, &Widget::onSeparateWindowClicked); + connect(&s, &Settings::compactLayoutChanged, contactListWidget, &FriendListWidget::onCompactChanged); + connect(&s, &Settings::groupchatPositionChanged, contactListWidget, &FriendListWidget::onGroupchatPositionChanged); + connect(&s, &Settings::separateWindowChanged, this, &Widget::onSeparateWindowClicked); #if (AUTOUPDATE_ENABLED) if (Settings::getInstance().getCheckUpdates()) AutoUpdater::checkUpdatesAsyncInteractive(); @@ -955,10 +956,11 @@ void Widget::addFriend(int friendId, const QString &userId) contactListWidget->addFriendWidget(newfriend->getFriendWidget(), Status::Offline, Settings::getInstance().getFriendCircleID(newfriend->getToxId())); + const Settings& s = Settings::getInstance(); Core* core = Nexus::getCore(); CoreAV* coreav = core->getAv(); connect(newfriend, &Friend::displayedNameChanged, this, &Widget::onFriendDisplayChanged); - connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::compactChange); + connect(&s, &Settings::compactLayoutChanged, newfriend->getFriendWidget(), &GenericChatroomWidget::compactChange); connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*, bool)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*, bool))); connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int))); connect(newfriend->getFriendWidget(), SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int))); @@ -1682,7 +1684,8 @@ Group *Widget::createGroup(int groupId) newgroup->getGroupWidget()->updateStatusLight(); contactListWidget->activateWindow(); - connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::compactChange); + const Settings& s = Settings::getInstance(); + connect(&s, &Settings::compactLayoutChanged, newgroup->getGroupWidget(), &GenericChatroomWidget::compactChange); connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*,bool)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*,bool))); connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int))); connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));