forked from qt-creator/qt-creator
QmlDesigner: Modify icons for 3d toolbar
Task-number: QDS-9082 Change-Id: Ib4536db2f353c5eba1b9eb18743f92372d5296d7 Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -49,8 +49,7 @@ Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
|||||||
const QKeySequence &key,
|
const QKeySequence &key,
|
||||||
bool checkable,
|
bool checkable,
|
||||||
bool checked,
|
bool checked,
|
||||||
const QIcon &iconOff,
|
const QIcon &icon,
|
||||||
const QIcon &iconOn,
|
|
||||||
Edit3DView *view,
|
Edit3DView *view,
|
||||||
SelectionContextOperation selectionAction,
|
SelectionContextOperation selectionAction,
|
||||||
const QString &toolTip)
|
const QString &toolTip)
|
||||||
@@ -68,17 +67,7 @@ Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
|||||||
if (!toolTip.isEmpty())
|
if (!toolTip.isEmpty())
|
||||||
action()->setToolTip(toolTip);
|
action()->setToolTip(toolTip);
|
||||||
|
|
||||||
if (checkable) {
|
action()->setIcon(icon);
|
||||||
QIcon onOffIcon;
|
|
||||||
const auto onAvail = iconOn.availableSizes(); // Assume both icons have same sizes available
|
|
||||||
for (const auto &size : onAvail) {
|
|
||||||
onOffIcon.addPixmap(iconOn.pixmap(size), QIcon::Normal, QIcon::On);
|
|
||||||
onOffIcon.addPixmap(iconOff.pixmap(size), QIcon::Normal, QIcon::Off);
|
|
||||||
}
|
|
||||||
action()->setIcon(onOffIcon);
|
|
||||||
} else {
|
|
||||||
action()->setIcon(iconOff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
||||||
@@ -118,11 +107,10 @@ Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId,
|
|||||||
const QKeySequence &key,
|
const QKeySequence &key,
|
||||||
bool checkable,
|
bool checkable,
|
||||||
bool checked,
|
bool checked,
|
||||||
const QIcon &iconOff,
|
const QIcon &icon,
|
||||||
const QIcon &iconOn,
|
|
||||||
Edit3DView *view,
|
Edit3DView *view,
|
||||||
SelectionContextOperation selectionAction)
|
SelectionContextOperation selectionAction)
|
||||||
: Edit3DAction(menuId, type, description, key, checkable, checked, iconOff, iconOn, view, selectionAction)
|
: Edit3DAction(menuId, type, description, key, checkable, checked, icon, view, selectionAction)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,8 +50,7 @@ public:
|
|||||||
const QKeySequence &key,
|
const QKeySequence &key,
|
||||||
bool checkable,
|
bool checkable,
|
||||||
bool checked,
|
bool checked,
|
||||||
const QIcon &iconOff,
|
const QIcon &icon,
|
||||||
const QIcon &iconOn,
|
|
||||||
Edit3DView *view,
|
Edit3DView *view,
|
||||||
SelectionContextOperation selectionAction = nullptr,
|
SelectionContextOperation selectionAction = nullptr,
|
||||||
const QString &toolTip = {});
|
const QString &toolTip = {});
|
||||||
@@ -98,8 +97,7 @@ public:
|
|||||||
const QKeySequence &key,
|
const QKeySequence &key,
|
||||||
bool checkable,
|
bool checkable,
|
||||||
bool checked,
|
bool checked,
|
||||||
const QIcon &iconOff,
|
const QIcon &icon,
|
||||||
const QIcon &iconOn,
|
|
||||||
Edit3DView *view,
|
Edit3DView *view,
|
||||||
SelectionContextOperation selectionAction = nullptr);
|
SelectionContextOperation selectionAction = nullptr);
|
||||||
|
|
||||||
|
@@ -37,6 +37,25 @@ static inline QIcon contextIcon (const DesignerIcons::IconId &iconId) {
|
|||||||
return DesignerActionManager::instance().contextIcon(iconId);
|
return DesignerActionManager::instance().contextIcon(iconId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static QIcon toolbarIcon (const Theme::Icon &iconOffId, const Theme::Icon &iconnOnId) {
|
||||||
|
QIcon iconOff = Theme::iconFromName(iconOffId);
|
||||||
|
QIcon iconOn= Theme::iconFromName(iconnOnId,
|
||||||
|
Theme::getColor(Theme::Color::DStextSelectedTextColor));
|
||||||
|
QIcon retIcon;
|
||||||
|
|
||||||
|
const auto onAvail = iconOff.availableSizes(); // Assume both icons have same sizes available
|
||||||
|
for (const auto &size : onAvail) {
|
||||||
|
retIcon.addPixmap(iconOff.pixmap(size), QIcon::Normal, QIcon::Off);
|
||||||
|
retIcon.addPixmap(iconOn.pixmap(size), QIcon::Normal, QIcon::On);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retIcon;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline QIcon toolbarIcon (const Theme::Icon &iconOffId) {
|
||||||
|
return toolbarIcon(iconOffId, iconOffId);
|
||||||
|
};
|
||||||
|
|
||||||
Edit3DView::Edit3DView(ExternalDependenciesInterface &externalDependencies)
|
Edit3DView::Edit3DView(ExternalDependenciesInterface &externalDependencies)
|
||||||
: AbstractView{externalDependencies}
|
: AbstractView{externalDependencies}
|
||||||
{
|
{
|
||||||
@@ -374,7 +393,6 @@ Edit3DAction *Edit3DView::createSelectBackgroundColorAction(QAction *syncBackgro
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
operation,
|
operation,
|
||||||
tooltip);
|
tooltip);
|
||||||
@@ -401,7 +419,6 @@ Edit3DAction *Edit3DView::createGridColorSelectionAction()
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
operation,
|
operation,
|
||||||
tooltip);
|
tooltip);
|
||||||
@@ -436,7 +453,6 @@ Edit3DAction *Edit3DView::createResetColorAction(QAction *syncBackgroundColorAct
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
operation,
|
operation,
|
||||||
tooltip);
|
tooltip);
|
||||||
@@ -457,7 +473,6 @@ Edit3DAction *Edit3DView::createSyncBackgroundColorAction()
|
|||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
{},
|
{},
|
||||||
tooltip);
|
tooltip);
|
||||||
@@ -491,8 +506,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_Q),
|
QKeySequence(Qt::Key_Q),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::selectOutline_medium),
|
toolbarIcon(Theme::selectOutline_medium, Theme::selectFill_medium),
|
||||||
Theme::iconFromName(Theme::Icon::selectFill_medium), //s_selection
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_moveToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_MOVE_TOOL,
|
m_moveToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_MOVE_TOOL,
|
||||||
@@ -502,8 +516,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_W),
|
QKeySequence(Qt::Key_W),
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
Theme::iconFromName(Theme::Icon::move_medium),
|
toolbarIcon(Theme::move_medium),
|
||||||
Theme::iconFromName(Theme::Icon::move_medium),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_rotateToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_ROTATE_TOOL,
|
m_rotateToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_ROTATE_TOOL,
|
||||||
@@ -513,8 +526,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_E),
|
QKeySequence(Qt::Key_E),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::roatate_medium),
|
toolbarIcon(Theme::roatate_medium),
|
||||||
Theme::iconFromName(Theme::Icon::roatate_medium),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_scaleToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_SCALE_TOOL,
|
m_scaleToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_SCALE_TOOL,
|
||||||
@@ -524,8 +536,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_R),
|
QKeySequence(Qt::Key_R),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::scale_medium),
|
toolbarIcon(Theme::scale_medium),
|
||||||
Theme::iconFromName(Theme::Icon::scale_medium),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_fitAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_FIT_SELECTED,
|
m_fitAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_FIT_SELECTED,
|
||||||
@@ -535,8 +546,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_F),
|
QKeySequence(Qt::Key_F),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::fitToView_medium),
|
toolbarIcon(Theme::fitToView_medium),
|
||||||
{},
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_alignCamerasAction = new Edit3DCameraAction(
|
m_alignCamerasAction = new Edit3DCameraAction(
|
||||||
@@ -546,8 +556,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(),
|
QKeySequence(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::alignToCam_medium),
|
toolbarIcon(Theme::alignToCam_medium),
|
||||||
{},
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_alignViewAction = new Edit3DCameraAction(
|
m_alignViewAction = new Edit3DCameraAction(
|
||||||
@@ -557,8 +566,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(),
|
QKeySequence(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::alignToView_medium),
|
toolbarIcon(Theme::alignToView_medium),
|
||||||
{},
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_cameraModeAction = new Edit3DAction(
|
m_cameraModeAction = new Edit3DAction(
|
||||||
@@ -569,8 +577,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_T),
|
QKeySequence(Qt::Key_T),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::orthCam_small),
|
toolbarIcon(Theme::orthCam_small, Theme::perspectiveCam_small),
|
||||||
Theme::iconFromName(Theme::Icon::perspectiveCam_small),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_orientationModeAction = new Edit3DAction(
|
m_orientationModeAction = new Edit3DAction(
|
||||||
@@ -580,19 +587,18 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_Y),
|
QKeySequence(Qt::Key_Y),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::localOrient_medium),
|
toolbarIcon(Theme::localOrient_medium),
|
||||||
Theme::iconFromName(Theme::Icon::globalOrient_medium),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_editLightAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_EDIT_LIGHT,
|
m_editLightAction = new Edit3DAction(
|
||||||
|
QmlDesigner::Constants::EDIT3D_EDIT_LIGHT,
|
||||||
View3DActionType::EditLightToggle,
|
View3DActionType::EditLightToggle,
|
||||||
QCoreApplication::translate("EditLightToggleAction",
|
QCoreApplication::translate("EditLightToggleAction",
|
||||||
"Toggle Edit Light On/Off"),
|
"Toggle Edit Light On/Off"),
|
||||||
QKeySequence(Qt::Key_U),
|
QKeySequence(Qt::Key_U),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::editLightOff_medium),
|
toolbarIcon(Theme::editLightOff_medium, Theme::editLightOn_medium),
|
||||||
Theme::iconFromName(Theme::Icon::editLightOn_medium),
|
|
||||||
this);
|
this);
|
||||||
|
|
||||||
m_showGridAction = new Edit3DAction(
|
m_showGridAction = new Edit3DAction(
|
||||||
@@ -603,7 +609,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
nullptr,
|
nullptr,
|
||||||
QCoreApplication::translate("ShowGridAction", "Toggle the visibility of the helper grid."));
|
QCoreApplication::translate("ShowGridAction", "Toggle the visibility of the helper grid."));
|
||||||
@@ -616,7 +621,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
nullptr,
|
nullptr,
|
||||||
QCoreApplication::translate("ShowSelectionBoxAction",
|
QCoreApplication::translate("ShowSelectionBoxAction",
|
||||||
@@ -630,7 +634,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
nullptr,
|
nullptr,
|
||||||
QCoreApplication::translate(
|
QCoreApplication::translate(
|
||||||
@@ -645,7 +648,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
nullptr,
|
nullptr,
|
||||||
QCoreApplication::translate(
|
QCoreApplication::translate(
|
||||||
@@ -662,7 +664,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
nullptr,
|
nullptr,
|
||||||
QCoreApplication::translate(
|
QCoreApplication::translate(
|
||||||
@@ -702,8 +703,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_V),
|
QKeySequence(Qt::Key_V),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::particleAnimation_medium),
|
toolbarIcon(Theme::particleAnimation_medium),
|
||||||
Theme::iconFromName(Theme::Icon::particleAnimation_medium),
|
|
||||||
this,
|
this,
|
||||||
particlesTrigger);
|
particlesTrigger);
|
||||||
particlemode = false;
|
particlemode = false;
|
||||||
@@ -714,8 +714,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_Comma),
|
QKeySequence(Qt::Key_Comma),
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
Theme::iconFromName(Theme::Icon::playOutline_medium), //Icons::EDIT3D_PARTICLE_PLAY.icon(),
|
toolbarIcon(Theme::playOutline_medium, Theme::pause), // Icons::EDIT3D_PARTICLE_PLAY.icon(), Icons::EDIT3D_PARTICLE_PAUSE.icon(),
|
||||||
Theme::iconFromName(Theme::Icon::pause), // Icons::EDIT3D_PARTICLE_PAUSE.icon(),
|
|
||||||
this,
|
this,
|
||||||
particlesPlayTrigger);
|
particlesPlayTrigger);
|
||||||
m_particlesRestartAction = new Edit3DAction(
|
m_particlesRestartAction = new Edit3DAction(
|
||||||
@@ -725,20 +724,19 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(Qt::Key_Slash),
|
QKeySequence(Qt::Key_Slash),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::restartParticles_medium),
|
toolbarIcon(Theme::restartParticles_medium),
|
||||||
Theme::iconFromName(Theme::Icon::restartParticles_medium),
|
|
||||||
this);
|
this);
|
||||||
m_particlesPlayAction->action()->setEnabled(particlemode);
|
m_particlesPlayAction->action()->setEnabled(particlemode);
|
||||||
m_particlesRestartAction->action()->setEnabled(particlemode);
|
m_particlesRestartAction->action()->setEnabled(particlemode);
|
||||||
|
|
||||||
m_resetAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_RESET_VIEW,
|
m_resetAction = new Edit3DAction(
|
||||||
|
QmlDesigner::Constants::EDIT3D_RESET_VIEW,
|
||||||
View3DActionType::Empty,
|
View3DActionType::Empty,
|
||||||
QCoreApplication::translate("ResetView", "Reset View"),
|
QCoreApplication::translate("ResetView", "Reset View"),
|
||||||
QKeySequence(Qt::Key_P),
|
QKeySequence(Qt::Key_P),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::resetView_small),
|
toolbarIcon(Theme::reload_medium),
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
resetTrigger);
|
resetTrigger);
|
||||||
|
|
||||||
@@ -766,8 +764,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(),
|
QKeySequence(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::invisible_medium),
|
toolbarIcon(Theme::invisible_medium, Theme::visible_medium),
|
||||||
Theme::iconFromName(Theme::Icon::visible_medium),
|
|
||||||
this,
|
this,
|
||||||
visibilityTogglesTrigger);
|
visibilityTogglesTrigger);
|
||||||
|
|
||||||
@@ -795,8 +792,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
QKeySequence(),
|
QKeySequence(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::iconFromName(Theme::Icon::colorSelection_medium),
|
toolbarIcon(Theme::colorSelection_medium),
|
||||||
{},
|
|
||||||
this,
|
this,
|
||||||
backgroundColorActionsTrigger);
|
backgroundColorActionsTrigger);
|
||||||
|
|
||||||
|
@@ -70,6 +70,10 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view)
|
|||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
QByteArray sheet = Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css");
|
||||||
|
sheet += Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css");
|
||||||
|
setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(sheet)));
|
||||||
|
|
||||||
Core::Context context(Constants::C_QMLEDITOR3D);
|
Core::Context context(Constants::C_QMLEDITOR3D);
|
||||||
m_context = new Core::IContext(this);
|
m_context = new Core::IContext(this);
|
||||||
m_context->setContext(context);
|
m_context->setContext(context);
|
||||||
|
Reference in New Issue
Block a user