Skip to content

Commit

Permalink
[added] more macroeditor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Popovici committed Oct 20, 2015
1 parent 4d09828 commit 4ce1c7f
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 39 deletions.
29 changes: 23 additions & 6 deletions macroeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ MacroEditor::MacroEditor(QWidget *parent) :
ui->setupUi(this);

connect(ui->pushButton_edit, SIGNAL(clicked()), this, SLOT(editCurrentSelectedMacro()));
connect(ui->comboBox_accounts, SIGNAL(currentTextChanged(QString)), this, SLOT(accountChanged(QString)));
connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(macroDoubleClicked(QListWidgetItem*)));

loadAccounts();
}
Expand All @@ -21,6 +23,21 @@ MacroEditor::~MacroEditor() {
delete ui;
}

void MacroEditor::accountChanged(QString account) {
ui->listWidget->clear();

loadMacros(account);
}

void MacroEditor::macroDoubleClicked(QListWidgetItem* item) {
GameMacro* macro = dynamic_cast<GameMacro*>(item);

if (macro == NULL)
return;

editCurrentSelectedMacro();
}

void MacroEditor::loadAccounts() {
QSettings settings;
QString folder = settings.value("swg_folder").toString();
Expand All @@ -39,7 +56,7 @@ void MacroEditor::loadAccounts() {
ui->comboBox_accounts->addItem(accounts.at(i));
}

loadMacros(accounts.at(0));
// loadMacros(accounts.at(0));
}

void MacroEditor::loadMacros(const QString& account) {
Expand All @@ -60,12 +77,12 @@ void MacroEditor::loadMacros(const QString& account) {
QStringList macros = loadMacroNames(file);

QMap<int, GameMacro*>::iterator i;
for (i = gameMacros.begin(); i != gameMacros.end(); ++i) {
//cout << i.key() << ": " << i.value() << endl;
GameMacro* macro = i.value();
for (i = gameMacros.begin(); i != gameMacros.end(); ++i) {
//cout << i.key() << ": " << i.value() << endl;
GameMacro* macro = i.value();

ui->listWidget->addItem(macro);
}
ui->listWidget->addItem(macro);
}
}

QStringList MacroEditor::loadMacroNames(QFile& macrosFile) {
Expand Down
2 changes: 2 additions & 0 deletions macroeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class MacroEditor : public QDialog

public slots:
void editCurrentSelectedMacro();
void accountChanged(QString account);
void macroDoubleClicked(QListWidgetItem* item);

protected:
void loadAccounts();
Expand Down
22 changes: 15 additions & 7 deletions macroeditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_add_account">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Add</string>
</property>
Expand Down Expand Up @@ -56,6 +59,9 @@
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_add_macro">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Add</string>
</property>
Expand All @@ -70,6 +76,9 @@
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_remove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove</string>
</property>
Expand All @@ -90,13 +99,19 @@
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_backup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Backup to file</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButton_restore">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Restore backup</string>
</property>
Expand All @@ -116,13 +131,6 @@
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
<zorder>graphicsView</zorder>
<zorder>label</zorder>
<zorder>label_2</zorder>
<zorder>plainTextEdit</zorder>
<zorder>label</zorder>
<zorder>label_3</zorder>
<zorder>lineEdit</zorder>
<zorder>label</zorder>
<zorder>comboBox_accounts</zorder>
<zorder>listWidget</zorder>
Expand Down
1 change: 0 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ int main(int argc, char *argv[]) {
//HANDLE instanceMutex = CreateMutex()



#ifdef Q_OS_WIN32
SingleInstance instance(TEXT("DCB15209-9E02-489D-9FD6-03689735BD49"));

Expand Down
Loading

0 comments on commit 4ce1c7f

Please sign in to comment.