Add misc improvements to Qt Quick GUI
This commit is contained in:
parent
d8b6aeb818
commit
e86d72dab9
|
@ -7,6 +7,7 @@ import org.kde.kirigami 2.5 as Kirigami
|
|||
Kirigami.ScrollablePage {
|
||||
id: page
|
||||
|
||||
property var main: undefined
|
||||
property alias entryModel: delegateModel.model
|
||||
property alias rootIndex: delegateModel.rootIndex
|
||||
|
||||
|
@ -145,34 +146,45 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
Controls.TextField {
|
||||
text: model.actualValue ? model.actualValue : ""
|
||||
echoMode: model.isPassword ? TextInput.PasswordEchoOnEdit : TextInput.Normal
|
||||
echoMode: model.isPassword
|
||||
&& (!activeFocus
|
||||
|| !main.showPasswordsOnFocus) ? TextInput.PasswordEchoOnEdit : TextInput.Normal
|
||||
onEditingFinished: fieldsListView.model.setData(
|
||||
fieldsListView.model.index(index, 1),
|
||||
text)
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Controls.Button {
|
||||
id: fieldsListItemToolButton
|
||||
text: qsTr("⋮")
|
||||
flat: true
|
||||
icon.name: model.isPassword ? "password-show-off" : "password-show-on"
|
||||
onClicked: fieldsListView.model.setData(
|
||||
fieldsListView.model.index(index, 0),
|
||||
model.isPassword ? 0 : 1, 0x0100 + 1)
|
||||
Layout.maximumWidth: Kirigami.Units.iconSizes.large
|
||||
Layout.maximumHeight: Kirigami.Units.iconSizes.large
|
||||
}
|
||||
Controls.Button {
|
||||
flat: true
|
||||
icon.name: "edit-delete"
|
||||
onClicked: fieldsListView.model.removeRows(index, 1)
|
||||
Layout.maximumWidth: Kirigami.Units.iconSizes.large
|
||||
Layout.maximumHeight: Kirigami.Units.iconSizes.large
|
||||
}
|
||||
Controls.Button {
|
||||
flat: true
|
||||
icon.name: "list-add"
|
||||
onClicked: fieldsListView.model.insertRows(index + 1, 1)
|
||||
Layout.maximumWidth: Kirigami.Units.iconSizes.large
|
||||
onClicked: fieldsListItemMenu.open()
|
||||
Layout.maximumWidth: Kirigami.Units.iconSizes.medium
|
||||
Layout.maximumHeight: Kirigami.Units.iconSizes.large
|
||||
|
||||
Controls.Menu {
|
||||
id: fieldsListItemMenu
|
||||
y: fieldsListItemToolButton.height
|
||||
|
||||
Controls.MenuItem {
|
||||
icon.name: model.isPassword ? "password-show-off" : "password-show-on"
|
||||
text: model.isPassword ? qsTr("Mark as normal field") : qsTr(
|
||||
"Mark as password field")
|
||||
onClicked: fieldsListView.model.setData(
|
||||
fieldsListView.model.index(index, 0),
|
||||
model.isPassword ? 0 : 1, 0x0100 + 1)
|
||||
}
|
||||
Controls.MenuItem {
|
||||
icon.name: "edit-delete"
|
||||
text: qsTr("Delete field")
|
||||
onClicked: fieldsListView.model.removeRows(index, 1)
|
||||
}
|
||||
Controls.MenuItem {
|
||||
icon.name: "list-add"
|
||||
text: qsTr("Insert empty field after this")
|
||||
onClicked: fieldsListView.model.insertRows(index + 1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
BIN
qml/banner.png
BIN
qml/banner.png
Binary file not shown.
Before Width: | Height: | Size: 190 KiB |
52
qml/main.qml
52
qml/main.qml
|
@ -7,6 +7,8 @@ import org.kde.kirigami 2.4 as Kirigami
|
|||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
||||
property alias showPasswordsOnFocus: showPasswordsOnFocusSwitch.checked
|
||||
|
||||
function clearStack() {
|
||||
pageStack.pop(root.pageStack.initialPage, Controls.StackView.Immediate)
|
||||
}
|
||||
|
@ -21,6 +23,7 @@ Kirigami.ApplicationWindow {
|
|||
return
|
||||
}
|
||||
var entriesPage = entriesComponent.createObject(root, {
|
||||
main: root,
|
||||
entryModel: entryModel,
|
||||
rootIndex: rootIndex,
|
||||
title: title
|
||||
|
@ -48,7 +51,7 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
}
|
||||
onRejected: {
|
||||
showPassiveNotification("Canceled file selection")
|
||||
showPassiveNotification(qsTr("Canceled file selection"))
|
||||
}
|
||||
|
||||
function openExisting() {
|
||||
|
@ -68,7 +71,8 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
onPasswordRequired: {
|
||||
enterPasswordDialog.askForExistingPassword(
|
||||
qsTr("Password required to open ") + filePath)
|
||||
qsTr("Password required to open %1").arg(
|
||||
nativeInterface.filePath))
|
||||
leftMenu.resetMenu()
|
||||
}
|
||||
onFileOpenChanged: {
|
||||
|
@ -77,13 +81,16 @@ Kirigami.ApplicationWindow {
|
|||
var entryModel = nativeInterface.entryModel
|
||||
var rootIndex = entryModel.index(0, 0)
|
||||
pushStackEntry(entryModel, rootIndex)
|
||||
showPassiveNotification(qsTr("File opened"))
|
||||
showPassiveNotification(qsTr("%1 opened").arg(
|
||||
nativeInterface.fileName))
|
||||
} else {
|
||||
showPassiveNotification(qsTr("File closed"))
|
||||
showPassiveNotification(qsTr("%1 closed").arg(
|
||||
nativeInterface.fileName))
|
||||
}
|
||||
}
|
||||
onFileSaved: {
|
||||
showPassiveNotification(qsTr("File saved"))
|
||||
showPassiveNotification(qsTr("%1 saved").arg(
|
||||
nativeInterface.fileName))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +100,32 @@ Kirigami.ApplicationWindow {
|
|||
id: leftMenu
|
||||
title: qsTr("Password manager")
|
||||
titleIcon: "passwordmanager"
|
||||
bannerImageSource: "banner.png"
|
||||
|
||||
topContent: ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
Controls.MenuSeparator {
|
||||
padding: 0
|
||||
topPadding: 8
|
||||
bottomPadding: 0
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Controls.Label {
|
||||
padding: 8
|
||||
wrapMode: Controls.Label.Wrap
|
||||
fontSizeMode: Text.HorizontalFit
|
||||
minimumPixelSize: 10
|
||||
font.pixelSize: 20
|
||||
Layout.fillWidth: true
|
||||
text: {
|
||||
if (nativeInterface.fileOpen) {
|
||||
return nativeInterface.fileName
|
||||
} else {
|
||||
return qsTr("No file opened")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: qsTr("Create new file")
|
||||
|
@ -126,6 +158,12 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
]
|
||||
|
||||
Controls.Switch {
|
||||
id: showPasswordsOnFocusSwitch
|
||||
text: qsTr("Show passwords on focus")
|
||||
checked: true
|
||||
}
|
||||
|
||||
Controls.Label {
|
||||
wrapMode: Controls.Label.Wrap
|
||||
Layout.fillWidth: true
|
||||
|
@ -133,7 +171,7 @@ Kirigami.ApplicationWindow {
|
|||
if (nativeInterface.fileOpen) {
|
||||
return nativeInterface.filePath
|
||||
} else {
|
||||
return qsTr("no file opened")
|
||||
return qsTr("No file opened")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <qtutilities/misc/dialogutils.h>
|
||||
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
#include <c++utilities/io/path.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
@ -37,6 +38,7 @@ void Controller::setFilePath(const QString &filePath)
|
|||
}
|
||||
m_file.clear();
|
||||
m_file.setPath(filePath.toLocal8Bit().data());
|
||||
m_fileName = QString::fromLocal8Bit(IoUtilities::fileName(m_file.path()).data());
|
||||
emit filePathChanged(m_filePath = filePath);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace QtGui {
|
|||
class Controller : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString filePath READ filePath WRITE setFilePath NOTIFY filePathChanged)
|
||||
Q_PROPERTY(QString fileName READ fileName NOTIFY filePathChanged)
|
||||
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
|
||||
Q_PROPERTY(QString windowTitle READ windowTitle NOTIFY windowTitleChanged)
|
||||
Q_PROPERTY(bool fileOpen READ isFileOpen NOTIFY fileOpenChanged)
|
||||
|
@ -30,6 +31,7 @@ public:
|
|||
explicit Controller(const QString &filePath = QString(), QObject *parent = nullptr);
|
||||
|
||||
const QString &filePath() const;
|
||||
const QString &fileName() const;
|
||||
void setFilePath(const QString &filePath);
|
||||
const QString &password() const;
|
||||
void setPassword(const QString &password);
|
||||
|
@ -74,6 +76,7 @@ private:
|
|||
void emitIoError(const QString &when);
|
||||
|
||||
QString m_filePath;
|
||||
QString m_fileName;
|
||||
QString m_password;
|
||||
QString m_windowTitle;
|
||||
Io::PasswordFile m_file;
|
||||
|
@ -90,6 +93,11 @@ inline const QString &Controller::filePath() const
|
|||
return m_filePath;
|
||||
}
|
||||
|
||||
inline const QString &Controller::fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
inline const QString &Controller::password() const
|
||||
{
|
||||
return m_password;
|
||||
|
|
|
@ -52,11 +52,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
|||
};
|
||||
|
||||
// init Quick GUI
|
||||
//qmlRegisterType<QtGui::EntryFilterModel>("martchus.passwordmanager", 2, 0, "EntryFilterModel");
|
||||
//qmlRegisterType<QtGui::EntryModel>("martchus.passwordmanager", 2, 0, "EntryModel");
|
||||
//qmlRegisterType<QtGui::FieldModel>("martchus.passwordmanager", 2, 0, "FieldModel");
|
||||
//qmlRegisterType<Io::AccountEntry>("martchus.passwordmanager", 2, 1, "AccountEntry");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
Controller controller(file);
|
||||
QQmlContext *const context(engine.rootContext());
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
<file alias="BasicDialog.qml">../qml/BasicDialog.qml</file>
|
||||
<file alias="PasswordDialog.qml">../qml/PasswordDialog.qml</file>
|
||||
<file alias="EntriesPage.qml">../qml/EntriesPage.qml</file>
|
||||
<file alias="banner.png">../qml/banner.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue