make custom sets directory configurable (#4047)

This commit is contained in:
ebbit1q 2020-08-23 19:24:30 +02:00 committed by GitHub
parent feee9cc328
commit 964207d04f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 4 deletions

View file

@ -116,6 +116,11 @@ GeneralSettingsPage::GeneralSettingsPage()
QPushButton *cardDatabasePathButton = new QPushButton("..."); QPushButton *cardDatabasePathButton = new QPushButton("...");
connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked())); connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked()));
customCardDatabasePathEdit = new QLineEdit(SettingsCache::instance().getCustomCardDatabasePath());
customCardDatabasePathEdit->setReadOnly(true);
QPushButton *customCardDatabasePathButton = new QPushButton("...");
connect(customCardDatabasePathButton, SIGNAL(clicked()), this, SLOT(customCardDatabaseButtonClicked()));
tokenDatabasePathEdit = new QLineEdit(SettingsCache::instance().getTokenDatabasePath()); tokenDatabasePathEdit = new QLineEdit(SettingsCache::instance().getTokenDatabasePath());
tokenDatabasePathEdit->setReadOnly(true); tokenDatabasePathEdit->setReadOnly(true);
QPushButton *tokenDatabasePathButton = new QPushButton("..."); QPushButton *tokenDatabasePathButton = new QPushButton("...");
@ -126,12 +131,14 @@ GeneralSettingsPage::GeneralSettingsPage()
replaysPathEdit->setEnabled(false); replaysPathEdit->setEnabled(false);
picsPathEdit->setEnabled(false); picsPathEdit->setEnabled(false);
cardDatabasePathEdit->setEnabled(false); cardDatabasePathEdit->setEnabled(false);
customCardDatabasePathEdit->setEnabled(false);
tokenDatabasePathEdit->setEnabled(false); tokenDatabasePathEdit->setEnabled(false);
deckPathButton->setVisible(false); deckPathButton->setVisible(false);
replaysPathButton->setVisible(false); replaysPathButton->setVisible(false);
picsPathButton->setVisible(false); picsPathButton->setVisible(false);
cardDatabasePathButton->setVisible(false); cardDatabasePathButton->setVisible(false);
customCardDatabasePathEdit->setVisible(false);
tokenDatabasePathButton->setVisible(false); tokenDatabasePathButton->setVisible(false);
} }
@ -148,9 +155,12 @@ GeneralSettingsPage::GeneralSettingsPage()
pathsGrid->addWidget(&cardDatabasePathLabel, 3, 0); pathsGrid->addWidget(&cardDatabasePathLabel, 3, 0);
pathsGrid->addWidget(cardDatabasePathEdit, 3, 1); pathsGrid->addWidget(cardDatabasePathEdit, 3, 1);
pathsGrid->addWidget(cardDatabasePathButton, 3, 2); pathsGrid->addWidget(cardDatabasePathButton, 3, 2);
pathsGrid->addWidget(&tokenDatabasePathLabel, 4, 0); pathsGrid->addWidget(&customCardDatabasePathLabel, 4, 0);
pathsGrid->addWidget(tokenDatabasePathEdit, 4, 1); pathsGrid->addWidget(customCardDatabasePathEdit, 4, 1);
pathsGrid->addWidget(tokenDatabasePathButton, 4, 2); pathsGrid->addWidget(customCardDatabasePathButton, 4, 2);
pathsGrid->addWidget(&tokenDatabasePathLabel, 5, 0);
pathsGrid->addWidget(tokenDatabasePathEdit, 5, 1);
pathsGrid->addWidget(tokenDatabasePathButton, 5, 2);
pathsGroupBox = new QGroupBox; pathsGroupBox = new QGroupBox;
pathsGroupBox->setLayout(pathsGrid); pathsGroupBox->setLayout(pathsGrid);
@ -220,6 +230,16 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
SettingsCache::instance().setCardDatabasePath(path); SettingsCache::instance().setCardDatabasePath(path);
} }
void GeneralSettingsPage::customCardDatabaseButtonClicked()
{
QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), customCardDatabasePathEdit->text());
if (path.isEmpty())
return;
customCardDatabasePathEdit->setText(path);
SettingsCache::instance().setCustomCardDatabasePath(path);
}
void GeneralSettingsPage::tokenDatabasePathButtonClicked() void GeneralSettingsPage::tokenDatabasePathButtonClicked()
{ {
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), tokenDatabasePathEdit->text()); QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), tokenDatabasePathEdit->text());
@ -250,6 +270,7 @@ void GeneralSettingsPage::retranslateUi()
replaysPathLabel.setText(tr("Replays directory:")); replaysPathLabel.setText(tr("Replays directory:"));
picsPathLabel.setText(tr("Pictures directory:")); picsPathLabel.setText(tr("Pictures directory:"));
cardDatabasePathLabel.setText(tr("Card database:")); cardDatabasePathLabel.setText(tr("Card database:"));
customCardDatabasePathLabel.setText(tr("Custom database directory:"));
tokenDatabasePathLabel.setText(tr("Token database:")); tokenDatabasePathLabel.setText(tr("Token database:"));
pixmapCacheLabel.setText(tr("Picture cache size:")); pixmapCacheLabel.setText(tr("Picture cache size:"));
updateReleaseChannelLabel.setText(tr("Update channel")); updateReleaseChannelLabel.setText(tr("Update channel"));

View file

@ -42,6 +42,7 @@ private slots:
void replaysPathButtonClicked(); void replaysPathButtonClicked();
void picsPathButtonClicked(); void picsPathButtonClicked();
void cardDatabasePathButtonClicked(); void cardDatabasePathButtonClicked();
void customCardDatabaseButtonClicked();
void tokenDatabasePathButtonClicked(); void tokenDatabasePathButtonClicked();
void languageBoxChanged(int index); void languageBoxChanged(int index);
@ -52,6 +53,7 @@ private:
QLineEdit *replaysPathEdit; QLineEdit *replaysPathEdit;
QLineEdit *picsPathEdit; QLineEdit *picsPathEdit;
QLineEdit *cardDatabasePathEdit; QLineEdit *cardDatabasePathEdit;
QLineEdit *customCardDatabasePathEdit;
QLineEdit *tokenDatabasePathEdit; QLineEdit *tokenDatabasePathEdit;
QSpinBox pixmapCacheEdit; QSpinBox pixmapCacheEdit;
QGroupBox *personalGroupBox; QGroupBox *personalGroupBox;
@ -66,6 +68,7 @@ private:
QLabel replaysPathLabel; QLabel replaysPathLabel;
QLabel picsPathLabel; QLabel picsPathLabel;
QLabel cardDatabasePathLabel; QLabel cardDatabasePathLabel;
QLabel customCardDatabasePathLabel;
QLabel tokenDatabasePathLabel; QLabel tokenDatabasePathLabel;
QLabel updateReleaseChannelLabel; QLabel updateReleaseChannelLabel;
QCheckBox showTipsOnStartup; QCheckBox showTipsOnStartup;

View file

@ -203,7 +203,6 @@ SettingsCache::SettingsCache()
} else { } else {
customPicsPath = getSafeConfigPath("paths/custompics", picsPath + "/CUSTOM/"); customPicsPath = getSafeConfigPath("paths/custompics", picsPath + "/CUSTOM/");
} }
// this has never been exposed as an user-configurable setting
customCardDatabasePath = getSafeConfigPath("paths/customsets", dataPath + "/customsets/"); customCardDatabasePath = getSafeConfigPath("paths/customsets", dataPath + "/customsets/");
cardDatabasePath = getSafeConfigFilePath("paths/carddatabase", dataPath + "/cards.xml"); cardDatabasePath = getSafeConfigFilePath("paths/carddatabase", dataPath + "/cards.xml");
@ -387,6 +386,12 @@ void SettingsCache::setReplaysPath(const QString &_replaysPath)
settings->setValue("paths/replays", replaysPath); settings->setValue("paths/replays", replaysPath);
} }
void SettingsCache::setCustomCardDatabasePath(const QString &_customCardDatabasePath)
{
customCardDatabasePath = _customCardDatabasePath;
settings->setValue("paths/customsets", customCardDatabasePath);
}
void SettingsCache::setPicsPath(const QString &_picsPath) void SettingsCache::setPicsPath(const QString &_picsPath)
{ {
picsPath = _picsPath; picsPath = _picsPath;

View file

@ -474,6 +474,7 @@ public slots:
void setSeenTips(const QList<int> &_seenTips); void setSeenTips(const QList<int> &_seenTips);
void setDeckPath(const QString &_deckPath); void setDeckPath(const QString &_deckPath);
void setReplaysPath(const QString &_replaysPath); void setReplaysPath(const QString &_replaysPath);
void setCustomCardDatabasePath(const QString &_customCardDatabasePath);
void setPicsPath(const QString &_picsPath); void setPicsPath(const QString &_picsPath);
void setCardDatabasePath(const QString &_cardDatabasePath); void setCardDatabasePath(const QString &_cardDatabasePath);
void setSpoilerDatabasePath(const QString &_spoilerDatabasePath); void setSpoilerDatabasePath(const QString &_spoilerDatabasePath);

View file

@ -102,6 +102,9 @@ void SettingsCache::setPicsPath(const QString &/* _picsPath */)
void SettingsCache::setCardDatabasePath(const QString &/* _cardDatabasePath */) void SettingsCache::setCardDatabasePath(const QString &/* _cardDatabasePath */)
{ {
} }
void SettingsCache::setCustomCardDatabasePath(const QString &/* _customCardDatabasePath */)
{
}
void SettingsCache::setSpoilerDatabasePath(const QString &/* _spoilerDatabasePath */) void SettingsCache::setSpoilerDatabasePath(const QString &/* _spoilerDatabasePath */)
{ {
} }

View file

@ -106,6 +106,9 @@ void SettingsCache::setPicsPath(const QString &/* _picsPath */)
void SettingsCache::setCardDatabasePath(const QString &/* _cardDatabasePath */) void SettingsCache::setCardDatabasePath(const QString &/* _cardDatabasePath */)
{ {
} }
void SettingsCache::setCustomCardDatabasePath(const QString &/* _customCardDatabasePath */)
{
}
void SettingsCache::setSpoilerDatabasePath(const QString &/* _spoilerDatabasePath */) void SettingsCache::setSpoilerDatabasePath(const QString &/* _spoilerDatabasePath */)
{ {
} }