{"action":"created","issue":{"url":"https://api.github.com/repos/luebking/virtuality/issues/31","labels_url":"https://api.github.com/repos/luebking/virtuality/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/luebking/virtuality/issues/31/comments","events_url":"https://api.github.com/repos/luebking/virtuality/issues/31/events","html_url":"https://github.com/luebking/virtuality/issues/31","id":121878219,"number":31,"title":"Invert icons in toolbar if toolbar is inverted","user":{"login":"beojan","id":3727925,"avatar_url":"https://avatars.githubusercontent.com/u/3727925?v=3","gravatar_id":"","url":"https://api.github.com/users/beojan","html_url":"https://github.com/beojan","followers_url":"https://api.github.com/users/beojan/followers","following_url":"https://api.github.com/users/beojan/following{/other_user}","gists_url":"https://api.github.com/users/beojan/gists{/gist_id}","starred_url":"https://api.github.com/users/beojan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beojan/subscriptions","organizations_url":"https://api.github.com/users/beojan/orgs","repos_url":"https://api.github.com/users/beojan/repos","events_url":"https://api.github.com/users/beojan/events{/privacy}","received_events_url":"https://api.github.com/users/beojan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-12T20:30:39Z","updated_at":"2015-12-13T21:15:38Z","closed_at":null,"body":"With KF5, icon themes are using monochrome toolbar icons. Because these icons are also used in the main window in some applications (e.g, kwrite's find bar), when the toolbar is inverted, neither the light background version nor the dark background version of the themes are satisfactory.\r\n\r\nCan you invert the icons if the toolbar is inverted, so the light version can be used?"},"comment":{"url":"https://api.github.com/repos/luebking/virtuality/issues/comments/164299113","html_url":"https://github.com/luebking/virtuality/issues/31#issuecomment-164299113","issue_url":"https://api.github.com/repos/luebking/virtuality/issues/31","id":164299113,"user":{"login":"luebking","id":5768413,"avatar_url":"https://avatars.githubusercontent.com/u/5768413?v=3","gravatar_id":"","url":"https://api.github.com/users/luebking","html_url":"https://github.com/luebking","followers_url":"https://api.github.com/users/luebking/followers","following_url":"https://api.github.com/users/luebking/following{/other_user}","gists_url":"https://api.github.com/users/luebking/gists{/gist_id}","starred_url":"https://api.github.com/users/luebking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luebking/subscriptions","organizations_url":"https://api.github.com/users/luebking/orgs","repos_url":"https://api.github.com/users/luebking/repos","events_url":"https://api.github.com/users/luebking/events{/privacy}","received_events_url":"https://api.github.com/users/luebking/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T21:15:37Z","updated_at":"2015-12-13T21:15:37Z","body":"Ah, ok - I figured it would be some icon theme.\r\n\r\nAs mentione, such as a perfect monochromatizing does not exist, the algorithm I implemented favors bright colors (for tinting, dark colors rather turn translucent - the thing was done for icon highlighting)\r\n\r\nThe icon theme uses fully back icons with a 50% opacity where this fails miserably - the icons turn entirely transparent.\r\n\r\n```\r\ndiff --git a/FX.cpp b/FX.cpp\r\nindex 95eed4b..118f727 100644\r\n--- a/FX.cpp\r\n+++ b/FX.cpp\r\n@@ -109,16 +109,40 @@ FX::tintedIcon(QPixmap &pix, int step, int maxSteps, QColor tint)\r\n         int size = img.width() * img.height();\r\n         QRgb *pixel = (QRgb*)img.bits();\r\n         const int r = tint.red(), g = tint.green(), b = tint.blue();\r\n+        int minV = 255, maxV = 0;\r\n+        bool mono = true;\r\n         for (int i = 0; i < size; ++i) {\r\n-            if (int a = qAlpha(*pixel)) {\r\n+            if (qAlpha(*pixel) > 24) {\r\n                 const int v = qGray(*pixel);\r\n-                // stretch alpha\r\n-                a = 255 - v*a/255;\r\n-                a = 255 - a*a/255;\r\n-                *pixel = qRgba(r, g, b, a);\r\n+                maxV = qMax(v, maxV);\r\n+                minV = qMin(v, minV);\r\n+                if (maxV - minV > 10) {\r\n+                    mono = false;\r\n+                    break;\r\n+                }\r\n             }\r\n             ++pixel;\r\n         }\r\n+        pixel = (QRgb*)img.bits();\r\n+        if (mono) {\r\n+            for (int i = 0; i < size; ++i) {\r\n+                if (int a = qAlpha(*pixel)) {\r\n+                    *pixel = qRgba(r, g, b, qAlpha(*pixel));\r\n+                }\r\n+                ++pixel;\r\n+            }\r\n+        } else {\r\n+            for (int i = 0; i < size; ++i) {\r\n+                if (int a = qAlpha(*pixel)) {\r\n+                    const int v = qGray(*pixel);\r\n+                    // stretch alpha\r\n+                    a = 255 - v*a/255;\r\n+                    a = 255 - a*a/255;\r\n+                    *pixel = qRgba(r, g, b, a);\r\n+                }\r\n+                ++pixel;\r\n+            }\r\n+        }\r\n         tintedIcon[1] = QPixmap::fromImage(img);\r\n         lastIconPix[1] = pix.cacheKey();\r\n     }\r\ndiff --git a/toolbars.cpp b/toolbars.cpp\r\nindex a1a75da..7b0f6b4 100644\r\n--- a/toolbars.cpp\r\n+++ b/toolbars.cpp\r\n@@ -169,6 +169,7 @@ Style::drawToolButtonLabel(const QStyleOption *option, QPainter *painter, const\r\n         const int style = config.btn.tool.disabledStyle;\r\n //         const QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off;\r\n         pm = toolbutton->icon.pixmap(RECT.size().boundedTo(pmSize), isEnabled || style ? QIcon::Normal : QIcon::Disabled, QIcon::Off);\r\n+        pm = FX::tintedIcon(pm, 1, 1, text);\r\n #if 0   // this is -in a way- the way it should be done..., but KIconLoader gives a shit on this or anything else\r\n         if (!isEnabled)\r\n             pm = generatedIconPixmap(QIcon::Disabled, pm, toolbutton);"}}