diff --git a/src/widgets/settingspages/CommandPage.cpp b/src/widgets/settingspages/CommandPage.cpp index 2000ce6b1..fae85752f 100644 --- a/src/widgets/settingspages/CommandPage.cpp +++ b/src/widgets/settingspages/CommandPage.cpp @@ -14,6 +14,7 @@ #include "util/StandardItemHelper.hpp" #include "widgets/helper/EditableModelView.hpp" //#include "widgets/helper/ComboBoxItemDelegate.hpp" +#include "util/CombinePath.hpp" #include #include @@ -25,6 +26,13 @@ // clang-format on namespace chatterino { +namespace { + QString c1settingsPath() + { + return combinePath(qgetenv("appdata"), + "Chatterino\\Custom\\Commands.txt"); + } +} // namespace CommandPage::CommandPage() : SettingsPage("Commands", ":/settings/commands.svg") @@ -45,6 +53,29 @@ CommandPage::CommandPage() Command{"/command", "I made a new command HeyGuys"}); }); + if (QFile(c1settingsPath()).exists()) + { + auto box = layout.emplace().withoutMargin(); + auto button = + box.emplace("Import commands from Chatterino 1"); + + QObject::connect(button.getElement(), &QPushButton::clicked, this, [] { + QFile c1settings = c1settingsPath(); + c1settings.open(QIODevice::ReadOnly); + for (auto line : QString(c1settings.readAll()) + .split(QRegularExpression("[\r\n]"), + QString::SkipEmptyParts)) + { + if (int index = line.indexOf(' '); index != -1) + { + getApp()->commands->items_.insertItem( + Command(line.mid(0, index), line.mid(index + 1))); + } + } + }); + box->addStretch(); + } + layout.append( this->createCheckBox("Also match the trigger at the end of the message", getSettings()->allowCommandsAtEnd));