2018-03-11 14:46:34 +01:00
|
|
|
#include "weathersettingswidget.h"
|
|
|
|
|
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
|
|
WeatherSettingsWidget::WeatherSettingsWidget(ZeiterfassungSettings &settings, QWidget *parent) :
|
|
|
|
|
SettingsWidget(parent),
|
|
|
|
|
m_settings(settings)
|
|
|
|
|
{
|
|
|
|
|
auto layout = new QFormLayout(this);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
|
2018-03-11 14:50:27 +01:00
|
|
|
m_lineEdit = new QLineEdit(m_settings.url().toString(), this);
|
2018-03-11 14:46:34 +01:00
|
|
|
layout->addRow(tr("Weather API:"), m_lineEdit);
|
|
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WeatherSettingsWidget::isValid(QString &message) const
|
|
|
|
|
{
|
2018-03-11 14:55:29 +01:00
|
|
|
auto valid = QUrl::fromUserInput(m_lineEdit->text()).isValid();
|
2018-03-11 14:46:34 +01:00
|
|
|
|
2018-03-11 14:55:29 +01:00
|
|
|
if(!valid)
|
|
|
|
|
message = tr("The weather api url is invalid!");
|
|
|
|
|
|
|
|
|
|
return valid;
|
2018-03-11 14:46:34 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-25 19:42:22 +02:00
|
|
|
bool WeatherSettingsWidget::apply()
|
2018-03-11 14:46:34 +01:00
|
|
|
{
|
2018-05-25 19:42:22 +02:00
|
|
|
return m_settings.setUrl(QUrl::fromUserInput(m_lineEdit->text()));
|
2018-03-11 14:46:34 +01:00
|
|
|
}
|