Skip to content

Commit b3dcde1

Browse files
Merge pull request #2937 from HelioGuilherme66/edit_settings
Edit settings from Preferences
2 parents 9d2a143 + 75a6cde commit b3dcde1

File tree

17 files changed

+291
-20
lines changed

17 files changed

+291
-20
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
99
== https://github.com/robotframework/RIDE[Unreleased]
1010

1111
=== Added
12+
- Added Settings Editor button to Preferences dialog, to edit settings.cfg.
13+
- Created backup of settings.cfg to allow recovering some settings when broken upgrades.
1214
- Added current executing keyword and other statuses to TestRunner status bar.
1315
- Added Config Panel button to supported installed Plugins next to their name in Plugin Manager dialog.
1416
- Added Config Panel button to Plugins, working examples in Text Editor and Test Runner.

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.2, but RIDE is known to work w
4040

4141
`pip install -U robotframework-ride`
4242

43-
(3.8 <= python <= 3.13) Install current development version (**2.2dev20**) with:
43+
(3.8 <= python <= 3.13) Install current development version (**2.2dev21**) with:
4444

4545
`pip install -U https://github.com/robotframework/RIDE/archive/develop.zip`
4646

src/robotide/application/CHANGELOG.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id1337"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
33
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
4+
Added Settings Editor button to Preferences dialog, to edit settings.cfg.
5+
</li><li class="listitem">
6+
Created backup of settings.cfg to allow recovering some settings when broken upgrades.
7+
</li><li class="listitem">
48
Added current executing keyword and other statuses to TestRunner status bar.
59
</li><li class="listitem">
610
Added Config Panel button to supported installed Plugins next to their name in Plugin Manager dialog.

src/robotide/application/application.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
from contextlib import contextmanager
2121
from pathlib import Path
2222

23-
from pygments.styles.dracula import background
24-
2523
from ..namespace import Namespace
2624
from ..controller import Project
2725
from ..spec import librarydatabase

src/robotide/application/releasenotes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def set_content(self, html_win, content):
170170
</ul>
171171
<p><strong>New Features and Fixes Highlights</strong></p>
172172
<ul class="simple">
173+
<li>Added Settings Editor button to Preferences dialog, to edit settings.cfg.</li>
174+
<li>Created backup of settings.cfg to allow recovering some settings when broken upgrades.</li>
173175
<li>Changed some informative dialogs and JSON Editor to use the customized colors.</li>
174176
<li>Added current executing keyword and other statuses to TestRunner status bar.</li>
175177
<li>Modified import statements to allow running RIDE without Robot Framework installed or versions older than 6.0.</li>
@@ -232,7 +234,7 @@ def set_content(self, html_win, content):
232234
<pre class="literal-block">python -m robotide.postinstall -install</pre>
233235
<p>or</p>
234236
<pre class="literal-block">ride_postinstall.py -install</pre>
235-
<p>RIDE {VERSION} was released on 12/April/2025.</p>
237+
<p>RIDE {VERSION} was released on 14/April/2025.</p>
236238
<!-- <br/>
237239
<h3>May The Fourth Be With You!</h3>
238240
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>

src/robotide/editor/customsourceeditor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import wx.stc as stc
2525
from robotide.editor.pythoneditor import PythonSTC
2626
from wx import Colour
27+
from ..widgets import ImageProvider
2728

2829
# ---------------------------------------------------------------------------
2930
# This is how you pre-establish a file filter so that the dialog
@@ -534,6 +535,11 @@ def main(filepath, frame=None):
534535
if frame is None:
535536
frame = wx.Frame(None)
536537
CodeEditorPanel(frame, None, filepath)
538+
image_provider = ImageProvider()
539+
frame.SetTitle(filepath)
540+
frame.SetSize((800, 600))
541+
frame.SetIcon(wx.Icon(image_provider.RIDE_ICON))
542+
frame.CenterOnScreen()
537543
frame.Show(True)
538544
app.MainLoop()
539545
# ----------------------------------------------------------------------------

src/robotide/preferences/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, settings):
4949
self.settings = settings
5050
self._preference_panels = []
5151
self._add_builtin_preferences()
52+
self.settings_path = self.settings._default_path
5253

5354
@property
5455
def preference_panels(self):

