Removing GSI methods which are no longer required as they are included in the base class now, added + fixed GSI unit tests for LayoutView

This commit is contained in:
Matthias Koefferlein 2025-09-04 19:50:51 +02:00
parent b3123d385a
commit 7f29cf91df
3 changed files with 29 additions and 70 deletions

View File

@ -1942,68 +1942,6 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (decl_Dispatcher,
"\n"
"This method has been added in version 0.26."
) +
// HINT: the cast is important to direct GSI to the LayoutView method rather than the
// Plugin method (in which case we get a segmentation violation ..)
// TODO: this method belongs to the Plugin interface and should be located there.
// Change this once there is a mixin concept available and the Plugin interface can
// be mixed into LayoutView.
gsi::method ("clear_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::clear_config,
"@brief Clears the local configuration parameters\n"
"\n"
"See \\set_config for a description of the local configuration parameters."
) +
// TODO: this method belongs to the Plugin interface and should be located there.
// Change this once there is a mixin concept available and the Plugin interface can
// be mixed into LayoutView.
gsi::method_ext ("get_config_names", &get_config_names,
"@brief Gets the configuration parameter names\n"
"\n"
"@return A list of configuration parameter names\n"
"\n"
"This method returns the names of all known configuration parameters. These names can be used to "
"get and set configuration parameter values.\n"
"\n"
"This method was introduced in version 0.25.\n"
) +
// TODO: this method belongs to the Plugin interface and should be located there.
// Change this once there is a mixin concept available and the Plugin interface can
// be mixed into LayoutView.
gsi::method ("get_config", (std::string (lay::LayoutViewBase::*)(const std::string &name) const) &lay::LayoutViewBase::config_get, gsi::arg ("name"),
"@brief Gets the value of a local configuration parameter\n"
"\n"
"@param name The name of the configuration parameter whose value shall be obtained (a string)\n"
"\n"
"@return The value of the parameter\n"
"\n"
"See \\set_config for a description of the local configuration parameters."
) +
// TODO: this method belongs to the Plugin interface and should be located there.
// Change this once there is a mixin concept available and the Plugin interface can
// be mixed into LayoutView.
gsi::method ("set_config", (void (lay::LayoutViewBase::*)(const std::string &name, const std::string &value)) &lay::LayoutViewBase::config_set, gsi::arg ("name"), gsi::arg ("value"),
"@brief Sets a local configuration parameter with the given name to the given value\n"
"\n"
"@param name The name of the configuration parameter to set\n"
"@param value The value to which to set the configuration parameter\n"
"\n"
"This method sets a local configuration parameter with the given name to the given value. "
"Values can only be strings. Numerical values have to be converted into strings first. "
"Local configuration parameters override global configurations for this specific view. "
"This allows for example to override global settings of background colors. "
"Any local settings are not written to the configuration file. "
) +
// TODO: this method belongs to the Plugin interface and should be located there.
// Change this once there is a mixin concept available and the Plugin interface can
// be mixed into LayoutView.
gsi::method ("commit_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::config_end,
"@brief Commits the configuration settings\n"
"\n"
"Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. "
"After a sequence of \\set_config calls, this method should be called to activate the "
"settings made by these calls.\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
gsi::method_ext ("transaction", &gsi::transaction, gsi::arg ("description"),
"@brief Begins a transaction\n"
"\n"

View File

@ -292,7 +292,7 @@ EditorOptionsModalPages::EditorOptionsModalPages (EditorOptionsPages *parent)
QVBoxLayout *ly = new QVBoxLayout (this);
ly->setContentsMargins (0, 0, 0, 0);
QVBoxLayout *ly4 = new QVBoxLayout (this);
QVBoxLayout *ly4 = new QVBoxLayout (0);
ly4->setContentsMargins (6, 6, 6, 0);
ly->addLayout (ly4);
mp_pages = new QTabWidget (this);
@ -306,9 +306,9 @@ EditorOptionsModalPages::EditorOptionsModalPages (EditorOptionsPages *parent)
ly->addWidget (mp_single_page_frame, 1);
mp_single_page_frame->hide ();
QVBoxLayout *ly3 = new QVBoxLayout (this);
ly->addLayout (ly3);
QVBoxLayout *ly3 = new QVBoxLayout (0);
ly3->setContentsMargins (6, 6, 6, 6);
ly->addLayout (ly3);
mp_button_box = new QDialogButtonBox (this);
ly3->addWidget (mp_button_box);
mp_button_box->setOrientation (Qt::Horizontal);

View File

@ -506,9 +506,8 @@ class LAYLayoutView_TestClass < TestBase
end
class DummyPlugin < RBA::Plugin
def initialize(manager, view)
self.manager = manager
self.view = view
def initialize
super
end
end
@ -516,8 +515,8 @@ class LAYLayoutView_TestClass < TestBase
def initialize()
register(1000, "dummy_plugin", "Dummy Plugin")
end
def create_plugin(manager, unused, view)
DummyPlugin::new(manager, view)
def create_plugin(manager, dispatcher, view)
DummyPlugin::new
end
end
@ -601,6 +600,28 @@ class LAYLayoutView_TestClass < TestBase
end
# private config
def test_10
lv = RBA::LayoutView::new(true)
assert_equal(lv.get_config_names.member?("edit-grid"), true)
lv.set_config("edit-grid", "0.01")
# smoke test
lv.commit_config
assert_equal(lv.get_config("edit-grid"), "0.01")
lv.clear_config
assert_equal(lv.get_config("edit-grid"), "")
# unknown config names can be used, but are not initialized
lv.set_config("does-not-exist", "aaa")
assert_equal(lv.get_config_names.member?("does-not-exist"), true)
assert_equal(lv.get_config("does-not-exist"), "aaa")
lv.clear_config
assert_equal(lv.get_config_names.member?("does-not-exist"), false)
end
end
load("test_epilogue.rb")