refactor(filemanager): migrate dialogs to FishUI windows
parent
291b5bdf31
commit
c61f84781c
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: revenmartin <revenmartin@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "createfolderdialog.h"
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickView>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <KIO/MkdirJob>
|
||||
|
||||
CreateFolderDialog::CreateFolderDialog(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CreateFolderDialog::setPath(const QString &path)
|
||||
{
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
void CreateFolderDialog::show()
|
||||
{
|
||||
QQmlApplicationEngine *engine = new QQmlApplicationEngine;
|
||||
engine->rootContext()->setContextProperty("main", this);
|
||||
engine->load(QUrl("qrc:/qml/Dialogs/CreateFolderDialog.qml"));
|
||||
}
|
||||
|
||||
void CreateFolderDialog::newFolder(const QString &folderName)
|
||||
{
|
||||
if (m_path.isEmpty() || folderName.isEmpty())
|
||||
return;
|
||||
|
||||
auto job = KIO::mkdir(QUrl(m_path + "/" + folderName));
|
||||
job->start();
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: revenmartin <revenmartin@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CREATEFOLDERDIALOG_H
|
||||
#define CREATEFOLDERDIALOG_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class CreateFolderDialog : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CreateFolderDialog(QObject *parent = nullptr);
|
||||
|
||||
void setPath(const QString &path);
|
||||
void show();
|
||||
|
||||
Q_INVOKABLE void newFolder(const QString &folderName);
|
||||
|
||||
private:
|
||||
QString m_path;
|
||||
};
|
||||
|
||||
#endif // CREATEFOLDERDIALOG_H
|
||||
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: revenmartin <revenmartin@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import FishUI 1.0 as FishUI
|
||||
|
||||
Window {
|
||||
id: control
|
||||
|
||||
title: qsTr("New folder name")
|
||||
flags: Qt.Dialog
|
||||
visible: true
|
||||
|
||||
width: 400 + FishUI.Units.largeSpacing * 2
|
||||
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
|
||||
|
||||
minimumWidth: width
|
||||
minimumHeight: height
|
||||
maximumWidth: width
|
||||
maximumHeight: height
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: FishUI.Theme.secondBackgroundColor
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: _mainLayout
|
||||
anchors.fill: parent
|
||||
anchors.margins: FishUI.Units.largeSpacing
|
||||
spacing: FishUI.Units.largeSpacing
|
||||
|
||||
FishUI.ActionTextField {
|
||||
id: _textField
|
||||
Layout.fillWidth: true
|
||||
Keys.onEscapePressed: control.close()
|
||||
text: qsTr("New folder")
|
||||
focus: true
|
||||
|
||||
onAccepted: {
|
||||
main.newFolder(_textField.text)
|
||||
control.close()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
_textField.selectAll()
|
||||
}
|
||||
|
||||
rightActions: [
|
||||
Action {
|
||||
icon.source: "image://icontheme/edit-clear"
|
||||
onTriggered: {
|
||||
_textField.text = ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: FishUI.Units.largeSpacing
|
||||
|
||||
Button {
|
||||
text: qsTr("Cancel")
|
||||
Layout.fillWidth: true
|
||||
onClicked: control.close()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("OK")
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
main.newFolder(_textField.text)
|
||||
control.close()
|
||||
}
|
||||
enabled: _textField.text
|
||||
flat: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue