diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 9e53829e..91ecd3c4 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -50,6 +50,10 @@ public Browser(FormBrowser form, FormNotificationMain notification) : base(form, public void OpenContextMenu(){ form.InvokeAsyncSafe(form.OpenContextMenu); } + + public void OpenProfileImport(){ + form.InvokeAsyncSafe(form.OpenProfileImport); + } public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ form.InvokeAsyncSafe(() => { diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index a84d540d..904fe8b2 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -5,11 +5,13 @@ using TweetDuck.Core.Bridge; using TweetDuck.Core.Controls; using TweetDuck.Core.Handling; +using TweetDuck.Core.Handling.General; using TweetDuck.Core.Management; using TweetDuck.Core.Notification; using TweetDuck.Core.Notification.Screenshot; using TweetDuck.Core.Other; using TweetDuck.Core.Other.Analytics; +using TweetDuck.Core.Other.Settings.Dialogs; using TweetDuck.Core.Utils; using TweetDuck.Plugins; using TweetDuck.Plugins.Enums; @@ -435,13 +437,13 @@ public void OpenContextMenu(){ public void OpenSettings(){ OpenSettings(null); } - + public void OpenSettings(Type startTab){ if (!FormManager.TryBringToFront<FormSettings>()){ bool prevEnableUpdateCheck = Config.EnableUpdateCheck; FormSettings form = new FormSettings(this, plugins, updates, analytics, startTab); - + form.FormClosed += (sender, args) => { if (!prevEnableUpdateCheck && Config.EnableUpdateCheck){ Config.DismissedUpdate = null; @@ -497,6 +499,18 @@ public void OpenPlugins(){ } } + public void OpenProfileImport(){ + FormManager.TryFind<FormSettings>()?.Close(); + + using(DialogSettingsManage dialog = new DialogSettingsManage(plugins, true)){ + if (dialog.ShowDialog() == DialogResult.OK && !dialog.IsRestarting){ + BrowserProcessHandler.UpdatePrefs(); + FormManager.TryFind<FormPlugins>()?.Close(); + plugins.Reload(); // also reloads the browser + } + } + } + public void OnTweetNotification(){ // may be called multiple times, once for each type of notification if (Config.EnableTrayHighlight && !ContainsFocus){ trayIcon.HasNotifications = true; diff --git a/Core/Other/Settings/Dialogs/DialogSettingsManage.cs b/Core/Other/Settings/Dialogs/DialogSettingsManage.cs index 237c4036..7128b6ed 100644 --- a/Core/Other/Settings/Dialogs/DialogSettingsManage.cs +++ b/Core/Other/Settings/Dialogs/DialogSettingsManage.cs @@ -34,7 +34,7 @@ private ProfileManager.Items SelectedItems{ private ProfileManager.Items _selectedItems = ProfileManager.Items.None; - public DialogSettingsManage(PluginManager plugins){ + public DialogSettingsManage(PluginManager plugins, bool openImportImmediately = false){ InitializeComponent(); this.plugins = plugins; @@ -44,6 +44,11 @@ public DialogSettingsManage(PluginManager plugins){ this.checkBoxMap[cbSystemConfig] = ProfileManager.Items.SystemConfig; this.checkBoxMap[cbSession] = ProfileManager.Items.Session; this.checkBoxMap[cbPluginData] = ProfileManager.Items.PluginData; + + if (openImportImmediately){ + radioImport.Checked = true; + btnContinue_Click(null, EventArgs.Empty); + } } private void radioDecision_CheckedChanged(object sender, EventArgs e){ diff --git a/Resources/Scripts/imports/styles/twitter.base.css b/Resources/Scripts/imports/styles/twitter.base.css index fdf3e777..50379600 100644 --- a/Resources/Scripts/imports/styles/twitter.base.css +++ b/Resources/Scripts/imports/styles/twitter.base.css @@ -59,3 +59,9 @@ button[type='submit'] { border: 1px solid rgba(0, 0, 0, 0.3) !important; border-radius: 0 !important; } + +.tweetduck-helper { + /* custom login text */ + margin-top: 15px !important; + font-weight: bold !important; +} diff --git a/Resources/Scripts/twitter.js b/Resources/Scripts/twitter.js index 6326f902..526f9fcd 100644 --- a/Resources/Scripts/twitter.js +++ b/Resources/Scripts/twitter.js @@ -39,6 +39,16 @@ for(let index = 0; index < links.length; index++){ links[index].addEventListener("click", openLinkExternally); } + + let texts = document.querySelector(".page-canvas > div:last-child"); + + if (texts){ + texts.insertAdjacentHTML("beforeend", `<p class="tweetduck-helper">Used the TweetDuck app before? <a href="#">Import your profile ยป</a></p>`); + + texts.querySelector(".tweetduck-helper > a").addEventListener("click", function(){ + $TD.openProfileImport(); + }); + } }); } //