2 * Copyright (C) 2014 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * This class lets the list of wizard pages be dynamic.
19 * - To add new ones, drop them into
20 * $XDG_DATA_DIRS/Wizard/Pages with a numbered prefix,
21 * like "21-custom-page.qml". The number determines the order in the page
22 * sequence that your page will appear.
23 * - To disable an existing page, add a file like "21-custom-page.qml.disabled"
24 * - To go to the next page, use pageStack.next()
25 * - To go back to the previous page, use pageStack.prev()
26 * - To load a page outside of the normal flow (so that it doesn't affect the
27 * back button), use pageStack.push(Qt.resolvedUrl("custom-page.qml")) in
29 * - See default pages for plenty of examples.
36#include <QStandardPaths>
38PageList::PageList(QObject *parent)
43 QString qmlSuffix = QStringLiteral(".qml");
44 QString disabledSuffix = QStringLiteral(".disabled");
45 QSet<QString> disabledPages;
48 if (!isRunningInstalled() && getenv("WIZARD_TESTING") == nullptr) {
49 dataDirs = QStringList() << qmlDirectory();
51 dataDirs = shellDataDirs();
54 Q_FOREACH(const QString &dataDir, dataDirs) {
55 QDir dir(dataDir + "/Wizard/Pages");
56 QStringList entries = dir.entryList(QStringList(QStringLiteral("[0-9]*")), QDir::Files | QDir::Readable);
57 Q_FOREACH(const QString &entry, entries) {
58 if (!m_pages.contains(entry) && entry.endsWith(qmlSuffix))
59 m_pages.insert(entry, dir.absoluteFilePath(entry));
60 else if (entry.endsWith(qmlSuffix + disabledSuffix))
61 disabledPages.insert(entry.left(entry.size() - disabledSuffix.size()));
65 // Now remove any explicitly disabled entries
66 Q_FOREACH(const QString &page, disabledPages) {
71QStringList PageList::entries() const
73 return m_pages.keys();
76QStringList PageList::paths() const
78 return m_pages.values();
81int PageList::index() const
86int PageList::numPages() const
88 return m_pages.size();
91QString PageList::prev()
94 return m_pages.values()[setIndex(m_index - 1)];
99QString PageList::next()
101 if (m_index < m_pages.count() - 1)
102 return m_pages.values()[setIndex(m_index + 1)];
107int PageList::setIndex(int index)
110 Q_EMIT indexChanged();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list