Sankore-861 Only standard created annotations change their color

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 19d31ccc55
commit 687b65658c
  1. 15
      src/board/UBBoardController.cpp
  2. 48
      src/domain/UBGraphicsStrokesGroup.cpp
  3. 8
      src/domain/UBGraphicsStrokesGroup.h

@ -1543,6 +1543,21 @@ void UBBoardController::changeBackground(bool isDark, bool isCrossed)
mActiveScene->setBackground(isDark, isCrossed);
foreach (QGraphicsItem *item, mActiveScene->items()) {
if (item->type() == UBGraphicsStrokesGroup::Type) {
UBGraphicsStrokesGroup *curGroup = static_cast<UBGraphicsStrokesGroup*>(item);
QColor compareColor = curGroup->color(currentIsDark ? UBGraphicsStrokesGroup::colorOnDarkBackground
: UBGraphicsStrokesGroup::colorOnLightBackground);
if (curGroup->color() == compareColor) {
QColor newColor = curGroup->color(!currentIsDark ? UBGraphicsStrokesGroup::colorOnDarkBackground
: UBGraphicsStrokesGroup::colorOnLightBackground);
curGroup->setColor(newColor);
}
}
}
updateBackgroundState();
emit backgroundChanged();

@ -32,6 +32,54 @@ void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void UBGraphicsStrokesGroup::setColor(const QColor &color, colorType pColorType)
{
//TODO Implement common mechanism of managing groups, drop UBGraphicsStroke if it's obsolete
//Using casting for the moment
foreach (QGraphicsItem *item, childItems()) {
if (item->type() == UBGraphicsPolygonItem::Type) {
UBGraphicsPolygonItem *curPolygon = static_cast<UBGraphicsPolygonItem *>(item);
switch (pColorType) {
case currentColor :
curPolygon->setColor(color);
break;
case colorOnLightBackground :
curPolygon->setColorOnLightBackground(color);
break;
case colorOnDarkBackground :
curPolygon->setColorOnDarkBackground(color);
break;
}
}
}
}
QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
{
QColor result;
foreach (QGraphicsItem *item, childItems()) {
if (item->type() == UBGraphicsPolygonItem::Type) {
UBGraphicsPolygonItem *curPolygon = static_cast<UBGraphicsPolygonItem *>(item);
switch (pColorType) {
case currentColor :
result = curPolygon->color();
break;
case colorOnLightBackground :
result = curPolygon->colorOnLightBackground();
break;
case colorOnDarkBackground :
result = curPolygon->colorOnDarkBackground();
break;
}
}
}
return result;
}
void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{

@ -11,6 +11,12 @@ class UBGraphicsStrokesGroup : public QObject, public QGraphicsItemGroup, public
{
Q_OBJECT
public:
enum colorType {
currentColor = 0
, colorOnLightBackground
, colorOnDarkBackground
};
UBGraphicsStrokesGroup(QGraphicsItem* parent = 0);
~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const;
@ -23,6 +29,8 @@ public:
return Type;
}
virtual void setUuid(const QUuid &pUuid);
void setColor(const QColor &color, colorType pColorType = currentColor);
QColor color(colorType pColorType = currentColor) const;
protected:

Loading…
Cancel
Save