Qt Utilities 6.14.4
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
QtUtilities::SettingsDialog Class Reference

The SettingsDialog class provides a framework for creating settings dialogs with different categories and subcategories. More...

#include <settingsdialog.h>

Inheritance diagram for QtUtilities::SettingsDialog:
[legend]
Collaboration diagram for QtUtilities::SettingsDialog:
[legend]

Public Slots

bool apply ()
 Applies all changes.
 
void reset ()
 Resets all changes.
 

Signals

void applied ()
 
void resetted ()
 
void retranslationRequired ()
 

Public Member Functions

 SettingsDialog (QWidget *parent=nullptr)
 Constructs a settings dialog.
 
 ~SettingsDialog () override
 Destroys the settings dialog.
 
bool isTabBarAlwaysVisible () const
 Returns whether the tab bar is always visible.
 
void setTabBarAlwaysVisible (bool value)
 Sets whether the tab bar is always visible.
 
OptionCategoryModelcategoryModel ()
 Returns the category model used by the settings dialog to manage the categories.
 
OptionCategorycategory (int categoryIndex) const
 Returns the category for the specified categoryIndex.
 
OptionPagepage (int categoryIndex, int pageIndex) const
 Returns the page for the specified categoryIndex and the specified pageIndex.
 
void showCategory (OptionCategory *category)
 Sets the current category to the specified category and updates the relevant widgets to show it.
 
void translateCategory (OptionCategory *category, const std::function< QString()> &translator)
 Allows to set the categories display name so that it is retranslated as needed.
 
void setSingleCategory (OptionCategory *singleCategory)
 Enables single-category mode to show only the specified singleCategory.
 
QWidget * cornerWidget (Qt::Corner corner=Qt::TopRightCorner) const
 Returns the tab-widget's corner widget.
 
void setCornerWidget (QWidget *widget, Qt::Corner corner=Qt::TopRightCorner)
 Sets the tab-widget's corner widget.
 
void addHeadingWidget (QWidget *widget)
 Adds a widget next to the heading.
 
void selectPage (int categoryIndex, int pageIndex)
 Selects the specified page within the specified category.
 

Protected Member Functions

bool event (QEvent *event) override
 
void showEvent (QShowEvent *event) override
 Resets all pages before the dialog is shown by the application.
 

Properties

bool tabBarAlwaysVisible
 

Detailed Description

The SettingsDialog class provides a framework for creating settings dialogs with different categories and subcategories.

Definition at line 21 of file settingsdialog.h.

Constructor & Destructor Documentation

◆ SettingsDialog()

QtUtilities::SettingsDialog::SettingsDialog ( QWidget * parent = nullptr)
explicit

Constructs a settings dialog.

Parameters
parentSpecifies the parent widget.

Definition at line 30 of file settingsdialog.cpp.

◆ ~SettingsDialog()

QtUtilities::SettingsDialog::~SettingsDialog ( )
override

Destroys the settings dialog.

Definition at line 64 of file settingsdialog.cpp.

Member Function Documentation

◆ addHeadingWidget()

void QtUtilities::SettingsDialog::addHeadingWidget ( QWidget * widget)

Adds a widget next to the heading.

Definition at line 213 of file settingsdialog.cpp.

◆ applied

void QtUtilities::SettingsDialog::applied ( )
signal

◆ apply

bool QtUtilities::SettingsDialog::apply ( )
slot

Applies all changes.

Calls OptionCategory::applyAllPages() for each category.

Remarks
Pages which have not been shown yet must have not been initialized anyways and hence are skipped.

Definition at line 307 of file settingsdialog.cpp.

◆ category()

OptionCategory * QtUtilities::SettingsDialog::category ( int categoryIndex) const

Returns the category for the specified categoryIndex.

The settings dialog keeps ownership over the returned category. If no category exists for the specified index a null pointer is returned.

Definition at line 86 of file settingsdialog.cpp.

◆ categoryModel()

OptionCategoryModel * QtUtilities::SettingsDialog::categoryModel ( )
inline

Returns the category model used by the settings dialog to manage the categories.

Definition at line 83 of file settingsdialog.h.

◆ cornerWidget()

QWidget * QtUtilities::SettingsDialog::cornerWidget ( Qt::Corner corner = Qt::TopRightCorner) const

Returns the tab-widget's corner widget.

Definition at line 197 of file settingsdialog.cpp.

◆ event()

bool QtUtilities::SettingsDialog::event ( QEvent * event)
overrideprotected

Definition at line 359 of file settingsdialog.cpp.

◆ isTabBarAlwaysVisible()

bool QtUtilities::SettingsDialog::isTabBarAlwaysVisible ( ) const
inline

Returns whether the tab bar is always visible.

The tab bar is always visible by default.

See also
SettingsDialog::setTabBarAlwaysVisible()

Definition at line 74 of file settingsdialog.h.

◆ page()

OptionPage * QtUtilities::SettingsDialog::page ( int categoryIndex,
int pageIndex ) const

Returns the page for the specified categoryIndex and the specified pageIndex.

The settings dialog keeps ownership over the returned category. If no page for the specified indices a null pointer is returned.

Definition at line 98 of file settingsdialog.cpp.

◆ reset

void QtUtilities::SettingsDialog::reset ( )
slot

Resets all changes.

Calls OptionCategory::resetAllPages() for each category.

Definition at line 351 of file settingsdialog.cpp.

◆ resetted

void QtUtilities::SettingsDialog::resetted ( )
signal

◆ retranslationRequired

void QtUtilities::SettingsDialog::retranslationRequired ( )
signal

◆ selectPage()

void QtUtilities::SettingsDialog::selectPage ( int categoryIndex,
int pageIndex )

Selects the specified page within the specified category.

Definition at line 221 of file settingsdialog.cpp.

◆ setCornerWidget()

void QtUtilities::SettingsDialog::setCornerWidget ( QWidget * widget,
Qt::Corner corner = Qt::TopRightCorner )

Sets the tab-widget's corner widget.

Definition at line 205 of file settingsdialog.cpp.

◆ setSingleCategory()

void QtUtilities::SettingsDialog::setSingleCategory ( OptionCategory * singleCategory)

Enables single-category mode to show only the specified singleCategory.

Remarks
  • In single-category mode category selection, filter and heading are hidden.
  • The single-category mode can be disabled again by setting singleCategory to nullptr.

Definition at line 181 of file settingsdialog.cpp.

◆ setTabBarAlwaysVisible()

void QtUtilities::SettingsDialog::setTabBarAlwaysVisible ( bool value)

Sets whether the tab bar is always visible.

See also
SettingsDialog::isTabBarAlwaysVisible()

Definition at line 72 of file settingsdialog.cpp.

◆ showCategory()

void QtUtilities::SettingsDialog::showCategory ( OptionCategory * category)

Sets the current category to the specified category and updates the relevant widgets to show it.

Definition at line 141 of file settingsdialog.cpp.

◆ showEvent()

void QtUtilities::SettingsDialog::showEvent ( QShowEvent * event)
overrideprotected

Resets all pages before the dialog is shown by the application.

Definition at line 111 of file settingsdialog.cpp.

◆ translateCategory()

void QtUtilities::SettingsDialog::translateCategory ( OptionCategory * category,
const std::function< QString()> & translator )

Allows to set the categories display name so that it is retranslated as needed.

Remarks
  • The specified translator is supposed to return the display name to assign to category for the current locale. The translator is called immediately for the initial assignment and on language change events.
  • This function is experimental and might change or be removed completely in the next minor release.

Definition at line 165 of file settingsdialog.cpp.

Property Documentation

◆ tabBarAlwaysVisible

bool QtUtilities::SettingsDialog::tabBarAlwaysVisible
readwrite

Definition at line 23 of file settingsdialog.h.


The documentation for this class was generated from the following files: