Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
creation-boutons.qt.cc
Go to the documentation of this file.
1 /*
2  * Moka : Un modeleur de 3-G-cartes.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of Moka
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "creation-boutons.qt.hh"
25 #include "creation-objet.qt.hh"
26 #include "window.qt.hh"
27 #include "HtmlEntities.hh"
28 
29 // #include <Qt3Support/Q3Accel>
30 
31 //***********************************
32 // Constructeurs *
33 //***********************************
34 BoutonsCreation::BoutonsCreation(CreationObjet * parent , QBoxLayout * layout)
35  :
36  QWidget(parent),
37  FParent(parent)
38 {
39  // Creation des images
40 
41  QIcon p1(":/boutonOK.png") ;
42  QIcon p2(":/boutonAnnuler.png") ;
43  QIcon p3(":/boutonReinit.png") ;
44  QIcon p4(":/boutonOptions.png") ;
45 
46  // Creation des boutons
47  FReinitialiser = new QPushButton(p3 , *HTML::decode("Reset"),
48  this) ;
49  FAnnuler = new QPushButton(p2 , "Close" , this) ;
50  FCreer = new QPushButton(p1 , *HTML::decode("Create") , this) ;
51  FOptions = new QPushButton(p4 , "Options" , this) ;
52 
53  // Raccourcis claviers
54 
55  /* Q3Accel * Raccourci = new Q3Accel ( this ) ;
56  Raccourci -> insertItem ( QKeySequence ( Qt::Key_Space ) , 2 ) ;
57  Raccourci -> connectItem ( 2 , this ,
58  SLOT ( cancel ( ) ) ) ;
59  */
60 
61  FReinitialiser->setShortcut(Qt::Key_Space);
62  FOptions->setShortcut(Qt::CTRL + Qt::Key_P);
63 
64  /*
65  Raccourci -> insertItem ( QKeySequence ( Qt::CTRL + Qt::Key_P ) , 3 ) ;
66  Raccourci -> connectItem ( 3 , this ,
67  SLOT ( options ( ) ) ) ;
68  */
69 
70  // Mise en place des ecoutes
71  QObject::connect(FReinitialiser , SIGNAL(clicked()) , this,
72  SLOT(reinit())) ;
73  QObject::connect(FAnnuler , SIGNAL(clicked()) , this,
74  SLOT(cancel())) ;
75  QObject::connect(FCreer , SIGNAL(clicked()) , this,
76  SLOT(create())) ;
77  QObject::connect(FOptions , SIGNAL(clicked()) , this,
78  SLOT(options())) ;
79 
80  // Positionnement avec un boxLayout
81 
82  if (layout != NULL)
83  {
84  layout -> addWidget(FReinitialiser) ;
85  layout -> addWidget(FAnnuler) ;
86  layout -> addWidget(FCreer) ;
87  layout -> addWidget(FOptions) ;
88  }
89  else
90  {
91  QToolBar* tl = (QToolBar*) parent;
92  tl -> addWidget(FReinitialiser) ;
93  tl -> addWidget(FAnnuler) ;
94  tl -> addWidget(FCreer) ;
95  tl -> addWidget(FOptions) ;
96  }
97 }
98 
99 //***********************************
100 // Destructeur *
101 //***********************************
103 
104 //***********************************
105 // Slots *
106 //***********************************
108 {
109  FParent -> getControler()
110  -> modeCreationReinitPosition() ;
111 
112  FParent -> update() ;
113  FParent -> repaint() ;
114 }
115 
117 {
118  FParent -> cancel() ;
119 }
120 
122 {
123  FParent -> getControler()
124  -> createObject() ;
125  FParent -> repaint() ;
126 }
127 
129 {
130  FParent -> showOptions() ;
131 }
132 
133 //***********************************
134 // Accesseurs *
135 //***********************************
137 {
138  return FAnnuler ;
139 }
140 
142 {
143  return FOptions ;
144 }