Sayonara Player
Public Member Functions | Protected Member Functions | List of all members
PreferenceInterface< T > Class Template Referenceabstract

#include <PreferenceInterface.h>

Detailed Description

template<typename T>
class PreferenceInterface< T >

Template class for implementing preference dialogs and preference widgets.

Public Member Functions

 PreferenceInterface (QWidget *parent=nullptr)
 Standard constructor. More...
 
virtual bool is_ui_initialized () const final
 checks if ui has already been initialized. More...
 
virtual QAction * get_action () final
 get action with translated text More...
 
virtual QString get_action_name () const =0
 has to be implemented and should return the translated action text More...
 
virtual void commit ()=0
 This method is called, when OK or apply is pressed. So all settings should be written there.
 
virtual void revert ()=0
 This method is called, when cancel is clicked. So the gui should be re-initialized when this method is called. This method should also be called in the init_ui() method.
 

Protected Member Functions

virtual void init_ui ()=0
 call setup_parent(this) here.
initialize compoenents and connections here.
After calling setup_parent(this), the preference Dialog is ready to use, language_changed() is called automatically
 
virtual void retranslate_ui ()=0
 call the Qt retranslateUi method here
 
template<typename W , typename UiClass >
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 the first to be called when calling init_ui() More...
 
virtual void language_changed () override final
 automatically called when language has changed. When overriding this method. Overriding this method should look like this: void GUI_FontConfig::language_changed()
{
translate_action();

More...
 
void translate_action ()
 Sets the new translated action name.
 
void showEvent (QShowEvent *e) override
 shows the widget and automatically calls init_ui() More...
 
void closeEvent (QCloseEvent *e) override
 closes the widget More...
 

Constructor & Destructor Documentation

template<typename T>
PreferenceInterface< T >::PreferenceInterface ( QWidget *  parent = nullptr)
inline

Standard constructor.

Parameters
parent

Member Function Documentation

template<typename T>
void PreferenceInterface< T >::closeEvent ( QCloseEvent *  e)
inlineoverrideprotected

closes the widget

Parameters
e
template<typename T>
virtual QAction* PreferenceInterface< T >::get_action ( )
inlinefinalvirtual

get action with translated text

Returns
template<typename T>
virtual QString PreferenceInterface< T >::get_action_name ( ) const
pure virtual
template<typename T>
virtual bool PreferenceInterface< T >::is_ui_initialized ( ) const
inlinefinalvirtual

checks if ui has already been initialized.

Returns
false, if the widget has never been activated before, true else
template<typename T>
virtual void PreferenceInterface< T >::language_changed ( )
inlinefinaloverrideprotectedvirtual

automatically called when language has changed. When overriding this method. Overriding this method should look like this: void GUI_FontConfig::language_changed()
{
translate_action();

if(!is_ui_initialized()){
return;
}

retranslateUi(this);
PreferenceWidgetInterface::language_changed();
}

Reimplemented in GUI_StartupDialog.

template<typename T>
template<typename W , typename UiClass >
void PreferenceInterface< T >::setup_parent ( W *  widget,
UiClass **  ui 
)
inlineprotected

Sets up the Preference dialog. After this method, the dialog is "ready to use"
This method should be the first to be called when calling init_ui()

Parameters
widgetshould always be "this"
template<typename T>
void PreferenceInterface< T >::showEvent ( QShowEvent *  e)
inlineoverrideprotected

shows the widget and automatically calls init_ui()

Parameters
e
Inheritance diagram for PreferenceInterface< T >: