Simplify initialization of Qt Quick GUI
This commit is contained in:
parent
932dc9cb59
commit
fdd8e28474
25
qml/main.qml
25
qml/main.qml
|
@ -7,7 +7,6 @@ import org.kde.kirigami 2.4 as Kirigami
|
|||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
property alias showPasswordsOnFocus: showPasswordsOnFocusSwitch.checked
|
||||
property var entriesComponent: undefined
|
||||
|
||||
header: Kirigami.ApplicationHeader {
|
||||
}
|
||||
|
@ -87,21 +86,7 @@ Kirigami.ApplicationWindow {
|
|||
contextDrawer: Kirigami.ContextDrawer {
|
||||
id: contextDrawer
|
||||
}
|
||||
Component.onCompleted: {
|
||||
// load the entries component
|
||||
entriesComponent = Qt.createComponent("EntriesPage.qml")
|
||||
if (entriesComponent.status !== Component.Ready) {
|
||||
var errorMessage = "Unable to load EntriesPage.qml: " + entriesComponent.errorString()
|
||||
showPassiveNotification(errorMessage)
|
||||
console.error(errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
// load file if one has been specified via CLI argument
|
||||
if (nativeInterface.filePath.length) {
|
||||
nativeInterface.load()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: nativeInterface.init()
|
||||
|
||||
PasswordDialog {
|
||||
id: enterPasswordDialog
|
||||
|
@ -174,13 +159,19 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: entriesComponent
|
||||
EntriesPage {
|
||||
main: root
|
||||
}
|
||||
}
|
||||
|
||||
function clearStack() {
|
||||
pageStack.pop(root.pageStack.initialPage, Controls.StackView.Immediate)
|
||||
}
|
||||
|
||||
function pushStackEntry(entryModel, rootIndex) {
|
||||
pageStack.push(entriesComponent.createObject(root, {
|
||||
main: root,
|
||||
entryModel: entryModel,
|
||||
rootIndex: rootIndex,
|
||||
title: entryModel.data(
|
||||
|
|
|
@ -87,6 +87,13 @@ void Controller::setPassword(const QString &password)
|
|||
emit passwordChanged(m_password = password);
|
||||
}
|
||||
|
||||
void Controller::init()
|
||||
{
|
||||
if (!m_filePath.isEmpty()) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::load(const QString &filePath)
|
||||
{
|
||||
if (!filePath.isEmpty()) {
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
const QStringList &recentFiles() const;
|
||||
|
||||
public slots:
|
||||
void init();
|
||||
void load(const QString &filePath = QString());
|
||||
void create(const QString &filePath = QString());
|
||||
void close();
|
||||
|
|
Loading…
Reference in New Issue