Skip to content

Commit

Permalink
Editable custom
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 13, 2024
1 parent b00b649 commit e3c92d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Option<QString, QString (*)()> Settings::CDOC2_DEFAULT_KEYSERVER { QString
return Application::confValue(QLatin1String("CDOC2-DEFAULT-KEYSERVER"))
.toString(QStringLiteral("00000000-0000-0000-0000-000000000000"));
}};
const Option<QString> Settings::CDOC2_UUID { QStringLiteral("CDOC2-UUID"), QStringLiteral("00000000-0000-0000-0000-000000000002") };
const Option<QString> Settings::CDOC2_GET { QStringLiteral("CDOC2-GET"), QStringLiteral(CDOC2_GET_URL) };
const Option<QByteArray> Settings::CDOC2_GET_CERT { QStringLiteral("CDOC2-GET-CERT") };
const Option<QString> Settings::CDOC2_POST { QStringLiteral("CDOC2-POST"), QStringLiteral(CDOC2_POST_URL) };
Expand Down
1 change: 1 addition & 0 deletions client/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct Settings
static const Option<bool> CDOC2_NOTIFICATION;
static const Option<bool> CDOC2_USE_KEYSERVER;
static const Option<QString, QString (*)()> CDOC2_DEFAULT_KEYSERVER;
static const Option<QString> CDOC2_UUID;
static const Option<QString> CDOC2_GET;
static const Option<QByteArray> CDOC2_GET_CERT;
static const Option<QString> CDOC2_POST;
Expand Down
12 changes: 9 additions & 3 deletions client/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
QJsonObject data = list.value(key).toObject();
ui->txtCdoc2Fetch->setText(data.value(QLatin1String("FETCH")).toString(Settings::CDOC2_GET));
ui->txtCdoc2Post->setText(data.value(QLatin1String("POST")).toString(Settings::CDOC2_POST));
bool disabled = ui->cmbCdoc2Name->currentIndex() < ui->cmbCdoc2Name->count() - 1;
ui->txtCdoc2UUID->setReadOnly(disabled);
ui->txtCdoc2Fetch->setReadOnly(disabled);
ui->txtCdoc2Post->setReadOnly(disabled);
};
for(QJsonObject::const_iterator i = list.constBegin(); i != list.constEnd(); ++i)
ui->cmbCdoc2Name->addItem(i.value().toObject().value(QLatin1String("NAME")).toString(), i.key());
if(Settings::CDOC2_GET.isSet() || Settings::CDOC2_POST.isSet())
ui->cmbCdoc2Name->addItem(QStringLiteral("Custom"), QStringLiteral("custom"));
ui->cmbCdoc2Name->addItem(tr("Custom"), Settings::CDOC2_UUID);
QString cdoc2Service = Settings::CDOC2_DEFAULT_KEYSERVER;
ui->cmbCdoc2Name->setCurrentIndex(ui->cmbCdoc2Name->findData(cdoc2Service));
connect(ui->cmbCdoc2Name, qOverload<int>(&QComboBox::currentIndexChanged), this, [this, setCDoc2Values] (int index) {
Expand All @@ -231,9 +234,12 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
setCDoc2Values(key);
});
setCDoc2Values(cdoc2Service);
connect(ui->txtCdoc2UUID, &QLineEdit::textEdited, this, Settings::CDOC2_UUID);
connect(ui->txtCdoc2Fetch, &QLineEdit::textEdited, this, Settings::CDOC2_GET);
connect(ui->txtCdoc2Post, &QLineEdit::textEdited, this, Settings::CDOC2_POST);
#else
ui->cmbCdoc2Name->addItem(QStringLiteral("Default"));
ui->txtCdoc2UUID->setText(QStringLiteral("default"));
ui->txtCdoc2UUID->setText(QStringLiteral("00000000-0000-0000-0000-000000000000"));
ui->txtCdoc2Fetch->setText(QStringLiteral(CDOC2_GET_URL));
ui->txtCdoc2Post->setText(QStringLiteral(CDOC2_POST_URL));
#endif
Expand Down
9 changes: 9 additions & 0 deletions client/dialogs/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,9 @@ max-height: 22px;
<property name="readOnly">
<bool>true</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
Expand All @@ -1157,6 +1160,9 @@ max-height: 22px;
<property name="readOnly">
<bool>true</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
Expand All @@ -1174,6 +1180,9 @@ max-height: 22px;
<property name="readOnly">
<bool>true</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down

0 comments on commit e3c92d4

Please sign in to comment.