From 0aef6ecc94c9b31369348201c62f65c013c0be7b Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Fri, 23 Jan 2015 10:25:56 +0100 Subject: [PATCH] Added option in chat settings --- cockatrice/src/chatview.cpp | 8 +++++--- cockatrice/src/dlg_settings.cpp | 5 +++++ cockatrice/src/dlg_settings.h | 1 + cockatrice/src/settingscache.cpp | 7 +++++++ cockatrice/src/settingscache.h | 7 +++++++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index cc93859d5..8daed9b80 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -133,9 +133,11 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use if (!sender.isEmpty()) { const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize(); cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel)); - QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); - if (buddyList.contains(sender)) - cursor.insertImage(PixmapGenerator::generatePixmap(pixelSize, ":/resources/buddy_icon.svg").toImage()); + if (settingsCache->getShowBuddyIcon()) { + QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); + if (buddyList.contains(sender)) + cursor.insertImage(PixmapGenerator::generatePixmap(pixelSize, ":/resources/buddy_icon.svg").toImage()); + } cursor.insertText(" "); } cursor.setCharFormat(senderFormat); diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 7d29b48bf..33f71285c 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -578,9 +578,13 @@ MessagesSettingsPage::MessagesSettingsPage() ignoreUnregUsersMainChat.setChecked(settingsCache->getIgnoreUnregisteredUsers()); connect(&ignoreUnregUsersMainChat, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUsers(int))); + showBuddyIcon.setChecked(settingsCache->getShowBuddyIcon()); + connect(&showBuddyIcon, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowBuddyIcon(int))); + QGridLayout *chatGrid = new QGridLayout; chatGrid->addWidget(&chatMentionCheckBox, 0, 0); chatGrid->addWidget(&ignoreUnregUsersMainChat, 1, 0); + chatGrid->addWidget(&showBuddyIcon, 2, 0); chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatGrid); @@ -651,6 +655,7 @@ void MessagesSettingsPage::retranslateUi() aRemove->setText(tr("&Remove")); chatGroupBox->setTitle(tr("Chat settings")); chatMentionCheckBox.setText(tr("Enable chat mentions ('@yourusername' in chat log will be highlighted)")); + showBuddyIcon.setText(tr("Show buddy Icon")); messageShortcuts->setTitle(tr("In-game message macros")); ignoreUnregUsersMainChat.setText(tr("Ignore unregistered users in main chat")); } diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index a3875c5c1..58caac297 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -162,6 +162,7 @@ private: QAction *aRemove; QCheckBox chatMentionCheckBox; QCheckBox ignoreUnregUsersMainChat; + QCheckBox showBuddyIcon; QGroupBox *chatGroupBox; QGroupBox *messageShortcuts; diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 8bfbeb2dd..57fea9925 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -59,6 +59,8 @@ SettingsCache::SettingsCache() ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool(); + showBuddyIcon = settings->value("chat/showbuddyicon", true).toBool(); + attemptAutoConnect = settings->value("server/auto_connect", 0).toBool(); } @@ -244,6 +246,11 @@ void SettingsCache::setChatMention(int _chatMention) { settings->setValue("chat/mention", chatMention); } +void SettingsCache::setShowBuddyIcon(int _showBuddyIcon) { + showBuddyIcon = _showBuddyIcon; + settings->setValue("chat/showbuddyicon", showBuddyIcon); +} + void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName) { zoneViewSortByName = _zoneViewSortByName; diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index b4d6e9bf1..6ecacdbcb 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -57,6 +57,7 @@ private: int minPlayersForMultiColumnLayout; bool tapAnimation; bool chatMention; + bool showBuddyIcon; bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView, zoneViewShuffle; bool soundEnabled; QString soundPath; @@ -96,6 +97,11 @@ public: int getMinPlayersForMultiColumnLayout() const { return minPlayersForMultiColumnLayout; } bool getTapAnimation() const { return tapAnimation; } bool getChatMention() const { return chatMention; } + /** + Returns if the buddy icon should be displayed in chat. + @return buddyIcon if the buddy icon should be displayed in chat. + */ + bool getShowBuddyIcon() const { return showBuddyIcon; } bool getZoneViewSortByName() const { return zoneViewSortByName; } bool getZoneViewSortByType() const { return zoneViewSortByType; } /** @@ -146,6 +152,7 @@ public slots: void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout); void setTapAnimation(int _tapAnimation); void setChatMention(int _chatMention); + void setShowBuddyIcon(int _showBuddyIcon); void setZoneViewSortByName(int _zoneViewSortByName); void setZoneViewSortByType(int _zoneViewSortByType); void setZoneViewPileView(int _zoneViewPileView);