diff options
Diffstat (limited to 'sigmodr/widgets/WeatherUI.cpp')
| -rw-r--r-- | sigmodr/widgets/WeatherUI.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/sigmodr/widgets/WeatherUI.cpp b/sigmodr/widgets/WeatherUI.cpp index 1b03281f..38ab41a8 100644 --- a/sigmodr/widgets/WeatherUI.cpp +++ b/sigmodr/widgets/WeatherUI.cpp @@ -18,24 +18,41 @@ // Header include #include "WeatherUI.h" +// Sigmodr widget includes +#include "ScriptWidget.h" + // Sigmod includes #include <sigmod/Weather.h> +// KDE includes +#include <KLineEdit> + +// Qt includes +#include <QtCore/QFile> +#include <QtUiTools/QUiLoader> + Sigmodr::Widgets::WeatherUI::WeatherUI(Sigmod::Weather* weather, QWidget* parent) : ObjectUI(parent) { - setupUi(this); setObjects(weather, new Sigmod::Weather(*weather)); } -Sigmodr::Widgets::WeatherUI::~WeatherUI() +void Sigmodr::Widgets::WeatherUI::initGui() { + QFile file(":/gui/weather.ui"); + file.open(QFile::ReadOnly); + QWidget *formWidget = QUiLoader().load(&file, this); + file.close(); + ui_name = formWidget->findChild<KLineEdit*>("varName"); + ui_script = formWidget->findChild<ScriptWidget*>("varScript"); + connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString))); + connect(ui_script, SIGNAL(scriptChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script))); } void Sigmodr::Widgets::WeatherUI::setGui() { - varName->setText(qobject_cast<Sigmod::Weather*>(modified())->name()); - varScript->setValue(qobject_cast<Sigmod::Weather*>(modified())->script()); + ui_name->setText(qobject_cast<Sigmod::Weather*>(modified())->name()); + ui_script->setValue(qobject_cast<Sigmod::Weather*>(modified())->script()); } void Sigmodr::Widgets::WeatherUI::apply() @@ -51,14 +68,14 @@ void Sigmodr::Widgets::WeatherUI::discard() emit(changed(false)); } -void Sigmodr::Widgets::WeatherUI::on_varName_textChanged(const QString& name) +void Sigmodr::Widgets::WeatherUI::nameChanged(const QString& name) { - const int cursor = varName->cursorPosition(); + const int cursor = ui_name->cursorPosition(); qobject_cast<Sigmod::Weather*>(modified())->setName(name); - varName->setCursorPosition(cursor); + ui_name->setCursorPosition(cursor); } -void Sigmodr::Widgets::WeatherUI::on_varScript_valueChanged(const Sigcore::Script& script) +void Sigmodr::Widgets::WeatherUI::scriptChanged(const Sigcore::Script& script) { qobject_cast<Sigmod::Weather*>(modified())->setScript(script); } |
