mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
5f8106e9fc
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
#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", "Enable regex", "Case-sensitive"});
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
QHeaderView::Fixed);
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
0, QHeaderView::Stretch);
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
1, QHeaderView::Stretch);
|
|
|
|
view->addButtonPressed.connect([] {
|
|
getSettings()->nicknames.append(
|
|
Nickname{"Username", "Nickname", false, false});
|
|
});
|
|
|
|
QTimer::singleShot(1, [view] {
|
|
view->getTableView()->resizeColumnsToContents();
|
|
view->getTableView()->setColumnWidth(0, 200);
|
|
});
|
|
}
|
|
|
|
} // namespace chatterino
|