knewstuffbutton.cpp
/*
Copyright (c) 2004 Aaron J. Seigo <aseigo@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kiconloader.h>
#include <klocale.h>
#include "downloaddialog.h"
#include "knewstuffbutton.h"
#include "knewstuffbutton.moc"
namespace KNS
{
Button::Button(const QString& what,
const QString& providerList,
const QString& resourceType,
QWidget* parent, const char* name)
: KPushButton(parent, name),
d(0),
m_providerList(providerList),
m_type(resourceType),
m_downloadDialog(0)
{
setButtonText(what);
init();
}
Button::Button(QWidget* parent, const char* name)
: KPushButton(parent, name),
d(0),
m_downloadDialog(0)
{
setButtonText(i18n("Download New Stuff"));
init();
}
void Button::init()
{
setIconSet(SmallIconSet("knewstuff"));
connect(this, SIGNAL(clicked()), SLOT(showDialog()));
}
void Button::setButtonText(const QString& what)
{
setText(i18n("Download New %1").arg(what));
}
void Button::setProviderList(const QString& providerList)
{
m_providerList = providerList;
}
void Button::setResourceType(const QString& resourceType)
{
m_type = resourceType;
}
void Button::showDialog()
{
emit aboutToShowDialog();
if (!m_downloadDialog)
{
m_downloadDialog = new DownloadDialog(0, this);
}
m_downloadDialog->setType(m_type);
m_downloadDialog->load(m_providerList);
m_downloadDialog->exec(); // TODO: make non-modal?
emit dialogFinished();
}
}
KNS::Button::setProviderList
void setProviderList(const QString &providerList)
set the URL to the list of providers for this button to use
Definition: knewstuffbutton.cpp:64
KNS::DownloadDialog::load
void load()
Fetches descriptions of all available data, optionally considering a previously set type...
Definition: downloaddialog.cpp:165
KNS::Button::Button
Button(const QString &what, const QString &providerList, const QString &resourceType, QWidget *parent, const char *name)
Constructor used when the details of the KHotNewStuff download is known when the button is created...
Definition: knewstuffbutton.cpp:30
KNS::Button::setButtonText
void setButtonText(const QString &what)
set the text that should appear on the button.
Definition: knewstuffbutton.cpp:59
KNS::DownloadDialog::setType
void setType(QString type)
Restricts the display of available data to a certain data type.
Definition: downloaddialog.cpp:843
KNS::Button::aboutToShowDialog
void aboutToShowDialog()
emitted when the Hot New Stuff dialog is about to be shown, usually as a result of the user having cl...
KNS::Button::dialogFinished
void dialogFinished()
emitted when the Hot New Stuff dialog has been closed
KNS::Button::setResourceType
void setResourceType(const QString &resourceType)
the Hotstuff data type for this downlaod such as "korganizer/calendar"
Definition: knewstuffbutton.cpp:69
KNS::DownloadDialog
Common download dialog for data browsing and installation.
Definition: downloaddialog.h:57

KDE Home | KDE Accessibility Home | Description of Access Keys