21 #ifndef PREFERENCEINTERFACE_H 22 #define PREFERENCEINTERFACE_H 27 #include "GUI/Helper/SayonaraWidget/SayonaraDialog.h" 28 #include "GUI/Helper/SayonaraWidget/SayonaraWidget.h" 71 virtual void init_ui()=0;
77 virtual void retranslate_ui()=0;
80 template<
typename W,
typename UiClass>
88 (*ui)->setupUi(widget);
90 _is_initialized =
true;
92 widget->language_changed();
114 if(!is_ui_initialized()){
118 QString new_name = get_action_name();
119 this->setWindowTitle(new_name);
130 QString new_name = this->get_action_name();
131 this->get_action()->setText(new_name +
"...");
144 if(!is_ui_initialized()){
150 if(!_geometry.isEmpty()){
151 this->restoreGeometry(_geometry);
176 _is_initialized =
false;
187 return _is_initialized;
199 QString name = get_action_name();
204 _action->setText(name +
"...");
214 virtual QString get_action_name()
const=0;
222 virtual void commit()=0;
229 virtual void revert()=0;
232 #endif // PREFERENCEINTERFACE_H Template class for implementing preference dialogs and preference widgets.
Definition: PreferenceInterface.h:58
virtual QAction * get_action() final
get action with translated text
Definition: PreferenceInterface.h:195
PreferenceInterface(QWidget *parent=nullptr)
Standard constructor.
Definition: PreferenceInterface.h:173
virtual bool is_ui_initialized() const final
checks if ui has already been initialized.
Definition: PreferenceInterface.h:185
The action, which is used to access the Preference.
Definition: PreferenceInterface.h:38
virtual void language_changed() override final
automatically called when language has changed. When overriding this method. Overriding this method s...
Definition: PreferenceInterface.h:110
void closeEvent(QCloseEvent *e) override
closes the widget
Definition: PreferenceInterface.h:161
void showEvent(QShowEvent *e) override
shows the widget and automatically calls init_ui()
Definition: PreferenceInterface.h:141
void setup_parent(W *widget, UiClass **ui)
Sets up the Preference dialog. After this method, the dialog is "ready to use" This method should be ...
Definition: PreferenceInterface.h:86
void translate_action()
Sets the new translated action name.
Definition: PreferenceInterface.h:128
PreferenceAction(const QString &text, QWidget *preference_interface)
PreferenceAction Create QAction object, which is automatically connected to the show event of the und...