1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-01 17:34:10 +02:00

Add an option to display column name in the notification title

This commit is contained in:
chylex 2017-04-06 18:11:52 +02:00
parent ba8e29a9f8
commit aca06ee805
10 changed files with 87 additions and 23 deletions

View File

@ -19,6 +19,7 @@ sealed class UserConfig{
// START OF CONFIGURATION // START OF CONFIGURATION
public WindowState BrowserWindow { get; set; } public WindowState BrowserWindow { get; set; }
public bool DisplayNotificationColumn { get; set; }
public bool DisplayNotificationTimer { get; set; } public bool DisplayNotificationTimer { get; set; }
public bool NotificationTimerCountDown { get; set; } public bool NotificationTimerCountDown { get; set; }
public bool NotificationNonIntrusiveMode { get; set; } public bool NotificationNonIntrusiveMode { get; set; }

View File

@ -57,10 +57,10 @@ public void OpenContextMenu(){
form.InvokeAsyncSafe(form.OpenContextMenu); form.InvokeAsyncSafe(form.OpenContextMenu);
} }
public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){ public void OnTweetPopup(string columnName, string tweetHtml, string tweetUrl, int tweetCharacters){
notification.InvokeAsyncSafe(() => { notification.InvokeAsyncSafe(() => {
form.OnTweetNotification(); form.OnTweetNotification();
notification.ShowNotification(new TweetNotification(tweetHtml, tweetUrl, tweetCharacters)); notification.ShowNotification(new TweetNotification(columnName, tweetHtml, tweetUrl, tweetCharacters));
}); });
} }

View File

@ -71,6 +71,7 @@ public bool IsNotificationVisible{
protected readonly Form owner; protected readonly Form owner;
protected readonly ChromiumWebBrowser browser; protected readonly ChromiumWebBrowser browser;
private string currentColumn;
private int pauseCounter; private int pauseCounter;
public bool IsPaused{ public bool IsPaused{
@ -151,6 +152,7 @@ public virtual void HideNotification(bool loadBlank){
} }
Location = ControlExtensions.InvisibleLocation; Location = ControlExtensions.InvisibleLocation;
currentColumn = null;
} }
public virtual void FinishCurrentNotification(){} public virtual void FinishCurrentNotification(){}
@ -175,6 +177,7 @@ protected virtual string GetTweetHTML(TweetNotification tweet){
protected virtual void LoadTweet(TweetNotification tweet){ protected virtual void LoadTweet(TweetNotification tweet){
CurrentUrl = tweet.Url; CurrentUrl = tweet.Url;
CurrentQuotedTweetUrl = string.Empty; // load from JS CurrentQuotedTweetUrl = string.Empty; // load from JS
currentColumn = tweet.Column;
browser.LoadHtml(GetTweetHTML(tweet), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks); browser.LoadHtml(GetTweetHTML(tweet), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
} }
@ -196,7 +199,7 @@ protected virtual void OnNotificationReady(){
} }
protected virtual void UpdateTitle(){ protected virtual void UpdateTitle(){
Text = Program.BrandName; Text = string.IsNullOrEmpty(currentColumn) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+currentColumn;
} }
public void DisplayTooltip(string text){ public void DisplayTooltip(string text){

View File

@ -165,6 +165,8 @@ public void ShowNotificationForSettings(bool reset){
else{ else{
PrepareAndDisplayWindow(); PrepareAndDisplayWindow();
} }
UpdateTitle();
} }
public override void HideNotification(bool loadBlank){ public override void HideNotification(bool loadBlank){

View File

@ -117,7 +117,11 @@ private void LoadNextNotification(){
} }
protected override void UpdateTitle(){ protected override void UpdateTitle(){
Text = tweetQueue.Count > 0 ? Program.BrandName+" ("+tweetQueue.Count+" more left)" : Program.BrandName; base.UpdateTitle();
if (tweetQueue.Count > 0){
Text = Text+" ("+tweetQueue.Count+" more left)";
}
} }
protected override void OnNotificationReady(){ protected override void OnNotificationReady(){

View File

@ -44,7 +44,7 @@ public void Trigger(string html, int width, int height){
CanMoveWindow = () => false CanMoveWindow = () => false
}; };
screenshot.LoadNotificationForScreenshot(new TweetNotification(html, string.Empty, 0), width, height); screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, string.Empty, 0), width, height);
screenshot.Show(); screenshot.Show();
timeout.Start(); timeout.Start();
} }

View File

@ -35,7 +35,7 @@ public static TweetNotification ExampleTweet{
#endif #endif
} }
return new TweetNotification(ExampleTweetHTML, "", 95, true); return new TweetNotification("Home", ExampleTweetHTML, "", 95, true);
} }
} }
@ -51,20 +51,28 @@ public enum Position{
TopLeft, TopRight, BottomLeft, BottomRight, Custom TopLeft, TopRight, BottomLeft, BottomRight, Custom
} }
public string Column{
get{
return column;
}
}
public string Url{ public string Url{
get{ get{
return url; return url;
} }
} }
private readonly string column;
private readonly string html; private readonly string html;
private readonly string url; private readonly string url;
private readonly int characters; private readonly int characters;
private readonly bool isExample; private readonly bool isExample;
public TweetNotification(string html, string url, int characters) : this(html, url, characters, false){} public TweetNotification(string column, string html, string url, int characters) : this(column, html, url, characters, false){}
private TweetNotification(string html, string url, int characters, bool isExample){ private TweetNotification(string column, string html, string url, int characters, bool isExample){
this.column = column;
this.html = html; this.html = html;
this.url = url; this.url = url;
this.characters = characters; this.characters = characters;

View File

@ -43,6 +43,7 @@ private void InitializeComponent() {
this.labelDurationValue = new System.Windows.Forms.Label(); this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar(); this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.groupUserInterface = new System.Windows.Forms.GroupBox(); this.groupUserInterface = new System.Windows.Forms.GroupBox();
this.checkColumnName = new System.Windows.Forms.CheckBox();
this.labelIdlePause = new System.Windows.Forms.Label(); this.labelIdlePause = new System.Windows.Forms.Label();
this.comboBoxIdlePause = new System.Windows.Forms.ComboBox(); this.comboBoxIdlePause = new System.Windows.Forms.ComboBox();
this.checkNonIntrusive = new System.Windows.Forms.CheckBox(); this.checkNonIntrusive = new System.Windows.Forms.CheckBox();
@ -71,7 +72,7 @@ private void InitializeComponent() {
this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance); this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance);
this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9); this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9);
this.groupNotificationLocation.Name = "groupNotificationLocation"; this.groupNotificationLocation.Name = "groupNotificationLocation";
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 256); this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264);
this.groupNotificationLocation.TabIndex = 2; this.groupNotificationLocation.TabIndex = 2;
this.groupNotificationLocation.TabStop = false; this.groupNotificationLocation.TabStop = false;
this.groupNotificationLocation.Text = "Location"; this.groupNotificationLocation.Text = "Location";
@ -199,7 +200,7 @@ private void InitializeComponent() {
this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons); this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons);
this.groupNotificationDuration.Controls.Add(this.labelDurationValue); this.groupNotificationDuration.Controls.Add(this.labelDurationValue);
this.groupNotificationDuration.Controls.Add(this.trackBarDuration); this.groupNotificationDuration.Controls.Add(this.trackBarDuration);
this.groupNotificationDuration.Location = new System.Drawing.Point(9, 160); this.groupNotificationDuration.Location = new System.Drawing.Point(9, 184);
this.groupNotificationDuration.Name = "groupNotificationDuration"; this.groupNotificationDuration.Name = "groupNotificationDuration";
this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89); this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89);
this.groupNotificationDuration.TabIndex = 1; this.groupNotificationDuration.TabIndex = 1;
@ -297,6 +298,7 @@ private void InitializeComponent() {
// //
// groupUserInterface // groupUserInterface
// //
this.groupUserInterface.Controls.Add(this.checkColumnName);
this.groupUserInterface.Controls.Add(this.labelIdlePause); this.groupUserInterface.Controls.Add(this.labelIdlePause);
this.groupUserInterface.Controls.Add(this.comboBoxIdlePause); this.groupUserInterface.Controls.Add(this.comboBoxIdlePause);
this.groupUserInterface.Controls.Add(this.checkNonIntrusive); this.groupUserInterface.Controls.Add(this.checkNonIntrusive);
@ -304,15 +306,29 @@ private void InitializeComponent() {
this.groupUserInterface.Controls.Add(this.checkNotificationTimer); this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
this.groupUserInterface.Location = new System.Drawing.Point(9, 9); this.groupUserInterface.Location = new System.Drawing.Point(9, 9);
this.groupUserInterface.Name = "groupUserInterface"; this.groupUserInterface.Name = "groupUserInterface";
this.groupUserInterface.Size = new System.Drawing.Size(183, 145); this.groupUserInterface.Size = new System.Drawing.Size(183, 169);
this.groupUserInterface.TabIndex = 0; this.groupUserInterface.TabIndex = 0;
this.groupUserInterface.TabStop = false; this.groupUserInterface.TabStop = false;
this.groupUserInterface.Text = "General"; this.groupUserInterface.Text = "General";
// //
// checkColumnName
//
this.checkColumnName.AutoSize = true;
this.checkColumnName.Location = new System.Drawing.Point(9, 21);
this.checkColumnName.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
this.checkColumnName.Name = "checkColumnName";
this.checkColumnName.Size = new System.Drawing.Size(129, 17);
this.checkColumnName.TabIndex = 5;
this.checkColumnName.Text = "Display Column Name";
this.toolTip.SetToolTip(this.checkColumnName, "Shows column name each notification originated\r\nfrom in the notification window t" +
"itle.");
this.checkColumnName.UseVisualStyleBackColor = true;
//
// labelIdlePause // labelIdlePause
// //
this.labelIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelIdlePause.AutoSize = true; this.labelIdlePause.AutoSize = true;
this.labelIdlePause.Location = new System.Drawing.Point(3, 99); this.labelIdlePause.Location = new System.Drawing.Point(3, 123);
this.labelIdlePause.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelIdlePause.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelIdlePause.Name = "labelIdlePause"; this.labelIdlePause.Name = "labelIdlePause";
this.labelIdlePause.Size = new System.Drawing.Size(89, 13); this.labelIdlePause.Size = new System.Drawing.Size(89, 13);
@ -321,11 +337,11 @@ private void InitializeComponent() {
// //
// comboBoxIdlePause // comboBoxIdlePause
// //
this.comboBoxIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.comboBoxIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxIdlePause.FormattingEnabled = true; this.comboBoxIdlePause.FormattingEnabled = true;
this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 115); this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 139);
this.comboBoxIdlePause.Name = "comboBoxIdlePause"; this.comboBoxIdlePause.Name = "comboBoxIdlePause";
this.comboBoxIdlePause.Size = new System.Drawing.Size(171, 21); this.comboBoxIdlePause.Size = new System.Drawing.Size(171, 21);
this.comboBoxIdlePause.TabIndex = 4; this.comboBoxIdlePause.TabIndex = 4;
@ -334,7 +350,7 @@ private void InitializeComponent() {
// checkNonIntrusive // checkNonIntrusive
// //
this.checkNonIntrusive.AutoSize = true; this.checkNonIntrusive.AutoSize = true;
this.checkNonIntrusive.Location = new System.Drawing.Point(9, 67); this.checkNonIntrusive.Location = new System.Drawing.Point(9, 90);
this.checkNonIntrusive.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); this.checkNonIntrusive.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkNonIntrusive.Name = "checkNonIntrusive"; this.checkNonIntrusive.Name = "checkNonIntrusive";
this.checkNonIntrusive.Size = new System.Drawing.Size(128, 17); this.checkNonIntrusive.Size = new System.Drawing.Size(128, 17);
@ -347,7 +363,7 @@ private void InitializeComponent() {
// checkTimerCountDown // checkTimerCountDown
// //
this.checkTimerCountDown.AutoSize = true; this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Location = new System.Drawing.Point(9, 44); this.checkTimerCountDown.Location = new System.Drawing.Point(9, 67);
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkTimerCountDown.Name = "checkTimerCountDown"; this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17); this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17);
@ -359,8 +375,8 @@ private void InitializeComponent() {
// checkNotificationTimer // checkNotificationTimer
// //
this.checkNotificationTimer.AutoSize = true; this.checkNotificationTimer.AutoSize = true;
this.checkNotificationTimer.Location = new System.Drawing.Point(9, 21); this.checkNotificationTimer.Location = new System.Drawing.Point(9, 44);
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3); this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.checkNotificationTimer.Name = "checkNotificationTimer"; this.checkNotificationTimer.Name = "checkNotificationTimer";
this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17); this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17);
this.checkNotificationTimer.TabIndex = 0; this.checkNotificationTimer.TabIndex = 0;
@ -418,5 +434,6 @@ private void InitializeComponent() {
private System.Windows.Forms.CheckBox checkNonIntrusive; private System.Windows.Forms.CheckBox checkNonIntrusive;
private System.Windows.Forms.Label labelIdlePause; private System.Windows.Forms.Label labelIdlePause;
private System.Windows.Forms.ComboBox comboBoxIdlePause; private System.Windows.Forms.ComboBox comboBoxIdlePause;
private System.Windows.Forms.CheckBox checkColumnName;
} }
} }

View File

@ -54,7 +54,8 @@ public TabSettingsNotifications(FormNotificationMain notification){
} }
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay); comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay);
checkColumnName.Checked = Config.DisplayNotificationColumn;
checkNotificationTimer.Checked = Config.DisplayNotificationTimer; checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
checkTimerCountDown.Enabled = checkNotificationTimer.Checked; checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
checkTimerCountDown.Checked = Config.NotificationTimerCountDown; checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
@ -78,6 +79,7 @@ public override void OnReady(){
btnDurationMedium.Click += btnDurationMedium_Click; btnDurationMedium.Click += btnDurationMedium_Click;
btnDurationLong.Click += btnDurationLong_Click; btnDurationLong.Click += btnDurationLong_Click;
checkColumnName.CheckedChanged += checkColumnName_CheckedChanged;
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged; checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged; checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged; checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
@ -138,6 +140,11 @@ private void btnDurationLong_Click(object sender, EventArgs e){
trackBarDuration.Value = 35; trackBarDuration.Value = 35;
} }
private void checkColumnName_CheckedChanged(object sender, EventArgs e){
Config.DisplayNotificationColumn = checkColumnName.Checked;
notification.ShowNotificationForSettings(false);
}
private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){ private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){
Config.DisplayNotificationTimer = checkNotificationTimer.Checked; Config.DisplayNotificationTimer = checkNotificationTimer.Checked;
checkTimerCountDown.Enabled = checkNotificationTimer.Checked; checkTimerCountDown.Enabled = checkNotificationTimer.Checked;

View File

@ -19,6 +19,29 @@
// //
var app = $(document.body).children(".js-app"); var app = $(document.body).children(".js-app");
//
// Constant: Column types mapped to their titles.
//
const columnTypes = {
"col_home": "Home",
"col_timeline" : "Home",
"col_mentions": "Mentions",
"col_me": "Mentions",
"col_inbox": "Messages",
"col_messages": "Messages",
"col_interactions": "Notifications",
"col_followers": "Followers",
"col_activity": "Activity",
"col_favorites": "Likes",
"col_usertweets": "User",
"col_search": "Search",
"col_list": "List",
"col_customtimeline": "Timeline",
"col_dataminr": "Dataminr",
"col_livevideo": "Live video",
"col_scheduled": "Scheduled"
};
// //
// Function: Prepends code at the beginning of a function. If the prepended function returns true, execution of the original function is cancelled. // Function: Prepends code at the beginning of a function. If the prepended function returns true, execution of the original function is cancelled.
// //
@ -59,7 +82,7 @@
// //
var onNewTweet = function(column, tweet){ var onNewTweet = function(column, tweet){
if (column.model.getHasNotification()){ if (column.model.getHasNotification()){
var html = $(tweet.render({ let html = $(tweet.render({
withFooter: false, withFooter: false,
withTweetActions: false, withTweetActions: false,
withMediaPreview: true, withMediaPreview: true,
@ -73,9 +96,8 @@
html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice
html.find(".js-quote-detail").removeClass("is-actionable"); html.find(".js-quote-detail").removeClass("is-actionable");
var url = html.find("time").first().children("a").first().attr("href") || ""; let url = html.find("time").first().children("a").first().attr("href") || "";
$TD.onTweetPopup(columnTypes[column.getColumnType()] || "", html.html(), url, tweet.text.length);
$TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column
} }
if (column.model.getHasSound()){ if (column.model.getHasSound()){