Make the inverted component more obvious
Mark inverted components as blue to differentiate with normal components.master
parent
1f8f7913a7
commit
753dfe9d8f
|
@ -796,6 +796,7 @@ DocumentWindow::DocumentWindow() :
|
||||||
connect(m_document, &Document::componentRemoved, partTreeWidget, &PartTreeWidget::componentRemoved);
|
connect(m_document, &Document::componentRemoved, partTreeWidget, &PartTreeWidget::componentRemoved);
|
||||||
connect(m_document, &Document::componentAdded, partTreeWidget, &PartTreeWidget::componentAdded);
|
connect(m_document, &Document::componentAdded, partTreeWidget, &PartTreeWidget::componentAdded);
|
||||||
connect(m_document, &Document::componentExpandStateChanged, partTreeWidget, &PartTreeWidget::componentExpandStateChanged);
|
connect(m_document, &Document::componentExpandStateChanged, partTreeWidget, &PartTreeWidget::componentExpandStateChanged);
|
||||||
|
connect(m_document, &Document::componentInverseStateChanged, partTreeWidget, &PartTreeWidget::componentInverseStateChanged);
|
||||||
connect(m_document, &Document::partPreviewChanged, partTreeWidget, &PartTreeWidget::partPreviewChanged);
|
connect(m_document, &Document::partPreviewChanged, partTreeWidget, &PartTreeWidget::partPreviewChanged);
|
||||||
connect(m_document, &Document::partLockStateChanged, partTreeWidget, &PartTreeWidget::partLockStateChanged);
|
connect(m_document, &Document::partLockStateChanged, partTreeWidget, &PartTreeWidget::partLockStateChanged);
|
||||||
connect(m_document, &Document::partVisibleStateChanged, partTreeWidget, &PartTreeWidget::partVisibleStateChanged);
|
connect(m_document, &Document::partVisibleStateChanged, partTreeWidget, &PartTreeWidget::partVisibleStateChanged);
|
||||||
|
|
|
@ -103,6 +103,11 @@ void PartTreeWidget::selectComponent(QUuid componentId, bool multiple)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartTreeWidget::updateComponentAppearance(QUuid componentId)
|
||||||
|
{
|
||||||
|
updateComponentSelectState(componentId, isComponentSelected(componentId));
|
||||||
|
}
|
||||||
|
|
||||||
void PartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected)
|
void PartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected)
|
||||||
{
|
{
|
||||||
const Component *component = m_document->findComponent(componentId);
|
const Component *component = m_document->findComponent(componentId);
|
||||||
|
@ -114,19 +119,19 @@ void PartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected
|
||||||
auto item = m_partItemMap.find(component->linkToPartId);
|
auto item = m_partItemMap.find(component->linkToPartId);
|
||||||
if (item != m_componentItemMap.end()) {
|
if (item != m_componentItemMap.end()) {
|
||||||
PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
|
PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
|
||||||
|
// Inverse state updating call should be called before check state updating call
|
||||||
|
widget->updateInverseState(component->inverse);
|
||||||
widget->updateCheckedState(selected);
|
widget->updateCheckedState(selected);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto item = m_componentItemMap.find(componentId);
|
auto item = m_componentItemMap.find(componentId);
|
||||||
if (item != m_componentItemMap.end()) {
|
if (item != m_componentItemMap.end()) {
|
||||||
if (selected) {
|
item->second->setFont(0, selected ? m_selectedFont : m_normalFont);
|
||||||
item->second->setFont(0, m_selectedFont);
|
if (component->inverse)
|
||||||
item->second->setForeground(0, QBrush(Theme::red));
|
item->second->setForeground(0, selected ? QBrush(Theme::blue) : QBrush(Theme::blue));
|
||||||
} else {
|
else
|
||||||
item->second->setFont(0, m_normalFont);
|
item->second->setForeground(0, selected ? QBrush(Theme::red) : QBrush(Theme::white));
|
||||||
item->second->setForeground(0, QBrush(Theme::white));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +259,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos)
|
||||||
} else {
|
} else {
|
||||||
QLabel *previewLabel = new QLabel;
|
QLabel *previewLabel = new QLabel;
|
||||||
previewLabel->setFixedHeight(Theme::partPreviewImageSize);
|
previewLabel->setFixedHeight(Theme::partPreviewImageSize);
|
||||||
previewLabel->setStyleSheet("QLabel {color: " + Theme::red.name() + "}");
|
previewLabel->setStyleSheet("QLabel {color: " + (component && component->inverse ? Theme::blue.name() : Theme::red.name()) + "}");
|
||||||
if (nullptr != component) {
|
if (nullptr != component) {
|
||||||
previewLabel->setText(component->name);
|
previewLabel->setText(component->name);
|
||||||
} else if (!componentIds.empty()) {
|
} else if (!componentIds.empty()) {
|
||||||
|
@ -650,6 +655,11 @@ void PartTreeWidget::componentExpandStateChanged(QUuid componentId)
|
||||||
componentItem->second->setExpanded(component->expanded);
|
componentItem->second->setExpanded(component->expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartTreeWidget::componentInverseStateChanged(QUuid componentId)
|
||||||
|
{
|
||||||
|
updateComponentAppearance(componentId);
|
||||||
|
}
|
||||||
|
|
||||||
void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem)
|
void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem)
|
||||||
{
|
{
|
||||||
const Component *parentComponent = m_document->findComponent(componentId);
|
const Component *parentComponent = m_document->findComponent(componentId);
|
||||||
|
|
|
@ -49,6 +49,7 @@ public slots:
|
||||||
void componentRemoved(QUuid componentId);
|
void componentRemoved(QUuid componentId);
|
||||||
void componentAdded(QUuid componentId);
|
void componentAdded(QUuid componentId);
|
||||||
void componentExpandStateChanged(QUuid componentId);
|
void componentExpandStateChanged(QUuid componentId);
|
||||||
|
void componentInverseStateChanged(QUuid componentId);
|
||||||
void partRemoved(QUuid partId);
|
void partRemoved(QUuid partId);
|
||||||
void partPreviewChanged(QUuid partid);
|
void partPreviewChanged(QUuid partid);
|
||||||
void partLockStateChanged(QUuid partId);
|
void partLockStateChanged(QUuid partId);
|
||||||
|
@ -77,6 +78,7 @@ private:
|
||||||
void selectComponent(QUuid componentId, bool multiple=false);
|
void selectComponent(QUuid componentId, bool multiple=false);
|
||||||
QWidget *createSmoothMenuWidget(QUuid componentId);
|
QWidget *createSmoothMenuWidget(QUuid componentId);
|
||||||
void updateComponentSelectState(QUuid componentId, bool selected);
|
void updateComponentSelectState(QUuid componentId, bool selected);
|
||||||
|
void updateComponentAppearance(QUuid componentId);
|
||||||
bool isComponentSelected(QUuid componentId);
|
bool isComponentSelected(QUuid componentId);
|
||||||
private:
|
private:
|
||||||
const Document *m_document = nullptr;
|
const Document *m_document = nullptr;
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
PartWidget::PartWidget(const Document *document, QUuid partId) :
|
PartWidget::PartWidget(const Document *document, QUuid partId) :
|
||||||
m_document(document),
|
m_document(document),
|
||||||
m_partId(partId)
|
m_partId(partId),
|
||||||
|
m_inverted(false)
|
||||||
{
|
{
|
||||||
QSizePolicy retainSizePolicy = sizePolicy();
|
QSizePolicy retainSizePolicy = sizePolicy();
|
||||||
retainSizePolicy.setRetainSizeWhenHidden(true);
|
retainSizePolicy.setRetainSizeWhenHidden(true);
|
||||||
|
@ -262,11 +263,20 @@ void PartWidget::updateAllButtons()
|
||||||
void PartWidget::updateCheckedState(bool checked)
|
void PartWidget::updateCheckedState(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid " + Theme::red.name() + ";}");
|
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid " + (m_inverted ? Theme::blue.name() : Theme::red.name()) + ";}");
|
||||||
else
|
else
|
||||||
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid transparent;}");
|
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid transparent;}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartWidget::updateInverseState(bool inverse)
|
||||||
|
{
|
||||||
|
if (m_inverted == inverse)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_inverted = inverse;
|
||||||
|
updateAllButtons();
|
||||||
|
}
|
||||||
|
|
||||||
void PartWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
void PartWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::mouseDoubleClickEvent(event);
|
QWidget::mouseDoubleClickEvent(event);
|
||||||
|
@ -429,7 +439,7 @@ void PartWidget::initButton(QPushButton *button)
|
||||||
|
|
||||||
void PartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted)
|
void PartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted)
|
||||||
{
|
{
|
||||||
Theme::updateAwesomeMiniButton(button, icon, highlighted);
|
Theme::updateAwesomeMiniButton(button, icon, highlighted, m_inverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartWidget::updatePreview()
|
void PartWidget::updatePreview()
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void updateColorButton();
|
void updateColorButton();
|
||||||
void updateWrapButton();
|
void updateWrapButton();
|
||||||
void updateCheckedState(bool checked);
|
void updateCheckedState(bool checked);
|
||||||
|
void updateInverseState(bool inverse);
|
||||||
static QSize preferredSize();
|
static QSize preferredSize();
|
||||||
ModelWidget *previewWidget();
|
ModelWidget *previewWidget();
|
||||||
protected:
|
protected:
|
||||||
|
@ -55,6 +56,7 @@ public slots:
|
||||||
private: // need initialize
|
private: // need initialize
|
||||||
const Document *m_document;
|
const Document *m_document;
|
||||||
QUuid m_partId;
|
QUuid m_partId;
|
||||||
|
bool m_inverted;
|
||||||
private:
|
private:
|
||||||
ModelWidget *m_previewWidget;
|
ModelWidget *m_previewWidget;
|
||||||
QPushButton *m_visibleButton;
|
QPushButton *m_visibleButton;
|
||||||
|
|
|
@ -103,18 +103,28 @@ void Theme::initAwesomeMiniButton(QPushButton *button)
|
||||||
button->setFocusPolicy(Qt::NoFocus);
|
button->setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::updateAwesomeMiniButton(QPushButton *button, QChar icon, bool highlighted)
|
void Theme::updateAwesomeMiniButton(QPushButton *button, QChar icon, bool highlighted, bool inverted)
|
||||||
{
|
{
|
||||||
button->setText(icon);
|
button->setText(icon);
|
||||||
QColor color;
|
QColor color;
|
||||||
if (highlighted)
|
bool needDesaturation = true;
|
||||||
color = QColor("#fc6621");
|
|
||||||
else
|
|
||||||
color = QColor("#525252");
|
|
||||||
|
|
||||||
color = color.toHsv();
|
if (highlighted) {
|
||||||
color.setHsv(color.hue(), color.saturation() / 5, color.value() * 2 / 3);
|
if (inverted) {
|
||||||
color = color.toRgb();
|
color = Theme::blue;
|
||||||
|
needDesaturation = false;
|
||||||
|
} else {
|
||||||
|
color = Theme::red;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
color = QColor("#525252");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needDesaturation) {
|
||||||
|
color = color.toHsv();
|
||||||
|
color.setHsv(color.hue(), color.saturation() / 5, color.value() * 2 / 3);
|
||||||
|
color = color.toRgb();
|
||||||
|
}
|
||||||
|
|
||||||
button->setStyleSheet("QPushButton {border: none; background: none; color: " + color.name() + ";}");
|
button->setStyleSheet("QPushButton {border: none; background: none; color: " + color.name() + ";}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
static void initAwesomeLabel(QLabel *label);
|
static void initAwesomeLabel(QLabel *label);
|
||||||
static void initAwesomeSmallButton(QPushButton *button);
|
static void initAwesomeSmallButton(QPushButton *button);
|
||||||
static void initAwesomeMiniButton(QPushButton *button);
|
static void initAwesomeMiniButton(QPushButton *button);
|
||||||
static void updateAwesomeMiniButton(QPushButton *button, QChar icon, bool highlighted);
|
static void updateAwesomeMiniButton(QPushButton *button, QChar icon, bool highlighted, bool inverted=false);
|
||||||
static void initAwesomeToolButton(QPushButton *button);
|
static void initAwesomeToolButton(QPushButton *button);
|
||||||
static void initAwesomeToolButtonWithoutFont(QPushButton *button);
|
static void initAwesomeToolButtonWithoutFont(QPushButton *button);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue