105 lines
3.0 KiB
C++
105 lines
3.0 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include <Log.h>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), dd(QLocale().name().toStdString()), lolaa(conf.getConfig(), dd, std::bind(&MainWindow::onPosChange, this, std::placeholders::_1)) {
|
|
ui->setupUi(this);
|
|
|
|
conf.load();
|
|
|
|
// for all tabs - set their config and datadragon
|
|
Config::RootConfig& rc = conf.getConfig();
|
|
for(int32_t tabnr = 0; tabnr < ui->tabWidget->count(); ++tabnr) {
|
|
SettingsTab* tab = (SettingsTab*) ui->tabWidget->widget(tabnr);
|
|
tab->setup(rc.getPositionConfig(tab->getPosition()), &dd);
|
|
|
|
QObject::connect(tab, SIGNAL( changed(Position, LolAutoAccept::State) ), this, SLOT( tabchanged(Position, LolAutoAccept::State) ));
|
|
QObject::connect(tab, SIGNAL( toggled(Position, LolAutoAccept::State, bool) ), this, SLOT( tabtoggled(Position, LolAutoAccept::State, bool) ));
|
|
}
|
|
|
|
ui->enableAll->setChecked(rc.enabledAutoAccept);
|
|
lolaa.setEnabled(rc.enabledAutoAccept, LolAutoAccept::State::LOBBY);
|
|
|
|
resizeEvent(nullptr);
|
|
}
|
|
|
|
MainWindow::~MainWindow() {
|
|
lolaa.stop();
|
|
conf.save();
|
|
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::closeEvent([[maybe_unused]] QCloseEvent* event) {
|
|
conf.save();
|
|
}
|
|
|
|
void MainWindow::resizeEvent([[maybe_unused]] QResizeEvent *event) {
|
|
ui->verticalLayoutWidget->setMinimumSize(ui->centralwidget->size());
|
|
ui->verticalLayoutWidget->setMaximumSize(ui->centralwidget->size());
|
|
ui->verticalLayoutWidget->setMinimumSize(ui->centralwidget->size());
|
|
}
|
|
|
|
void MainWindow::toggleMainswitch(bool state) {
|
|
Log::info << "mainswitch toggled: " << state;
|
|
|
|
if(state) {
|
|
if(!lolaa.init()) {
|
|
Log::error << "League Client not found!";
|
|
ui->statusbar->showMessage(tr("League of Legends Client not found!"));
|
|
ui->mainswitch->setCheckState(Qt::CheckState::Unchecked);
|
|
return;
|
|
}
|
|
|
|
ui->runedisplay->setRuneMeta(lolaa.getRuneAspekts());
|
|
|
|
lolaa.run();
|
|
|
|
ui->statusbar->showMessage(tr("Auto-Acceptor started!"));
|
|
|
|
} else {
|
|
lolaa.stop();
|
|
ui->statusbar->showMessage(tr("Auto-Acceptor stoped!"));
|
|
}
|
|
}
|
|
|
|
void MainWindow::aatoggled(bool state) {
|
|
Log::info << "enableAll checkbox toggled " << state;
|
|
|
|
lolaa.setEnabled(state, LolAutoAccept::State::LOBBY);
|
|
conf.getConfig().enabledAutoAccept = state;
|
|
}
|
|
|
|
void MainWindow::tabtoggled(Position p, LolAutoAccept::State s, bool state) {
|
|
Log::info << "checkbox toggled " << state << " position: " << p << " state: " << (int) s;
|
|
|
|
if(s == LolAutoAccept::State::LOBBY) {
|
|
lolaa.setEnabled(state, s);
|
|
}
|
|
|
|
lolaa.reload();
|
|
}
|
|
|
|
void MainWindow::tabchanged(Position p, LolAutoAccept::State s) {
|
|
Log::info << "edited position: " << p << " state: " << (int) s;
|
|
|
|
lolaa.reload();
|
|
}
|
|
|
|
void MainWindow::applyRunes() {
|
|
Log::info << "applyRunes pressed";
|
|
|
|
lolaa.applyRunes();
|
|
}
|
|
|
|
void MainWindow::onPosChange(Position newpos) {
|
|
if(newpos != Position::INVALID) {
|
|
emit requestTabChange((int) newpos -1);
|
|
}
|
|
}
|
|
|
|
void MainWindow::onRuneChanged(const std::vector<uint32_t>& runes, uint32_t prim, uint32_t sec) {
|
|
ui->runedisplay->setRunes(runes, prim, sec);
|
|
}
|