From 4453d587364e38c11f218c46db482f0b2ebe93ae Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 24 Feb 2009 03:02:23 -0500 Subject: Converted some classes to load from the resource instead of using inheritence for forms --- sigmodr/widgets/WeatherUI.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'sigmodr/widgets/WeatherUI.cpp') 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 +// KDE includes +#include + +// Qt includes +#include +#include + 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("varName"); + ui_script = formWidget->findChild("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(modified())->name()); - varScript->setValue(qobject_cast(modified())->script()); + ui_name->setText(qobject_cast(modified())->name()); + ui_script->setValue(qobject_cast(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(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(modified())->setScript(script); } -- cgit