From e7b4527a0ff27e5a315c7cfe63c9b82b08767355 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 26 Aug 2019 14:07:21 +0200 Subject: [PATCH] added regex help link --- src/widgets/helper/EditableModelView.cpp | 21 ++++++++++++++++++- src/widgets/helper/EditableModelView.hpp | 9 ++++++-- src/widgets/settingspages/CommandPage.cpp | 13 +++++------- .../settingspages/HighlightingPage.cpp | 6 ++++-- src/widgets/settingspages/IgnoresPage.cpp | 1 + 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/widgets/helper/EditableModelView.cpp b/src/widgets/helper/EditableModelView.cpp index 1f01c7ec1..76242d155 100644 --- a/src/widgets/helper/EditableModelView.cpp +++ b/src/widgets/helper/EditableModelView.cpp @@ -22,10 +22,10 @@ EditableModelView::EditableModelView(QAbstractTableModel *model) // create layout QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); - vbox->addWidget(this->tableView_); // create button layout QHBoxLayout *buttons = new QHBoxLayout(this); + this->buttons_ = buttons; vbox->addLayout(buttons); // add @@ -46,6 +46,11 @@ EditableModelView::EditableModelView(QAbstractTableModel *model) } }); + buttons->addStretch(); + + // add tableview + vbox->addWidget(this->tableView_); + // finish button layout buttons->addStretch(1); } @@ -75,4 +80,18 @@ QAbstractTableModel *EditableModelView::getModel() return this->model_; } +void EditableModelView::addCustomButton(QWidget *widget) +{ + this->buttons_->addWidget(widget); +} + +void EditableModelView::addRegexHelpLink() +{ + auto regexHelpLabel = + new QLabel("regex info"); + regexHelpLabel->setOpenExternalLinks(true); + this->addCustomButton(regexHelpLabel); +} + } // namespace chatterino diff --git a/src/widgets/helper/EditableModelView.hpp b/src/widgets/helper/EditableModelView.hpp index 86a2b1540..f9ec4b204 100644 --- a/src/widgets/helper/EditableModelView.hpp +++ b/src/widgets/helper/EditableModelView.hpp @@ -6,6 +6,7 @@ class QAbstractTableModel; class QTableView; +class QHBoxLayout; namespace chatterino { @@ -21,9 +22,13 @@ public: pajlada::Signals::NoArgSignal addButtonPressed; + void addCustomButton(QWidget *widget); + void addRegexHelpLink(); + private: - QTableView *tableView_; - QAbstractTableModel *model_; + QTableView *tableView_{}; + QAbstractTableModel *model_{}; + QHBoxLayout *buttons_{}; }; } // namespace chatterino diff --git a/src/widgets/settingspages/CommandPage.cpp b/src/widgets/settingspages/CommandPage.cpp index fae85752f..60b112e18 100644 --- a/src/widgets/settingspages/CommandPage.cpp +++ b/src/widgets/settingspages/CommandPage.cpp @@ -20,9 +20,7 @@ #include // clang-format off -#define TEXT "{1} => first word, {2} => second word, ...\n"\ - "{1+} => first word and after, {2+} => second word and after, ...\n"\ - "{{1} => {1}" +#define TEXT "{1} => first word     {1+} => first word and after     {{ => {     more info" // clang-format on namespace chatterino { @@ -55,11 +53,10 @@ CommandPage::CommandPage() if (QFile(c1settingsPath()).exists()) { - auto box = layout.emplace().withoutMargin(); - auto button = - box.emplace("Import commands from Chatterino 1"); + auto button = new QPushButton("Import commands from Chatterino 1"); + view->addCustomButton(button); - QObject::connect(button.getElement(), &QPushButton::clicked, this, [] { + QObject::connect(button, &QPushButton::clicked, this, [] { QFile c1settings = c1settingsPath(); c1settings.open(QIODevice::ReadOnly); for (auto line : QString(c1settings.readAll()) @@ -73,7 +70,6 @@ CommandPage::CommandPage() } } }); - box->addStretch(); } layout.append( @@ -83,6 +79,7 @@ CommandPage::CommandPage() QLabel *text = layout.emplace(TEXT).getElement(); text->setWordWrap(true); text->setStyleSheet("color: #bbb"); + text->setOpenExternalLinks(true); // ---- end of layout this->commandsEditTimer_.setSingleShot(true); diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index eb49b3452..66c3aeb55 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -24,8 +24,7 @@ #define HIGHLIGHT_MSG "Highlight messages containing your name" #define PLAY_SOUND "Play sound when your name is mentioned" #define FLASH_TASKBAR "Flash taskbar when your name is mentioned" -#define ALWAYS_PLAY \ - "Always play highlight sound (Even if Chatterino is focused)" +#define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused" namespace chatterino { @@ -53,6 +52,7 @@ HighlightingPage::HighlightingPage() app->highlights->createModel(nullptr)) .getElement(); + view->addRegexHelpLink(); view->setTitles({"Pattern", "Flash\ntaskbar", "Play\nsound", "Enable\nregex"}); view->getTableView()->horizontalHeader()->setSectionResizeMode( @@ -81,6 +81,7 @@ HighlightingPage::HighlightingPage() app->highlights->createUserModel(nullptr)) .getElement(); + view->addRegexHelpLink(); view->setTitles({"Username", "Flash\ntaskbar", "Play\nsound", "Enable\nregex"}); view->getTableView()->horizontalHeader()->setSectionResizeMode( @@ -111,6 +112,7 @@ HighlightingPage::HighlightingPage() app->highlights->createBlacklistModel(nullptr)) .getElement(); + view->addRegexHelpLink(); view->setTitles({"Pattern", "Enable\nregex"}); view->getTableView()->horizontalHeader()->setSectionResizeMode( QHeaderView::Fixed); diff --git a/src/widgets/settingspages/IgnoresPage.cpp b/src/widgets/settingspages/IgnoresPage.cpp index daf941cf6..8b0981e01 100644 --- a/src/widgets/settingspages/IgnoresPage.cpp +++ b/src/widgets/settingspages/IgnoresPage.cpp @@ -56,6 +56,7 @@ void addPhrasesTab(LayoutCreator layout) QHeaderView::Fixed); view->getTableView()->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch); + view->addRegexHelpLink(); QTimer::singleShot(1, [view] { view->getTableView()->resizeColumnsToContents();