1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(settings): connect "value changed" signals to settings

This commit is contained in:
Nils Fenner 2016-08-08 13:02:43 +02:00
parent e2f9d2cfe8
commit 63db185b6b
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
4 changed files with 15 additions and 19 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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()));