Skip to content

Commit

Permalink
Added repository item to about menu
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleruss committed Dec 11, 2017
1 parent 13cef02 commit 7f2843e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/main/java/com/kyleruss/imgsnippet/gui/SnippetTray.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

public class SnippetTray implements ActionListener
Expand All @@ -31,7 +31,8 @@ public class SnippetTray implements ActionListener
private SystemTray tray;
private TrayIcon trayIcon;
private PopupMenu trayMenu, aboutMenu;
private MenuItem exitItem, settingsItem, browseItem, screenshotItem, drawCaptureItem, authorItem, licenseItem;
private MenuItem exitItem, settingsItem, browseItem, screenshotItem;
private MenuItem drawCaptureItem, authorItem, licenseItem, repositoryItem;

public SnippetTray()
{
Expand Down Expand Up @@ -74,9 +75,11 @@ private void initMenuItems()
drawCaptureItem = new MenuItem("Snippet");
authorItem = new MenuItem("Author");
licenseItem = new MenuItem("License");
repositoryItem = new MenuItem("Repository");

aboutMenu.add(authorItem);
aboutMenu.add(licenseItem);
aboutMenu.add(repositoryItem);

trayMenu.add(aboutMenu);
trayMenu.addSeparator();
Expand All @@ -94,6 +97,7 @@ private void initMenuItems()
screenshotItem.addActionListener(this);
authorItem.addActionListener(this);
licenseItem.addActionListener(this);
repositoryItem.addActionListener(this);
}
}

Expand All @@ -103,6 +107,21 @@ public void showAuthorDialog()
JOptionPane.showMessageDialog(null, authorText);
}

public void showRepository()
{
try
{
String repositoryURL = "https://github.com/kyleruss/img-snippet";
Desktop.getDesktop().browse(new URL(repositoryURL).toURI());
}

catch(Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Could not open the repository");
}
}

public void showLicense()
{
try
Expand Down Expand Up @@ -141,6 +160,9 @@ else if(src == licenseItem)

else if(src == authorItem)
showAuthorDialog();

else if(src == repositoryItem)
showRepository();
}

public SystemTray getTray()
Expand Down

0 comments on commit 7f2843e

Please sign in to comment.