|
@@ -24,11 +24,13 @@ package com.dmdirc.addons.osdplugin;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.Main;
|
26
|
26
|
import com.dmdirc.commandparser.CommandManager;
|
|
27
|
+import com.dmdirc.config.ConfigManager;
|
27
|
28
|
import com.dmdirc.config.Identity;
|
28
|
29
|
import com.dmdirc.config.IdentityManager;
|
29
|
30
|
import com.dmdirc.plugins.Plugin;
|
30
|
31
|
import com.dmdirc.ui.interfaces.PreferencesInterface;
|
31
|
32
|
import com.dmdirc.ui.interfaces.PreferencesPanel;
|
|
33
|
+import com.dmdirc.ui.swing.components.ColourChooser;
|
32
|
34
|
|
33
|
35
|
import java.awt.BorderLayout;
|
34
|
36
|
import java.util.Properties;
|
|
@@ -55,6 +57,12 @@ public final class OsdPlugin extends Plugin implements PreferencesInterface {
|
55
|
57
|
/** Font size spinner. */
|
56
|
58
|
private JSpinner spinner;
|
57
|
59
|
|
|
60
|
+ /** Background colour chooser. */
|
|
61
|
+ private ColourChooser bgColour;
|
|
62
|
+
|
|
63
|
+ /** Background colour chooser. */
|
|
64
|
+ private ColourChooser fgColour;
|
|
65
|
+
|
58
|
66
|
/**
|
59
|
67
|
* Creates a new instance of OsdPlugin.
|
60
|
68
|
*/
|
|
@@ -96,31 +104,46 @@ public final class OsdPlugin extends Plugin implements PreferencesInterface {
|
96
|
104
|
|
97
|
105
|
/** {@inheritDoc}. */
|
98
|
106
|
public void showConfig() {
|
99
|
|
- final PreferencesPanel preferencesPanel = Main.getUI().getPreferencesPanel(this, "OSD Plugin - Config");
|
100
|
|
- final JPanel panel = new JPanel();
|
|
107
|
+ final ConfigManager config = IdentityManager.getGlobalConfig();
|
|
108
|
+ final PreferencesPanel preferencesPanel = Main.getUI().
|
|
109
|
+ getPreferencesPanel(this, "OSD Plugin - Config");
|
|
110
|
+ final JPanel spinnerPanel = new JPanel(new BorderLayout());
|
|
111
|
+ final JPanel bgColourPanel = new JPanel(new BorderLayout());
|
|
112
|
+ final JPanel fgColourPanel = new JPanel(new BorderLayout());
|
101
|
113
|
spinner = new JSpinner(new SpinnerNumberModel());
|
|
114
|
+ bgColour = new ColourChooser();
|
|
115
|
+ fgColour = new ColourChooser();
|
102
|
116
|
|
103
|
|
- spinner.setValue(IdentityManager.getGlobalConfig().getOptionInt(MY_DOMAIN, "fontSize", 20));
|
|
117
|
+ spinner.setValue(config.getOptionInt(MY_DOMAIN, "fontSize", 20));
|
|
118
|
+ bgColour.setColour(config.getOption(MY_DOMAIN, "bgcolour", "2222aa"));
|
|
119
|
+ fgColour.setColour(config.getOption(MY_DOMAIN, "fgcolour", "ffffff"));
|
104
|
120
|
|
105
|
|
- panel.setLayout(new BorderLayout());
|
106
|
|
- panel.add(spinner);
|
|
121
|
+ spinnerPanel.add(spinner);
|
|
122
|
+ bgColourPanel.add(bgColour);
|
|
123
|
+ fgColourPanel.add(fgColour);
|
107
|
124
|
|
108
|
125
|
preferencesPanel.addCategory("General", "General configuration for OSD plugin.");
|
109
|
126
|
|
110
|
127
|
preferencesPanel.addPanelOption("General", "fontsize", "Font size: ",
|
111
|
|
- "Changes the font size of the OSD", panel);
|
112
|
|
- preferencesPanel.addColourOption("General", "bgcolour",
|
|
128
|
+ "Changes the font size of the OSD", spinnerPanel);
|
|
129
|
+ preferencesPanel.addPanelOption("General", "bgcolour",
|
113
|
130
|
"Background Colour: ", "Background colour for the OSD",
|
114
|
|
- IdentityManager.getGlobalConfig().getOption(MY_DOMAIN, "bgcolour", "2222aa"), true, true);
|
115
|
|
- preferencesPanel.addColourOption("General", "fgcolour",
|
116
|
|
- "Foreground Colour: ", "Foreground colour for the OSD",
|
117
|
|
- IdentityManager.getGlobalConfig().getOption(MY_DOMAIN, "fgcolour", "ffffff"), true, true);
|
|
131
|
+ bgColourPanel);
|
|
132
|
+ preferencesPanel.addPanelOption("General", "fgcolour",
|
|
133
|
+ "Foreground Colour: ", "Foreground colour for the OSD",
|
|
134
|
+ fgColourPanel);
|
118
|
135
|
preferencesPanel.addSpinnerOption("General", "timeout", "Timeout: ",
|
119
|
136
|
"Length of times in seconds before the OSD window times out",
|
120
|
137
|
IdentityManager.getGlobalConfig().getOptionInt(MY_DOMAIN, "timeout", 15));
|
121
|
138
|
|
122
|
139
|
osdWindow = new OsdWindow("Please drag this OSD to position", true);
|
123
|
140
|
|
|
141
|
+ spinner.addChangeListener(osdWindow);
|
|
142
|
+ bgColour.addActionListener(osdWindow);
|
|
143
|
+ bgColour.setActionCommand("backgroundColour");
|
|
144
|
+ fgColour.addActionListener(osdWindow);
|
|
145
|
+ fgColour.setActionCommand("foregroundColour");
|
|
146
|
+
|
124
|
147
|
preferencesPanel.display();
|
125
|
148
|
}
|
126
|
149
|
|
|
@@ -131,11 +154,11 @@ public final class OsdPlugin extends Plugin implements PreferencesInterface {
|
131
|
154
|
if (spinner != null) {
|
132
|
155
|
config.setOption(MY_DOMAIN, "fontSize", String.valueOf(spinner.getValue()));
|
133
|
156
|
}
|
134
|
|
- if (properties.getProperty("fgcolour") != null) {
|
135
|
|
- config.setOption(MY_DOMAIN, "fgcolour", properties.getProperty("fgcolour"));
|
|
157
|
+ if (fgColour != null) {
|
|
158
|
+ config.setOption(MY_DOMAIN, "fgcolour", fgColour.getColour());
|
136
|
159
|
}
|
137
|
|
- if (properties.getProperty("bgcolour") != null) {
|
138
|
|
- config.setOption(MY_DOMAIN, "bgcolour", properties.getProperty("bgcolour"));
|
|
160
|
+ if (bgColour != null) {
|
|
161
|
+ config.setOption(MY_DOMAIN, "bgcolour", bgColour.getColour());
|
139
|
162
|
}
|
140
|
163
|
if (properties.getProperty("timeout") != null) {
|
141
|
164
|
config.setOption(MY_DOMAIN, "timeout", properties.getProperty("timeout"));
|