Krita Source Code Documentation
Loading...
Searching...
No Matches
kmainwindow.h File Reference
#include <kritawidgetutils_export.h>
#include <QMainWindow>
#include <QMetaClassInfo>

Go to the source code of this file.

Classes

class  KisKMainWindow
 KDE top level main window More...
 

Macros

#define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS   3
 
#define XMLGUI_DECLARE_PRIVATE(classname)
 

Functions

template<typename T >
void kRestoreMainWindows ()
 
template<typename T0 , typename T1 >
void kRestoreMainWindows ()
 
template<typename T0 , typename T1 , typename T2 >
void kRestoreMainWindows ()
 

Macro Definition Documentation

◆ KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS

#define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS   3

Returns the maximal number of arguments that are actually supported by kRestoreMainWindows().

Definition at line 498 of file kmainwindow.h.

◆ XMLGUI_DECLARE_PRIVATE

#define XMLGUI_DECLARE_PRIVATE ( classname)
Value:
inline classname ## Private *k_func() { return reinterpret_cast<classname ## Private *>(k_ptr); } \
inline const classname ## Private *k_func() const { return reinterpret_cast<classname ## Private *>(k_ptr); } \
friend class classname ## Private;

Definition at line 33 of file kmainwindow.h.

33#define XMLGUI_DECLARE_PRIVATE(classname) \
34 inline classname ## Private *k_func() { return reinterpret_cast<classname ## Private *>(k_ptr); } \
35 inline const classname ## Private *k_func() const { return reinterpret_cast<classname ## Private *>(k_ptr); } \
36 friend class classname ## Private;

Function Documentation

◆ kRestoreMainWindows() [1/3]

template<typename T >
void kRestoreMainWindows ( )
inline

Restores the last session. (To be used in your main function).

These functions work also if you have more than one kind of toplevel widget (each derived from KisKMainWindow, of course).

Imagine you have three kinds of toplevel widgets: the classes childMW1, childMW2 and childMW3. Than you can just do:

if (qApp->isSessionRestored())
kRestoreMainWindows< childMW1, childMW2, childMW3 >();
else {
// create default application as usual
}

kRestoreMainWindows<>() will create (on the heap) as many instances of your main windows as have existed in the last session and call KisKMainWindow::restore() with the correct arguments. Note that also QWidget::show() is called implicitly.

Currently, these functions are provided for up to three template arguments. If you need more, tell us. To help you in deciding whether or not you can use kRestoreMainWindows, a define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.

See also
KisKMainWindow::restore()
KisKMainWindow::classNameOfToplevel()

Definition at line 531 of file kmainwindow.h.

532{
533 for (int n = 1; KisKMainWindow::canBeRestored(n); ++n) {
534 const QString className = KisKMainWindow::classNameOfToplevel(n);
535 if (className == QLatin1String(T::staticMetaObject.className())) {
536 (new T)->restore(n);
537 }
538 }
539}
static const QString classNameOfToplevel(int number)
static bool canBeRestored(int number)

References KisKMainWindow::canBeRestored(), and KisKMainWindow::classNameOfToplevel().

◆ kRestoreMainWindows() [2/3]

template<typename T0 , typename T1 >
void kRestoreMainWindows ( )
inline

Definition at line 542 of file kmainwindow.h.

543{
544 const char *classNames[2];
545 classNames[0] = T0::staticMetaObject.className();
546 classNames[1] = T1::staticMetaObject.className();
547 for (int n = 1; KisKMainWindow::canBeRestored(n); ++n) {
548 const QString className = KisKMainWindow::classNameOfToplevel(n);
549 if (className == QLatin1String(classNames[0])) {
550 (new T0)->restore(n);
551 } else if (className == QLatin1String(classNames[1])) {
552 (new T1)->restore(n);
553 }
554 }
555}

References KisKMainWindow::canBeRestored(), and KisKMainWindow::classNameOfToplevel().

◆ kRestoreMainWindows() [3/3]

template<typename T0 , typename T1 , typename T2 >
void kRestoreMainWindows ( )
inline

Definition at line 558 of file kmainwindow.h.

559{
560 const char *classNames[3];
561 classNames[0] = T0::staticMetaObject.className();
562 classNames[1] = T1::staticMetaObject.className();
563 classNames[2] = T2::staticMetaObject.className();
564 for (int n = 1; KisKMainWindow::canBeRestored(n); ++n) {
565 const QString className = KisKMainWindow::classNameOfToplevel(n);
566 if (className == QLatin1String(classNames[0])) {
567 (new T0)->restore(n);
568 } else if (className == QLatin1String(classNames[1])) {
569 (new T1)->restore(n);
570 } else if (className == QLatin1String(classNames[2])) {
571 (new T2)->restore(n);
572 }
573 }
574}

References KisKMainWindow::canBeRestored(), and KisKMainWindow::classNameOfToplevel().