PageRenderTime 32ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/guitone-1.0rc5/src/view/dialogs/Dialog.cpp

#
C++ | 65 lines | 37 code | 11 blank | 17 comment | 1 complexity | f4019fd31e7330eb8a0ea2d3af0d5a3d MD5 | raw file
Possible License(s): GPL-3.0
  1. /***************************************************************************
  2. * Copyright (C) 2007 by Thomas Keller *
  3. * me@thomaskeller.biz *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation, either version 3 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  17. ***************************************************************************/
  18. #include "Dialog.h"
  19. #include "Settings.h"
  20. #include "MainWindow.h"
  21. #include "vocab.h"
  22. #include <QMenuBar>
  23. Dialog::Dialog(QWidget * parent) : QDialog(parent) {}
  24. Dialog::Dialog(QWidget * parent, const QString & objName)
  25. : QDialog(parent)
  26. {
  27. setObjectName(objName);
  28. }
  29. Dialog::~Dialog()
  30. {
  31. saveState();
  32. }
  33. void Dialog::init()
  34. {
  35. restoreState();
  36. }
  37. void Dialog::restoreState(void)
  38. {
  39. restoreGeometry(Settings::getWindowGeometry(objectName()));
  40. }
  41. void Dialog::saveState(void)
  42. {
  43. Settings::setWindowGeometry(objectName(), saveGeometry());
  44. }
  45. void Dialog::setStayOnTop()
  46. {
  47. if (isVisible()) return;
  48. setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
  49. }
  50. void Dialog::hideEvent(QHideEvent * event)
  51. {
  52. emit dialogHidden();
  53. event->accept();
  54. }