Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Change tray highlight to trigger on any notification and reset on win…
Browse files Browse the repository at this point in the history
…dow focus

Closes #33
  • Loading branch information
chylex committed Jul 27, 2016
1 parent 5d3721a commit 41a45a1
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 32 deletions.
12 changes: 10 additions & 2 deletions Configuration/UserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sealed class UserConfig{
Binder = new SerializationCompatibilityHandler()
};

private const int CurrentFileVersion = 3;
private const int CurrentFileVersion = 4;

// START OF CONFIGURATION

Expand All @@ -33,9 +33,11 @@ sealed class UserConfig{
public int NotificationDisplay { get; set; }
public bool NotificationLegacyLoad { get; set; }

public bool ExpandLinksOnHover { get; set; }
public bool EnableTrayHighlight { get; set; }

public bool EnableUpdateCheck { get; set; }
public string DismissedUpdate { get; set; }
public bool ExpandLinksOnHover { get; set; }

public PluginConfig Plugins { get; private set; }
public WindowState PluginsWindow { get; set; }
Expand Down Expand Up @@ -104,6 +106,7 @@ sealed class UserConfig{
NotificationEdgeDistance = 8;
EnableUpdateCheck = true;
ExpandLinksOnHover = true;
EnableTrayHighlight = true;
Plugins = new PluginConfig();
PluginsWindow = new WindowState();
}
Expand Down Expand Up @@ -132,6 +135,11 @@ sealed class UserConfig{
++fileVersion;
}

if (fileVersion == 3){
EnableTrayHighlight = true;
++fileVersion;
}

// update the version
fileVersion = CurrentFileVersion;
Save();
Expand Down
1 change: 1 addition & 0 deletions Core/FormBrowser.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions Core/FormBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sealed partial class FormBrowser : Form{
}

public FormNotification CreateNotificationForm(bool autoHide){
return new FormNotification(this,plugins,trayIcon,autoHide);
return new FormNotification(this,plugins,autoHide);
}

// window setup
Expand Down Expand Up @@ -117,6 +117,12 @@ sealed partial class FormBrowser : Form{
}
}

private void FormBrowser_Activated(object sender, EventArgs e){
if (!isLoaded)return;

trayIcon.HasNotifications = false;
}

private void FormBrowser_Resize(object sender, EventArgs e){
if (!isLoaded)return;

Expand Down Expand Up @@ -234,6 +240,10 @@ sealed partial class FormBrowser : Form{
Config.Save();
updates.Check(false);
}
if (!Config.EnableTrayHighlight){
trayIcon.HasNotifications = false;
}
};

ShowChildForm(currentFormSettings);
Expand Down Expand Up @@ -262,8 +272,10 @@ sealed partial class FormBrowser : Form{
}
}

public void OnTweetSound(){

public void OnTweetNotification(){
if (Config.EnableTrayHighlight && !ContainsFocus){
trayIcon.HasNotifications = true;
}
}

public void DisplayTooltip(string text){
Expand Down
13 changes: 3 additions & 10 deletions Core/FormNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ sealed partial class FormNotification : Form{

private readonly Form owner;
private readonly PluginManager plugins;
private readonly TrayIcon trayIcon;
private readonly ChromiumWebBrowser browser;

private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
Expand Down Expand Up @@ -81,14 +80,13 @@ sealed partial class FormNotification : Form{
}
}

public FormNotification(FormBrowser owner, PluginManager pluginManager, TrayIcon trayIcon, bool autoHide){
public FormNotification(FormBrowser owner, PluginManager pluginManager, bool autoHide){
InitializeComponent();

Text = Program.BrandName;

this.owner = owner;
this.plugins = pluginManager;
this.trayIcon = trayIcon;
this.autoHide = autoHide;

owner.FormClosed += (sender, args) => Close();
Expand Down Expand Up @@ -156,12 +154,8 @@ sealed partial class FormNotification : Form{
if (Program.UserConfig.MuteNotifications){
HideNotification(true);
}
else{
if (tweetQueue.Count > 0){
LoadNextNotification();
}

trayIcon.HasNotifications = false;
else if (tweetQueue.Count > 0){
LoadNextNotification();
}
}

Expand Down Expand Up @@ -213,7 +207,6 @@ sealed partial class FormNotification : Form{
public void ShowNotification(TweetNotification notification){
if (Program.UserConfig.MuteNotifications){
tweetQueue.Enqueue(notification);
trayIcon.HasNotifications = true;
}
else{
tweetQueue.Enqueue(notification);
Expand Down
3 changes: 2 additions & 1 deletion Core/Handling/TweetDeckBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ class TweetDeckBridge{

public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){
notification.InvokeSafe(() => {
form.OnTweetNotification();
notification.ShowNotification(new TweetNotification(tweetHtml,tweetUrl,tweetCharacters));
});
}

public void OnTweetSound(){
form.InvokeSafe(form.OnTweetSound);
form.InvokeSafe(form.OnTweetNotification);
}

public void OnNotificationReady(){
Expand Down
79 changes: 63 additions & 16 deletions Core/Other/Settings/TabSettingsGeneral.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Core/Other/Settings/TabSettingsGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ partial class TabSettingsGeneral : BaseTabSettings{
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior,0),comboBoxTrayType.Items.Count-1);

checkExpandLinks.Checked = Program.UserConfig.ExpandLinksOnHover;
checkTrayHighlight.Checked = Program.UserConfig.EnableTrayHighlight;
}

private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
Expand All @@ -26,5 +27,11 @@ partial class TabSettingsGeneral : BaseTabSettings{

Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
}

private void checkTrayHighlight_CheckedChanged(object sender, EventArgs e){
if (!Ready)return;

Config.EnableTrayHighlight = checkTrayHighlight.Checked;
}
}
}

0 comments on commit 41a45a1

Please sign in to comment.