Skip to content

Commit

Permalink
Merge pull request #1958 from alcomposer/git-hash-welcome
Browse files Browse the repository at this point in the history
Add click-to-copy git hash display on welcome screen (only for nightl…
  • Loading branch information
timothyschoen authored Nov 25, 2024
2 parents 2787bd8 + 094030c commit 1fcf886
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Source/Statusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,13 @@ Statusbar::Statusbar(PluginProcessor* processor, PluginEditor* e)
snapEnableButton.setButtonText(Icons::Magnet);
snapSettingsButton.setButtonText(Icons::ThinDown);

if (String(PLUGDATA_GIT_HASH).isNotEmpty()) {
plugdataString.setText(String("Nightly build: ") + String(PLUGDATA_GIT_HASH), dontSendNotification);
addAndMakeVisible(plugdataString);
plugdataString.setTooltip("Click to copy hash to clipboard");
plugdataString.addMouseListener(this, false);
}

helpButton.setButtonText(Icons::Help);
helpButton.onClick = []() {
URL("https://plugdata.org/documentation.html").launchInDefaultBrowser();
Expand Down Expand Up @@ -1334,6 +1341,12 @@ void Statusbar::paint(Graphics& g)
g.drawLine(secondSeparatorPosition, 6.0f, secondSeparatorPosition, getHeight() - 6.0f);
}

void Statusbar::mouseDown(const MouseEvent& e)
{
if (e.originalComponent == &plugdataString)
SystemClipboard::copyTextToClipboard(String(PLUGDATA_GIT_HASH));
}

void Statusbar::resized()
{
int pos = 0;
Expand Down Expand Up @@ -1375,6 +1388,9 @@ void Statusbar::resized()

auto lastButtonPosition = position(getHeight(), true);
helpButton.setBounds(4, 0, 34, getHeight());
if (plugdataString.isVisible())
plugdataString.setBounds(helpButton.getRight() + 4, 0, 200, getHeight());

sidebarExpandButton.setBounds(lastButtonPosition, 0, getHeight(), getHeight());
audioSettingsButton.setBounds(lastButtonPosition, 0, getHeight(), getHeight());
powerButton.setBounds(position(getHeight() - 6, true), 0, getHeight(), getHeight());
Expand Down Expand Up @@ -1458,6 +1474,7 @@ void Statusbar::setWelcomePanelShown(bool isShowing)
audioSettingsButton.setVisible(!isShowing);
sidebarExpandButton.setVisible(isShowing);
helpButton.setVisible(isShowing);
plugdataString.setVisible(isShowing);
if(!isShowing) sidebarExpandButton.setToggleState(false, dontSendNotification);
}

Expand Down
3 changes: 3 additions & 0 deletions Source/Statusbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class Statusbar : public Component
void setWelcomePanelShown(bool isShowing);

private:
void mouseDown(const MouseEvent& e) override;

void handleAsyncUpdate() override;

std::unique_ptr<LevelMeter> levelMeter;
Expand All @@ -125,6 +127,7 @@ class Statusbar : public Component
SmallIconButton snapEnableButton, snapSettingsButton;
SmallIconButton powerButton, audioSettingsButton;
SmallIconButton sidebarExpandButton, helpButton;
Label plugdataString;
std::unique_ptr<CommandButton> commandInputButton;

SafePointer<CallOutBox> commandInputCallout;
Expand Down

0 comments on commit 1fcf886

Please sign in to comment.