Commit 3520e894 authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Move the create widget into a class that will handle it

parent 873eff24
......@@ -2,6 +2,7 @@
set(webaccounts_SRCS
webaccounts.cpp
create.cpp
)
qt4_automoc(${webaccounts_SRCS})
......
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "create.h"
#include "ui_types.h"
#include <QtGui/QWidget>
Create::Create(QWidget* parent): QObject(parent)
{
m_parent = parent;
}
Create::~Create()
{
}
QWidget* Create::widget()
{
m_form = new Ui::createForm();
QWidget *widget = new QWidget(m_parent);
m_form->setupUi(widget);
return widget;
}
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef CREATE_H
#define CREATE_H
#include <QtCore/QObject>
namespace Ui {
class createForm;
}
class Create : public QObject
{
Q_OBJECT
public:
Create (QWidget *parent);
virtual ~Create();
QWidget* widget();
private:
QWidget *m_parent;
Ui::createForm *m_form;
};
#endif// CREATE_H
\ No newline at end of file
......@@ -17,8 +17,8 @@
*************************************************************************************/
#include "webaccounts.h"
#include "create.h"
#include "ui_kcm.h"
#include "ui_types.h"
#include <QtGui/QLabel>
#include <QtGui/QMenu>
......@@ -30,7 +30,9 @@
K_PLUGIN_FACTORY(WebAccountsFactory, registerPlugin<WebAccounts>();)
K_EXPORT_PLUGIN(WebAccountsFactory("webaccounts", "webaccounts"))
WebAccounts::WebAccounts(QWidget *parent, const QVariantList&) : KCModule(WebAccountsFactory::componentData(), parent)
WebAccounts::WebAccounts(QWidget *parent, const QVariantList&)
: KCModule(WebAccountsFactory::componentData(), parent)
, m_create(0)
{
m_ui = new Ui::KCMWebAccounts();
......@@ -61,13 +63,12 @@ void WebAccounts::addBtnClicked()
void WebAccounts::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
{
if (current == m_newAccountItem) {
if (!m_create) {
m_create = new Create(this);
}
m_ui->accountInfo->setTitle(i18n("Select a supported Web Account"));
Ui::createForm *form = new Ui::createForm();
QWidget *widget = new QWidget();
form->setupUi(widget);
m_ui->accountInfo->layout()->addWidget(widget);
m_ui->accountInfo->layout()->addWidget(m_create->widget());
}
}
......
......@@ -21,6 +21,7 @@
#include <kcmodule.h>
class Create;
class QListWidgetItem;
namespace Ui {
class KCMWebAccounts;
......@@ -38,6 +39,7 @@ private Q_SLOTS:
void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
private:
Create *m_create;
QListWidgetItem *m_newAccountItem;
Ui::KCMWebAccounts *m_ui;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment