Skip to content

Commit

Permalink
Change default icon color in Windows and allow toggling
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandoislas committed May 27, 2016
1 parent 6f2ed28 commit e2ce3e4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
46 changes: 37 additions & 9 deletions Source/IconMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,7 @@ IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(
activePluginList.recreateFromXml(*savedPluginListActive);
loadActivePlugins();
activePluginList.addChangeListener(this);
// Set menu icon
#if JUCE_MAC
if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1)
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize));
else
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
#else
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
#endif
setIcon();
setIconTooltip(JUCEApplication::getInstance()->getApplicationName());
};

Expand All @@ -100,6 +92,33 @@ IconMenu::~IconMenu()
savePluginStates();
}

void IconMenu::setIcon()
{
// Set menu icon
#if JUCE_MAC
if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1)
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize));
else
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
#else
String defaultColor;
#if JUCE_WINDOWS
defaultColor = "white";
#elif JUCE_LINUX
defaultColor = "black";
#endif
if (!getAppProperties().getUserSettings()->containsKey("icon"))
getAppProperties().getUserSettings()->setValue("icon", defaultColor);
String color = getAppProperties().getUserSettings()->getValue("icon");
Image icon;
if (color.equalsIgnoreCase("white"))
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize);
else if (color.equalsIgnoreCase("black"))
icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize);
setIconImage(icon);
#endif
}

void IconMenu::loadActivePlugins()
{
const int INPUT = 1000000;
Expand Down Expand Up @@ -253,6 +272,9 @@ void IconMenu::timerCallback()
menu.addItem(1, "Quit");
menu.addSeparator();
menu.addItem(2, "Delete Plugin States");
#if !JUCE_MAC
menu.addItem(3, "Invert Icon Color");
#endif
}
#if JUCE_MAC || JUCE_LINUX
menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), ModalCallbackFunction::forComponent(menuInvocationCallback, this));
Expand Down Expand Up @@ -296,6 +318,12 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
im->deletePluginStates();
return im->loadActivePlugins();
}
if (id == 3)
{
String color = getAppProperties().getUserSettings()->getValue("icon");
getAppProperties().getUserSettings()->setValue("icon", color.equalsIgnoreCase("black") ? "white" : "black");
return im->setIcon();
}
}
#if JUCE_MAC
// Click elsewhere
Expand Down
1 change: 1 addition & 0 deletions Source/IconMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis
PluginDescription getNextPluginOlderThanTime(int &time);
void removePluginsLackingInputOutput();
std::vector<PluginDescription> getTimeSortedList();
void setIcon();

AudioDeviceManager deviceManager;
AudioPluginFormatManager formatManager;
Expand Down

0 comments on commit e2ce3e4

Please sign in to comment.