diff --git a/src/frmmain.cpp b/src/frmmain.cpp index d331482e..41a41e62 100644 --- a/src/frmmain.cpp +++ b/src/frmmain.cpp @@ -1810,6 +1810,37 @@ void frmMain::applySettings() { m_codeDrawer->setColorEnd(m_settings.colors("ToolpathEnd")); m_codeDrawer->update(); + // Adapt visualizer buttons colors + const int LIGHTBOUND = 127; + const int NORMALSHIFT = 40; + const int HIGHLIGHTSHIFT = 80; + + QColor base = m_settings.colors("VisualizerBackground"); + bool light = base.value() > LIGHTBOUND; + QColor normal, highlight; + + normal.setHsv(base.hue(), base.saturation(), base.value() + (light ? -NORMALSHIFT : NORMALSHIFT)); + highlight.setHsv(base.hue(), base.saturation(), base.value() + (light ? -HIGHLIGHTSHIFT : HIGHLIGHTSHIFT)); + + ui->glwVisualizer->setStyleSheet(QString("QToolButton {border: 1px solid %1; \ + background-color: %3} QToolButton:hover {border: 1px solid %2;}") + .arg(normal.name()).arg(highlight.name()) + .arg(base.name())); + + ui->cmdFit->setIcon(QIcon(":/images/fit_1.png")); + ui->cmdIsometric->setIcon(QIcon(":/images/cube.png")); + ui->cmdFront->setIcon(QIcon(":/images/cubeFront.png")); + ui->cmdLeft->setIcon(QIcon(":/images/cubeLeft.png")); + ui->cmdTop->setIcon(QIcon(":/images/cubeTop.png")); + + if (!light) { + Util::invertButtonIconColors(ui->cmdFit); + Util::invertButtonIconColors(ui->cmdIsometric); + Util::invertButtonIconColors(ui->cmdFront); + Util::invertButtonIconColors(ui->cmdLeft); + Util::invertButtonIconColors(ui->cmdTop); + } + ui->cboCommand->setMinimumHeight(ui->cboCommand->height()); ui->cmdClearConsole->setFixedHeight(ui->cboCommand->height()); ui->cmdCommandSend->setFixedHeight(ui->cboCommand->height()); diff --git a/src/frmmain.ui b/src/frmmain.ui index 38b25781..2b95755e 100644 --- a/src/frmmain.ui +++ b/src/frmmain.ui @@ -159,25 +159,6 @@ QSlider::handle:horizontal:hover { Isometric view - - QToolButton { /* all types of tool button */ - color: lightgray; - border: 1px solid lightgray; - border-radius: 0px; - background-color: white; -} - -QToolButton:hover { /* all types of tool button */ - border: 1px solid gray; - color: gray; -} - -QToolButton:pressed { -} - -QToolButton:checked { /* all types of tool button */ -} - @@ -204,25 +185,6 @@ QToolButton:checked { /* all types of tool button */ Top view - - QToolButton { /* all types of tool button */ - color: lightgray; - border: 1px solid lightgray; - border-radius: 0px; - background-color: white; -} - -QToolButton:hover { /* all types of tool button */ - border: 1px solid gray; - color: gray; -} - -QToolButton:pressed { -} - -QToolButton:checked { /* all types of tool button */ -} - @@ -249,25 +211,6 @@ QToolButton:checked { /* all types of tool button */ Front view - - QToolButton { /* all types of tool button */ - color: lightgray; - border: 1px solid lightgray; - border-radius: 0px; - background-color: white; -} - -QToolButton:hover { /* all types of tool button */ - border: 1px solid gray; - color: gray; -} - -QToolButton:pressed { -} - -QToolButton:checked { /* all types of tool button */ -} - @@ -294,25 +237,6 @@ QToolButton:checked { /* all types of tool button */ Left view - - QToolButton { /* all types of tool button */ - color: lightgray; - border: 1px solid lightgray; - border-radius: 0px; - background-color: white; -} - -QToolButton:hover { /* all types of tool button */ - border: 1px solid gray; - color: gray; -} - -QToolButton:pressed { -} - -QToolButton:checked { /* all types of tool button */ -} - @@ -339,25 +263,6 @@ QToolButton:checked { /* all types of tool button */ Fit - - QToolButton { /* all types of tool button */ - color: lightgray; - border: 1px solid lightgray; - border-radius: 0px; - background-color: white; -} - -QToolButton:hover { /* all types of tool button */ - border: 1px solid gray; - color: gray; -} - -QToolButton:pressed { -} - -QToolButton:checked { /* all types of tool button */ -} - diff --git a/src/utils/util.h b/src/utils/util.h index e6948084..45886547 100644 --- a/src/utils/util.h +++ b/src/utils/util.h @@ -5,6 +5,9 @@ #define UTIL #include +#include +#include +#include #include #include #include @@ -40,6 +43,19 @@ class Util QTimer::singleShot(ms, &loop, SLOT(quit())); loop.exec(); } + + static QIcon invertIconColors(QIcon icon) + { + QImage img = icon.pixmap(icon.actualSize(QSize(64, 64))).toImage(); + img.invertPixels(); + + return QIcon(QPixmap::fromImage(img)); + } + + static void invertButtonIconColors(QAbstractButton *button) + { + button->setIcon(invertIconColors(button->icon())); + } }; #endif // UTIL