Merge remote-tracking branch 'origin/master' into zneix/feature/qt6

This commit is contained in:
zneix 2021-07-31 17:34:13 +02:00
commit a0228fbd6d
No known key found for this signature in database
GPG key ID: 911916E0523B22F6
23 changed files with 304 additions and 68 deletions

View file

@ -10,6 +10,7 @@ FreeBSD 13.0-CURRENT.
1. Install build dependencies from package sources (or build from the
ports tree): `# pkg install qt5-core qt5-multimedia qt5-svg qt5-qmake qt5-buildtools gstreamer-plugins-good boost-libs rapidjson`
1. go into project directory
1. create build folder `$ mkdir build && cd build`
1. `$ qmake .. && make`
1. Go into the project directory
1. Create a build folder and go into it (`mkdir build && cd build`)
1. Proceed to compiling using the command
`qmake .. && make`

View file

@ -4,27 +4,28 @@ Note on Qt version compatibility: If you are installing Qt from a package manage
## Ubuntu 18.04
_most likely works the same for other Debian-like distros_
_Most likely works the same for other Debian-like distros_
1. Install dependencies `sudo apt install qttools5-dev qtmultimedia5-dev libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev cmake g++`
1. Install all of the dependencies using `sudo apt install qttools5-dev qtmultimedia5-dev libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev cmake g++`
### Through Qt Creator
### Compiling through Qt Creator
1. Install C++ IDE Qt Creator `sudo apt install qtcreator`
1. Install C++ IDE Qt Creator by using `sudo apt install qtcreator`
1. Open `chatterino.pro` with Qt Creator and select build
### Manually
1. go into project directory
1. create build folder `mkdir build && cd build`
1. Go into the project directory
1. Create a build folder and go into it (`mkdir build && cd build`)
1. Use one of the options below to compile it
#### Using QMake
### Using CMake
1. `qmake .. && make`
`cmake .. && make`
#### Using CMake
### Using QMake
1. `cmake .. && make`
`qmake .. && make`
## Arch Linux
@ -34,50 +35,47 @@ _most likely works the same for other Debian-like distros_
### Manually
1. `sudo pacman -S qt5-base qt5-multimedia qt5-svg qt5-tools gst-plugins-ugly gst-plugins-good boost rapidjson pkgconf openssl cmake`
1. go into project directory
1. create build folder `mkdir build && cd build`
1. Install all of the dependencies using `sudo pacman -S qt5-base qt5-multimedia qt5-svg qt5-tools gst-plugins-ugly gst-plugins-good boost rapidjson pkgconf openssl cmake`
1. Go into the project directory
1. Create a build folder and go into it (`mkdir build && cd build`)
1. Use one of the options below to compile it
#### Using QMake
### Using CMake
1. `qmake .. && make`
`cmake .. && make`
#### Using CMake
### Using QMake
1. `cmake .. && make`
`qmake .. && make`
## Fedora 28 and above
_most likely works the same for other Red Hat-like distros. Substitue `dnf` with `yum`._
_Most likely works the same for other Red Hat-like distros. Substitute `dnf` with `yum`._
1. `sudo dnf install qt5-qtbase-devel qt5-qtmultimedia-devel qt5-qtsvg-devel libsecret-devel openssl-devel boost-devel cmake`
1. go into project directory
1. create build folder `mkdir build && cd build`
### Using QMake
1. `qmake-qt5 .. && make -j$(nproc)`
1. Install all of the dependencies using `sudo dnf install qt5-qtbase-devel qt5-qtmultimedia-devel qt5-qtsvg-devel libsecret-devel openssl-devel boost-devel cmake`
1. Go into the project directory
1. Create a build folder and go into it (`mkdir build && cd build`)
1. Use one of the options below to compile it
### Using CMake
1. `cmake .. && make -j$(nproc)`
`cmake .. && make -j$(nproc)`
### Optional dependencies
### Using QMake
_`gstreamer-plugins-good` package is retired in Fedora 31, see: [rhbz#1735324](https://bugzilla.redhat.com/show_bug.cgi?id=1735324)_
1. `sudo dnf install gstreamer-plugins-good` _(optional: for audio output)_
`qmake-qt5 .. && make -j$(nproc)`
## NixOS 18.09+
1. enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config cmake`
1. go into project directory
1. create build folder `mkdir build && cd build`
### Using QMake
1. `qmake .. && make`
1. Enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config cmake`
1. Go into the project directory
1. Create a build folder and go into it (`mkdir build && cd build`)
1. Use one of the options below to compile it
### Using CMake
1. `cmake .. && make`
`cmake .. && make`
### Using QMake
`qmake .. && make`

View file

@ -4,15 +4,15 @@
#### Note - Chatterino 2 is only tested on macOS 10.14 and above - anything below that is considered unsupported. It may or may not work on earlier versions
1. Install Xcode and Xcode Command Line Utilites
2. Start Xcode, settings -> Locations, activate your Command Line Tools
1. Install Xcode and Xcode Command Line Utilities
2. Start Xcode, go into Settings -> Locations, and activate your Command Line Tools
3. Install brew https://brew.sh/
4. `brew install boost openssl rapidjson`
5. `brew install qt`
6. Step 5 should output some directions to add qt to your path, you will need to do this for qmake
7. Go into project directory
8. Create build folder `mkdir build && cd build`
9. `qmake .. && make`
4. Install the dependencies using `brew install boost openssl rapidjson`
5. Install Qt using `brew install qt`
6. Step 5 should output some directions to add Qt to your path, you will need to do this for qmake
7. Go into the project directory
8. Create a build folder and go into it (`mkdir build && cd build`)
9. Compile using `qmake .. && make`
_If you want to use cmake instead of qmake, just replace the above qmake command with cmake_
@ -21,7 +21,7 @@ If the Project does not build at this point, you might need to add additional Pa
`brew info openssl`
`brew info boost`
If brew doesn't link openssl properly then you should be able to link it yourself using those two commands:
If brew doesn't link OpenSSL properly then you should be able to link it yourself by using these two commands:
- `ln -s /usr/local/opt/openssl/lib/* /usr/local/lib`
- `ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl`

View file

@ -1,8 +1,8 @@
# Building on Windows
**Note that installing all the development prerequisites and libraries will require about 30 GB of free disk space. Please ensure this space is available on your `C:` drive before proceeding.**
**Note that installing all of the development prerequisites and libraries will require about 30 GB of free disk space. Please ensure this space is available on your `C:` drive before proceeding.**
This guide assumes you are on a 64-bit system. You might need to manually search out alternate download links should you desire to build chatterino on a 32-bit system.
This guide assumes you are on a 64-bit system. You might need to manually search out alternate download links should you desire to build Chatterino on a 32-bit system.
## Visual Studio 2019
@ -39,12 +39,12 @@ Note: This installation will take about 1.5 GB of disk space.
### For Qt SSL, we need OpenSSL 1.0
1. Download OpenSSL for windows, version `1.0.2u`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe)**
1. Download OpenSSL for Windows, version `1.0.2u`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe)**
2. When prompted, install it to any arbitrary empty directory.
3. When prompted, copy the OpenSSL DLLs to "The OpenSSL binaries (/bin) directory".
4. Copy the OpenSSL 1.0 files from its `\bin` folder to `C:\local\bin` (You will need to create the folder)
5. Then copy the OpenSSL 1.1 files from its `\bin` folder to `C:\local\bin` (Overwrite any duplicate files)
6. Add `C:\local\bin` to your path folder ([Follow guide here if you don't know how to do it](https://www.computerhope.com/issues/ch000549.htm#windows10))
6. Add `C:\local\bin` to your path folder ([Follow the guide here if you don't know how to do it](https://www.computerhope.com/issues/ch000549.htm#windows10))
**If the download links above do not work, try downloading similar 1.1.x & 1.0.x versions [here](https://slproweb.com/products/Win32OpenSSL.html). Note: Don't download the "light" installers, they do not have the required files.**
@ -82,7 +82,7 @@ Compiling with Breakpad support enables crash reports that can be of use for dev
## Run the build in Qt Creator
1. Open the `chatterino.pro` file by double-clicking or by opening it via Qt Creator.
1. Open the `chatterino.pro` file by double-clicking it, or by opening it via Qt Creator.
2. You will be presented with a screen that is titled "Configure Project". In this screen, you should have at least one option present ready to be configured, like this:
![Qt Create Configure Project screenshot](https://i.imgur.com/dbz45mB.png)
3. Select the profile(s) you want to build with and click "Configure Project".
@ -105,10 +105,10 @@ To produce a standalone package, you need to generate all required files using t
To produce all supplement files for a standalone build, follow these steps (adjust paths as required):
1. Navigate to your build output directory with windows explorer, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release`
1. Navigate to your build output directory with Windows Explorer, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release`
2. Enter the `release` directory
3. Delete all files except the `chatterino.exe` file. You should be left with a directory only containing `chatterino.exe`.
4. Open a `cmd` window and execute:
4. Open a command prompt and execute:
cd C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\release
C:\Qt\5.15.2\msvc2019_64\bin\windeployqt.exe chatterino.exe
@ -124,9 +124,9 @@ To produce all supplement files for a standalone build, follow these steps (adju
You can now create a zip archive of all the contents in `releases` and distribute the program as is, without requiring any development tools to be present on the target system. (However, the vcredist package must be present, as usual - see the [README](README.md)).
## Building with CMake
## Using CMake
Open up your terminal with the Visual Studio environment variables, then:
Open up your terminal with the Visual Studio environment variables, then enter the following commands:
1. `mkdir build`
2. `cd build`

View file

@ -3,6 +3,7 @@
## Unversioned
- Major: Newly uploaded Twitch emotes are once again present in emote picker and can be autocompleted with Tab as well. (#2992)
- Major: Added the ability to add nicknames for users. (#137, #2981)
- Minor: Added autocompletion in /whispers for Twitch emotes, Global Bttv/Ffz emotes and emojis. (#2999, #3033)
- Minor: Received Twitch messages now use the exact same timestamp (obtained from Twitch's server) for every Chatterino user instead of assuming message timestamp on client's side. (#3021)
- Minor: Received IRC messages use `time` message tag for timestamp if it's available. (#3021)

View file

@ -1,6 +1,6 @@
# Chatterino code guidelines
This is a set of guidelines for contributing to Chatterino. The goal is to teach programmers without C++ background (java/python/etc.), people who haven't used Qt or otherwise have different experience the idioms of the codebase. Thus we will focus on those which are different from those other environments. There are extra guidelines available [here](https://hackmd.io/@fourtf/chatterino-pendantic-guidelines) but they are considered as extras and not as important.
This is a set of guidelines for contributing to Chatterino. The goal is to teach programmers without a C++ background (java/python/etc.), people who haven't used Qt, or otherwise have different experience, the idioms of the codebase. Thus we will focus on those which are different from those other environments. There are extra guidelines available [here](https://hackmd.io/@fourtf/chatterino-pendantic-guidelines) but they are considered as extras and not as important.
# Tooling
@ -70,7 +70,7 @@ void myFunc() {
## Passing parameters
The way a parameter is passed signals how it is going to be used inside of the function. C++ doesn't have multiple return values so there is "out parameters" (reference to a variable that is going to be assigned inside of the function) to simulate multiple return values.
The way a parameter is passed, signals how it is going to be used inside of the function. C++ doesn't have multiple return values, so there are "out parameters" (reference to a variable that is going to be assigned inside of the function) to simulate multiple return values.
**Cheap to copy types** like int/enum/etc. can be passed in per value since copying them is fast.
@ -122,11 +122,11 @@ void main() {
}
```
Generally the lowest level of requirement should be used e.g. passing `Channel&` instead of `std::shared_ptr<Channel>&` (aka `ChannelPtr`) if possible.
Generally the lowest level of requirement should be used, e.g. passing `Channel&` instead of `std::shared_ptr<Channel>&` (aka `ChannelPtr`) if possible.
## Members
All functions names are in `camelCase`. _Private_ member variables are in `camelCase_` (note the underscore at the end). We don't use the `get` prefix for getters. We mark functions as `const` [if applicable](https://stackoverflow.com/questions/751681/meaning-of-const-last-in-a-function-declaration-of-a-class).
All function names are in `camelCase`. _Private_ member variables are in `camelCase_` (note the underscore at the end). We don't use the `get` prefix for getters. We mark functions as `const` [if applicable](https://stackoverflow.com/questions/751681/meaning-of-const-last-in-a-function-declaration-of-a-class).
```cpp
class NamedObject
@ -212,6 +212,6 @@ Keep the element on the stack if possible. If you need a pointer or have complex
#### QObject classes
- Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetime where possible. Objects are destroyed when their parent object is destroyed.
- Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetimes where possible. Objects are destroyed when their parent object is destroyed.
- If you have to explicitly delete an object use `variable->deleteLater()` instead of `delete variable`. This ensures that it will be deleted on the correct thread.
- If an object doesn't have a parent consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope or the object is destroyed.
- If an object doesn't have a parent, consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope, or the object is destroyed.

View file

@ -162,6 +162,7 @@ SOURCES += \
src/controllers/ignores/IgnoreModel.cpp \
src/controllers/moderationactions/ModerationAction.cpp \
src/controllers/moderationactions/ModerationActionModel.cpp \
src/controllers/nicknames/NicknamesModel.cpp \
src/controllers/notifications/NotificationController.cpp \
src/controllers/notifications/NotificationModel.cpp \
src/controllers/pings/MutedChannelModel.cpp \
@ -315,6 +316,7 @@ SOURCES += \
src/widgets/settingspages/IgnoresPage.cpp \
src/widgets/settingspages/KeyboardSettingsPage.cpp \
src/widgets/settingspages/ModerationPage.cpp \
src/widgets/settingspages/NicknamesPage.cpp \
src/widgets/settingspages/NotificationPage.cpp \
src/widgets/settingspages/SettingsPage.cpp \
src/widgets/splits/ClosedSplits.cpp \
@ -391,6 +393,8 @@ HEADERS += \
src/controllers/ignores/IgnorePhrase.hpp \
src/controllers/moderationactions/ModerationAction.hpp \
src/controllers/moderationactions/ModerationActionModel.hpp \
src/controllers/nicknames/Nickname.hpp \
src/controllers/nicknames/NicknamesModel.hpp \
src/controllers/notifications/NotificationController.hpp \
src/controllers/notifications/NotificationModel.hpp \
src/controllers/pings/MutedChannelModel.hpp \

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -43,6 +43,8 @@ matthewde | https://github.com/m4tthewde | :/avatars/matthewde.jpg | Contributor
Karar Al-Remahy | https://github.com/KararTY | :/avatars/kararty.png | Contributor
Talen | https://github.com/talneoran | | Contributor
SLCH | https://github.com/SLCH | :/avatars/slch.png | Contributor
ALazyMeme | https://github.com/alazymeme | :/avatars/alazymeme.png | Contributor
xHeaveny_ | https://github.com/xHeaveny | :/avatars/xheaveny.png | Contributor
# If you are a contributor add yourself above this line

View file

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>avatars/alazymeme.png</file>
<file>avatars/fourtf.png</file>
<file>avatars/kararty.png</file>
<file>avatars/matthewde.jpg</file>
@ -7,6 +8,7 @@
<file>avatars/pajlada.png</file>
<file>avatars/revolter.jpg</file>
<file>avatars/slch.png</file>
<file>avatars/xheaveny.png</file>
<file>avatars/zneix.png</file>
<file>buttons/addSplit.png</file>
<file>buttons/addSplitDark.png</file>
@ -105,4 +107,4 @@
<file>twitch/verified.png</file>
<file>twitch/vip.png</file>
</qresource>
</RCC>
</RCC>

View file

@ -96,6 +96,10 @@ set(SOURCE_FILES
controllers/moderationactions/ModerationActionModel.cpp
controllers/moderationactions/ModerationActionModel.hpp
controllers/nicknames/NicknamesModel.cpp
controllers/nicknames/NicknamesModel.hpp
controllers/nicknames/Nickname.hpp
controllers/notifications/NotificationController.cpp
controllers/notifications/NotificationController.hpp
controllers/notifications/NotificationModel.cpp
@ -428,6 +432,8 @@ set(SOURCE_FILES
widgets/settingspages/KeyboardSettingsPage.hpp
widgets/settingspages/ModerationPage.cpp
widgets/settingspages/ModerationPage.hpp
widgets/settingspages/NicknamesPage.cpp
widgets/settingspages/NicknamesPage.hpp
widgets/settingspages/NotificationPage.cpp
widgets/settingspages/NotificationPage.hpp
widgets/settingspages/SettingsPage.cpp

View file

@ -4,11 +4,13 @@ namespace chatterino {
Resources2::Resources2()
{
this->avatars.alazymeme = QPixmap(":/avatars/alazymeme.png");
this->avatars.fourtf = QPixmap(":/avatars/fourtf.png");
this->avatars.kararty = QPixmap(":/avatars/kararty.png");
this->avatars.mm2pl = QPixmap(":/avatars/mm2pl.png");
this->avatars.pajlada = QPixmap(":/avatars/pajlada.png");
this->avatars.slch = QPixmap(":/avatars/slch.png");
this->avatars.xheaveny = QPixmap(":/avatars/xheaveny.png");
this->avatars.zneix = QPixmap(":/avatars/zneix.png");
this->buttons.addSplit = QPixmap(":/buttons/addSplit.png");
this->buttons.addSplitDark = QPixmap(":/buttons/addSplitDark.png");
@ -61,4 +63,4 @@ Resources2::Resources2()
this->twitch.vip = QPixmap(":/twitch/vip.png");
}
} // namespace chatterino
} // namespace chatterino

View file

@ -9,11 +9,13 @@ public:
Resources2();
struct {
QPixmap alazymeme;
QPixmap fourtf;
QPixmap kararty;
QPixmap mm2pl;
QPixmap pajlada;
QPixmap slch;
QPixmap xheaveny;
QPixmap zneix;
} avatars;
struct {
@ -77,4 +79,4 @@ public:
} twitch;
};
} // namespace chatterino
} // namespace chatterino

View file

@ -0,0 +1,77 @@
#pragma once
#include "controllers/accounts/AccountController.hpp"
#include "util/RapidJsonSerializeQString.hpp"
#include "util/RapidjsonHelpers.hpp"
#include <QString>
#include <pajlada/serialize.hpp>
#include <memory>
namespace chatterino {
class Nickname
{
public:
Nickname(const QString &name, const QString &replace)
: name_(name)
, replace_(replace)
{
}
const QString &name() const
{
return this->name_;
}
const QString &replace() const
{
return this->replace_;
}
private:
QString name_;
QString replace_;
};
} // namespace chatterino
namespace pajlada {
template <>
struct Serialize<chatterino::Nickname> {
static rapidjson::Value get(const chatterino::Nickname &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
chatterino::rj::set(ret, "name", value.name(), a);
chatterino::rj::set(ret, "replace", value.replace(), a);
return ret;
}
};
template <>
struct Deserialize<chatterino::Nickname> {
static chatterino::Nickname get(const rapidjson::Value &value,
bool *error = nullptr)
{
if (!value.IsObject())
{
PAJLADA_REPORT_ERROR(error)
return chatterino::Nickname(QString(), QString());
}
QString _name;
QString _replace;
chatterino::rj::getSafe(value, "name", _name);
chatterino::rj::getSafe(value, "replace", _replace);
return chatterino::Nickname(_name, _replace);
}
};
} // namespace pajlada

View file

@ -0,0 +1,31 @@
#include "NicknamesModel.hpp"
#include "Application.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "singletons/Settings.hpp"
#include "util/StandardItemHelper.hpp"
namespace chatterino {
NicknamesModel::NicknamesModel(QObject *parent)
: SignalVectorModel<Nickname>(2, parent)
{
}
// turn a vector item into a model row
Nickname NicknamesModel::getItemFromRow(std::vector<QStandardItem *> &row,
const Nickname &original)
{
return Nickname{row[0]->data(Qt::DisplayRole).toString(),
row[1]->data(Qt::DisplayRole).toString()};
}
// turns a row in the model into a vector item
void NicknamesModel::getRowFromItem(const Nickname &item,
std::vector<QStandardItem *> &row)
{
setStringItem(row[0], item.name());
setStringItem(row[1], item.replace());
}
} // namespace chatterino

View file

@ -0,0 +1,25 @@
#pragma once
#include <QObject>
#include "common/SignalVectorModel.hpp"
#include "controllers/nicknames/Nickname.hpp"
namespace chatterino {
class NicknamesModel : public SignalVectorModel<Nickname>
{
public:
explicit NicknamesModel(QObject *parent);
protected:
// turn a vector item into a model row
virtual Nickname getItemFromRow(std::vector<QStandardItem *> &row,
const Nickname &original) override;
// turns a row in the model into a vector item
virtual void getRowFromItem(const Nickname &item,
std::vector<QStandardItem *> &row) override;
};
} // namespace chatterino

View file

@ -689,6 +689,18 @@ void TwitchMessageBuilder::appendUsername()
break;
}
auto nicknames = getCSettings().nicknames.readOnly();
auto loginLower = this->message().loginName.toLower();
for (const auto &nickname : *nicknames)
{
if (nickname.name().toLower() == loginLower)
{
usernameText = nickname.replace();
break;
}
}
if (this->args.isSentWhisper)
{
// TODO(pajlada): Re-implement

View file

@ -23,6 +23,7 @@ ConcurrentSettings::ConcurrentSettings()
, ignoredMessages(*new SignalVector<IgnorePhrase>())
, mutedChannels(*new SignalVector<QString>())
, filterRecords(*new SignalVector<FilterRecordPtr>())
, nicknames(*new SignalVector<Nickname>())
, moderationActions(*new SignalVector<ModerationAction>)
{
persist(this->highlightedMessages, "/highlighting/highlights");
@ -32,6 +33,7 @@ ConcurrentSettings::ConcurrentSettings()
persist(this->ignoredMessages, "/ignore/phrases");
persist(this->mutedChannels, "/pings/muted");
persist(this->filterRecords, "/filtering/filters");
persist(this->nicknames, "/nicknames");
// tagged users?
persist(this->moderationActions, "/moderation/actions");
}

View file

@ -10,6 +10,7 @@
#include "controllers/highlights/HighlightBadge.hpp"
#include "controllers/highlights/HighlightPhrase.hpp"
#include "controllers/moderationactions/ModerationAction.hpp"
#include "controllers/nicknames/Nickname.hpp"
#include "singletons/Toasts.hpp"
#include "util/StreamerMode.hpp"
#include "widgets/Notebook.hpp"
@ -23,6 +24,7 @@ class HighlightBlacklistUser;
class IgnorePhrase;
class TaggedUser;
class FilterRecord;
class Nickname;
/// Settings which are availlable for reading on all threads.
class ConcurrentSettings
@ -37,6 +39,7 @@ public:
SignalVector<IgnorePhrase> &ignoredMessages;
SignalVector<QString> &mutedChannels;
SignalVector<FilterRecordPtr> &filterRecords;
SignalVector<Nickname> &nicknames;
//SignalVector<TaggedUser> &taggedUsers;
SignalVector<ModerationAction> &moderationActions;

View file

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

View file

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

View file

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