/bulmages/bulmafact/plugins/pluginbf_balance/pluginbf_balance.cpp

https://github.com/i02sopop/Bulmages · C++ · 102 lines · 57 code · 19 blank · 26 comment · 4 complexity · f8efa8fedaa445cf8ba1268cb2f79a82 MD5 · raw file

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Tomeu Borras Riera *
  3. * tborras@conetxia.com *
  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 2 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, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #include <cstdio>
  21. #include <QtWidgets/QAction>
  22. #include <QtWidgets/QMessageBox>
  23. #include <QtWidgets/QMessageBox>
  24. #include <QtWidgets/QWidget>
  25. #include <QtGui/QIcon>
  26. #include <QtWidgets/QApplication>
  27. #include <QtCore/QObject>
  28. #include <QtCore/QTextCodec>
  29. #include <QtCore/QLocale>
  30. #include "pluginbf_balance.h"
  31. #include "balanceview.h"
  32. #include "bfcompany.h"
  33. BfBulmaFact *g_pluginbf_balance = NULL;
  34. ///
  35. /**
  36. \param bcont
  37. **/
  38. int entryPoint ( BfBulmaFact *bcont )
  39. {
  40. BL_FUNC_DEBUG
  41. /// Inicializa el sistema de traducciones 'gettext'.
  42. setlocale ( LC_ALL, "" );
  43. blBindTextDomain ( "pluginbf_balance", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() );
  44. g_pluginbf_balance = bcont;
  45. QMenu *pPluginMenu = bcont->newMenu( _("&Ver"), "menuVer", "menuMaestro");
  46. BlAction *accionA = new BlAction ( _ ( "&Balance" ), 0 );
  47. accionA->setStatusTip ( _ ( "Permite realizar balances" ) );
  48. accionA->setWhatsThis ( _ ( "Podra disponer de la informacion del balance" ) );
  49. accionA->setIcon ( QIcon ( QString::fromUtf8 ( ":/BulmaCont32x32/images/png/i_balance.xpm" ) ) );
  50. accionA->setObjectName("mui_actionBalance");
  51. pPluginMenu->addAction ( accionA );
  52. /// A&ntilde;adimos la nueva opci&oacute;n al men&uacute; principal del programa.
  53. /// Usamos un toolBox especial para meter los botones de contabilidad.
  54. QToolBar *toolCont = bcont->findChild<QToolBar *> ( "contabilidad" );
  55. if ( !toolCont) {
  56. toolCont = new QToolBar(bcont);
  57. toolCont->setObjectName("contabilidad");
  58. toolCont->setFocusPolicy(Qt::TabFocus);
  59. toolCont->setOrientation(Qt::Horizontal);
  60. toolCont->setIconSize(QSize(32, 32));
  61. toolCont->setWindowTitle(N_("Contabilidad", 0));
  62. toolCont->setToolTip(N_("Contabilidad", 0));
  63. toolCont->setStatusTip(N_("Contabilidad", 0));
  64. toolCont->setWhatsThis(N_("Contabilidad", 0));
  65. toolCont->setAccessibleName(N_("Contabilidad", 0));
  66. toolCont->setAccessibleDescription(N_("Contabilidad", 0));
  67. bcont->addToolBar(Qt::TopToolBarArea, toolCont);
  68. } // end if
  69. toolCont->addAction(accionA);
  70. return 0;
  71. }
  72. int BlAction_actionTriggered(BlAction *accion) {
  73. BL_FUNC_DEBUG
  74. if (accion->objectName() == "mui_actionBalance") {
  75. if (!g_pluginbf_balance->company()->showWindow("BalanceView")) {
  76. BalanceView *balance = new BalanceView ( g_pluginbf_balance->company(), 0 );
  77. balance->setObjectName("BalanceView");
  78. g_pluginbf_balance->company()->pWorkspace() ->addSubWindow ( balance );
  79. balance->show();
  80. } // end if
  81. } // end if
  82. return 0;
  83. }