src/robotide/preferences/editor.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@
3131
"""
3232

3333
import builtins
34+
import os.path
35+
3436
import wx
3537
from wx import Colour
3638
from wx.lib.scrolledpanel import ScrolledPanel
3739

3840
from .settings import RideSettings
41+
from ..widgets import ButtonWithHandler
3942

4043
_ = wx.GetTranslation # To keep linter/code analyser happy
4144
builtins.__dict__['_'] = wx.GetTranslation
@@ -199,15 +202,25 @@ class PanelContainer(wx.Panel):
199202
"""
200203
def __init__(self, *args, **kwargs):
201204
super(PanelContainer, self).__init__(*args, **kwargs)
202-
205+
self.parent = self.GetParent()
203206
self._current_panel = None
204207
self._settings = RideSettings()
205208
self.settings = self._settings['General']
206209
self.title = wx.StaticText(self, label="Your message here")
210+
hsizer = wx.BoxSizer(wx.HORIZONTAL)
211+
config_button = ButtonWithHandler(self, _('Settings'), bitmap='wrench_orange.png',
212+
fsize=self.settings[FONT_SIZE],
213+
handler=lambda e: self.on_edit_settings())
214+
config_button.SetBackgroundColour(self.settings['background'])
215+
config_button.SetOwnBackgroundColour(self.settings['background'])
216+
config_button.SetForegroundColour(self.settings['foreground'])
217+
hsizer.Add(config_button, 0, wx.TOP | wx.RIGHT | wx.EXPAND, 4)
218+
hsizer.Add(self.title, 0, wx.TOP | wx.LEFT | wx.EXPAND, 4)
207219
self.panels_container = ScrolledPanel(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
208220
self.panels_container.SetupScrolling()
209221
sizer = wx.BoxSizer(wx.VERTICAL)
210-
sizer.Add(self.title, 0, wx.TOP | wx.LEFT | wx.EXPAND, 4)
222+
sizer.Add(hsizer)
223+
# sizer.Add(self.title, 0, wx.TOP | wx.LEFT | wx.EXPAND, 4)
211224
sizer.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4)
212225
sizer.Add(self.panels_container, 1, wx.EXPAND)
213226
self.SetSizer(sizer)
@@ -256,3 +269,12 @@ def ShowPanel(self, panel):
256269
def SetTitle(self, title):
257270
"""Set the title of the panel"""
258271
self.title.SetLabel(title)
272+
273+
def on_edit_settings(self):
274+
"""Starts Text Editor for settings file and closes all if changed"""
275+
from ..editor import customsourceeditor
276+
from ..context import SETTINGS_DIRECTORY
277+
main_settings_path = os.path.join(SETTINGS_DIRECTORY, 'settings.cfg')
278+
customsourceeditor.main(main_settings_path)
279+
# DEBUG close parent test
280+
# self.parent.Close()

src/robotide/preferences/general.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self, settings, *args, **kwargs):
8686
# don't have the time to do that right now, so this will have
8787
# to suffice.
8888

89+
# print(f"DEBUG: preferences/general.py GeneralPeferences settings_path={self._settings._default_path}")
8990
ui_language = self._select_ui_language()
9091
font_editor = self._create_font_editor()
9192
colors_sizer = self.create_colors_sizer()

src/robotide/preferences/settings.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def _copy_or_migrate_user_settings(settings_dir, source_path, dest_file_name):
4949
m_error = None
5050
if not os.path.exists(source_path):
5151
raise(FileNotFoundError(source_path))
52+
else:
53+
shutil.copyfile(source_path, source_path + '._backup')
5254
if not dest_file_name:
5355
dest_file_name = os.path.basename(source_path)
5456
settings_path = os.path.join(settings_dir, dest_file_name)
@@ -60,12 +62,12 @@ def _copy_or_migrate_user_settings(settings_dir, source_path, dest_file_name):
6062
SettingsMigrator(source_path, settings_path).migrate()
6163
# print(f"DEBUG: settings After migration {source_path} with {settings_path}")
6264
except ConfigObjError as parsing_error:
63-
print("WARNING! corrupted configuration file replaced with defaults")
65+
print("WARNING! corrupted configuration file replaced with defaults\n"
66+
f"A backup of the settings is at: {source_path + '._backup'}")
6467
print(parsing_error)
6568
m_error = parsing_error
6669
shutil.copyfile(settings_path, settings_path + '_old_broken')
67-
print("(backed up corrupted configuration file at: %s)" %
68-
(settings_path + '_old_broken'))
70+
print(f"(backed up corrupted configuration file at: {settings_path + '_old_broken'}")
6971
shutil.copyfile(source_path, settings_path)
7072
# print("DEBUG: source %s corrupted settings %s\n" % (source_path, settings_path))
7173
finally: # DEBUG Try to merge some settings
@@ -362,22 +364,24 @@ def __init__(self, path=None):
362364
elif path.endswith('.cfg') and os.path.exists(path):
363365
self._default_path = path
364366
# print(f"DEBUG: settings.py RideSettings SETTINGS {self._default_path=}")
365-
user_path = initialize_settings(self._default_path)
366-
Settings.__init__(self, user_path)
367-
self._settings_dir = os.path.dirname(user_path)
367+
self.user_path = initialize_settings(self._default_path)
368+
Settings.__init__(self, self.user_path)
369+
self._settings_dir = os.path.dirname(self.user_path)
368370
# print(f"DEBUG: RideSettings, self._settings_dir={self._settings_dir}")
369371
self.get('install root', os.path.dirname(os.path.dirname(__file__)))
370372
self.executable = self.get('executable', EXECUTABLE)
371373
if self.executable != EXECUTABLE:
372374
digest = 0
373375
for c in EXECUTABLE:
374376
digest += ord(c)
375-
new_user_path = user_path.replace("settings.cfg", f"settings_{digest}.cfg")
376-
new_user_path = initialize_settings(user_path, new_user_path)
377+
new_user_path = self.user_path.replace("settings.cfg", f"settings_{digest}.cfg")
378+
new_user_path = initialize_settings(self.user_path, new_user_path)
377379
Settings.__init__(self, new_user_path)
378380
self._settings_dir = os.path.dirname(new_user_path)
379381
self.set('install root', os.path.dirname(os.path.dirname(__file__)))
380-
self.executable = self.set('executable', EXECUTABLE)
382+
self.set('executable', EXECUTABLE)
383+
self.set('last_settings_path', new_user_path)
384+
self.user_path = new_user_path
381385

382386
def get_path(self, *parts):
383387
"""Returns path which combines settings directory and given parts."""

0 commit comments

Comments
 (0)