-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettingstabpageform.cpp
More file actions
114 lines (93 loc) · 3.78 KB
/
Copy pathsettingstabpageform.cpp
File metadata and controls
114 lines (93 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "settingstabpageform.h"
#include "ui_settingstabpageform.h"
#include <QFileDialog>
SettingsTabPageForm::SettingsTabPageForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::SettingsTabPageForm)
{
ui->setupUi(this);
mOptions = NULL;
connect(ui->InfiniteStashFolderPushButton, SIGNAL(pressed()), this,
SLOT(OnSetInfiniteStashFolderClicked()));
connect(ui->Torchlight2SharedStashFolderPushButton, SIGNAL(pressed()), this,
SLOT(OnSetTorchlight2SharedStashFileClicked()));
connect(ui->Torchlight2SharedStashMaxNumberOfItemsSpinBox, SIGNAL(valueChanged(int)), this,
SLOT(OnMaxItemsPerStashTabValueChanged(qint32)));
}
SettingsTabPageForm::~SettingsTabPageForm()
{
delete ui;
}
void SettingsTabPageForm::LoadValues()
{
if (mOptions != NULL)
{
ui->InfiniteStashFolderLineEdit->setText(mOptions->Get(OptionKeys::StashManagerFolder));
ui->InfiniteStashFolderLineEdit->setToolTip(ui->InfiniteStashFolderLineEdit->text());
ui->Torchlight2SharedStashFolderLineEdit->setText(mOptions->Get(OptionKeys::Torchlight2SharedStashFile));
ui->Torchlight2SharedStashFolderLineEdit->setToolTip(ui->Torchlight2SharedStashFolderLineEdit->text());
QString maxItemsPerStashTab = mOptions->Get(OptionKeys::MaxNumberOfItemsPerStashTab);
if (maxItemsPerStashTab.isNull() || maxItemsPerStashTab.isEmpty())
{
maxItemsPerStashTab = "40";
mOptions->Set(OptionKeys::MaxNumberOfItemsPerStashTab, maxItemsPerStashTab);
}
ui->Torchlight2SharedStashMaxNumberOfItemsSpinBox->setValue(maxItemsPerStashTab.toInt());
}
}
void SettingsTabPageForm::OnSetTorchlight2SharedStashFileClicked()
{
if (mOptions != NULL)
{
QString currentSharedStashFile = mOptions->Get(OptionKeys::Torchlight2SharedStashFile);
QString file;
QString openFileMessage = "Choose Torchlight 2 Shared Stash File";
if (currentSharedStashFile.length() > 0)
{
file = QFileDialog::getOpenFileName(this, openFileMessage, currentSharedStashFile);
}
else
{
file = QFileDialog::getOpenFileName(this, openFileMessage);
}
if (!file.isNull() && !file.isEmpty())
{
ui->Torchlight2SharedStashFolderLineEdit->setText(file);
ui->Torchlight2SharedStashFolderLineEdit->setToolTip(file);
mOptions->Set(OptionKeys::Torchlight2SharedStashFile, file);
emit torchlight2SharedStashFileChanged(file);
}
}
}
void SettingsTabPageForm::OnSetInfiniteStashFolderClicked()
{
if (mOptions != NULL)
{
QDir infiniteStashFolderPath(mOptions->Get(OptionKeys::StashManagerFolder));
QString folder = QDir::current().absolutePath();
if (infiniteStashFolderPath.exists())
{
folder = QFileDialog::getExistingDirectory(this, "Choose folder", infiniteStashFolderPath.absolutePath());
}
else
{
folder = QFileDialog::getExistingDirectory(this, "Choose folder");
}
infiniteStashFolderPath.setPath(folder);
if (infiniteStashFolderPath.exists())
{
ui->InfiniteStashFolderLineEdit->setText(folder);
ui->InfiniteStashFolderLineEdit->setToolTip(folder);
mOptions->Set(OptionKeys::StashManagerFolder, folder);
emit infiniteStashFolderChanged(folder);
}
}
}
void SettingsTabPageForm::OnMaxItemsPerStashTabValueChanged(qint32 newValue)
{
if (mOptions != NULL)
{
mOptions->Set(OptionKeys::MaxNumberOfItemsPerStashTab, QString::number(newValue));
emit maxItemsPerStashTabChanged(newValue);
}
}