30 #include "../../../core/pattern/mvc/ItemObserver.h"
31 #include "../../../outside/GridSettingsModel.h"
32 #include "../../../outside/GridSettingsController.h"
33 #include "../../../core/pattern/mvc/OutsideObserver.h"
34 #include "../../outside/GridSettingsOutside.h"
35 #include "../../../core/pattern/mvc/ItemController.h"
36 #include "../../../core/enum/Enums.h"
37 #include "../../../outside/TextGridSettingsModel.h"
38 #include "../../../outside/TextGridSettingsController.h"
39 #include "../../outside/TextGridSettingsOutside.h"
40 #include "../pattern/command/ChangePropertyCommand.h"
41 #include "../../../core/pattern/singleton/Context.h"
50 #include <QGraphicsItem>
51 #include <QImageReader>
54 #include <QFileDialog>
56 #include <QMessageBox>
60 #include <QFontDialog>
62 #include <QColorDialog>
64 #include <QUndoCommand>
65 #include <QApplication>
67 #include <QDesktopWidget>
95 m_graphicsItems = items;
97 if(m_graphicsItems.empty())
101 m_properties = m_propUtils->intersection(items, window);
112 m_menu =
new QMenu();
113 connect(m_menu, SIGNAL(triggered(QAction*)),
this, SLOT(onMenuTriggered(QAction*)));
117 foreach(
Property prop, m_properties->getProperties())
122 std::string label = prop.
getLabel();
123 if(label.compare(
"") == 0)
126 QAction* action = createAction(label, prop.
getName(), prop.
getIcon());
127 m_menu->addAction(action);
130 action->setCheckable(
true);
138 QAction *actionMenu =
new QAction(text.c_str(),
this);
139 actionMenu->setObjectName(objName.c_str());
141 actionMenu->setIcon(QIcon::fromTheme(icon.c_str()));
142 actionMenu->setToolTip(tooltip.c_str());
152 m_currentPropertyClicked = findMnuProperty(action->objectName().toStdString());
156 if(m_currentPropertyClicked.getType() == dataType->getDataTypeColor())
160 else if(m_currentPropertyClicked.getType() == dataType->getDataTypeFont())
164 else if(m_currentPropertyClicked.getType() == dataType->getDataTypeGridSettings())
166 onShowGridSettingsDlg();
168 else if(m_currentPropertyClicked.getType() == dataType->getDataTypeImage())
172 else if(m_currentPropertyClicked.getType() == dataType->getDataTypeBool())
174 checkedBool(action->isChecked());
176 else if(m_currentPropertyClicked.getType() == dataType->getDataTypeTextGridSettings())
178 onShowTextGridSettingsDlg();
184 QWidget* wdg =
dynamic_cast<QWidget*
>(parent());
191 Property property = m_currentPropertyClicked;
200 font =
property.getValue().toFont();
203 qFont.setBold(font.
isBold());
209 QFont newFont = QFontDialog::getFont(&ok, qFont, wdg, tr(
"Select Font"));
211 if (!ok || newFont == qFont)
214 font.
setFamily(newFont.family().toStdString());
223 emit changeDlgProperty(property);
228 QWidget* wdg =
dynamic_cast<QWidget*
>(parent());
235 Property property = m_currentPropertyClicked;
244 color =
property.getValue().toColor();
245 qcolor.setRed(color.
getRed());
247 qcolor.setBlue(color.
getBlue());
250 QRgb oldRgba = qcolor.rgba();
252 QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, wdg);
254 if (!ok || newRgba == oldRgba)
257 qcolor = QColor::fromRgba(newRgba);
261 color.
setColor(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha());
264 emit changeDlgProperty(property);
272 Property property = m_currentPropertyClicked;
278 changePropertyValue(property);
283 changePropertyValue(property);
295 std::vector<QGraphicsItem*> commandItems;
296 std::vector<Properties*> commandOld;
297 std::vector<Properties*> commandNew;
299 foreach(QGraphicsItem* item, m_graphicsItems)
328 commandItems.push_back(item);
329 commandOld.push_back(oldCommand);
330 commandNew.push_back(newCommand);
337 if(!m_graphicsItems.isEmpty())
349 std::map<std::string, Property>::iterator it;
351 foreach(
Property pro, m_properties->getProperties())
367 std::map<std::string, Property>::iterator it;
369 foreach(
Property pro, m_properties->getProperties())
371 if(pro.
getName().compare(name) == 0)
std::string getName()
Method that returns the name of this property.
virtual bool addProperty(Property property)
Adds the specified property to the set of properties for this object.
void changeDlgProperty(Property property)
bool isBold()
Returns true if font use bold, false otherwise.
Variant getValue()
Returns stored value.
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
bool isStrikeout()
Returns true if font use strikeout, false otherwise.
void setStrikeout(bool strikeout)
Sets font with strikeout style.
int getRed() const
It returns the red component color value (a value from 0 to 255).
virtual EnumType * getDataTypeBool() const
Returns value that represents type bool belonging to enumeration.
void setKerning(bool kerning)
Sets font with kerning style.
virtual void setHashCode(int hashCode)
Sets the hashcode of a MVC component.
int getPointSize()
Returns point size of the font.
virtual EnumType * getDataTypeNone() const
Returns value that represents type none belonging to enumeration.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
void setPointSize(int point)
Sets point size of the font.
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
virtual bool isMenu()
Returns true if property will be used in a menu, false otherwise.
virtual void setObjectName(std::string name)
Sets object name that owns these properties.
virtual void redraw(bool bRefresh=true)
Redraws the graphic component.
virtual bool isVisible()
Return true if visible, false otherwise.
virtual void setTypeObj(EnumType *type)
Sets object type that owns these properties.
virtual void updateProperties(te::layout::Properties *properties)=0
Updated model state with properties. Reimplement this function in a Observable subclass to provide th...
void setBold(bool bold)
Sets font with bold style.
static Enums & getInstance()
It returns a reference to the singleton instance.
virtual EnumType * getTypeObj()
Returns object type that owns these properties.
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
void setFamily(std::string family)
Returns font family name.
virtual std::string getObjectName()
Returns object name that owns these properties.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
virtual int getHashCode()=0
Returns the hashcode of a MVC component. Reimplement this function in a Observable subclass to provid...
void setUnderline(bool underline)
Sets font with underline style.
bool isItalic()
Returns true if font use italic, false otherwise.
virtual te::layout::Properties * getProperties() const =0
Returns the model state as properties. Reimplement this function in a Observable subclass to provide ...
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
bool isUnderline()
Returns true if font use underline, false otherwise.
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
virtual std::string getIcon()
Manage properties dialogs values.
Utility class with functions to facilitate handling of qt properties and properties layout module...
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Utility class with functions to facilitate handling of qt properties and properties layout module...
virtual EnumType * getDataTypeFont() const
Returns value that represents type Font belonging to enumeration.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
virtual Observable * getModel()
Returns the "Model" part of the MVC.
void setItalic(bool italic)
Sets font with italic style.
virtual void addUndoStack(QUndoCommand *command)
Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack.
std::string getFamily()
Sets font family name.
AbstractScene * getScene()
Returns abstract scene for QGraphicsScene class, part of Graphics View Framework. ...
Undo/Redo for changes in component properties.
EnumType * getType()
Returns the type of this property.
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
bool isKerning()
Returns true if font use kerning, false otherwise.
bool toBool()
Returns the value of boolean type. (The setValue method received a boolean)
virtual std::string getLabel()
Returns the label of this property.