added regex help link

This commit is contained in:
fourtf 2019-08-26 14:07:21 +02:00
parent a64e5b2834
commit e7b4527a0f
5 changed files with 37 additions and 13 deletions

View file

@ -22,10 +22,10 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
// create layout // create layout
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0); vbox->setMargin(0);
vbox->addWidget(this->tableView_);
// create button layout // create button layout
QHBoxLayout *buttons = new QHBoxLayout(this); QHBoxLayout *buttons = new QHBoxLayout(this);
this->buttons_ = buttons;
vbox->addLayout(buttons); vbox->addLayout(buttons);
// add // add
@ -46,6 +46,11 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
} }
}); });
buttons->addStretch();
// add tableview
vbox->addWidget(this->tableView_);
// finish button layout // finish button layout
buttons->addStretch(1); buttons->addStretch(1);
} }
@ -75,4 +80,18 @@ QAbstractTableModel *EditableModelView::getModel()
return this->model_; return this->model_;
} }
void EditableModelView::addCustomButton(QWidget *widget)
{
this->buttons_->addWidget(widget);
}
void EditableModelView::addRegexHelpLink()
{
auto regexHelpLabel =
new QLabel("<a href='https://chatterino.com/help/regex'><span "
"style='color:#99f'>regex info</span></a>");
regexHelpLabel->setOpenExternalLinks(true);
this->addCustomButton(regexHelpLabel);
}
} // namespace chatterino } // namespace chatterino

View file

@ -6,6 +6,7 @@
class QAbstractTableModel; class QAbstractTableModel;
class QTableView; class QTableView;
class QHBoxLayout;
namespace chatterino { namespace chatterino {
@ -21,9 +22,13 @@ public:
pajlada::Signals::NoArgSignal addButtonPressed; pajlada::Signals::NoArgSignal addButtonPressed;
void addCustomButton(QWidget *widget);
void addRegexHelpLink();
private: private:
QTableView *tableView_; QTableView *tableView_{};
QAbstractTableModel *model_; QAbstractTableModel *model_{};
QHBoxLayout *buttons_{};
}; };
} // namespace chatterino } // namespace chatterino

View file

@ -20,9 +20,7 @@
#include <QTextEdit> #include <QTextEdit>
// clang-format off // clang-format off
#define TEXT "{1} => first word, {2} => second word, ...\n"\ #define TEXT "{1} => first word &nbsp;&nbsp;&nbsp; {1+} => first word and after &nbsp;&nbsp;&nbsp; {{ => { &nbsp;&nbsp;&nbsp; <a href='https://chatterino.com/help/commands'>more info</a>"
"{1+} => first word and after, {2+} => second word and after, ...\n"\
"{{1} => {1}"
// clang-format on // clang-format on
namespace chatterino { namespace chatterino {
@ -55,11 +53,10 @@ CommandPage::CommandPage()
if (QFile(c1settingsPath()).exists()) if (QFile(c1settingsPath()).exists())
{ {
auto box = layout.emplace<QHBoxLayout>().withoutMargin(); auto button = new QPushButton("Import commands from Chatterino 1");
auto button = view->addCustomButton(button);
box.emplace<QPushButton>("Import commands from Chatterino 1");
QObject::connect(button.getElement(), &QPushButton::clicked, this, [] { QObject::connect(button, &QPushButton::clicked, this, [] {
QFile c1settings = c1settingsPath(); QFile c1settings = c1settingsPath();
c1settings.open(QIODevice::ReadOnly); c1settings.open(QIODevice::ReadOnly);
for (auto line : QString(c1settings.readAll()) for (auto line : QString(c1settings.readAll())
@ -73,7 +70,6 @@ CommandPage::CommandPage()
} }
} }
}); });
box->addStretch();
} }
layout.append( layout.append(
@ -83,6 +79,7 @@ CommandPage::CommandPage()
QLabel *text = layout.emplace<QLabel>(TEXT).getElement(); QLabel *text = layout.emplace<QLabel>(TEXT).getElement();
text->setWordWrap(true); text->setWordWrap(true);
text->setStyleSheet("color: #bbb"); text->setStyleSheet("color: #bbb");
text->setOpenExternalLinks(true);
// ---- end of layout // ---- end of layout
this->commandsEditTimer_.setSingleShot(true); this->commandsEditTimer_.setSingleShot(true);

View file

@ -24,8 +24,7 @@
#define HIGHLIGHT_MSG "Highlight messages containing your name" #define HIGHLIGHT_MSG "Highlight messages containing your name"
#define PLAY_SOUND "Play sound when your name is mentioned" #define PLAY_SOUND "Play sound when your name is mentioned"
#define FLASH_TASKBAR "Flash taskbar when your name is mentioned" #define FLASH_TASKBAR "Flash taskbar when your name is mentioned"
#define ALWAYS_PLAY \ #define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused"
"Always play highlight sound (Even if Chatterino is focused)"
namespace chatterino { namespace chatterino {
@ -53,6 +52,7 @@ HighlightingPage::HighlightingPage()
app->highlights->createModel(nullptr)) app->highlights->createModel(nullptr))
.getElement(); .getElement();
view->addRegexHelpLink();
view->setTitles({"Pattern", "Flash\ntaskbar", "Play\nsound", view->setTitles({"Pattern", "Flash\ntaskbar", "Play\nsound",
"Enable\nregex"}); "Enable\nregex"});
view->getTableView()->horizontalHeader()->setSectionResizeMode( view->getTableView()->horizontalHeader()->setSectionResizeMode(
@ -81,6 +81,7 @@ HighlightingPage::HighlightingPage()
app->highlights->createUserModel(nullptr)) app->highlights->createUserModel(nullptr))
.getElement(); .getElement();
view->addRegexHelpLink();
view->setTitles({"Username", "Flash\ntaskbar", "Play\nsound", view->setTitles({"Username", "Flash\ntaskbar", "Play\nsound",
"Enable\nregex"}); "Enable\nregex"});
view->getTableView()->horizontalHeader()->setSectionResizeMode( view->getTableView()->horizontalHeader()->setSectionResizeMode(
@ -111,6 +112,7 @@ HighlightingPage::HighlightingPage()
app->highlights->createBlacklistModel(nullptr)) app->highlights->createBlacklistModel(nullptr))
.getElement(); .getElement();
view->addRegexHelpLink();
view->setTitles({"Pattern", "Enable\nregex"}); view->setTitles({"Pattern", "Enable\nregex"});
view->getTableView()->horizontalHeader()->setSectionResizeMode( view->getTableView()->horizontalHeader()->setSectionResizeMode(
QHeaderView::Fixed); QHeaderView::Fixed);

View file

@ -56,6 +56,7 @@ void addPhrasesTab(LayoutCreator<QVBoxLayout> layout)
QHeaderView::Fixed); QHeaderView::Fixed);
view->getTableView()->horizontalHeader()->setSectionResizeMode( view->getTableView()->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::Stretch); 0, QHeaderView::Stretch);
view->addRegexHelpLink();
QTimer::singleShot(1, [view] { QTimer::singleShot(1, [view] {
view->getTableView()->resizeColumnsToContents(); view->getTableView()->resizeColumnsToContents();