QtCanpool 3.3.0
载入中...
搜索中...
未找到
QxApp::QxAppShell类 参考

The window skeleton of a ribbon application. 更多...

#include <qxapp/qxappshell.h>

类 QxApp::QxAppShell 继承关系图:

Public 成员函数

 QxAppShell (QWidget *parent=0)
 
 ~QxAppShell () override
 
QxNavigationBar * navigationBar () const
 The navigation rail; owned by the shell.
 
QxDock::DockWindow * dockWindow () const
 The dock area; owned by the shell.
 
void addPage (const QString &id, const QIcon &icon, const QString &title, QWidget *page)
 Adds a page at the end of the workspace and an entry with the same icon and title to the rail.
 
void insertPage (int index, const QString &id, const QIcon &icon, const QString &title, QWidget *page)
 Inserts a page at the given index of the workspace and of the rail.
 
void removePage (const QString &id)
 Removes the page with id and its rail entry.
 
int pageCount () const
 
int indexOfPage (const QString &id) const
 Index of the page with id, or -1 when there is no such page.
 
QString pageId (int index) const
 Id of the page at the given index, or an empty string.
 
QWidget * page (const QString &id) const
 The page widget with id, or null.
 
int currentPageIndex () const
 
QString currentPageId () const
 
QWidget * currentPage () const
 
QxDock::DockWidget * addDock (Qx::DockWidgetArea area, const QString &id, const QString &title, QWidget *widget)
 Creates a dock widget named id, titles it title, fills it with widget and drops it in area.
 
QxDock::DockWidget * dock (const QString &id) const
 The dock widget created with addDock() under id, or null.
 
void setStatusMessage (const QString &message)
 Text of the permanent message line at the left of the status bar.
 
QString statusMessage () const
 
void setBusy (bool busy)
 Shows or hides the busy indicator in the status bar.
 
bool isBusy () const
 
void setProgressRange (int minimum, int maximum)
 Range the progress runs in, 0 to 100 by default.
 
int progressMinimum () const
 
int progressMaximum () const
 
void setProgress (int value)
 Shows how far the work has got, which also shows the indicator - setting a progress means wanting it seen.
 
int progress () const
 
void clearProgress ()
 Hides the indicator and puts the progress back at the minimum.
 
bool isProgressVisible () const
 Whether the indicator is up, in either of its two modes.
 
QxToastManager * toastManager () const
 The stack of toasts that shows up over the shell, created on first use and owned by the shell.
 
QxToast * showToast (const QString &text, QxToast::Level level=QxToast::Information, int timeoutMs=QxToast::DefaultTimeout)
 Puts a toast over the shell and returns it, so that a caller who needs to can hold on to it or dismiss it early.
 
QxWorkspaceManager * workspaceManager () const
 The named layouts of this shell, created on first use and owned by it.
 
QStringList workspaceNames () const
 Names of the stored workspaces, in the order they were saved.
 
bool saveWorkspace (const QString &name)
 Stores the current arrangement under name - see QxWorkspaceManager::saveWorkspace().
 
bool applyWorkspace (const QString &name)
 Brings back the arrangement stored under name - see QxWorkspaceManager::applyWorkspace().
 
QxCore::QxSettings * settings () const
 The settings object backing persistence; created on first use from the application name and owned by the shell.
 
void setSettings (QxCore ::QxSettings *settings)
 Replaces the settings object; ownership is transferred to the shell.
 
void saveLayout ()
 Stores the geometry, the dock layout and the current page.
 
void restoreLayout ()
 Restores whatever saveLayout() stored.
 
bool autoSaveLayout () const
 Whether closeEvent() calls saveLayout(); true by default.
 
void setAutoSaveLayout (bool on)
 
void setCurrentPage (int index)
 Brings the page at the given index to the front.
 
void setCurrentPage (const QString &id)
 Brings the page with id to the front.
 
void currentPageChanged (int index, const QString &id)
 Emitted when the page on screen changes, which also covers the case where another page was inserted or removed and the index of the visible page shifted.
 
- Public 成员函数 继承自 QxApp::RibbonAppWindow
 RibbonAppWindow (QWidget *parent=0, Qt::WindowFlags flags=Qt::WindowFlags())
 
 ~RibbonAppWindow () override
 
void updateWindowFlags (Qt::WindowFlags flags) override
 

Protected 成员函数

void closeEvent (QCloseEvent *event) override
 
- Protected 成员函数 继承自 QxApp::RibbonAppWindow
virtual bool event (QEvent *e) override
 

详细描述

The window skeleton of a ribbon application.

It is a RibbonAppWindow - so it already carries the ribbon, the window agent and a state bar - with the three parts every application otherwise rebuilds by hand:

  • a navigation rail (QxNavigationBar) on the left edge,
  • a page stack in the middle, one page per rail entry,
  • a qxdock DockWindow whose docks surround the pages.

On top of that it plugs the shell into the rest of the framework: the status bar gets a message line and a busy indicator, and saveLayout()/restoreLayout() keep the geometry, the dock layout and the selected page in a QxSettings object.

Typical use:

QxAppShell shell;
shell.addPage(QStringLiteral("home"), homeIcon, tr("Home"), new HomePage);
shell.addPage(QStringLiteral("log"), logIcon, tr("Log"), new LogPage);
shell.addDock(Qx::BottomDockWidgetArea, QStringLiteral("output"), tr("Output"), new OutputView);
shell.setStatusMessage(tr("Ready"));
shell.restoreLayout(); // after every page and dock exists
shell.show();
The window skeleton of a ribbon application.
Definition qxappshell.h:69
void setStatusMessage(const QString &message)
Text of the permanent message line at the left of the status bar.
void restoreLayout()
Restores whatever saveLayout() stored.
void addPage(const QString &id, const QIcon &icon, const QString &title, QWidget *page)
Adds a page at the end of the workspace and an entry with the same icon and title to the rail.
QxDock::DockWidget * addDock(Qx::DockWidgetArea area, const QString &id, const QString &title, QWidget *widget)
Creates a dock widget named id, titles it title, fills it with widget and drops it in area.
@ BottomDockWidgetArea

Pages are pages of a QStackedWidget, not dock widgets: they are the fixed workspace in the middle, while the docks around them can be moved, floated and closed as usual.

在文件 qxappshell.h 第 68 行定义.

构造及析构函数说明

◆ QxAppShell()

QxApp::QxAppShell::QxAppShell ( QWidget *  parent = 0)
explicit

在文件 qxappshell.cpp 第 220 行定义.

◆ ~QxAppShell()

QxApp::QxAppShell::~QxAppShell ( )
override

在文件 qxappshell.cpp 第 229 行定义.

成员函数说明

◆ addDock()

QxDock::DockWidget * QxApp::QxAppShell::addDock ( Qx::DockWidgetArea  area,
const QString &  id,
const QString &  title,
QWidget *  widget 
)

Creates a dock widget named id, titles it title, fills it with widget and drops it in area.

The id is stored as the object name, which is what dock() and the persisted layout use.

Returns null when id is empty or already in use.

在文件 qxappshell.cpp 第 376 行定义.

◆ addPage()

void QxApp::QxAppShell::addPage ( const QString &  id,
const QIcon &  icon,
const QString &  title,
QWidget *  page 
)

Adds a page at the end of the workspace and an entry with the same icon and title to the rail.

The id addresses the page in the configuration file, so it has to be stable and unique; the shell takes ownership of page while it is installed.

The first page added becomes the current one.

在文件 qxappshell.cpp 第 246 行定义.

◆ applyWorkspace()

bool QxApp::QxAppShell::applyWorkspace ( const QString &  name)

Brings back the arrangement stored under name - see QxWorkspaceManager::applyWorkspace().

Returns false when there is no such workspace.

if (!shell.applyWorkspace(QStringLiteral("Writing"))) {
shell.showToast(tr("That layout is gone"), QxToast::Warning);
}

在文件 qxappshell.cpp 第 530 行定义.

◆ autoSaveLayout()

bool QxApp::QxAppShell::autoSaveLayout ( ) const

Whether closeEvent() calls saveLayout(); true by default.

在文件 qxappshell.cpp 第 593 行定义.

◆ clearProgress()

void QxApp::QxAppShell::clearProgress ( )

Hides the indicator and puts the progress back at the minimum.

在文件 qxappshell.cpp 第 486 行定义.

◆ closeEvent()

void QxApp::QxAppShell::closeEvent ( QCloseEvent *  event)
overrideprotected

在文件 qxappshell.cpp 第 627 行定义.

◆ currentPage()

QWidget * QxApp::QxAppShell::currentPage ( ) const

在文件 qxappshell.cpp 第 370 行定义.

◆ currentPageChanged()

void QxApp::QxAppShell::currentPageChanged ( int  index,
const QString &  id 
)

Emitted when the page on screen changes, which also covers the case where another page was inserted or removed and the index of the visible page shifted.

id is the stable name of the page, empty when there is none.

◆ currentPageId()

QString QxApp::QxAppShell::currentPageId ( ) const

在文件 qxappshell.cpp 第 364 行定义.

◆ currentPageIndex()

int QxApp::QxAppShell::currentPageIndex ( ) const

在文件 qxappshell.cpp 第 358 行定义.

◆ dock()

QxDock::DockWidget * QxApp::QxAppShell::dock ( const QString &  id) const

The dock widget created with addDock() under id, or null.

在文件 qxappshell.cpp 第 398 行定义.

◆ dockWindow()

QxDock::DockWindow * QxApp::QxAppShell::dockWindow ( ) const

The dock area; owned by the shell.

在文件 qxappshell.cpp 第 240 行定义.

◆ indexOfPage()

int QxApp::QxAppShell::indexOfPage ( const QString &  id) const

Index of the page with id, or -1 when there is no such page.

在文件 qxappshell.cpp 第 336 行定义.

◆ insertPage()

void QxApp::QxAppShell::insertPage ( int  index,
const QString &  id,
const QIcon &  icon,
const QString &  title,
QWidget *  page 
)

Inserts a page at the given index of the workspace and of the rail.

在文件 qxappshell.cpp 第 252 行定义.

◆ isBusy()

bool QxApp::QxAppShell::isBusy ( ) const

在文件 qxappshell.cpp 第 432 行定义.

◆ isProgressVisible()

bool QxApp::QxAppShell::isProgressVisible ( ) const

Whether the indicator is up, in either of its two modes.

The question is about the indicator, not about the window: a hidden window leaves the answer where the last call put it.

在文件 qxappshell.cpp 第 494 行定义.

◆ navigationBar()

QxNavigationBar * QxApp::QxAppShell::navigationBar ( ) const

The navigation rail; owned by the shell.

在文件 qxappshell.cpp 第 234 行定义.

◆ page()

QWidget * QxApp::QxAppShell::page ( const QString &  id) const

The page widget with id, or null.

在文件 qxappshell.cpp 第 348 行定义.

◆ pageCount()

int QxApp::QxAppShell::pageCount ( ) const

在文件 qxappshell.cpp 第 330 行定义.

◆ pageId()

QString QxApp::QxAppShell::pageId ( int  index) const

Id of the page at the given index, or an empty string.

在文件 qxappshell.cpp 第 342 行定义.

◆ progress()

int QxApp::QxAppShell::progress ( ) const

在文件 qxappshell.cpp 第 480 行定义.

◆ progressMaximum()

int QxApp::QxAppShell::progressMaximum ( ) const

在文件 qxappshell.cpp 第 459 行定义.

◆ progressMinimum()

int QxApp::QxAppShell::progressMinimum ( ) const

在文件 qxappshell.cpp 第 453 行定义.

◆ removePage()

void QxApp::QxAppShell::removePage ( const QString &  id)

Removes the page with id and its rail entry.

The page widget is only taken out of the shell - it stays alive and the caller owns it again.

在文件 qxappshell.cpp 第 296 行定义.

◆ restoreLayout()

void QxApp::QxAppShell::restoreLayout ( )

Restores whatever saveLayout() stored.

Missing or stale values are skipped, so calling it on a fresh installation is harmless.

在文件 qxappshell.cpp 第 568 行定义.

◆ saveLayout()

void QxApp::QxAppShell::saveLayout ( )

Stores the geometry, the dock layout and the current page.

在文件 qxappshell.cpp 第 555 行定义.

◆ saveWorkspace()

bool QxApp::QxAppShell::saveWorkspace ( const QString &  name)

Stores the current arrangement under name - see QxWorkspaceManager::saveWorkspace().

Returns false for an empty name.

在文件 qxappshell.cpp 第 524 行定义.

◆ setAutoSaveLayout()

void QxApp::QxAppShell::setAutoSaveLayout ( bool  on)

在文件 qxappshell.cpp 第 599 行定义.

◆ setBusy()

void QxApp::QxAppShell::setBusy ( bool  busy)

Shows or hides the busy indicator in the status bar.

It is a bar without a percentage: the shell only reports "working", the caller knows how far the work is.

The indicator is one widget with two modes, and the last call wins: setting a progress takes it over, and going busy takes it back.

在文件 qxappshell.cpp 第 416 行定义.

◆ setCurrentPage() [1/2]

void QxApp::QxAppShell::setCurrentPage ( const QString &  id)

Brings the page with id to the front.

Unknown id: no-op.

在文件 qxappshell.cpp 第 617 行定义.

◆ setCurrentPage() [2/2]

void QxApp::QxAppShell::setCurrentPage ( int  index)

Brings the page at the given index to the front.

Out of range: no-op.

在文件 qxappshell.cpp 第 605 行定义.

◆ setProgress()

void QxApp::QxAppShell::setProgress ( int  value)

Shows how far the work has got, which also shows the indicator - setting a progress means wanting it seen.

value is clamped to the range.

shell.setStatusMessage(tr("Copying..."));
shell.setProgressRange(0, files.count());
for (...) { copy(); shell.setProgress(++done); }
shell.clearProgress();

在文件 qxappshell.cpp 第 465 行定义.

◆ setProgressRange()

void QxApp::QxAppShell::setProgressRange ( int  minimum,
int  maximum 
)

Range the progress runs in, 0 to 100 by default.

The range is remembered and applied the next time a progress is shown, so changing it while the busy indicator is up does not turn that indicator into a bar at zero.

在文件 qxappshell.cpp 第 438 行定义.

◆ setSettings()

void QxApp::QxAppShell::setSettings ( QxCore ::QxSettings *  settings)

Replaces the settings object; ownership is transferred to the shell.

Unlike the theme manager this does not apply anything: a layout can only be restored once the pages and docks it refers to exist, so call restoreLayout() yourself, after the shell has been built.

在文件 qxappshell.cpp 第 542 行定义.

◆ setStatusMessage()

void QxApp::QxAppShell::setStatusMessage ( const QString &  message)

Text of the permanent message line at the left of the status bar.

在文件 qxappshell.cpp 第 404 行定义.

◆ settings()

QxCore::QxSettings * QxApp::QxAppShell::settings ( ) const

The settings object backing persistence; created on first use from the application name and owned by the shell.

在文件 qxappshell.cpp 第 536 行定义.

◆ showToast()

QxToast * QxApp::QxAppShell::showToast ( const QString &  text,
QxToast::Level  level = QxToast::Information,
int  timeoutMs = QxToast::DefaultTimeout 
)

Puts a toast over the shell and returns it, so that a caller who needs to can hold on to it or dismiss it early.

shell.showToast(tr("The document was saved"), QxToast::Success);

在文件 qxappshell.cpp 第 506 行定义.

◆ statusMessage()

QString QxApp::QxAppShell::statusMessage ( ) const

在文件 qxappshell.cpp 第 410 行定义.

◆ toastManager()

QxToastManager * QxApp::QxAppShell::toastManager ( ) const

The stack of toasts that shows up over the shell, created on first use and owned by the shell.

A shell is a plain window, so it never asks for the object itself before someone has something to say; once it exists, every showToast() lands in it - see QxToastManager for the stacking, the timeout and the placement.

在文件 qxappshell.cpp 第 500 行定义.

◆ workspaceManager()

QxWorkspaceManager * QxApp::QxAppShell::workspaceManager ( ) const

The named layouts of this shell, created on first use and owned by it.

A shell persists one layout - the one saveLayout() writes - and that is enough for "start where I left off". The manager adds the cases that need a name: keeping two arrangements apart and asking for one back. See QxWorkspaceManager for what a workspace holds and, more to the point, what it does not.

在文件 qxappshell.cpp 第 512 行定义.

◆ workspaceNames()

QStringList QxApp::QxAppShell::workspaceNames ( ) const

Names of the stored workspaces, in the order they were saved.

在文件 qxappshell.cpp 第 518 行定义.


该类的文档由以下文件生成: