TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

knewstuffbutton.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Copyright (c) 2004 Aaron J. Seigo <aseigo@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include <kiconloader.h>
  17. #include <tdelocale.h>
  18. #include "downloaddialog.h"
  19. #include "knewstuffbutton.h"
  20. #include "knewstuffbutton.moc"
  21. namespace KNS
  22. {
  23. Button::Button(const TQString& what,
  24. const TQString& providerList,
  25. const TQString& resourceType,
  26. TQWidget* parent, const char* name)
  27. : KPushButton(parent, name),
  28. d(0),
  29. m_providerList(providerList),
  30. m_type(resourceType),
  31. m_downloadDialog(0)
  32. {
  33. setButtonText(what);
  34. init();
  35. }
  36. Button::Button(TQWidget* parent, const char* name)
  37. : KPushButton(parent, name),
  38. d(0),
  39. m_downloadDialog(0)
  40. {
  41. setButtonText(i18n("Download New Stuff"));
  42. init();
  43. }
  44. void Button::init()
  45. {
  46. setIconSet(SmallIconSet("knewstuff"));
  47. connect(this, TQT_SIGNAL(clicked()), TQT_SLOT(showDialog()));
  48. }
  49. void Button::setButtonText(const TQString& what)
  50. {
  51. setText(i18n("Download New %1").arg(what));
  52. }
  53. void Button::setProviderList(const TQString& providerList)
  54. {
  55. m_providerList = providerList;
  56. }
  57. void Button::setResourceType(const TQString& resourceType)
  58. {
  59. m_type = resourceType;
  60. }
  61. void Button::showDialog()
  62. {
  63. emit aboutToShowDialog();
  64. if (!m_downloadDialog)
  65. {
  66. m_downloadDialog = new DownloadDialog(0, this);
  67. }
  68. m_downloadDialog->setType(m_type);
  69. m_downloadDialog->load(m_providerList);
  70. m_downloadDialog->exec(); // TODO: make non-modal?
  71. emit dialogFinished();
  72. }
  73. }