diff --git a/qml/FileOpenWindow.qml b/qml/FileOpenWindow.qml
new file mode 100644
index 0000000..c85afd9
--- /dev/null
+++ b/qml/FileOpenWindow.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.12
+import QtQuick.Window 2.12
+import QtQuick.Controls 2.5
+
+import space.developers 1.0
+
+ApplicationWindow {
+ id: openImageWindow
+ signal signalExit
+ minimumWidth: 300
+ minimumHeight: 300
+ width: 400
+ height: 400
+ visible: true
+
+ Rectangle {
+ width: parent.width
+ height: parent.height - anotherWindow_button.height
+ color: "gray"
+
+ WorkWithFiles {
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width
+ height: parent.height
+ }
+ }
+
+ Button {
+ id: anotherWindow_button
+ text: qsTr("Главное окно")
+ width: 180
+ height: 50
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ openImageWindow.close()
+ }
+ }
+}
diff --git a/qml/NewTable.qml b/qml/NewTable.qml
index 9c01a45..345cad3 100644
--- a/qml/NewTable.qml
+++ b/qml/NewTable.qml
@@ -1,6 +1,8 @@
import QtQuick 2.0
import QtQuick.Controls 1.0
+import space.developers 1.0
+
Rectangle {
id:colorRecta
color: "#F0F8FF" // crimson
@@ -22,7 +24,15 @@ Rectangle {
dataModel.updateData(model.path)
}
else {
- workFile.openFile(model.path,model.flag)
+ if (model.flag === "jpg" || model.flag === "png" || model.flag === "jpeg") {
+ workWithFiles.openImage(model.path)
+ var component = Qt.createComponent("FileOpenWindow.qml")
+ var window = component.createObject("root")
+ window.show()
+ }
+ else {
+ workWithFiles.openFile(model.path)
+ }
}
}
}
diff --git a/qml/main.qml b/qml/main.qml
index 61f0190..4c7e790 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -17,9 +17,8 @@ Window {
id: dataModel
}
- WorkFile {
- id: workFile
+ WorkWithFiles {
+ id: workWithFiles
}
-
}
diff --git a/qml/qml.qrc b/qml/qml.qrc
index 6da25f1..9066b4e 100644
--- a/qml/qml.qrc
+++ b/qml/qml.qrc
@@ -8,6 +8,7 @@
ColumnFlag.qml
PathMenu.qml
MasterButton.qml
+ FileOpenWindow.qml
imeg/back-icon.png
diff --git a/src/executionfile.cpp b/src/executionfile.cpp
index a6b7d73..9935eed 100644
--- a/src/executionfile.cpp
+++ b/src/executionfile.cpp
@@ -1,11 +1,39 @@
#include "executionfile.h"
+#include
+#include
-ExecutionFile::ExecutionFile(QObject *parent): QObject (parent)
+ExecutionFile::ExecutionFile(QQuickItem *parent): QQuickPaintedItem(parent)
{
}
-void ExecutionFile::openFile(QString path, QString flag)
+void ExecutionFile::paint(QPainter *painter)
{
- m_fale=path+flag;
+ qDebug() << "paint" << m_filePath;
+ QPixmap pixmap("C:/Users/User/Desktop/img.jpg");
+ QRectF source(0, 0, 0, 0);
+ QRectF imageRect = boundingRect();
+ imageRect.setSize(pixmap.size().scaled(boundingRect().size().toSize(),Qt::KeepAspectRatio));
+ imageRect.moveCenter(boundingRect().center());
+ painter->drawPixmap(imageRect, pixmap, source);
+}
+
+void ExecutionFile::openFile(const QString &path)
+{
+ QDesktopServices::openUrl(QUrl::fromLocalFile(path));
+}
+
+void ExecutionFile::filePath(const QString &path)
+{
+ if (m_filePath == path)
+ return;
+ m_filePath = path;
+ update();
+}
+
+void ExecutionFile::openImage(const QString &path)
+{
+ filePath(path);
+ qDebug() << "m_filePath =" << m_filePath;
+ QQuickPaintedItem::update();
}
diff --git a/src/executionfile.h b/src/executionfile.h
index dccbe1a..f1c4c19 100644
--- a/src/executionfile.h
+++ b/src/executionfile.h
@@ -1,16 +1,22 @@
#ifndef EXECUTIONFILE_H
#define EXECUTIONFILE_H
-#include
+#include
+#include
-class ExecutionFile : public QObject
+class ExecutionFile : public QQuickPaintedItem
{
Q_OBJECT
public:
- ExecutionFile(QObject *parent = nullptr);
- Q_INVOKABLE void openFile(QString path,QString flag);
+ ExecutionFile(QQuickItem *parent = nullptr);
+
+ void paint(QPainter *painter) override;
+
+ Q_INVOKABLE void openFile(const QString &path);
+ Q_INVOKABLE void filePath(const QString &path);
+ Q_INVOKABLE void openImage(const QString &path);
private:
- QString m_fale;
+ QString m_filePath;
};
#endif // EXECUTIONFILE_H
diff --git a/src/main.cpp b/src/main.cpp
index 2c851f6..482814a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,12 +10,11 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
qmlRegisterType("space.developers", 1, 0, "NewTable");
- qmlRegisterType("space.developers", 1, 0, "WorkFile");
+ qmlRegisterType("space.developers", 1, 0, "WorkWithFiles");
QQmlApplicationEngine engine;
-
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {