From b48cebf7472f2a30e1ae8747349045661ecf6547 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 24 Feb 2009 10:21:30 -0500 Subject: Cleaned up more classes to load ui files at runtime --- sigmodr/widgets/CoinListUI.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'sigmodr/widgets/CoinListUI.cpp') diff --git a/sigmodr/widgets/CoinListUI.cpp b/sigmodr/widgets/CoinListUI.cpp index e35cce5e..14b1039c 100644 --- a/sigmodr/widgets/CoinListUI.cpp +++ b/sigmodr/widgets/CoinListUI.cpp @@ -18,25 +18,42 @@ // Header include #include "CoinListUI.h" +// Sigmodr widget includes +#include "ScriptWidget.h" + // Sigmod includes #include #include +// KDE includes +#include + +// Qt includes +#include +#include + Sigmodr::Widgets::CoinListUI::CoinListUI(Sigmod::CoinList* coinList, QWidget* parent) : ObjectUI(parent) { - setupUi(this); setObjects(coinList, new Sigmod::CoinList(*coinList)); } -Sigmodr::Widgets::CoinListUI::~CoinListUI() +void Sigmodr::Widgets::CoinListUI::initGui() { + QFile file(":/gui/coinlist.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(valueChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script))); } void Sigmodr::Widgets::CoinListUI::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::CoinListUI::apply() @@ -52,14 +69,14 @@ void Sigmodr::Widgets::CoinListUI::discard() emit(changed(false)); } -void Sigmodr::Widgets::CoinListUI::on_varName_textChanged(const QString& name) +void Sigmodr::Widgets::CoinListUI::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::CoinListUI::on_varScript_valueChanged(const Sigcore::Script& script) +void Sigmodr::Widgets::CoinListUI::scriptChanged(const Sigcore::Script& script) { qobject_cast(modified())->setScript(script); } -- cgit