Added the ability to add nicknames for users (#2981)
Co-authored-by: Mm2PL <mm2pl+gh@kotmisia.pl> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "widgets/settingspages/IgnoresPage.hpp"
|
||||
#include "widgets/settingspages/KeyboardSettingsPage.hpp"
|
||||
#include "widgets/settingspages/ModerationPage.hpp"
|
||||
#include "widgets/settingspages/NicknamesPage.hpp"
|
||||
#include "widgets/settingspages/NotificationPage.hpp"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
@@ -164,6 +165,7 @@ void SettingsDialog::addTabs()
|
||||
this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg");
|
||||
this->ui_.tabContainer->addSpacing(16);
|
||||
this->addTab([]{return new AccountsPage;}, "Accounts", ":/settings/accounts.svg", SettingsTabId::Accounts);
|
||||
this->addTab([]{return new NicknamesPage;}, "Nicknames", ":/settings/accounts.svg");
|
||||
this->ui_.tabContainer->addSpacing(16);
|
||||
this->addTab([]{return new CommandPage;}, "Commands", ":/settings/commands.svg");
|
||||
this->addTab([]{return new HighlightingPage;}, "Highlights", ":/settings/notifications.svg");
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "NicknamesPage.hpp"
|
||||
|
||||
#include "controllers/nicknames/NicknamesModel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
NicknamesPage::NicknamesPage()
|
||||
{
|
||||
LayoutCreator<NicknamesPage> layoutCreator(this);
|
||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||
|
||||
layout.emplace<QLabel>(
|
||||
"Nicknames do not work with features such as search or user highlights."
|
||||
"\nWith those features you will still need to use the user's original "
|
||||
"name.");
|
||||
EditableModelView *view =
|
||||
layout
|
||||
.emplace<EditableModelView>(
|
||||
(new NicknamesModel(nullptr))
|
||||
->initialized(&getSettings()->nicknames))
|
||||
.getElement();
|
||||
|
||||
view->setTitles({"Username", "Nickname"});
|
||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Interactive);
|
||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||
1, QHeaderView::Stretch);
|
||||
|
||||
view->addButtonPressed.connect([] {
|
||||
getSettings()->nicknames.append(Nickname{"Username", "Nickname"});
|
||||
});
|
||||
|
||||
QTimer::singleShot(1, [view] {
|
||||
view->getTableView()->resizeColumnsToContents();
|
||||
view->getTableView()->setColumnWidth(0, 250);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
#include "widgets/settingspages/SettingsPage.hpp"
|
||||
|
||||
#include <QStringListModel>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class NicknamesPage : public SettingsPage
|
||||
{
|
||||
public:
|
||||
NicknamesPage();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user