added button to import commands from chatterino 1
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include "util/StandardItemHelper.hpp"
|
#include "util/StandardItemHelper.hpp"
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
//#include "widgets/helper/ComboBoxItemDelegate.hpp"
|
//#include "widgets/helper/ComboBoxItemDelegate.hpp"
|
||||||
|
#include "util/CombinePath.hpp"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
@@ -25,6 +26,13 @@
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace {
|
||||||
|
QString c1settingsPath()
|
||||||
|
{
|
||||||
|
return combinePath(qgetenv("appdata"),
|
||||||
|
"Chatterino\\Custom\\Commands.txt");
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
CommandPage::CommandPage()
|
CommandPage::CommandPage()
|
||||||
: SettingsPage("Commands", ":/settings/commands.svg")
|
: SettingsPage("Commands", ":/settings/commands.svg")
|
||||||
@@ -45,6 +53,29 @@ CommandPage::CommandPage()
|
|||||||
Command{"/command", "I made a new command HeyGuys"});
|
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(
|
layout.append(
|
||||||
this->createCheckBox("Also match the trigger at the end of the message",
|
this->createCheckBox("Also match the trigger at the end of the message",
|
||||||
getSettings()->allowCommandsAtEnd));
|
getSettings()->allowCommandsAtEnd));
|
||||||
|
|||||||
Reference in New Issue
Block a user