Skip to content

Commit cc1d049

Browse files
committed
Plugins Manager scaffolding
1 parent 9ae9d69 commit cc1d049

File tree

9 files changed

+165
-5
lines changed

9 files changed

+165
-5
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Flow.Launcher.Infrastructure.UserSettings;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Flow.Launcher.Plugin.PluginsManager
7+
{
8+
internal class ContextMenu : IContextMenu
9+
{
10+
private PluginInitContext Context { get; set; }
11+
12+
private Settings Settings { get; set; }
13+
14+
public ContextMenu(PluginInitContext context, Settings settings)
15+
{
16+
Context = context;
17+
Settings = settings;
18+
}
19+
20+
public List<Result> LoadContextMenus(Result selectedResult)
21+
{
22+
// Open website
23+
// Go to source code
24+
// Report an issue?
25+
// Request a feature?
26+
return new List<Result>();
27+
}
28+
}
29+
}

Plugins/Flow.Launcher.Plugin.PluginManager/Flow.Launcher.Plugin.PluginsManager.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@
2727
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2828
</None>
2929
</ItemGroup>
30+
31+
<ItemGroup>
32+
<Folder Include="Images\" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<Folder Include="Languages\" />
37+
</ItemGroup>
3038
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:system="clr-namespace:System;assembly=mscorlib">
4+
5+
<!--Dialogues-->
6+
7+
<!--Controls-->
8+
9+
<!--Plugin Infos-->
10+
<system:String x:Key="plugin_pluginsmanager_plugin_name">Plugins Manager</system:String>
11+
<system:String x:Key="plugin_pluginsmanager_plugin_description">Management of installing, uninstalling or updating Flow Launcher plugins</system:String>
12+
13+
<!--Context menu items-->
14+
15+
</ResourceDictionary>
Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1-
using System;
1+
using Flow.Launcher.Infrastructure.Storage;
2+
using Flow.Launcher.Infrastructure.UserSettings;
3+
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
4+
using Flow.Launcher.Plugin.PluginsManager.Views;
25
using System.Collections.Generic;
3-
using System.Text;
6+
using System.Windows.Controls;
47

58
namespace Flow.Launcher.Plugin.PluginsManager
69
{
7-
class Main
10+
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI18n
811
{
12+
internal PluginInitContext Context { get; set; }
13+
14+
internal Settings Settings;
15+
16+
private SettingsViewModel viewModel;
17+
18+
private IContextMenu contextMenu;
19+
20+
public Control CreateSettingPanel()
21+
{
22+
return new PluginsManagerSettings(viewModel);
23+
}
24+
25+
public void Init(PluginInitContext context)
26+
{
27+
Context = context;
28+
viewModel = new SettingsViewModel(context);
29+
Settings = viewModel.Settings;
30+
contextMenu = new ContextMenu(Context, Settings);
31+
}
32+
33+
public List<Result> LoadContextMenus(Result selectedResult)
34+
{
35+
return contextMenu.LoadContextMenus(selectedResult);
36+
}
37+
38+
public List<Result> Query(Query query)
39+
{
40+
return new List<Result>();
41+
}
42+
43+
public void Save()
44+
{
45+
viewModel.Save();
46+
}
47+
48+
public string GetTranslatedPluginTitle()
49+
{
50+
return Context.API.GetTranslation("plugin_pluginsmanager_plugin_name");
51+
}
52+
53+
public string GetTranslatedPluginDescription()
54+
{
55+
return Context.API.GetTranslation("plugin_pluginsmanager_plugin_description");
56+
}
957
}
1058
}

Plugins/Flow.Launcher.Plugin.PluginManager/Plugins.cs renamed to Plugins/Flow.Launcher.Plugin.PluginManager/Models/Plugins.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text;
44

5-
namespace Flow.Launcher.Plugin.PluginsManager
5+
namespace Flow.Launcher.Plugin.PluginsManager.Models
66
{
77
internal class Plugin
88
{

Plugins/Flow.Launcher.Plugin.PluginManager/PluginsManifest.cs renamed to Plugins/Flow.Launcher.Plugin.PluginManager/Models/PluginsManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Net;
77
using System.Text;
88

9-
namespace Flow.Launcher.Plugin.PluginsManager
9+
namespace Flow.Launcher.Plugin.PluginsManager.Models
1010
{
1111
class PluginsManifest
1212
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Flow.Launcher.Infrastructure.Storage;
2+
using Flow.Launcher.Infrastructure.UserSettings;
3+
4+
namespace Flow.Launcher.Plugin.PluginsManager.ViewModels
5+
{
6+
public class SettingsViewModel
7+
{
8+
private readonly PluginJsonStorage<Settings> storage;
9+
10+
internal Settings Settings { get; set; }
11+
12+
internal PluginInitContext Context { get; set; }
13+
14+
public SettingsViewModel(PluginInitContext context)
15+
{
16+
Context = context;
17+
storage = new PluginJsonStorage<Settings>();
18+
Settings = storage.Load();
19+
}
20+
21+
public void Save()
22+
{
23+
storage.Save();
24+
}
25+
}
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Window x:Class="Flow.Launcher.Plugin.PluginsManager.Views.PluginsManagerSettings"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:Flow.Launcher.Plugin.PluginsManager.Views"
7+
mc:Ignorable="d"
8+
Title="PluginsManagerSettings" Height="450" Width="800">
9+
<Grid>
10+
11+
</Grid>
12+
</Window>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
3+
4+
namespace Flow.Launcher.Plugin.PluginsManager.Views
5+
{
6+
/// <summary>
7+
/// Interaction logic for PluginsManagerSettings.xaml
8+
/// </summary>
9+
public partial class PluginsManagerSettings
10+
{
11+
private readonly SettingsViewModel viewModel;
12+
13+
public PluginsManagerSettings(SettingsViewModel viewModel)
14+
{
15+
InitializeComponent();
16+
17+
this.viewModel = viewModel;
18+
19+
//RefreshView();
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)