Commit 9b818e4f authored by Martin Höher's avatar Martin Höher

Allow to rename libraries

Libraries now can be renamed. A new entry has been added to the library
page menu, which opens a dialog which in turn lets the user input a new
name.
parent 91905a93
Pipeline #18916570 passed with stages
in 14 minutes and 22 seconds
......@@ -17,7 +17,7 @@ Item {
id: dialog
title: qsTr("Attach File")
parent: MainWindow.window.contentItem
parent: MainWindow.overlay
onAccepted: {
item.item.attachFile(App.urlToLocalFile(fileUrl))
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.10
import QtQuick.Controls 2.3
import OpenTodoList.UI 1.0
......@@ -7,7 +7,7 @@ Dialog {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: Math.min(parent.width * 0.7, 800)
parent: ApplicationWindow.window.contentItem
parent: ApplicationWindow.overlay
padding: Globals.defaultPadding
dim: true
}
......@@ -15,6 +15,17 @@ Menu {
signal openPage(var component, var properties)
MenuItem {
text: qsTr("Rename")
onClicked: {
renameLibraryDialog.renameLibrary(menu.library)
}
RenameLibraryDialog {
id: renameLibraryDialog
}
}
MenuItem {
text: qsTr("Edit Sync Settings")
enabled: menu.library.hasSynchronizer
......
......@@ -12,7 +12,6 @@ CenteredDialog {
function renameItem(item) {
__item = item;
edit.text = item.title;
dialog.parent = MainWindow.window.contentItem;
dialog.open();
edit.forceActiveFocus();
}
......
import QtQuick 2.10
import QtQuick.Controls 2.3
import OpenTodoList 1.0
import OpenTodoList.UI 1.0
CenteredDialog {
id: dialog
function renameLibrary(item) {
d.library = item;
edit.text = item.name;
dialog.open();
edit.forceActiveFocus();
}
standardButtons: Dialog.Ok | Dialog.Cancel
title: qsTr("Rename Library")
onAccepted: {
if (edit.text !== "") {
d.library.name = edit.text;
}
}
onVisibleChanged: {
if (!visible) {
Globals.appWindow.focus();
}
}
QtObject {
id: d
property Library library
}
TextField {
id: edit
placeholderText: qsTr("Enter library title...")
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: Globals.defaultMargin
}
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
selectByMouse: Globals.selectTextWithMouse
onAccepted: dialog.accept()
}
}
......@@ -32,6 +32,7 @@ NotePage 1.0 NotePage.qml
OpenFileDialog 1.0 OpenFileDialog.qml
OpenImageDialog 1.0 OpenImageDialog.qml
RenameItemDialog 1.0 RenameItemDialog.qml
RenameLibraryDialog 1.0 RenameLibraryDialog.qml
ReorderWeightedItem 1.0 ReorderWeightedItem.qml
RichTextEditor 1.0 RichTextEditor.qml
RichTextEditorFormatMenu 1.0 RichTextEditorFormatMenu.qml
......
......@@ -75,5 +75,6 @@
<file>OpenTodoList/UI/BackgroundLabel.qml</file>
<file>OpenTodoList/UI/SyncIndicatorBar.qml</file>
<file>OpenTodoList/UI/LibraryPageMenu.qml</file>
<file>OpenTodoList/UI/RenameLibraryDialog.qml</file>
</qresource>
</RCC>
......@@ -66,12 +66,15 @@ Library::Library(QObject* parent) : QObject(parent),
connect(&m_tasks, &ItemContainer::itemDeleted, [=]() {
m_itemDataChanged = true;
});
connect(this, &Library::nameChanged, [=]() {
m_itemDataChanged = true;
});
auto quickSaveTimer = new QTimer(this);
quickSaveTimer->setInterval(10000);
quickSaveTimer->setSingleShot(false);
connect(quickSaveTimer, &QTimer::timeout, [=]() {
if (m_itemDataChanged) {
if (m_itemDataChanged && !m_synchronizing) {
emit needSync();
m_itemDataChanged = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment