Quick GUI: Move filter to its own dialog
Because under Android the usability of the text box inside the drawer is not very good.
This commit is contained in:
parent
863970fdb3
commit
9c370b375d
|
@ -13,7 +13,7 @@ set(META_GUI_OPTIONAL YES)
|
|||
set(META_USE_QQC2 ON)
|
||||
set(META_VERSION_MAJOR 3)
|
||||
set(META_VERSION_MINOR 2)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
# add project files
|
||||
|
|
71
qml/main.qml
71
qml/main.qml
|
@ -36,6 +36,7 @@ Kirigami.ApplicationWindow {
|
|||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: filterTextField.implicitHeight
|
||||
enabled: nativeInterface.fileOpen
|
||||
visible: !nativeInterface.filterAsDialog
|
||||
|
||||
Controls.TextField {
|
||||
id: filterTextField
|
||||
|
@ -150,7 +151,31 @@ Kirigami.ApplicationWindow {
|
|||
shortcut: "Ctrl+P"
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: "Close file"
|
||||
text: nativeInterface.entryFilter.length === 0 ? qsTr("Search") : qsTr(
|
||||
"Adjust search")
|
||||
enabled: nativeInterface.fileOpen
|
||||
visible: nativeInterface.filterAsDialog
|
||||
iconName: "search"
|
||||
onTriggered: {
|
||||
leftMenu.resetMenu()
|
||||
filterDialog.open()
|
||||
}
|
||||
shortcut: "Ctrl+F"
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: qsTr("Clear search")
|
||||
enabled: nativeInterface.fileOpen
|
||||
visible: nativeInterface.filterAsDialog
|
||||
&& nativeInterface.entryFilter.length > 0
|
||||
iconName: "edit-clear"
|
||||
onTriggered: {
|
||||
leftMenu.resetMenu()
|
||||
nativeInterface.entryFilter = ""
|
||||
}
|
||||
shortcut: "Ctrl+Shift+F"
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: qsTr("Close file")
|
||||
enabled: nativeInterface.fileOpen
|
||||
iconName: "document-close"
|
||||
onTriggered: nativeInterface.close()
|
||||
|
@ -214,8 +239,52 @@ Kirigami.ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
BasicDialog {
|
||||
id: filterDialog
|
||||
title: qsTr("Search for categories and accounts")
|
||||
onAccepted: nativeInterface.entryFilter = filterDialogTextField.text
|
||||
onReset: {
|
||||
nativeInterface.entryFilter = ""
|
||||
filterDialog.close()
|
||||
}
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
filterDialogTextField.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
footer: Controls.DialogButtonBox {
|
||||
Controls.Button {
|
||||
text: qsTr("Apply search term")
|
||||
Controls.DialogButtonBox.buttonRole: Controls.DialogButtonBox.AcceptRole
|
||||
enabled: filterDialogTextField.text.length > 0
|
||||
}
|
||||
Controls.Button {
|
||||
text: qsTr("Clear search")
|
||||
Controls.DialogButtonBox.buttonRole: Controls.DialogButtonBox.ResetRole
|
||||
enabled: nativeInterface.entryFilter
|
||||
}
|
||||
Controls.Button {
|
||||
text: qsTr("Quit dialog")
|
||||
Controls.DialogButtonBox.buttonRole: Controls.DialogButtonBox.RejectRole
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Controls.TextField {
|
||||
id: filterDialogTextField
|
||||
Layout.preferredWidth: filterDialog.availableWidth
|
||||
Keys.onPressed: filterDialog.acceptOnReturn(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: nativeInterface
|
||||
onEntryFilterChanged: {
|
||||
if (filterTextField.text !== newFilter) {
|
||||
filterTextField.text = newFilter
|
||||
}
|
||||
}
|
||||
onFileError: {
|
||||
showPassiveNotification(errorMessage)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,13 @@ Controller::Controller(QSettings &settings, const QString &filePath, QObject *pa
|
|||
, m_fileOpen(false)
|
||||
, m_fileModified(false)
|
||||
, m_useNativeFileDialog(false)
|
||||
, m_filterAsDialog(
|
||||
#ifdef Q_OS_ANDROID
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
)
|
||||
{
|
||||
m_entryFilterModel.setSourceModel(&m_entryModel);
|
||||
connect(&m_entryModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, &Controller::handleEntriesRemoved);
|
||||
|
|
|
@ -36,6 +36,7 @@ class Controller : public QObject {
|
|||
Q_PROPERTY(bool supportsNativeFileDialog READ supportsNativeFileDialog NOTIFY supportsNativeFileDialogChanged)
|
||||
Q_PROPERTY(QString entryFilter READ entryFilter WRITE setEntryFilter NOTIFY entryFilterChanged)
|
||||
Q_PROPERTY(bool hasEntryFilter READ hasEntryFilter NOTIFY hasEntryFilterChanged)
|
||||
Q_PROPERTY(bool filterAsDialog READ filterAsDialog NOTIFY filterAsDialogChanged)
|
||||
|
||||
public:
|
||||
explicit Controller(QSettings &settings, const QString &filePath = QString(), QObject *parent = nullptr);
|
||||
|
@ -73,6 +74,7 @@ public:
|
|||
QString entryFilter() const;
|
||||
void setEntryFilter(const QString &filter);
|
||||
bool hasEntryFilter() const;
|
||||
bool filterAsDialog() const;
|
||||
|
||||
public slots:
|
||||
void init();
|
||||
|
@ -107,6 +109,7 @@ signals:
|
|||
void entryAboutToBeRemoved(const QModelIndex &removedIndex);
|
||||
void entryFilterChanged(const QString &newFilter);
|
||||
void hasEntryFilterChanged(bool hasEntryFilter);
|
||||
void filterAsDialogChanged(bool filterAsDialog);
|
||||
|
||||
private slots:
|
||||
void handleEntriesRemoved(const QModelIndex &parentIndex, int first, int last);
|
||||
|
@ -134,6 +137,7 @@ private:
|
|||
bool m_fileOpen;
|
||||
bool m_fileModified;
|
||||
bool m_useNativeFileDialog;
|
||||
bool m_filterAsDialog;
|
||||
};
|
||||
|
||||
inline QModelIndex Controller::ensureSourceEntryIndex(const QModelIndex &entryIndexMaybeFromFilterModel) const
|
||||
|
@ -279,6 +283,11 @@ inline bool Controller::hasEntryFilter() const
|
|||
return !m_entryFilterModel.filterRegExp().isEmpty();
|
||||
}
|
||||
|
||||
inline bool Controller::filterAsDialog() const
|
||||
{
|
||||
return m_filterAsDialog;
|
||||
}
|
||||
|
||||
} // namespace QtGui
|
||||
|
||||
#endif // QT_QUICK_GUI_CONTROLLER_H
|
||||
|
|
Loading…
Reference in New Issue