mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
broke everything (revert if needed)
This commit is contained in:
parent
21f65b716d
commit
f9d50954d9
|
@ -83,6 +83,9 @@ SOURCES += \
|
||||||
src/controllers/taggedusers/TaggedUser.cpp \
|
src/controllers/taggedusers/TaggedUser.cpp \
|
||||||
src/controllers/taggedusers/TaggedUsersController.cpp \
|
src/controllers/taggedusers/TaggedUsersController.cpp \
|
||||||
src/controllers/taggedusers/TaggedUsersModel.cpp \
|
src/controllers/taggedusers/TaggedUsersModel.cpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButton.cpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButtonController.cpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButtonModel.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/messages/Emote.cpp \
|
src/messages/Emote.cpp \
|
||||||
src/messages/Image.cpp \
|
src/messages/Image.cpp \
|
||||||
|
@ -253,6 +256,9 @@ HEADERS += \
|
||||||
src/controllers/taggedusers/TaggedUser.hpp \
|
src/controllers/taggedusers/TaggedUser.hpp \
|
||||||
src/controllers/taggedusers/TaggedUsersController.hpp \
|
src/controllers/taggedusers/TaggedUsersController.hpp \
|
||||||
src/controllers/taggedusers/TaggedUsersModel.hpp \
|
src/controllers/taggedusers/TaggedUsersModel.hpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButton.hpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButtonController.hpp \
|
||||||
|
src/controllers/timeoutbuttons/TimeoutButtonModel.hpp \
|
||||||
src/messages/Emote.hpp \
|
src/messages/Emote.hpp \
|
||||||
src/messages/Image.hpp \
|
src/messages/Image.hpp \
|
||||||
src/messages/ImageSet.hpp \
|
src/messages/ImageSet.hpp \
|
||||||
|
|
|
@ -19,6 +19,7 @@ class AccountController;
|
||||||
class ModerationActions;
|
class ModerationActions;
|
||||||
class NotificationController;
|
class NotificationController;
|
||||||
class PingController;
|
class PingController;
|
||||||
|
class TimeoutButtonController;
|
||||||
|
|
||||||
class Theme;
|
class Theme;
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
@ -58,12 +59,12 @@ public:
|
||||||
Emotes *const emotes{};
|
Emotes *const emotes{};
|
||||||
WindowManager *const windows{};
|
WindowManager *const windows{};
|
||||||
Toasts *const toasts{};
|
Toasts *const toasts{};
|
||||||
|
|
||||||
AccountController *const accounts{};
|
AccountController *const accounts{};
|
||||||
CommandController *const commands{};
|
CommandController *const commands{};
|
||||||
HighlightController *const highlights{};
|
HighlightController *const highlights{};
|
||||||
NotificationController *const notifications{};
|
NotificationController *const notifications{};
|
||||||
PingController *const pings{};
|
PingController *const pings{};
|
||||||
|
TimeoutButtonController *const timeoutButtons{};
|
||||||
IgnoreController *const ignores{};
|
IgnoreController *const ignores{};
|
||||||
TaggedUsersController *const taggedUsers{};
|
TaggedUsersController *const taggedUsers{};
|
||||||
ModerationActions *const moderationActions{};
|
ModerationActions *const moderationActions{};
|
||||||
|
|
34
src/controllers/timeoutbuttons/TimeoutButton.cpp
Normal file
34
src/controllers/timeoutbuttons/TimeoutButton.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include "TimeoutButton.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
TimeoutButton::TimeoutButton(const int &duration, const QString &unit)
|
||||||
|
: duration_(duration)
|
||||||
|
, unit_(unit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int TimeoutButton::getDuration() const
|
||||||
|
{
|
||||||
|
return this->duration_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TimeoutButton::getDurationString() const
|
||||||
|
{
|
||||||
|
return QString::number(this->getDuration());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TimeoutButton::getUnit() const
|
||||||
|
{
|
||||||
|
return this->unit_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TimeoutButton::getTimeoutDuration() const
|
||||||
|
{
|
||||||
|
static const QMap<QString, int> durations{
|
||||||
|
{"s", 1}, {"m", 60}, {"h", 3600}, {"d", 86400}, {"w", 604800},
|
||||||
|
};
|
||||||
|
return this->duration_ * durations[this->unit_];
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
63
src/controllers/timeoutbuttons/TimeoutButton.hpp
Normal file
63
src/controllers/timeoutbuttons/TimeoutButton.hpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "util/RapidJsonSerializeQString.hpp"
|
||||||
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class TimeoutButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TimeoutButton(const int &duration, const QString &unit);
|
||||||
|
|
||||||
|
int getDuration() const;
|
||||||
|
QString getDurationString() const;
|
||||||
|
QString getUnit() const;
|
||||||
|
int getTimeoutDuration() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int duration_;
|
||||||
|
QString unit_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
||||||
|
|
||||||
|
namespace pajlada {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Serialize<chatterino::TimeoutButton> {
|
||||||
|
static rapidjson::Value get(const chatterino::TimeoutButton &value,
|
||||||
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "duration", value.getDuration(), a);
|
||||||
|
chatterino::rj::set(ret, "unit", value.getUnit(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<chatterino::TimeoutButton> {
|
||||||
|
static chatterino::TimeoutButton get(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (!value.IsObject())
|
||||||
|
{
|
||||||
|
return chatterino::TimeoutButton(int(), QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
int _duration;
|
||||||
|
QString _unit;
|
||||||
|
|
||||||
|
chatterino::rj::getSafe(value, "duration", _duration);
|
||||||
|
chatterino::rj::getSafe(value, "unit", _unit);
|
||||||
|
|
||||||
|
return chatterino::TimeoutButton(_duration, _unit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pajlada
|
33
src/controllers/timeoutbuttons/TimeoutButtonController.cpp
Normal file
33
src/controllers/timeoutbuttons/TimeoutButtonController.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "TimeoutButtonController.hpp"
|
||||||
|
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButton.hpp"
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButtonModel.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
TimeoutButtonController::TimeoutButtonController()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeoutButtonModel *TimeoutButtonController::createModel(QObject *parent)
|
||||||
|
{
|
||||||
|
TimeoutButtonModel *model = new TimeoutButtonModel(parent);
|
||||||
|
|
||||||
|
// this breaks NaM - idk why
|
||||||
|
model->init(&this->buttons);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeoutButtonController::initialize(Settings &settings, Paths &paths)
|
||||||
|
{
|
||||||
|
this->initialized_ = true;
|
||||||
|
log("hallo");
|
||||||
|
for (const TimeoutButton &button : this->timeoutButtons_.getValue())
|
||||||
|
{
|
||||||
|
this->buttons.appendItem(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace chatterino
|
35
src/controllers/timeoutbuttons/TimeoutButtonController.hpp
Normal file
35
src/controllers/timeoutbuttons/TimeoutButtonController.hpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "common/ChatterinoSetting.hpp"
|
||||||
|
#include "common/SignalVector.hpp"
|
||||||
|
#include "common/Singleton.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class TimeoutButton;
|
||||||
|
|
||||||
|
class TimeoutButtonModel;
|
||||||
|
|
||||||
|
class Settings;
|
||||||
|
|
||||||
|
class TimeoutButtonController final : public Singleton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TimeoutButtonController();
|
||||||
|
|
||||||
|
TimeoutButtonModel *createModel(QObject *parent);
|
||||||
|
|
||||||
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||||
|
|
||||||
|
UnsortedSignalVector<TimeoutButton> buttons;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool initialized_ = false;
|
||||||
|
|
||||||
|
ChatterinoSetting<std::vector<TimeoutButton>> timeoutButtons_ = {
|
||||||
|
"/timeouts/timeoutButtons"};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
29
src/controllers/timeoutbuttons/TimeoutButtonModel.cpp
Normal file
29
src/controllers/timeoutbuttons/TimeoutButtonModel.cpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#include "TimeoutButtonModel.hpp"
|
||||||
|
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButton.hpp"
|
||||||
|
#include "util/StandardItemHelper.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
TimeoutButtonModel::TimeoutButtonModel(QObject *parent)
|
||||||
|
: SignalVectorModel<TimeoutButton>(2, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn a vector item into a model row
|
||||||
|
TimeoutButton TimeoutButtonModel::getItemFromRow(
|
||||||
|
std::vector<QStandardItem *> &row, const TimeoutButton &original)
|
||||||
|
{
|
||||||
|
return TimeoutButton(row[0]->data(Qt::EditRole).toInt(),
|
||||||
|
row[1]->data(Qt::EditRole).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
void TimeoutButtonModel::getRowFromItem(const TimeoutButton &item,
|
||||||
|
std::vector<QStandardItem *> &row)
|
||||||
|
{
|
||||||
|
row[0]->setData(item.getDurationString(), Qt::DisplayRole);
|
||||||
|
row[1]->setData(item.getUnit(), Qt::DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
31
src/controllers/timeoutbuttons/TimeoutButtonModel.hpp
Normal file
31
src/controllers/timeoutbuttons/TimeoutButtonModel.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/SignalVectorModel.hpp"
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButton.hpp"
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButtonController.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class TimeoutButton;
|
||||||
|
class TimeoutButtonController;
|
||||||
|
|
||||||
|
class TimeoutButtonModel : public SignalVectorModel<TimeoutButton>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TimeoutButtonModel(QObject *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// turn a vector item into a model row
|
||||||
|
virtual TimeoutButton getItemFromRow(
|
||||||
|
std::vector<QStandardItem *> &row,
|
||||||
|
const TimeoutButton &original) override;
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
virtual void getRowFromItem(const TimeoutButton &item,
|
||||||
|
std::vector<QStandardItem *> &row) override;
|
||||||
|
friend class TimeoutButtonController;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -9,8 +9,6 @@
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
|
||||||
using TimeoutButton = std::pair<QString, int>;
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Settings : public ABSettings
|
class Settings : public ABSettings
|
||||||
|
@ -197,13 +195,6 @@ public:
|
||||||
|
|
||||||
QStringSetting cachePath = {"/cache/path", ""};
|
QStringSetting cachePath = {"/cache/path", ""};
|
||||||
|
|
||||||
/// Timeout buttons
|
|
||||||
|
|
||||||
ChatterinoSetting<std::vector<TimeoutButton>> timeoutButtons = {
|
|
||||||
"/timeouts/timeoutButtons",
|
|
||||||
{ { "s", 1 }, { "s", 30 }, { "m", 1 }, { "m", 5 },
|
|
||||||
{ "m", 30 }, { "h", 1 }, { "d", 1 }, { "w", 1 } } };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateModerationActions();
|
void updateModerationActions();
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,14 +34,6 @@ namespace {
|
||||||
|
|
||||||
const auto borderColor = QColor(255, 255, 255, 80);
|
const auto borderColor = QColor(255, 255, 255, 80);
|
||||||
|
|
||||||
int calculateTimeoutDuration(TimeoutButton timeout)
|
|
||||||
{
|
|
||||||
static const QMap<QString, int> durations{
|
|
||||||
{"s", 1}, {"m", 60}, {"h", 3600}, {"d", 86400}, {"w", 604800},
|
|
||||||
};
|
|
||||||
return timeout.second * durations[timeout.first];
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelPtr filterMessages(const QString &userName, ChannelPtr channel)
|
ChannelPtr filterMessages(const QString &userName, ChannelPtr channel)
|
||||||
{
|
{
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot =
|
LimitedQueueSnapshot<MessagePtr> snapshot =
|
||||||
|
@ -544,28 +536,32 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto addTimeouts = [&](const QString &title) {
|
// const auto addTimeouts = [&](const QString &title) {
|
||||||
auto hbox = addLayout(title);
|
// auto hbox = addLayout(title);
|
||||||
|
|
||||||
for (const auto &item : getSettings()->timeoutButtons.getValue())
|
// for (const auto &item :
|
||||||
{
|
// getSettings()->timeoutButtons.getValue())
|
||||||
auto a = hbox.emplace<EffectLabel2>();
|
// {
|
||||||
a->getLabel().setText(QString::number(item.second) + item.first);
|
// auto a = hbox.emplace<EffectLabel2>();
|
||||||
|
// a->getLabel().setText(QString::number(item.second) +
|
||||||
|
// item.first);
|
||||||
|
|
||||||
a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
// a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||||
a->setBorderColor(borderColor);
|
// a->setBorderColor(borderColor);
|
||||||
|
|
||||||
const auto pair =
|
// const auto pair =
|
||||||
std::make_pair(Action::Timeout, calculateTimeoutDuration(item));
|
// std::make_pair(Action::Timeout,
|
||||||
|
// calculateTimeoutDuration(item));
|
||||||
|
|
||||||
QObject::connect(
|
// QObject::connect(
|
||||||
a.getElement(), &EffectLabel2::leftClicked,
|
// a.getElement(), &EffectLabel2::leftClicked,
|
||||||
[this, pair] { this->buttonClicked.invoke(pair); });
|
// [this, pair] { this->buttonClicked.invoke(pair); });
|
||||||
}
|
// }
|
||||||
};
|
|
||||||
|
// };
|
||||||
|
|
||||||
addButton(Unban, "Unban", getApp()->resources->buttons.unban);
|
addButton(Unban, "Unban", getApp()->resources->buttons.unban);
|
||||||
addTimeouts("Timeouts");
|
// addTimeouts("Timeouts");
|
||||||
addButton(Ban, "Ban", getApp()->resources->buttons.ban);
|
addButton(Ban, "Ban", getApp()->resources->buttons.ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,14 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
||||||
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButtonController.hpp"
|
||||||
|
#include "controllers/timeoutbuttons/TimeoutButtonModel.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
@ -29,6 +32,8 @@ AdvancedPage::AdvancedPage()
|
||||||
{
|
{
|
||||||
LayoutCreator<AdvancedPage> layoutCreator(this);
|
LayoutCreator<AdvancedPage> layoutCreator(this);
|
||||||
|
|
||||||
|
auto *app = getApp();
|
||||||
|
|
||||||
auto tabs = layoutCreator.emplace<QTabWidget>();
|
auto tabs = layoutCreator.emplace<QTabWidget>();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -72,10 +77,9 @@ AdvancedPage::AdvancedPage()
|
||||||
getSettings()->cachePath = ""; //
|
getSettings()->cachePath = ""; //
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Logs end
|
// Logs end
|
||||||
|
|
||||||
|
// Timeoutbuttons
|
||||||
// Timeoutbuttons
|
|
||||||
{
|
{
|
||||||
auto timeoutLayout = tabs.appendTab(new QVBoxLayout, "Timeouts");
|
auto timeoutLayout = tabs.appendTab(new QVBoxLayout, "Timeouts");
|
||||||
auto texts = timeoutLayout.emplace<QVBoxLayout>().withoutMargin();
|
auto texts = timeoutLayout.emplace<QVBoxLayout>().withoutMargin();
|
||||||
|
@ -94,75 +98,29 @@ AdvancedPage::AdvancedPage()
|
||||||
texts->setContentsMargins(0, 0, 0, 15);
|
texts->setContentsMargins(0, 0, 0, 15);
|
||||||
texts->setSizeConstraint(QLayout::SetMaximumSize);
|
texts->setSizeConstraint(QLayout::SetMaximumSize);
|
||||||
|
|
||||||
const auto valueChanged = [=] {
|
EditableModelView *view =
|
||||||
const auto index = QObject::sender()->objectName().toInt();
|
timeoutLayout
|
||||||
|
.emplace<EditableModelView>(
|
||||||
|
app->timeoutButtons->createModel(nullptr))
|
||||||
|
.getElement();
|
||||||
|
|
||||||
const auto line = this->durationInputs_[index];
|
view->setTitles({"Duration", "Unit"});
|
||||||
const auto duration = line->text().toInt();
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||||
const auto unit = this->unitInputs_[index]->currentText();
|
QHeaderView::Fixed);
|
||||||
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||||
|
0, QHeaderView::Stretch);
|
||||||
|
|
||||||
// safety mechanism for setting days and weeks
|
// fourtf: make class extrend BaseWidget and add this to
|
||||||
if (unit == "d" && duration > 14)
|
// dpiChanged
|
||||||
{
|
QTimer::singleShot(1, [view] {
|
||||||
line->setText("14");
|
view->getTableView()->resizeColumnsToContents();
|
||||||
return;
|
view->getTableView()->setColumnWidth(0, 200);
|
||||||
}
|
});
|
||||||
else if (unit == "w" && duration > 2)
|
|
||||||
{
|
|
||||||
line->setText("2");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto timeouts = getSettings()->timeoutButtons.getValue();
|
view->addButtonPressed.connect([] {
|
||||||
timeouts[index] = TimeoutButton{ unit, duration };
|
getApp()->timeoutButtons->buttons.appendItem(TimeoutButton{1, "s"});
|
||||||
getSettings()->timeoutButtons.setValue(timeouts);
|
});
|
||||||
};
|
|
||||||
|
|
||||||
// build one line for each customizable button
|
|
||||||
auto i = 0;
|
|
||||||
for (const auto tButton : getSettings()->timeoutButtons.getValue())
|
|
||||||
{
|
|
||||||
const auto buttonNumber = QString::number(i);
|
|
||||||
auto timeout = timeoutLayout.emplace<QHBoxLayout>().withoutMargin();
|
|
||||||
|
|
||||||
auto buttonLabel = timeout.emplace<QLabel>();
|
|
||||||
buttonLabel->setText(QString("Button %1: ").arg(++i));
|
|
||||||
|
|
||||||
auto *lineEditDurationInput = new QLineEdit();
|
|
||||||
lineEditDurationInput->setObjectName(buttonNumber);
|
|
||||||
lineEditDurationInput->setValidator(
|
|
||||||
new QIntValidator(1, 99, this));
|
|
||||||
lineEditDurationInput->setText(
|
|
||||||
QString::number(tButton.second));
|
|
||||||
lineEditDurationInput->setAlignment(Qt::AlignRight);
|
|
||||||
lineEditDurationInput->setMaximumWidth(30);
|
|
||||||
timeout.append(lineEditDurationInput);
|
|
||||||
|
|
||||||
auto *timeoutDurationUnit = new QComboBox();
|
|
||||||
timeoutDurationUnit->setObjectName(buttonNumber);
|
|
||||||
timeoutDurationUnit->addItems({ "s", "m", "h", "d", "w" });
|
|
||||||
timeoutDurationUnit->setCurrentText(tButton.first);
|
|
||||||
timeout.append(timeoutDurationUnit);
|
|
||||||
|
|
||||||
QObject::connect(lineEditDurationInput,
|
|
||||||
&QLineEdit::textChanged, this,
|
|
||||||
valueChanged);
|
|
||||||
|
|
||||||
QObject::connect(timeoutDurationUnit,
|
|
||||||
&QComboBox::currentTextChanged, this,
|
|
||||||
valueChanged);
|
|
||||||
|
|
||||||
timeout->addStretch();
|
|
||||||
|
|
||||||
this->durationInputs_.push_back(lineEditDurationInput);
|
|
||||||
this->unitInputs_.push_back(timeoutDurationUnit);
|
|
||||||
|
|
||||||
timeout->setContentsMargins(40, 0, 0, 0);
|
|
||||||
timeout->setSizeConstraint(QLayout::SetMaximumSize);
|
|
||||||
}
|
|
||||||
timeoutLayout->addStretch();
|
|
||||||
}
|
}
|
||||||
// Timeoutbuttons end
|
// Timeoutbuttons end
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue