QtCanpool 3.3.0
载入中...
搜索中...
未找到
qxappshell.cpp
浏览该文件的文档.
1
5#include "qxappshell.h"
6#include "qxnavigationbar.h"
7#include "qxtoastmanager.h"
9
10#include "qxcore/qxsettings.h"
11#include "qxdock/dockwidget.h"
12#include "qxdock/dockwindow.h"
13
14#include <QtCore/QCoreApplication>
15#include <QtCore/QDebug>
16#include <QtCore/QSignalBlocker>
17#include <QtCore/QStringList>
18#include <QtCore/QVector>
19#include <QtGui/QCloseEvent>
20#include <QtWidgets/QHBoxLayout>
21#include <QtWidgets/QLabel>
22#include <QtWidgets/QProgressBar>
23#include <QtWidgets/QStackedWidget>
24#include <QtWidgets/QStatusBar>
25
29
31
33#ifndef QX_APP_FALLBACK_ORGANIZATION
34#define QX_APP_FALLBACK_ORGANIZATION "qtcanpool"
35#endif
36
37namespace
38{
39
40const char *const kGroup = "ui";
41const char *const kGeometryKey = "windowGeometry";
42const char *const kWindowStateKey = "windowState";
43const char *const kDockStateKey = "dockState";
44const char *const kCurrentPageKey = "currentPage";
45
47const int kProgressWidth = 140;
48
49} // namespace
50
51class QxAppShellPrivate
52{
53 QX_DECLARE_PUBLIC(QxAppShell)
54public:
56 struct Page {
57 QString id;
58 QString title;
59 QIcon icon;
60 QWidget *m_widget = Q_NULLPTR;
61 };
62
63 QxAppShellPrivate();
64 void init();
70 void resyncCurrentPage(int previousIndex, const QString &previousId);
71 int indexOfPage(const QString &id) const;
72 QString pageId(int index) const;
74 QX_CORE_PREPEND_NAMESPACE(QxSettings) * ensureSettings() const;
76 QxToastManager *ensureToastManager() const;
78 QxWorkspaceManager *ensureWorkspaceManager() const;
79public:
80 QxNavigationBar *m_navigationBar = Q_NULLPTR;
82 QStackedWidget *m_pageStack = Q_NULLPTR;
83 QLabel *m_statusLabel = Q_NULLPTR;
84 QProgressBar *m_progress = Q_NULLPTR;
85 QVector<Page> m_pages;
86 mutable QX_CORE_PREPEND_NAMESPACE(QxSettings) *m_settings = Q_NULLPTR;
87 mutable QxToastManager *m_toastManager = Q_NULLPTR;
88 mutable QxWorkspaceManager *m_workspaceManager = Q_NULLPTR;
90 mutable QxPlugin::QxPluginContext *m_context = Q_NULLPTR;
91 int m_currentIndex = -1;
92 bool m_busy = false;
93 bool m_autoSaveLayout = true;
94 int m_progressMinimum = 0;
95 int m_progressMaximum = 100;
96
98 ~QxAppShellPrivate();
99};
100
101QxAppShellPrivate::QxAppShellPrivate() = default;
102
103QxAppShellPrivate::~QxAppShellPrivate()
104{
105 delete m_context;
106}
107
116class QxAppShellContext : public QxPlugin::QxPluginContext
117{
118public:
119 explicit QxAppShellContext(QxAppShell *shell)
120 : m_shell(shell)
121 {
122 }
123
124 void addPage(const QString &id, const QIcon &icon, const QString &title, QWidget *page) override
125 {
126 m_shell->addPage(id, icon, title, page);
127 }
128
129 void setCurrentPage(const QString &id) override
130 {
131 m_shell->setCurrentPage(id);
132 }
133
134 QString currentPageId() const override
135 {
136 return m_shell->currentPageId();
137 }
138
139 QWidget *addDock(QxPlugin::QxPluginContext::DockArea area, const QString &id, const QString &title,
140 QWidget *widget) override
141 {
142 // The context area bits mirror Qx::DockWidgetArea, so the cast is exact.
143 return m_shell->addDock(static_cast<Qx::DockWidgetArea>(area), id, title, widget);
144 }
145
146 void setStatusMessage(const QString &message) override
147 {
148 m_shell->setStatusMessage(message);
149 }
150
151 void setBusy(bool busy) override
152 {
153 m_shell->setBusy(busy);
154 }
155
156 void setProgressRange(int minimum, int maximum) override
157 {
158 m_shell->setProgressRange(minimum, maximum);
159 }
160
161 void setProgress(int value) override
162 {
163 m_shell->setProgress(value);
164 }
165
166 void clearProgress() override
167 {
168 m_shell->clearProgress();
169 }
170
171 void showToast(const QString &text, QxPlugin::QxPluginContext::ToastLevel level, int timeoutMs) override
172 {
173 // The context levels mirror QxToast::Level in order, so the cast is exact.
174 m_shell->showToast(text, static_cast<QxToast::Level>(level), timeoutMs);
175 }
176
178 {
179 return m_shell->settings();
180 }
181private:
182 QxAppShell *m_shell;
183};
184
185void QxAppShellPrivate::init()
186{
187 Q_Q(QxAppShell);
188
189 // The rail and the dock area share the window's central widget, with the
190 // rail pinned to the left edge, so the docks stay inside the dock area.
191 QWidget *central = new QWidget(q);
192 QHBoxLayout *layout = new QHBoxLayout(central);
193 layout->setContentsMargins(0, 0, 0, 0);
194 layout->setSpacing(0);
195
196 m_navigationBar = new QxNavigationBar(central);
197 layout->addWidget(m_navigationBar);
198
199 m_dockWindow = new DockWindow(central);
200 layout->addWidget(m_dockWindow, 1);
201
202 q->setCentralWidget(central);
203
204 // The pages are the dock window's central widget, so every dock added
205 // later ends up around them. qxdock requires the central widget to be the
206 // very first dock widget, hence the order here.
207 m_pageStack = new QStackedWidget();
208 DockWidget *workspace = new DockWidget(QString());
209 workspace->setObjectName(QStringLiteral("qxapp_workspace"));
210 workspace->setWidget(m_pageStack);
211 m_dockWindow->setCentralWidget(workspace);
212
213 QObject::connect(m_navigationBar, &QxNavigationBar::currentChanged, q, [this](int index) {
214 if (index < -1 || index >= m_pages.count()) {
215 return;
216 }
217 const int previousIndex = m_currentIndex;
218 const QString previousId = pageId(previousIndex);
219 m_currentIndex = index;
220 resyncCurrentPage(previousIndex, previousId);
221 });
222
223 // Status bar: a permanent message line plus an indicator that only shows up
224 // while the shell is busy.
225 m_statusLabel = new QLabel(q->statusBar());
226 q->statusBar()->addWidget(m_statusLabel, 1);
227
228 m_progress = new QProgressBar(q->statusBar());
229 m_progress->setRange(0, 0);
230 m_progress->setTextVisible(false);
231 m_progress->setFixedWidth(kProgressWidth);
232 m_progress->hide();
233 q->statusBar()->addPermanentWidget(m_progress);
234}
235
236void QxAppShellPrivate::resyncCurrentPage(int previousIndex, const QString &previousId)
237{
238 Q_Q(QxAppShell);
239
240 {
241 // The rail is an output here, not an input: writing the index back must
242 // not run the selection logic a second time.
243 const QSignalBlocker blocker(m_navigationBar);
244 m_navigationBar->setCurrentIndex(m_currentIndex);
245 }
246 if (m_currentIndex >= 0) {
247 m_pageStack->setCurrentIndex(m_currentIndex);
248 }
249
250 const QString id = pageId(m_currentIndex);
251 if (m_currentIndex != previousIndex || id != previousId) {
252 Q_EMIT q->currentPageChanged(m_currentIndex, id);
253 }
254}
255
256int QxAppShellPrivate::indexOfPage(const QString &id) const
257{
258 for (int i = 0; i < m_pages.count(); ++i) {
259 if (m_pages.at(i).id == id) {
260 return i;
261 }
262 }
263 return -1;
264}
265
266QString QxAppShellPrivate::pageId(int index) const
267{
268 if (index < 0 || index >= m_pages.count()) {
269 return QString();
270 }
271 return m_pages.at(index).id;
272}
273
274QX_CORE_PREPEND_NAMESPACE(QxSettings) * QxAppShellPrivate::ensureSettings() const
275{
276 if (!m_settings) {
277 QString organization = QCoreApplication::organizationName();
278 if (organization.isEmpty()) {
279 organization = QString::fromLatin1(QX_APP_FALLBACK_ORGANIZATION);
280 }
281 QString application = QCoreApplication::applicationName();
282 if (application.isEmpty()) {
283 application = organization;
284 }
285 m_settings = new QX_CORE_PREPEND_NAMESPACE(QxSettings)(organization, application, q_ptr);
286 }
287 return m_settings;
288}
289
290QxToastManager *QxAppShellPrivate::ensureToastManager() const
291{
292 if (!m_toastManager) {
293 // The toasts are children of the shell, which is what puts them above
294 // the ribbon, the rail and the docks without touching a window manager.
295 m_toastManager = new QxToastManager(q_ptr, q_ptr);
296 }
297 return m_toastManager;
298}
299
300QxWorkspaceManager *QxAppShellPrivate::ensureWorkspaceManager() const
301{
302 if (!m_workspaceManager) {
303 m_workspaceManager = new QxWorkspaceManager(q_ptr, q_ptr);
304 }
305 return m_workspaceManager;
306}
307
308QxAppShell::QxAppShell(QWidget *parent)
309 : RibbonAppWindow(parent)
310 , d_ptr(new QxAppShellPrivate())
311{
312 d_ptr->setPublic(this);
313 Q_D(QxAppShell);
314 d->init();
315}
316
321
323{
324 Q_D(const QxAppShell);
325 if (!d->m_context) {
326 // The adapter lives as long as the shell; const_cast is safe because the
327 // shell is the owner and the adapter only reads through the public API.
328 d->m_context = new QxAppShellContext(const_cast<QxAppShell *>(this));
329 }
330 return d->m_context;
331}
332
334{
335 Q_D(const QxAppShell);
336 return d->m_navigationBar;
337}
338
340{
341 Q_D(const QxAppShell);
342 return d->m_dockWindow;
343}
344
345void QxAppShell::addPage(const QString &id, const QIcon &icon, const QString &title, QWidget *page)
346{
347 Q_D(QxAppShell);
348 insertPage(d->m_pages.count(), id, icon, title, page);
349}
350
351void QxAppShell::insertPage(int index, const QString &id, const QIcon &icon, const QString &title, QWidget *page)
352{
353 Q_D(QxAppShell);
354 if (!page || index < 0 || index > d->m_pages.count()) {
355 return;
356 }
357 if (id.isEmpty()) {
358 qWarning("QxAppShell: a page needs a non-empty id");
359 return;
360 }
361 if (d->indexOfPage(id) >= 0) {
362 qWarning("QxAppShell: a page with id '%s' already exists", qPrintable(id));
363 return;
364 }
365
366 QxAppShellPrivate::Page entry;
367 entry.id = id;
368 entry.title = title;
369 entry.icon = icon;
370 entry.m_widget = page;
371
372 const bool wasEmpty = d->m_pages.isEmpty();
373 const int current = d->m_currentIndex;
374 const QString previous = d->pageId(current);
375
376 d->m_pages.insert(index, entry);
377 d->m_pageStack->insertWidget(index, page);
378 {
379 // The rail is rebuilt underneath us, so its signal must not drive the
380 // selection while the page list is only half updated.
381 const QSignalBlocker blocker(d->m_navigationBar);
382 d->m_navigationBar->insertItem(index, icon, title);
383 }
384
385 if (wasEmpty) {
386 // The first page of a shell has nothing to compete with.
387 d->m_currentIndex = index;
388 } else if (index <= current) {
389 // The page that was on screen kept its identity but moved up by one.
390 d->m_currentIndex = current + 1;
391 }
392 d->resyncCurrentPage(current, previous);
393}
394
395void QxAppShell::removePage(const QString &id)
396{
397 Q_D(QxAppShell);
398 const int index = d->indexOfPage(id);
399 if (index < 0) {
400 return;
401 }
402
403 const int current = d->m_currentIndex;
404 const QString previous = d->pageId(current);
405
406 QWidget *page = d->m_pages.at(index).m_widget;
407 d->m_pages.removeAt(index);
408 d->m_pageStack->removeWidget(page);
409 if (page) {
410 // Out of the shell the caller owns the page again; it is only hidden.
411 page->setParent(Q_NULLPTR);
412 }
413 {
414 const QSignalBlocker blocker(d->m_navigationBar);
415 d->m_navigationBar->removeItem(index);
416 }
417
418 if (d->m_pages.isEmpty()) {
419 d->m_currentIndex = -1;
420 } else if (index < current) {
421 d->m_currentIndex = current - 1;
422 } else if (index == current) {
423 // The visible page is gone: fall back to the one that took its place.
424 d->m_currentIndex = qMin(current, d->m_pages.count() - 1);
425 }
426 d->resyncCurrentPage(current, previous);
427}
428
430{
431 Q_D(const QxAppShell);
432 return d->m_pages.count();
433}
434
435int QxAppShell::indexOfPage(const QString &id) const
436{
437 Q_D(const QxAppShell);
438 return d->indexOfPage(id);
439}
440
441QString QxAppShell::pageId(int index) const
442{
443 Q_D(const QxAppShell);
444 return d->pageId(index);
445}
446
447QWidget *QxAppShell::page(const QString &id) const
448{
449 Q_D(const QxAppShell);
450 const int index = d->indexOfPage(id);
451 if (index < 0) {
452 return Q_NULLPTR;
453 }
454 return d->m_pages.at(index).m_widget;
455}
456
458{
459 Q_D(const QxAppShell);
460 return d->m_currentIndex;
461}
462
464{
465 Q_D(const QxAppShell);
466 return d->pageId(d->m_currentIndex);
467}
468
470{
471 Q_D(const QxAppShell);
472 return d->m_currentIndex >= 0 ? d->m_pages.at(d->m_currentIndex).m_widget : Q_NULLPTR;
473}
474
476 const QString &title, QWidget *widget)
477{
478 Q_D(QxAppShell);
479 if (id.isEmpty()) {
480 qWarning("QxAppShell: a dock needs a non-empty id");
481 return Q_NULLPTR;
482 }
483 if (d->m_dockWindow->findDockWidget(id)) {
484 qWarning("QxAppShell: a dock with id '%s' already exists", qPrintable(id));
485 return Q_NULLPTR;
486 }
487
488 DockWidget *dock = new DockWidget(title);
489 dock->setObjectName(id);
490 if (widget) {
491 dock->setWidget(widget);
492 }
493 d->m_dockWindow->addDockWidget(area, dock);
494 return dock;
495}
496
498{
499 Q_D(const QxAppShell);
500 return d->m_dockWindow->findDockWidget(id);
501}
502
503void QxAppShell::setStatusMessage(const QString &message)
504{
505 Q_D(QxAppShell);
506 d->m_statusLabel->setText(message);
507}
508
510{
511 Q_D(const QxAppShell);
512 return d->m_statusLabel->text();
513}
514
515void QxAppShell::setBusy(bool busy)
516{
517 Q_D(QxAppShell);
518 if (d->m_busy == busy) {
519 return;
520 }
521 d->m_busy = busy;
522 if (busy) {
523 // A marquee: the bar has no percentage to show, and QProgressBar reads
524 // a range of its own minimum as "unknown".
525 d->m_progress->setRange(0, 0);
526 d->m_progress->setTextVisible(false);
527 }
528 d->m_progress->setVisible(busy);
529}
530
532{
533 Q_D(const QxAppShell);
534 return d->m_busy;
535}
536
537void QxAppShell::setProgressRange(int minimum, int maximum)
538{
539 Q_D(QxAppShell);
540 if (maximum <= minimum) {
541 // A range of zero width is the busy indicator's own signal, not a range.
542 qWarning("QxAppShell: a progress range has to run to a maximum above %d", minimum);
543 return;
544 }
545 d->m_progressMinimum = minimum;
546 d->m_progressMaximum = maximum;
547 if (!d->m_busy) {
548 d->m_progress->setRange(minimum, maximum);
549 }
550}
551
553{
554 Q_D(const QxAppShell);
555 return d->m_progressMinimum;
556}
557
559{
560 Q_D(const QxAppShell);
561 return d->m_progressMaximum;
562}
563
565{
566 Q_D(QxAppShell);
567 // The indicator is shared with the busy marquee, so showing a progress is
568 // also saying the work is no longer of unknown length.
569 d->m_busy = false;
570 d->m_progress->setRange(d->m_progressMinimum, d->m_progressMaximum);
571 d->m_progress->setTextVisible(true);
572 // Clamped here rather than left to QProgressBar, which draws a clamped bar
573 // but keeps the value it was handed - so progress() would report a number
574 // nobody can see.
575 d->m_progress->setValue(qBound(d->m_progressMinimum, value, d->m_progressMaximum));
576 d->m_progress->setVisible(true);
577}
578
580{
581 Q_D(const QxAppShell);
582 return d->m_progress->value();
583}
584
586{
587 Q_D(QxAppShell);
588 d->m_busy = false;
589 d->m_progress->setValue(d->m_progressMinimum);
590 d->m_progress->setVisible(false);
591}
592
594{
595 Q_D(const QxAppShell);
596 return d->m_progress->isVisibleTo(d->m_progress->parentWidget());
597}
598
600{
601 Q_D(const QxAppShell);
602 return d->ensureToastManager();
603}
604
605QxToast *QxAppShell::showToast(const QString &text, QxToast::Level level, int timeoutMs)
606{
607 Q_D(QxAppShell);
608 return d->ensureToastManager()->show(text, level, timeoutMs);
609}
610
612{
613 Q_D(const QxAppShell);
614 return d->ensureWorkspaceManager();
615}
616
617QStringList QxAppShell::workspaceNames() const
618{
619 Q_D(const QxAppShell);
620 return d->ensureWorkspaceManager()->workspaceNames();
621}
622
623bool QxAppShell::saveWorkspace(const QString &name)
624{
625 Q_D(QxAppShell);
626 return d->ensureWorkspaceManager()->saveWorkspace(name);
627}
628
630{
631 Q_D(QxAppShell);
632 return d->ensureWorkspaceManager()->applyWorkspace(name);
633}
634
636{
637 Q_D(const QxAppShell);
638 return d->ensureSettings();
639}
640
642{
643 Q_D(QxAppShell);
644 if (d->m_settings == settings) {
645 return;
646 }
647 delete d->m_settings;
648 d->m_settings = settings;
649 if (d->m_settings) {
650 d->m_settings->setParent(this);
651 }
652}
653
655{
656 Q_D(QxAppShell);
657 QX_CORE_PREPEND_NAMESPACE(QxSettings) *settings = d->ensureSettings();
658 settings->beginGroup(QString::fromLatin1(kGroup));
659 settings->setValue(QString::fromLatin1(kGeometryKey), saveGeometry());
660 settings->setValue(QString::fromLatin1(kWindowStateKey), QMainWindow::saveState());
661 settings->setValue(QString::fromLatin1(kDockStateKey), d->m_dockWindow->saveState());
662 settings->setValue(QString::fromLatin1(kCurrentPageKey), currentPageId());
664 settings->sync();
665}
666
668{
669 Q_D(QxAppShell);
670 QX_CORE_PREPEND_NAMESPACE(QxSettings) *settings = d->ensureSettings();
671 settings->beginGroup(QString::fromLatin1(kGroup));
672 const QByteArray geometry = settings->value(QString::fromLatin1(kGeometryKey)).toByteArray();
673 const QByteArray windowState = settings->value(QString::fromLatin1(kWindowStateKey)).toByteArray();
674 const QByteArray dockState = settings->value(QString::fromLatin1(kDockStateKey)).toByteArray();
675 const QString pageId = settings->stringValue(QString::fromLatin1(kCurrentPageKey));
677
678 if (!geometry.isEmpty()) {
679 restoreGeometry(geometry);
680 }
681 if (!windowState.isEmpty()) {
682 QMainWindow::restoreState(windowState);
683 }
684 if (!dockState.isEmpty()) {
685 d->m_dockWindow->restoreState(dockState);
686 }
687 if (!pageId.isEmpty()) {
689 }
690}
691
693{
694 Q_D(const QxAppShell);
695 return d->m_autoSaveLayout;
696}
697
699{
700 Q_D(QxAppShell);
701 d->m_autoSaveLayout = on;
702}
703
705{
706 Q_D(QxAppShell);
707 if (index < 0 || index >= d->m_pages.count()) {
708 return;
709 }
710 const int previousIndex = d->m_currentIndex;
711 const QString previousId = d->pageId(previousIndex);
712 d->m_currentIndex = index;
713 d->resyncCurrentPage(previousIndex, previousId);
714}
715
716void QxAppShell::setCurrentPage(const QString &id)
717{
718 Q_D(QxAppShell);
719 const int index = d->indexOfPage(id);
720 if (index < 0) {
721 return;
722 }
723 setCurrentPage(index);
724}
725
726void QxAppShell::closeEvent(QCloseEvent *event)
727{
728 Q_D(QxAppShell);
729 if (d->m_autoSaveLayout) {
730 saveLayout();
731 }
732 RibbonAppWindow::closeEvent(event);
733}
734
The window skeleton of a ribbon application.
Definition qxappshell.h:70
void setBusy(bool busy)
Shows or hides the busy indicator in the status bar.
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.
QxPlugin::QxPluginContext * pluginContext() const
Returns the QxPluginContext adapter.
void setStatusMessage(const QString &message)
Text of the permanent message line at the left of the status bar.
void closeEvent(QCloseEvent *event) override
int progressMaximum() const
int progressMinimum() const
void restoreLayout()
Restores whatever saveLayout() stored.
QWidget * page(const QString &id) const
The page widget with id, or null.
QString statusMessage() const
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.
bool isBusy() const
bool saveWorkspace(const QString &name)
Stores the current arrangement under name - see QxWorkspaceManager::saveWorkspace().
QxWorkspaceManager * workspaceManager() const
The named layouts of this shell, created on first use and owned by it.
int progress() const
int currentPageIndex() const
QStringList workspaceNames() const
Names of the stored workspaces, in the order they were saved.
void setProgressRange(int minimum, int maximum)
Range the progress runs in, 0 to 100 by default.
bool isProgressVisible() const
Whether the indicator is up, in either of its two modes.
QString pageId(int index) const
Id of the page at the given index, or an empty string.
void saveLayout()
Stores the geometry, the dock layout and the current page.
QString currentPageId() const
int indexOfPage(const QString &id) const
Index of the page with id, or -1 when there is no such page.
QxNavigationBar * navigationBar() const
The navigation rail; owned by the shell.
void clearProgress()
Hides the indicator and puts the progress back at the minimum.
void setAutoSaveLayout(bool on)
bool autoSaveLayout() const
Whether closeEvent() calls saveLayout(); true by default.
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.
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 dismis...
bool applyWorkspace(const QString &name)
Brings back the arrangement stored under name - see QxWorkspaceManager::applyWorkspace().
void removePage(const QString &id)
Removes the page with id and its rail entry.
QxDock::DockWidget * dock(const QString &id) const
The dock widget created with addDock() under id, or null.
QxToastManager * toastManager() const
The stack of toasts that shows up over the shell, created on first use and owned by the shell.
int pageCount() const
void setCurrentPage(int index)
Brings the page at the given index to the front.
void setSettings(QxCore ::QxSettings *settings)
Replaces the settings object; ownership is transferred to the shell.
~QxAppShell() override
void setProgress(int value)
Shows how far the work has got, which also shows the indicator - setting a progress means wanting it ...
QWidget * currentPage() const
QxCore::QxSettings * settings() const
The settings object backing persistence; created on first use from the application name and owned by ...
A vertical rail of exclusive, checkable entries.
The stack of toasts of one window.
One short message, shown over the window it belongs to and gone a few seconds later.
Definition qxtoast.h:54
Level
What the message is about; it selects the icon and the accent colour.
Definition qxtoast.h:58
The named layouts of one shell.
virtual bool event(QEvent *e) override
Thin wrapper around QSettings that keeps call sites free of the usual boilerplate: typed accessors wi...
Definition qxsettings.h:32
QSettings * settings() const
The underlying QSettings instance, never null.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
QString stringValue(const QString &key, const QString &defaultValue=QString()) const
void beginGroup(const QString &prefix)
void setValue(const QString &key, const QVariant &value)
The DockWidget class provides a widget that can be docked inside a DockWindow or floated as a top-lev...
Definition dockwidget.h:31
void setWidget(QWidget *w, WidgetInsertMode insertMode=AutoScrollArea)
Sets the widget for the dock widget to widget.
The central dock window that maintains the complete docking system.
Definition dockwindow.h:36
The thin surface a plugin programs against.
virtual void setStatusMessage(const QString &message)=0
Replaces the host's persistent status-line message.
ToastLevel
Toast severity understood by every host.
virtual QString currentPageId() const =0
Id of the page currently on screen, or an empty string when there is none.
DockArea
Where a newly added dock lands.
virtual void setProgress(int value)=0
Shows how far the work has got, clamped to the range set by setProgressRange().
virtual void setBusy(bool busy)=0
Shows or hides the host's indeterminate "working" indicator.
virtual void showToast(const QString &text, ToastLevel level=ToastLevel::Information, int timeoutMs=-1)=0
Shows a toast over the host; timeoutMs < 0 means the host's default.
virtual QxCore::QxSettings * settings() const =0
The settings object backing persistence; never null.
virtual void addPage(const QString &id, const QIcon &icon, const QString &title, QWidget *page)=0
Adds a page to the host's central workspace and registers it under id, which must be stable and uniqu...
virtual void setProgressRange(int minimum, int maximum)=0
Sets the range the progress runs in; maximum must be above minimum.
virtual QWidget * addDock(DockArea area, const QString &id, const QString &title, QWidget *widget)=0
Creates a dock widget named id, titled title, filled with widget and dropped in area.
virtual void clearProgress()=0
Hides the progress or busy indicator and resets it to the minimum.
virtual void setCurrentPage(const QString &id)=0
Brings the page registered under id to the front.
DockWidgetArea
#define QX_APP_END_NAMESPACE
#define QX_DECLARE_PUBLIC(Class)
#define Q_NULLPTR
Copyleft (C) 2025 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
#define QX_APP_BEGIN_NAMESPACE
#define QX_FINI_PRIVATE()
#define QX_APP_FALLBACK_ORGANIZATION
Where settings land when the application never named itself.
#define QX_CORE_USE_NAMESPACE
#define QX_CORE_PREPEND_NAMESPACE(name)
#define QX_DOCK_USE_NAMESPACE
#define QX_DOCK_PREPEND_NAMESPACE(name)
QtMessageHandler previous
Definition qxlogger.cpp:28
#define QX_PLUGIN_USE_NAMESPACE
const char * name
Definition qxtheme.cpp:25
const char * id
Definition qxtheme.cpp:24
QColor text