ImageDescriptionForm.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * ImageDescriptionForm.cpp
  3. *
  4. * Created on: Oct 6, 2011
  5. * Author: Gapchich Vlad
  6. */
  7. #include "ImageDescriptionForm.h"
  8. #include <QLineEdit>
  9. #include <QPushButton>
  10. #include <QBoxLayout>
  11. #include <QMessageBox>
  12. #include <QApplication>
  13. #include <QDesktopWidget>
  14. ImageDescriptionForm::ImageDescriptionForm(QWidget *aParent)
  15. : QWidget(aParent)
  16. {
  17. setWindowTitle(tr("Image Description"));
  18. layout_v_ = new QVBoxLayout(this);
  19. layout_h_ = new QHBoxLayout;
  20. image_description_ = new QLineEdit(this);
  21. button_ok_ = new QPushButton(this);
  22. button_ok_->setText(tr("OK"));
  23. button_cancel_ = new QPushButton(this);
  24. button_cancel_->setText(tr("Cancel"));
  25. layout_v_->addWidget(image_description_);
  26. layout_v_->addLayout(layout_h_);
  27. layout_h_->addWidget(button_ok_);
  28. layout_h_->addWidget(button_cancel_);
  29. connect(
  30. button_ok_,
  31. SIGNAL(clicked()),
  32. this,
  33. SLOT(setDescription())
  34. );
  35. connect(
  36. button_cancel_,
  37. SIGNAL(clicked()),
  38. this,
  39. SLOT(hide())
  40. );
  41. adjustSize();
  42. move(QApplication::desktop()->screen()->rect().center() - rect().center());
  43. }
  44. ImageDescriptionForm::~ImageDescriptionForm()
  45. {
  46. delete image_description_;
  47. delete button_ok_;
  48. delete button_cancel_;
  49. delete layout_v_;
  50. }
  51. void
  52. ImageDescriptionForm::setDescription()
  53. {
  54. if (!image_description_->text().isEmpty()) {
  55. emit descriptionSet(image_description_->text());
  56. hide();
  57. }
  58. else
  59. QMessageBox::warning(
  60. this,
  61. tr("Warning!"),
  62. tr("Image description is empty"),
  63. QMessageBox::Ok,
  64. QMessageBox::Cancel
  65. );
  66. }
  67. /*
  68. *
  69. */