Коммит 4a93c0d5 создал по автору OMP Education's avatar OMP Education
Просмотр файлов

[Structure] Setup application template.

владелец 509c0abb
*.tgz filter=lfs diff=lfs merge=lfs -text
*.tar.gz filter=lfs diff=lfs merge=lfs -text
*.tar.xz filter=lfs diff=lfs merge=lfs -text
*.tar.bz2 filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
application/LibreOfficeKit
.apptool
.DS_Store
.mb2
......
[submodule "upstream"]
path = upstream
url = git://anongit.freedesktop.org/libreoffice/core
# Authors
* Anton Zernin, <a.zernin@omp.ru>
* Developer, 2023
# Reviewers
* Kirill Chuvilin, <k.chuvilin@omp.ru>
* Product owner, 2023
* Maintainer, 2023
* Konstantin Zvyagin <k.zvyagin@omp.ru>
* Reviewer, 2023
# Code of Conduct
## What is this code of conduct for?
Code of conduct is a current set of rules of the Open Mobile Platform
which informs you how we expect
the members of the Open Mobile Platform community
will interact while contributing and communicating.
We are committed to providing a friendly, safe and welcoming
environment for all, regardless of gender, gender identity and expression,
sexual orientation, ability, physical appearance, body size, race, age,
socioeconomic status, religion (or lack thereof),
or other marginalized aspect of community members.
We expect all members of the Open Mobile Platform community
to abide by this Code of Conduct whenever interacting
in Open Mobile Platform venues
(merge requests, pull requests, issues, 1-1 or group chat, meetups, conferences, etc.)
## Examples of appropriate behavior
* Using welcoming and inclusive language.
* Being respectful of differing viewpoints and experiences.
* Gracefully accepting constructive criticism.
* Focusing on what is best for the community.
* Showing empathy towards other community members.
## Examples of inappropriate behavior
Because we come from a variety of backgrounds,
we do not want to assume that everyone has the same assumptions
about what is and is not appropriate.
Here are some examples of inappropriate behavior
that are incompatible with our community's ethos:
* spamming, trolling, intentionally disrupting conversations,
or irrelevant solicitation or advertisement;
* making demeaning or discriminatory comments;
* making negative assumptions about someone's background,
abilities, or intentions;
* harassing or stalking individuals (online or in person).
In general: treat others how you would like to be treated,
were you in their place.
Do ask questions.
Do keep conflicts productively focused on technical issues.
Do remember that we are all people, not robots,
and all equally deserving of sensitivity and respect.
## What will organizers do about inappropriate behavior?
If we notice you doing or saying something inappropriate,
an organizer will ask you to stop.
We will not demonize you.
But please do stop the inappropriate behavior
so we can get back to writing and discussing code in a safe environment.
If you have philosophical disagreements about what is actually inappropriate,
please take them to a separate public or private conversation
with an Open Mobile Platform maintainer
so we don't turn pull requests into an ethics debate.
If you keep doing unacceptable things,
we will likely ban you, report you to the administration,
or take other appropriate action.
## What if I see or am subject to what feels like inappropriate behavior?
Let us know.
Please notify a community organizer as soon as possible.
Full contact information is listed in the Contact Info section of this document.
All communications will be kept strictly confidential,
unless otherwise required by law.
No issue will be considered too inconsequential or unimportant for us
to have a conversation about.
## Contact Info
If you need to report an incident,
please contact <community@omp.ru>.
This work is licensed under a Creative Commons Attribution 3.0 Unported License
For attribution requirements:
«Open Mobile Platform Code of Conduct»
Copyright (c) 2021 Open Mobile Platform LLC,
used under a [Creative Commons Attribution Unported license](http://creativecommons.org/licenses/by/3.0/).
# Contributor License Agreements
Thank you for your interest in contributing
to software projects managed by Open Mobile Platform («We» or «Us»).
This contributor agreement («Agreement»)
documents the rights granted by contributors to Us.
To make this document effective,
please sign it and send it to Us by email or electronic submission.
This is a legally binding document,
so please read it carefully before agreeing to it.
The Agreement may cover more than one software project managed by Us.
## 1. Definitions
**«We» or «Us»** means Open Mobile Platform Limited Liability Company
(Open Mobile Platform LLC),
420500, Republic of Tatarstan, Verkhneuslonsky District,
Innopolis, Universitetskaya Street, h. 7, office 59,
OGRN (Primary State Registration Number) 1161690087020.
**«You»** means the individual who Submits a Contribution to Us.
**«Contribution»** means any work of authorship
that is Submitted by You to Us
in which You own or assert ownership of the Copyright.
**«Copyright»** means all rights protecting works of authorship
owned or controlled by You,
including copyright, moral and neighboring rights, as appropriate,
for the full term of their existence including any extensions by You.
**«Material»** means the work of authorship
which is made available by Us to third parties.
When this Agreement covers more than one software project,
the Material means the work of authorship
to which the Contribution was Submitted.
After You Submit the Contribution,
it may be included in the Material.
**«Submit»** means any form of electronic, verbal, or written communication
sent to Us or our representatives,
including but not limited to electronic mailing lists,
source code control systems, and issue tracking systems
that are managed by, or on behalf of, Us
for the purpose of discussing and improving the Material,
but excluding communication that is conspicuously marked
or otherwise designated in writing by You as «Not a Contribution».
**«Submission Date»** means the date
on which You Submit a Contribution to Us.
**«Effective Date»** means the date You execute this Agreement
or the date You first Submit a Contribution to Us,
whichever is earlier.
**«Media»** means any portion of a Contribution which is not software.
## 2. Grant of Rights
### 2.1. Copyright License
(a) You retain ownership of the Copyright in Your Contribution
and have the same rights to use or license the Contribution
which You would have had without entering into the Agreement.
(b) To the maximum extent permitted by the relevant law,
You grant to Us a perpetual, worldwide, non-exclusive,
transferable, royalty-free, irrevocable license
under the Copyright covering the Contribution,
with the right to sublicense
such rights through multiple tiers of sublicensees,
to reproduce, modify, display, perform and distribute
the Contribution as part of the Material;
provided that this license is conditioned upon compliance with Section 2.3.
### 2.2. Patent License
For patent claims including, without limitation,
method, process, and apparatus claims
which You own, control or have the right to grant, now or in the future,
You grant to Us a perpetual, worldwide, non-exclusive,
transferable, royalty-free, irrevocable patent license,
with the right to sublicense these rights to multiple tiers of sublicensees,
to make, have made, use, sell, offer for sale, import
and otherwise transfer the Contribution
and the Contribution in combination with the Material
(and portions of such combination).
This license is granted only to the extent
that the exercise of the licensed rights infringes such patent claims;
and provided that this license is conditioned upon compliance with Section 2.3.
### 2.3. Outbound License
Based on the grant of rights in Sections 2.1 and 2.2,
if We include Your Contribution in a Material,
We may license the Contribution under any license,
including copyleft, permissive, commercial, or proprietary licenses.
As a condition on the exercise of this right,
We agree to also license the Contribution
under the terms of the license or licenses
which We are using for the Material on the Submission Date.
### 2.4. Our Rights
You acknowledge that We are not obligated
to use Your Contribution as part of the Material
and may decide to include any Contribution We consider appropriate.
## 3. Agreement
You confirm that:
(a) You have the legal authority to enter into this Agreement.
(b) You own the Copyright and patent claims
covering the Contribution which are required
to grant the rights under Section 2.
(c) The grant of rights under Section 2
does not violate any grant of rights
which You have made to third parties, including Your employer.
If You are an employee,
You have had Your employer approve this Agreement
or sign the Entity version of this document.
If You are less than eighteen years old,
please have Your parents or guardian sign the Agreement.
## 4. Disclaimer
EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3,
THE CONTRIBUTION IS PROVIDED «AS IS».
MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES
INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE
AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US.
TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED,
SUCH WARRANTY IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW.
## 5. Miscellaneous
5.1. This Agreement will be governed by and construed
in accordance with the laws of Russian Federation.
5.2. This Agreement sets out the entire agreement between You
and Us for Your Contributions to Us
and overrides all other agreements or understandings.
5.3. If You or We assign the rights or obligations
received through this Agreement to a third party,
as a condition of the assignment,
that third party must agree in writing
to abide by all the rights and obligations in the Agreement.
5.4. The failure of either party to require performance
by the other party of any provision of this Agreement in one situation
shall not affect the right of a party
to require such performance at any time in the future.
A waiver of performance under a provision in one situation
shall not be considered a waiver of the performance
of the provision in the future or a waiver of the provision in its entirety.
5.5. If any provision of this Agreement is found void and unenforceable,
such provision will be replaced to the extent possible with a provision
that comes closest to the meaning of the original provision
and which is enforceable.
The terms and conditions set forth in this Agreement
shall apply notwithstanding any failure of essential purpose
of this Agreement or any limited remedy
to the maximum extent possible under law.
# The 3-Clause BSD License
_Copyright (C) 2023 ru.auroraos_
Redistribution and use in source and binary forms,
with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain
the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce
the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
......@@ -5,6 +5,55 @@ This project provides an example using LibreOffice to open documents.
## Terms of Use and Participation
The source code of the project is provided under
[the license](LICENSE.BSD-3-Clause.md),
[the license](LICENSE.BSD-3-CLAUSE.md),
that allows it to be used in third-party applications.
The [contributor agreement](CONTRIBUTING.md)
documents the rights granted by contributors to the Open Mobile Platform.
[Code of conduct](CODE_OF_CONDUCT.md) is a current set of rules
of the Open Mobile Platform which informs you how we expect
the members of the community will interact while contributing and communicating.
For information about contributors see [AUTHORS](AUTHORS.md).
## Project Structure
The project has a common structure
of an application based on C++ and QML for Aurora OS.
* **[ru.auroraos.DocumentConverter.pro](application/ru.auroraos.DocumentConverter.pro)** file
describes the subdirs project that contains two two subprojects where the first is responsible
for building the libreoffice, and the second describes the structure of the application for
the qmake build system.
* **[icons](application/icons)** directory contains application icons for different screen resolutions.
* **[qml](application/qml)** directory contains the QML source code and the UI resources.
* **[cover](application/qml/cover)** directory contains the application cover implementations.
* **[icons](application/qml/icons)** directory contains the custom UI icons.
* **[pages](application/qml/pages)** directory contains the application pages.
* **[DocumentConverter.qml](application/qml/DocumentConverter.qml)** file
provides the application window implementation.
* **[rpm](rpm)** directory contains the rpm-package build settings.
**[ru.auroraos.DocumentConverter.spec](rpm/ru.auroraos.DocumentConverter.spec)** file is used by rpmbuild tool.
* **[src](application/src)** directory contains the C++ source code.
* **[main.cpp](application/src/main.cpp)** file is the application entry point.
* **[translations](application/translations)** directory contains the UI translation files.
* **[ru.auroraos.DocumentConverter.desktop](application/ru.auroraos.DocumentConverter.desktop)** file
defines the display and parameters for launching the application.
* **[libreoffice](upstream)** directory contains source code LibreOffice (git submodule)
* **[tarballs](tarballs)** directory of dependencies in the form of archives necessary for the build LibreOffice.
## Building
* Open a terminal or command prompt.
* Navigate to the directory that contains your Git repository.
* Execute the command "git lfs pull" to download any files tracked by LFS.
* Execute the command "git submodule update --init" to update and initialize any submodules in the repository.
* Execute the command "mb2 -t AuroraOS-4.0.2.209-base-armv7hl prepare" to apply the patches needed for the build.
* Execute the command "mb2 -t AuroraOS-4.0.2.209-base-armv7hl build" to start building the package.
Note: To execute the steps "git lfs pull" and "git submodule update --init", you will need to have Git Large File Storage (LFS) and Git Submodule plugins installed on your system.
## Package signature
You can read about package signing in [package_signing](https://community.omprussia.ru/documentation/software_development/guides/package_signing.html)
################################################################################
##
## Copyright (C) 2023 Open Mobile Platform LLC.
## Contact: https://community.omprussia.ru/open-source
##
## This file is part of the DocumentConverter project.
##
## Redistribution and use in source and binary forms,
## with or without modification, are permitted provided
## that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright notice,
## this list of conditions and the following disclaimer
## in the documentation and/or other materials provided with the distribution.
## * Neither the name of the copyright holder nor the names of its contributors
## may be used to endorse or promote products derived from this software
## without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
## FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
## OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
## LOSS OF USE, DATA, OR PROFITS;
## OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
################################################################################
TARGET = ru.auroraos.DocumentConverter
CONFIG += \
auroraapp
PKGCONFIG += \
SOURCES += \
src/converter.cpp \
src/main.cpp \
HEADERS += \
src/converter.h
INCLUDEPATH += \
LibreOfficeKit
LIBS += -ldl
DISTFILES += \
qml/DocumentConverter.qml \
qml/pages/MainPage.qml \
qml/pages/ConvertPage.qml \
qml/cover/DefaultCoverPage.qml
AURORAAPP_ICONS = 86x86 108x108 128x128 172x172
CONFIG += auroraapp_i18n
TRANSLATIONS += \
translations/ru.auroraos.DocumentConverter.ts \
translations/ru.auroraos.DocumentConverter-ru.ts \
translations.path = /usr/share/$${TARGET}/translations
translations.files = $$TRANSLATIONS
INSTALLS += \
translations
/*******************************************************************************
**
** Copyright (C) 2023 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the DocumentConverter project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
import QtQuick 2.0
import Sailfish.Silica 1.0
ApplicationWindow {
objectName: "applicationWindow"
initialPage: Qt.resolvedUrl("pages/MainPage.qml")
cover: Qt.resolvedUrl("cover/DefaultCoverPage.qml")
allowedOrientations: defaultAllowedOrientations
}
/*******************************************************************************
**
** Copyright (C) 2023 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the DocumentConverter project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
import QtQuick 2.0
import Sailfish.Silica 1.0
CoverBackground {
objectName: "defaultCover"
CoverPlaceholder {
objectName: "placeholder"
text: qsTr("Document Converter")
icon {
source: Qt.resolvedUrl("../icons/icon-document-converter.svg")
sourceSize { width: icon.width; height: icon.height }
}
forceFit: true
}
}
<svg width="86" height="86" viewBox="0 0 86 86" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 30.0246C0 14.8691 0 9.41638 4.70819 4.70819C9.41638 0 14.8691 0 32.1495 0H53.8505C71.1308 0 76.5836 0 81.2918 4.70819C86 9.41638 86 14.8691 86 32.1495V53.8505C86 71.1308 86 76.5836 81.2918 81.2918C76.5836 86 71.1308 86 53.8505 86H32.1495C14.8691 86 9.41638 86 4.70819 81.2918C0 76.5836 0 71.1308 0 53.8505V30.0246Z" fill="url(#paint0_radial_3320_38777)"/>
<path d="M30.06 19.5813C30.06 19.7788 30.2201 19.9389 30.4176 19.9389L38.2848 19.9399C38.6798 19.9399 39 20.2602 39 20.6552V20.6552C39 19.9683 38.7271 19.3095 38.2414 18.8238L31.1762 11.7586C30.6905 11.2729 30.0317 11 29.3448 11V11C29.7395 11 30.0595 11.3197 30.06 11.7143V19.5813Z" fill="white"/>
<path d="M11 15.6667C11 13.0893 13.0893 11 15.6667 11H28.756C30.0024 11 31.197 11.4986 32.0735 12.3847L37.6509 18.0225C38.5152 18.8962 39 20.0755 39 21.3045V43.023C39 45.6003 36.9107 47.6897 34.3333 47.6897H15.6667C13.0893 47.6897 11 45.6003 11 43.023V15.6667Z" fill="url(#paint1_radial_3320_38777)"/>
<g filter="url(#filter0_i_3320_38777)">
<path d="M11 15.55C11 13.0371 13.0371 11 15.55 11H28.8047C30.0199 11 31.1846 11.4861 32.0393 12.3501L37.6846 18.0566C38.5273 18.9084 39 20.0583 39 21.2565V43.1396C39 45.6525 36.9629 47.6897 34.45 47.6897H15.55C13.0371 47.6897 11 45.6525 11 43.1397V15.55Z" fill="url(#paint2_radial_3320_38777)" fill-opacity="0.6"/>
</g>
<path d="M66.06 46.5813C66.06 46.7788 66.2201 46.9389 66.4176 46.9389L74.2848 46.9399C74.6798 46.9399 75 47.2602 75 47.6552V46.5824L66.4176 38H65.3448C65.7395 38 66.0595 38.3197 66.06 38.7143V46.5813Z" fill="url(#paint3_radial_3320_38777)"/>
<path d="M47 42.6667C47 40.0893 49.0893 38 51.6667 38H64.756C66.0024 38 67.197 38.4986 68.0735 39.3847L73.6509 45.0225C74.5152 45.8962 75 47.0755 75 48.3045V70.023C75 72.6003 72.9107 74.6897 70.3333 74.6897H51.6667C49.0893 74.6897 47 72.6003 47 70.023V42.6667Z" fill="url(#paint4_radial_3320_38777)"/>
<g filter="url(#filter1_i_3320_38777)">
<path d="M47 42.55C47 40.0371 49.0371 38 51.55 38H64.8047C66.0199 38 67.1846 38.4861 68.0393 39.3501L73.6846 45.0566C74.5273 45.9084 75 47.0583 75 48.2565V70.1396C75 72.6525 72.9629 74.6897 70.45 74.6897H51.55C49.0371 74.6897 47 72.6525 47 70.1397V42.55Z" fill="url(#paint5_radial_3320_38777)"/>
</g>
<rect x="16" y="24" width="15" height="2" rx="1" fill="url(#paint6_linear_3320_38777)"/>
<rect x="53" y="52" width="15" height="2" rx="1" fill="url(#paint7_linear_3320_38777)"/>
<rect x="16" y="28" width="12" height="2" rx="1" fill="url(#paint8_linear_3320_38777)"/>
<rect x="53" y="56" width="12" height="2" rx="1" fill="url(#paint9_linear_3320_38777)"/>
<rect x="16" y="32" width="9" height="2" rx="1" fill="url(#paint10_linear_3320_38777)"/>
<rect x="53" y="60" width="9" height="2" rx="1" fill="url(#paint11_linear_3320_38777)"/>
<g filter="url(#filter2_i_3320_38777)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.4919 73.6895C33.7791 73.6902 32.0835 73.3473 30.5056 72.681C28.9223 72.0124 27.4899 71.0318 26.2937 69.7978C25.0975 68.5638 24.162 67.1016 23.543 65.4983C22.9546 63.9746 22.6636 62.3531 22.6847 60.7215L17.1991 60.7215L24.9933 52.4715L32.7875 60.7215L27.4578 60.7215C27.4363 61.7657 27.6187 62.8044 27.9951 63.7793C28.3834 64.7849 28.9701 65.7021 29.7204 66.4761C30.4707 67.2501 31.3691 67.8651 32.3622 68.2844C33.3526 68.7027 34.4169 68.9178 35.4919 68.917L35.4919 68.913L39 68.913L39 73.6895L35.4919 73.6895Z" fill="url(#paint12_radial_3320_38777)"/>
</g>
<g filter="url(#filter3_i_3320_38777)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.5081 12C52.2209 11.9992 53.9165 12.3421 55.4944 13.0085C57.0777 13.6771 58.5101 14.6576 59.7063 15.8916C60.9025 17.1256 61.838 18.5878 62.457 20.1911C63.0454 21.7149 63.3364 23.3363 63.3153 24.968L68.8009 24.968L61.0067 33.218L53.2125 24.968L58.5422 24.968C58.5637 23.9238 58.3813 22.885 58.0049 21.9101C57.6166 20.9045 57.0299 19.9874 56.2796 19.2134C55.5293 18.4394 54.6309 17.8244 53.6378 17.405C52.6474 16.9868 51.5831 16.7717 50.5081 16.7725V16.7765L47 16.7765V12H50.5081Z" fill="url(#paint13_radial_3320_38777)"/>
</g>
<defs>
<filter id="filter0_i_3320_38777" x="11" y="11" width="28" height="36.6895" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset/>
<feGaussianBlur stdDeviation="3.5"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.33 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_3320_38777"/>
</filter>
<filter id="filter1_i_3320_38777" x="47" y="38" width="28" height="36.6895" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset/>
<feGaussianBlur stdDeviation="3.5"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.33 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_3320_38777"/>
</filter>
<filter id="filter2_i_3320_38777" x="17.1992" y="52.4717" width="21.8008" height="21.2178" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset/>
<feGaussianBlur stdDeviation="2.91062"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.98 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_3320_38777"/>
</filter>
<filter id="filter3_i_3320_38777" x="47" y="12" width="21.8008" height="21.2178" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset/>
<feGaussianBlur stdDeviation="2.91062"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.98 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_3320_38777"/>
</filter>
<radialGradient id="paint0_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(-0.302126 -0.301911) rotate(47.9609) scale(124.067)">
<stop offset="0.0920323" stop-color="#59E480"/>
<stop offset="1" stop-color="#103A1C"/>
</radialGradient>
<radialGradient id="paint1_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(32 17.5517) rotate(125.336) scale(38.5502 38.4149)">
<stop offset="0.0001" stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="white" stop-opacity="0.81"/>
</radialGradient>
<radialGradient id="paint2_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(12.2208 11.0978) rotate(54.5371) scale(42.1353 42.3851)">
<stop stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.54"/>
</radialGradient>
<radialGradient id="paint3_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(67.7586 39.7241) rotate(47.1075) scale(11.2961 11.8965)">
<stop offset="0.0001" stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="white" stop-opacity="0.81"/>
</radialGradient>
<radialGradient id="paint4_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(71 50.5) rotate(135) scale(27.5772 27.4804)">
<stop offset="0.0001" stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="white" stop-opacity="0.81"/>
</radialGradient>
<radialGradient id="paint5_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(68 44.5517) rotate(127.975) scale(56.329 56.1313)">
<stop offset="0.0001" stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="white" stop-opacity="0.81"/>
</radialGradient>
<linearGradient id="paint6_linear_3320_38777" x1="16.5" y1="25" x2="53" y2="25" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<linearGradient id="paint7_linear_3320_38777" x1="53.5" y1="53" x2="90" y2="53" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<linearGradient id="paint8_linear_3320_38777" x1="16.4" y1="29" x2="51" y2="29" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<linearGradient id="paint9_linear_3320_38777" x1="53.4" y1="57" x2="88" y2="57" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<linearGradient id="paint10_linear_3320_38777" x1="16.3" y1="33" x2="44.5" y2="33" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<linearGradient id="paint11_linear_3320_38777" x1="53.3" y1="61" x2="81.5" y2="61" gradientUnits="userSpaceOnUse">
<stop offset="0.0171927" stop-color="white"/>
<stop offset="1" stop-color="white" stop-opacity="0.05"/>
</linearGradient>
<radialGradient id="paint12_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(29.6998 67.3678) rotate(49.7998) scale(21.1006 20.2956)">
<stop stop-color="white" stop-opacity="0.46"/>
<stop offset="0.776042" stop-color="white" stop-opacity="0.93"/>
</radialGradient>
<radialGradient id="paint13_radial_3320_38777" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(62.9468 33.218) rotate(-119.724) scale(32.1623 30.9352)">
<stop stop-color="white" stop-opacity="0.46"/>
<stop offset="0.776042" stop-color="white" stop-opacity="0.93"/>
</radialGradient>
</defs>
</svg>
/*******************************************************************************
**
** Copyright (C) 2023 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the DocumentConverter project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
import QtQuick 2.2
import Sailfish.Silica 1.0
import Sailfish.Pickers 1.0
import ru.auroraos.DocumentConverter 1.0
Page {
id: loadFilePage
property string fileSourcePath
property string fileResultPath
property string fileName
objectName: "loadFilePage"
allowedOrientations: Orientation.All
PageHeader {
id: pageHader
objectName: "pageHeader"
title: qsTr("converting")
}
BusyIndicator {
id: indicator
size: BusyIndicatorSize.Large
anchors.centerIn: parent
running: visible
}
Timer {
id: timer
interval: 4500
running: true
onTriggered: {
if (converter.state === Converter.Saved) {
indicator.visible = false
postIndicatorText.visible = true
}
}
}
Text {
id: preIndicatorText
anchors {
top: indicator.bottom
topMargin: Theme.paddingLarge
}
width: parent.width
color: Theme.highlightColor
text: qsTr("Converting file ...")
font.pixelSize: Theme.fontSizeLarge
horizontalAlignment: Qt.AlignHCenter
visible: indicator.visible
}
Text {
id: postIndicatorText
anchors.centerIn: parent
width: parent.width
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
text: qsTr("File %1 saved").arg(fileName)
horizontalAlignment: Qt.AlignHCenter
visible: false
}
Text {
id: errorIndicatorText
anchors.centerIn: parent
width: parent.width
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Failed to convert %1").arg(fileName)
horizontalAlignment: Qt.AlignHCenter
visible: false
}
Converter {
id: converter
onStateChanged: {
switch (state) {
case Converter.Opening:
indicator.visible = true
break
case Converter.Saved:
if (!timer.running) {
indicator.visible = false
postIndicatorText.visible = true
}
break
case Converter.Failed:
indicator.visible = false
errorIndicatorText.visible = true
break
}
}
}
Component.onCompleted: {
converter.convert(fileSourcePath, fileResultPath)
}
}
/*******************************************************************************
**
** Copyright (C) 2023 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the DocumentConverter project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
import QtQuick 2.0
import Nemo.FileManager 1.0
import Sailfish.Silica 1.0
import Sailfish.Pickers 1.0
Page {
id: loadPage
objectName: "loadPage"
SilicaListView {
id: lisView
property string currentPath
property string resultFileName
property string resultPath
property string defaultPath
property string directoryPath
anchors.fill: parent
model: fileModel
header: PageHeader {
title: fileModel.directoryName
}
delegate: ListItem {
width: parent.width
Image {
id: icon
anchors.verticalCenter: parent.verticalCenter
x: Theme.horizontalPageMargin
source: "image://theme/icon-m-file" + (model.isDir ? "-folder" : "-other") + (highlighted ? '?' + Theme.highlightColor : '')
}
Item {
id: description
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: -Theme.paddingMedium
right: parent.right
rightMargin: Theme.horizontalPageMargin
left: icon.right
leftMargin: Theme.paddingMedium
}
height: fileNameLabel.height
baselineOffset: fileNameLabel.baselineOffset
Label {
id: fileNameLabel
text: model.fileName
color: highlighted ? Theme.highlightColor : Theme.primaryColor
truncationMode: TruncationMode.Fade
width: parent.width - sizeLabel.width - Theme.paddingMedium
}
Label {
id: sizeLabel
text: Format.formatFileSize(model.size)
font.pixelSize: Theme.fontSizeExtraSmall
anchors.right: parent.right
anchors.baseline: parent.baseline
color: highlighted ? Theme.highlightColor : Theme.primaryColor
}
}
menu: ContextMenu {
hasContent: !model.isDir && (fileName.lastIndexOf(".pdf") === -1)
Repeater {
model: listExtension(fileName)
MenuItem {
text: qsTr("Conver to %1").arg(modelData)
onClicked: {
lisView.currentPath = absolutePath
lisView.resultFileName = createFileName(fileName, modelData)
pageStack.push(folderPickerDialog)
}
}
}
}
Row {
spacing: Theme.paddingSmall
anchors {
top: description.bottom
right: description.right
}
Label {
opacity: 0.6
color: highlighted ? Theme.highlightColor : Theme.primaryColor
font.pixelSize: Theme.fontSizeExtraSmall
anchors.verticalCenter: parent.verticalCenter
text: Format.formatDate(model.modified, Format.Timepoint)
}
}
onClicked: {
if (model.isDir) {
fileModel.path = model.absolutePath
}
}
}
VerticalScrollDecorator {}
}
Component {
id: folderPickerDialog
FolderPickerPage {
showSystemFiles: false
dialogTitle: qsTr("Save as ...")
onSelectedPathChanged: {
lisView.resultPath = ("%1/%2").arg(selectedPath).arg(lisView.resultFileName)
var loadPage_ = pageStack.find(function(page) { if (page.objectName === "loadPage") return page })
pageStack.replaceAbove(loadPage_, Qt.resolvedUrl("ConvertPage.qml"), {
"fileSourcePath" : lisView.currentPath,
"fileResultPath" : lisView.resultPath,
"fileName": lisView.resultFileName
})
}
}
}
FileModel {
id: fileModel
active: true
includeDirectories: true
includeParentDirectory: false
directorySort: FileModel.SortDirectoriesBeforeFiles
nameFilters: ["*.doc", "*.docx", "*.pdf", "*.odt", "*.xls", "*.xlsx", "*.ods", "*.ppt", "*.pptx", "*.odp"]
sortBy: FileModel.SortByName
sortOrder: Qt.AscendingOrder
path: StandardPaths.documents
}
function createFileName(fileName, extension){
var tmpIndex = fileName.lastIndexOf(".")
fileName = fileName.slice(0, tmpIndex)
return ("%1%2").arg(fileName).arg(extension)
}
function listExtension(fileName) {
var exIndex = fileName.lastIndexOf(".")
var extension = fileName.slice(exIndex)
var listDocumentsExtension = [".doc", ".docx", ".odt", ".pdf"]
var listTablesExtension = [".xls", ".xlsx", ".ods", ".pdf"]
var listPresentationExtension = [".ppt", ".pptx", ".odp", ".pdf"]
var listOfList = [listDocumentsExtension, listTablesExtension, listPresentationExtension]
for (var i = 0; i < listOfList.length; i++) {
var element = listOfList[i]
var tmpIndex = element.indexOf(extension)
if (tmpIndex !== -1 && extension !== ".pdf") {
element.splice(tmpIndex, 1)
return element
}
}
}
}
[Desktop Entry]
Type=Application
X-Nemo-Application-Type=silica-qt5
Icon=ru.auroraos.DocumentConverter
Exec=/usr/bin/ru.auroraos.DocumentConverter
Name=Document Converter
Name[ru]=Конвертер Документов
[X-Application]
Permissions=RemovableMedia;UserDirs
OrganizationName=ru.auroraos
ApplicationName=DocumentConverter
ExecDBus=/usr/bin/ru.auroraos.DocumentConverter
/*******************************************************************************
**
** Copyright (C) 2023 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the DocumentConverter project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
#include "converter.h"
#include <QDir>
#include <QThreadPool>
#include <QtConcurrent/QtConcurrent>
#include <QDebug>
#define LIBREOFFICE_PATH "/usr/share/ru.auroraos.DocumentConverter/lib/libreoffice/program"
Converter::Converter(QObject *parent)
: QObject(parent)
, m_office(nullptr)
, m_document(nullptr)
, m_state(State::Initilize)
{
qRegisterMetaType<Converter::State>("Converter::State");
m_office = lok::lok_cpp_init(LIBREOFFICE_PATH);
if (!m_office) {
setState(Converter::State::Failed);
qWarning("Worker error: can't init the office instance");
}
}
void Converter::convert(const QString &fileSourcePath, const QString &fileResultPath)
{
if (m_state != State::Opened)
return;
auto worker = new ConverterWorker(m_office, fileSourcePath.toUtf8(), fileResultPath.toUtf8());
connect(worker, &ConverterWorker::satateChanged, this, &Converter::setState);
QThreadPool::globalInstance()->start(worker);
}
Converter::State Converter::state() const
{
return m_state;
}
void Converter::setState(State newState)
{
if (m_state == newState)
return;
m_state = newState;
emit stateChanged();
}
ConverterWorker::ConverterWorker(lok::Office *office, const QByteArray &srcUrl, const QByteArray &dstUrl)
: m_office(office)
, m_srcUrl(srcUrl)
, m_dstUrl(dstUrl)
{
}
void ConverterWorker::run()
{
emit satateChanged(Converter::State::Opening);
const int flags = LOK_FEATURE_DOCUMENT_PASSWORD | LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
| LOK_FEATURE_RANGE_HEADERS | LOK_FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK
| LOK_FEATURE_NO_TILED_ANNOTATIONS;
m_office->setOptionalFeatures(flags);
QString options;
qDebug() << "Converting" << m_srcUrl << m_dstUrl;
auto document = m_office->documentLoad(m_srcUrl.data(), options.toStdString().c_str());
if (!document) {
emit satateChanged(Converter::State::Failed);
return;
}
emit satateChanged(Converter::State::Opened);
emit satateChanged(Converter::State::Saving);
bool status = document->saveAs(m_dstUrl.data());
if (status) {
emit satateChanged(Converter::State::Saved);
qDebug() << "Converted" << m_dstUrl;
} else {
emit satateChanged(Converter::State::Failed);
qDebug() << "Failed" << m_srcUrl << m_dstUrl;
}
}
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать