Bibletime – a bible study tool
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.

cinputdialog.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. //own includes
  10. #include "cinputdialog.h"
  11. //TQt includes
  12. #include <tqwidget.h>
  13. #include <tqlabel.h>
  14. #include <tqtextedit.h>
  15. #include <tqpushbutton.h>
  16. #include <tqlayout.h>
  17. //KDE includes
  18. #include <tdelocale.h>
  19. #include <kseparator.h>
  20. CInputDialog::CInputDialog(const TQString& caption, const TQString& description, const TQString& text, TQWidget *parent, const char *name, const bool modal ) : KDialog(parent,name,modal) {
  21. setPlainCaption(caption);
  22. TQVBoxLayout* topLayout = new TQVBoxLayout(this, 5,5);
  23. TQLabel* l = new TQLabel(description, this);
  24. topLayout->addWidget(l);
  25. topLayout->addSpacing(10);
  26. m_editWidget = new TQTextEdit(this, "edit widget");
  27. m_editWidget->setWordWrap( TQTextEdit::WidgetWidth );
  28. m_editWidget->setText(text);
  29. if (!text.isEmpty())
  30. m_editWidget->selectAll();
  31. topLayout->addWidget(m_editWidget);
  32. KSeparator* separator = new KSeparator(KSeparator::HLine, this);
  33. topLayout->addWidget(separator);
  34. TQHBoxLayout* buttonLayout = new TQHBoxLayout(topLayout);
  35. buttonLayout->addStretch(2);
  36. TQPushButton* cancel = new TQPushButton(this);
  37. cancel->setText(i18n("&Cancel"));
  38. connect(cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));
  39. buttonLayout->addWidget(cancel,1);
  40. buttonLayout->addSpacing(15);
  41. TQPushButton* clear = new TQPushButton(this);
  42. clear->setText(i18n("C&lear"));
  43. connect(clear, TQT_SIGNAL(clicked()),m_editWidget, TQT_SLOT(clear()));
  44. buttonLayout->addWidget(clear,1);
  45. buttonLayout->addSpacing(15);
  46. TQPushButton* ok = new TQPushButton(this);
  47. ok->setText(i18n("&Ok"));
  48. connect(ok, TQT_SIGNAL(clicked()), TQT_SLOT(accept()));
  49. buttonLayout->addWidget(ok,1);
  50. m_editWidget->setFocus();
  51. }
  52. /** Returns the text entered at the moment. */
  53. const TQString CInputDialog::text() {
  54. return m_editWidget->text();
  55. }
  56. /** A static function to get some using CInputDialog. */
  57. const TQString CInputDialog::getText( const TQString& caption, const TQString& description, const TQString& text, bool* ok, TQWidget* parent, bool modal) {
  58. CInputDialog* dlg = new CInputDialog(caption, description, text, parent, "", modal);
  59. TQString ret = TQString();
  60. const bool isOk = (dlg->exec() == CInputDialog::Accepted);
  61. if (isOk) {
  62. ret = dlg->text();
  63. }
  64. if (ok) { //change the ok param to return the value
  65. *ok = isOk;
  66. }
  67. delete dlg;
  68. return ret;
  69. }
  70. #include "cinputdialog.moc"