mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added button to import commands from chatterino 1
This commit is contained in:
parent
ea28269951
commit
cced199eaf
|
@ -14,6 +14,7 @@
|
|||
#include "util/StandardItemHelper.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
//#include "widgets/helper/ComboBoxItemDelegate.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTextEdit>
|
||||
|
@ -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<QHBoxLayout>().withoutMargin();
|
||||
auto button =
|
||||
box.emplace<QPushButton>("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));
|
||||
|
|
Loading…
Reference in a new issue