added basic settings page for accounts
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ IrcManager IrcManager::instance;
|
|||||||
const QString IrcManager::defaultClientId("7ue61iz46fz11y3cugd0l3tawb4taal");
|
const QString IrcManager::defaultClientId("7ue61iz46fz11y3cugd0l3tawb4taal");
|
||||||
|
|
||||||
IrcManager::IrcManager()
|
IrcManager::IrcManager()
|
||||||
: _account(AccountManager::getInstance().getAnon())
|
: _account(AccountManager::getInstance().getTwitchAnon())
|
||||||
, _connection()
|
, _connection()
|
||||||
, _connectionMutex()
|
, _connectionMutex()
|
||||||
, _connectionGeneration(0)
|
, _connectionGeneration(0)
|
||||||
|
|||||||
+31
-3
@@ -5,12 +5,40 @@ namespace chatterino {
|
|||||||
AccountManager AccountManager::instance;
|
AccountManager AccountManager::instance;
|
||||||
|
|
||||||
AccountManager::AccountManager()
|
AccountManager::AccountManager()
|
||||||
: _anon("justinfan64537", "", "")
|
: _twitchAnon("justinfan64537", "", "")
|
||||||
|
, _twitchUsers()
|
||||||
|
, _twitchUsersMutex()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
twitch::TwitchUser &AccountManager::getAnon()
|
twitch::TwitchUser &AccountManager::getTwitchAnon()
|
||||||
{
|
{
|
||||||
return _anon;
|
return _twitchAnon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<twitch::TwitchUser> AccountManager::getTwitchUsers()
|
||||||
|
{
|
||||||
|
return std::vector<twitch::TwitchUser>(_twitchUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AccountManager::removeTwitchUser(const QString &userName)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_twitchUsersMutex);
|
||||||
|
|
||||||
|
for (auto it = _twitchUsers.begin(); it != _twitchUsers.end(); it++) {
|
||||||
|
if ((*it).getUserName() == userName) {
|
||||||
|
_twitchUsers.erase(it);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountManager::addTwitchUser(const twitch::TwitchUser &user)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_twitchUsersMutex);
|
||||||
|
|
||||||
|
_twitchUsers.push_back(user);
|
||||||
|
}
|
||||||
|
} // namespace chatterino
|
||||||
|
|||||||
+11
-3
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "twitch/twitchuser.h"
|
#include "twitch/twitchuser.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class AccountManager
|
class AccountManager
|
||||||
@@ -13,15 +15,21 @@ public:
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
twitch::TwitchUser &getAnon();
|
twitch::TwitchUser &getTwitchAnon();
|
||||||
|
|
||||||
|
std::vector<twitch::TwitchUser> getTwitchUsers();
|
||||||
|
bool removeTwitchUser(const QString &userName);
|
||||||
|
void addTwitchUser(const twitch::TwitchUser &user);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AccountManager instance;
|
static AccountManager instance;
|
||||||
|
|
||||||
AccountManager();
|
AccountManager();
|
||||||
|
|
||||||
twitch::TwitchUser _anon;
|
twitch::TwitchUser _twitchAnon;
|
||||||
|
std::vector<twitch::TwitchUser> _twitchUsers;
|
||||||
|
std::mutex _twitchUsersMutex;
|
||||||
};
|
};
|
||||||
}
|
} // namespace chatterino
|
||||||
|
|
||||||
#endif // ACCOUNTMANAGER_H
|
#endif // ACCOUNTMANAGER_H
|
||||||
|
|||||||
+52
-12
@@ -1,4 +1,6 @@
|
|||||||
#include "widgets/settingsdialog.h"
|
#include "widgets/settingsdialog.h"
|
||||||
|
#include "twitch/twitchuser.h"
|
||||||
|
#include "usermanager.h"
|
||||||
#include "widgets/settingsdialogtab.h"
|
#include "widgets/settingsdialogtab.h"
|
||||||
#include "windowmanager.h"
|
#include "windowmanager.h"
|
||||||
|
|
||||||
@@ -7,6 +9,7 @@
|
|||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QListWidget>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QResource>
|
#include <QResource>
|
||||||
|
|
||||||
@@ -63,6 +66,38 @@ void SettingsDialog::addTabs()
|
|||||||
|
|
||||||
QVBoxLayout *vbox;
|
QVBoxLayout *vbox;
|
||||||
|
|
||||||
|
// Accounts
|
||||||
|
vbox = new QVBoxLayout();
|
||||||
|
|
||||||
|
{
|
||||||
|
// add remove buttons
|
||||||
|
auto buttonBox = new QDialogButtonBox(this);
|
||||||
|
|
||||||
|
auto addButton = new QPushButton("add", this);
|
||||||
|
auto removeButton = new QPushButton("remove", this);
|
||||||
|
|
||||||
|
buttonBox->addButton(addButton, QDialogButtonBox::YesRole);
|
||||||
|
buttonBox->addButton(removeButton, QDialogButtonBox::NoRole);
|
||||||
|
|
||||||
|
vbox->addWidget(buttonBox);
|
||||||
|
|
||||||
|
// listview
|
||||||
|
auto listWidget = new QListWidget(this);
|
||||||
|
|
||||||
|
listWidget->addItem("xD");
|
||||||
|
listWidget->addItem("vi von");
|
||||||
|
listWidget->addItem("monkaS");
|
||||||
|
|
||||||
|
for (auto &user : AccountManager::getInstance().getTwitchUsers()) {
|
||||||
|
listWidget->addItem(user.getUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
vbox->addWidget(listWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
// vbox->addStretch(1);
|
||||||
|
addTab(vbox, "Accounts", ":/images/Message_16xLG.png");
|
||||||
|
|
||||||
// Appearance
|
// Appearance
|
||||||
vbox = new QVBoxLayout();
|
vbox = new QVBoxLayout();
|
||||||
|
|
||||||
@@ -81,7 +116,7 @@ void SettingsDialog::addTabs()
|
|||||||
form->addRow("Theme:", combo);
|
form->addRow("Theme:", combo);
|
||||||
form->addRow("Theme color:", slider);
|
form->addRow("Theme color:", slider);
|
||||||
form->addRow("Font:", font);
|
form->addRow("Font:", font);
|
||||||
form->addRow("", compactTabs);
|
form->addRow("Tabbar:", compactTabs);
|
||||||
form->addRow("", hidePreferencesButton);
|
form->addRow("", hidePreferencesButton);
|
||||||
form->addRow("", hideUserButton);
|
form->addRow("", hideUserButton);
|
||||||
|
|
||||||
@@ -148,21 +183,26 @@ void SettingsDialog::addTabs()
|
|||||||
// Behaviour
|
// Behaviour
|
||||||
vbox = new QVBoxLayout();
|
vbox = new QVBoxLayout();
|
||||||
|
|
||||||
vbox->addWidget(createCheckbox("Hide input box if empty", settings.hideEmptyInput));
|
|
||||||
vbox->addWidget(
|
|
||||||
createCheckbox("Mention users with a @ (except in commands)", settings.mentionUsersWithAt));
|
|
||||||
vbox->addWidget(createCheckbox("Window always on top", settings.windowTopMost));
|
|
||||||
vbox->addWidget(
|
|
||||||
createCheckbox("Show last read message indicator", settings.showLastMessageIndicator));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto v = new QVBoxLayout();
|
auto form = new QFormLayout();
|
||||||
v->addWidget(new QLabel("Mouse scroll speed"));
|
|
||||||
|
form->addRow("Window:", createCheckbox("Window always on top", settings.windowTopMost));
|
||||||
|
form->addRow("Messages:", createCheckbox("Mention users with a @ (except in commands)",
|
||||||
|
settings.mentionUsersWithAt));
|
||||||
|
form->addRow("", createCheckbox("Hide input box if empty", settings.hideEmptyInput));
|
||||||
|
form->addRow("", createCheckbox("Show last read message indicator",
|
||||||
|
settings.showLastMessageIndicator));
|
||||||
|
|
||||||
|
// auto v = new QVBoxLayout();
|
||||||
|
// v->addWidget(new QLabel("Mouse scroll speed"));
|
||||||
|
|
||||||
auto scroll = new QSlider(Qt::Horizontal);
|
auto scroll = new QSlider(Qt::Horizontal);
|
||||||
|
form->addRow("Mouse scroll speed:", scroll);
|
||||||
|
|
||||||
v->addWidget(scroll);
|
// v->addWidget(scroll);
|
||||||
v->addStretch(1);
|
// v->addStretch(1);
|
||||||
|
// vbox->addLayout(v);
|
||||||
|
vbox->addLayout(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
vbox->addStretch(1);
|
vbox->addStretch(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user