diff --git a/3rd-parties/qtsingleapplication/CMakeLists.txt b/3rd-parties/qtsingleapplication/CMakeLists.txt
new file mode 100644
index 0000000..784cb47
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.16)
+project(qtsingleapplication)
+
+find_package(Qt5 COMPONENTS
+ Core Gui Widgets Network
+ REQUIRED)
+
+include_directories(src)
+set(SRCS src/qtsingleapplication.h src/qtsingleapplication.cpp src/qtlocalpeer.h src/qtlocalpeer.cpp)
+
+add_library(${PROJECT_NAME} STATIC ${SRCS})
+target_include_directories(${PROJECT_NAME} PRIVATE src)
+target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
diff --git a/3rd-parties/qtsingleapplication/INSTALL.TXT b/3rd-parties/qtsingleapplication/INSTALL.TXT
new file mode 100644
index 0000000..bbb74a9
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/INSTALL.TXT
@@ -0,0 +1,254 @@
+INSTALLATION INSTRUCTIONS
+
+These instructions refer to the package you are installing as
+some-package.tar.gz or some-package.zip. The .zip file is intended for use
+on Windows.
+
+The directory you choose for the installation will be referred to as
+your-install-dir.
+
+Note to Qt Visual Studio Integration users: In the instructions below,
+instead of building from command line with nmake, you can use the menu
+command 'Qt->Open Solution from .pro file' on the .pro files in the
+example and plugin directories, and then build from within Visual
+Studio.
+
+Unpacking and installation
+--------------------------
+
+1. Unpacking the archive (if you have not done so already).
+
+ On Unix and Mac OS X (in a terminal window):
+
+ cd your-install-dir
+ gunzip some-package.tar.gz
+ tar xvf some-package.tar
+
+ This creates the subdirectory some-package containing the files.
+
+ On Windows:
+
+ Unpack the .zip archive by right-clicking it in explorer and
+ choosing "Extract All...". If your version of Windows does not
+ have zip support, you can use the infozip tools available
+ from www.info-zip.org.
+
+ If you are using the infozip tools (in a command prompt window):
+ cd your-install-dir
+ unzip some-package.zip
+
+2. Configuring the package.
+
+ The configure script is called "configure" on unix/mac and
+ "configure.bat" on Windows. It should be run from a command line
+ after cd'ing to the package directory.
+
+ You can choose whether you want to use the component by including
+ its source code directly into your project, or build the component
+ as a dynamic shared library (DLL) that is loaded into the
+ application at run-time. The latter may be preferable for
+ technical or licensing (LGPL) reasons. If you want to build a DLL,
+ run the configure script with the argument "-library". Also see
+ the note about usage below.
+
+ (Components that are Qt plugins, e.g. styles and image formats,
+ are by default built as a plugin DLL.)
+
+ The configure script will prompt you in some cases for further
+ information. Answer these questions and carefully read the license text
+ before accepting the license conditions. The package cannot be used if
+ you do not accept the license conditions.
+
+3. Building the component and examples (when required).
+
+ If a DLL is to be built, or if you would like to build the
+ examples, next give the commands
+
+ qmake
+ make [or nmake if your are using Microsoft Visual C++]
+
+ The example program(s) can be found in the directory called
+ "examples" or "example".
+
+ Components that are Qt plugins, e.g. styles and image formats, are
+ ready to be used as soon as they are built, so the rest of this
+ installation instruction can be skipped.
+
+4. Building the Qt Designer plugin (optional).
+
+ Some of the widget components are provided with plugins for Qt
+ Designer. To build and install the plugin, cd into the
+ some-package/plugin directory and give the commands
+
+ qmake
+ make [or nmake if your are using Microsoft Visual C++]
+
+ Restart Qt Designer to make it load the new widget plugin.
+
+ Note: If you are using the built-in Qt Designer from the Qt Visual
+ Studio Integration, you will need to manually copy the plugin DLL
+ file, i.e. copy
+ %QTDIR%\plugins\designer\some-component.dll
+ to the Qt Visual Studio Integration plugin path, typically:
+ C:\Program Files\Trolltech\Qt VS Integration\plugins
+
+ Note: If you for some reason are using a Qt Designer that is built
+ in debug mode, you will need to build the plugin in debug mode
+ also. Edit the file plugin.pro in the plugin directory, changing
+ 'release' to 'debug' in the CONFIG line, before running qmake.
+
+
+
+Solutions components are intended to be used directly from the package
+directory during development, so there is no 'make install' procedure.
+
+
+Using a component in your project
+---------------------------------
+
+To use this component in your project, add the following line to the
+project's .pro file (or do the equivalent in your IDE):
+
+ include(your-install-dir/some-package/src/some-package.pri)
+
+This adds the package's sources and headers to the SOURCES and HEADERS
+project variables respectively (or, if the component has been
+configured as a DLL, it adds that library to the LIBS variable), and
+updates INCLUDEPATH to contain the package's src
+directory. Additionally, the .pri file may include some dependencies
+needed by the package.
+
+To include a header file from the package in your sources, you can now
+simply use:
+
+ #include
+
+or alternatively, in pre-Qt 4 style:
+
+ #include
+
+Refer to the documentation to see the classes and headers this
+components provides.
+
+
+
+Install documentation (optional)
+--------------------------------
+
+The HTML documentation for the package's classes is located in the
+your-install-dir/some-package/doc/html/index.html. You can open this
+file and read the documentation with any web browser.
+
+To install the documentation into Qt Assistant (for Qt version 4.4 and
+later):
+
+1. In Assistant, open the Edit->Preferences dialog and choose the
+ Documentation tab. Click the Add... button and select the file
+ your-install-dir/some-package/doc/html/some-package.qch
+
+For Qt versions prior to 4.4, do instead the following:
+
+1. The directory your-install-dir/some-package/doc/html contains a
+ file called some-package.dcf. Execute the following commands in a
+ shell, command prompt or terminal window:
+
+ cd your-install-dir/some-package/doc/html/
+ assistant -addContentFile some-package.dcf
+
+The next time you start Qt Assistant, you can access the package's
+documentation.
+
+
+Removing the documentation from assistant
+-----------------------------------------
+
+If you have installed the documentation into Qt Assistant, and want to uninstall it, do as follows, for Qt version 4.4 and later:
+
+1. In Assistant, open the Edit->Preferences dialog and choose the
+ Documentation tab. In the list of Registered Documentation, select
+ the item com.nokia.qtsolutions.some-package_version, and click
+ the Remove button.
+
+For Qt versions prior to 4.4, do instead the following:
+
+1. The directory your-install-dir/some-package/doc/html contains a
+ file called some-package.dcf. Execute the following commands in a
+ shell, command prompt or terminal window:
+
+ cd your-install-dir/some-package/doc/html/
+ assistant -removeContentFile some-package.dcf
+
+
+
+Using the component as a DLL
+----------------------------
+
+1. Normal components
+
+ The shared library (DLL) is built and placed in the
+ some-package/lib directory. It is intended to be used directly
+ from there during development. When appropriate, both debug and
+ release versions are built, since the run-time linker will in some
+ cases refuse to load a debug-built DLL into a release-built
+ application or vice versa.
+
+ The following steps are taken by default to help the dynamic
+ linker to locate the DLL at run-time (during development):
+
+ Unix: The some-package.pri file will add linker instructions to
+ add the some-package/lib directory to the rpath of the
+ executable. (When distributing, or if your system does not support
+ rpath, you can copy the shared library to another place that is
+ searched by the dynamic linker, e.g. the "lib" directory of your
+ Qt installation.)
+
+ Mac: The full path to the library is hardcoded into the library
+ itself, from where it is copied into the executable at link time,
+ and ready by the dynamic linker at run-time. (When distributing,
+ you will want to edit these hardcoded paths in the same way as for
+ the Qt DLLs. Refer to the document "Deploying an Application on
+ Mac OS X" in the Qt Reference Documentation.)
+
+ Windows: the .dll file(s) are copied into the "bin" directory of
+ your Qt installation. The Qt installation will already have set up
+ that directory to be searched by the dynamic linker.
+
+
+2. Plugins
+
+ For Qt Solutions plugins (e.g. image formats), both debug and
+ release versions of the plugin are built by default when
+ appropriate, since in some cases the release Qt library will not
+ load a debug plugin, and vice versa. The plugins are automatically
+ copied into the plugins directory of your Qt installation when
+ built, so no further setup is required.
+
+ Plugins may also be built statically, i.e. as a library that will be
+ linked into your application executable, and so will not need to
+ be redistributed as a separate plugin DLL to end users. Static
+ building is required if Qt itself is built statically. To do it,
+ just add "static" to the CONFIG variable in the plugin/plugin.pro
+ file before building. Refer to the "Static Plugins" section in the
+ chapter "How to Create Qt Plugins" for explanation of how to use a
+ static plugin in your application. The source code of the example
+ program(s) will also typically contain the relevant instructions
+ as comments.
+
+
+
+Uninstalling
+------------
+
+ The following command will remove any fils that have been
+ automatically placed outside the package directory itself during
+ installation and building
+
+ make distclean [or nmake if your are using Microsoft Visual C++]
+
+ If Qt Assistant documentation or Qt Designer plugins have been
+ installed, they can be uninstalled manually, ref. above.
+
+
+Enjoy! :)
+
+- The Qt Solutions Team.
diff --git a/src/QtSingleApplication/QtLockedFile b/3rd-parties/qtsingleapplication/QtLockedFile
similarity index 100%
rename from src/QtSingleApplication/QtLockedFile
rename to 3rd-parties/qtsingleapplication/QtLockedFile
diff --git a/src/QtSingleApplication/QtSingleApplication b/3rd-parties/qtsingleapplication/QtSingleApplication
similarity index 100%
rename from src/QtSingleApplication/QtSingleApplication
rename to 3rd-parties/qtsingleapplication/QtSingleApplication
diff --git a/3rd-parties/qtsingleapplication/README.TXT b/3rd-parties/qtsingleapplication/README.TXT
new file mode 100644
index 0000000..06abb09
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/README.TXT
@@ -0,0 +1,33 @@
+Qt Solutions Component: Single Application
+
+The QtSingleApplication component provides support for
+applications that can be only started once per user.
+
+
+
+Version history:
+
+2.0: - Version 1.3 ported to Qt 4.
+
+2.1: - Fix compilation problem on Mac.
+
+2.2: - Really fix the Mac compilation problem.
+ - Mac: fix crash due to wrong object releasing.
+ - Mac: Fix memory leak.
+
+2.3: - Windows: Force creation of internal widget to make it work
+ with Qt 4.2.
+
+2.4: - Fix the system for automatic window raising on message
+ reception. NOTE: minor API change.
+
+2.5: - Mac: Fix isRunning() to work and report correctly.
+
+2.6: - - initialize() is now obsolete, no longer necessary to call
+ it
+ - - Fixed race condition where multiple instances migth be started
+ - - QtSingleCoreApplication variant provided for non-GUI (console)
+ usage
+ - Complete reimplementation. Visible changes:
+ - LGPL release.
+
diff --git a/3rd-parties/qtsingleapplication/buildlib/buildlib.pro b/3rd-parties/qtsingleapplication/buildlib/buildlib.pro
new file mode 100644
index 0000000..37dddcd
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/buildlib/buildlib.pro
@@ -0,0 +1,13 @@
+TEMPLATE=lib
+CONFIG += qt dll qtsingleapplication-buildlib
+mac:CONFIG += absolute_library_soname
+win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all
+include(../src/qtsingleapplication.pri)
+TARGET = $$QTSINGLEAPPLICATION_LIBNAME
+DESTDIR = $$QTSINGLEAPPLICATION_LIBDIR
+win32 {
+ DLLDESTDIR = $$[QT_INSTALL_BINS]
+ QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSINGLEAPPLICATION_LIBNAME}.dll
+}
+target.path = $$DESTDIR
+INSTALLS += target
diff --git a/3rd-parties/qtsingleapplication/common.pri b/3rd-parties/qtsingleapplication/common.pri
new file mode 100644
index 0000000..924c57c
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/common.pri
@@ -0,0 +1,14 @@
+exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib
+
+TEMPLATE += fakelib
+greaterThan(QT_MAJOR_VERSION, 5)|\
+ if(equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 4))|\
+ if(equals(QT_MAJOR_VERSION, 5):equals(QT_MINOR_VERSION, 4):greaterThan(QT_PATCH_VERSION, 1)) {
+ QTSINGLEAPPLICATION_LIBNAME = $$qt5LibraryTarget(QtSolutions_SingleApplication-head)
+} else {
+ QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head)
+}
+TEMPLATE -= fakelib
+
+QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib
+unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR
diff --git a/3rd-parties/qtsingleapplication/configure b/3rd-parties/qtsingleapplication/configure
new file mode 100755
index 0000000..3c4edff
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/configure
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ "x$1" != "x" -a "x$1" != "x-library" ]; then
+ echo "Usage: $0 [-library]"
+ echo
+ echo "-library: Build the component as a dynamic library (DLL). Default is to"
+ echo " include the component source code directly in the application."
+ echo
+ exit 0
+fi
+
+rm -f config.pri
+if [ "x$1" = "x-library" ]; then
+ echo "Configuring to build this component as a dynamic library."
+ echo "SOLUTIONS_LIBRARY = yes" > config.pri
+fi
+
+echo
+echo "This component is now configured."
+echo
+echo "To build the component library (if requested) and example(s),"
+echo "run qmake and your make command."
+echo
+echo "To remove or reconfigure, run make distclean."
+echo
diff --git a/3rd-parties/qtsingleapplication/configure.bat b/3rd-parties/qtsingleapplication/configure.bat
new file mode 100644
index 0000000..2927549
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/configure.bat
@@ -0,0 +1,43 @@
+:: Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+:: SPDX-License-Identifier: BSD-3-Clause
+
+@echo off
+
+rem
+rem "Main"
+rem
+
+if not "%1"=="" (
+ if not "%1"=="-library" (
+ call :PrintUsage
+ goto EOF
+ )
+)
+
+if exist config.pri. del config.pri
+if "%1"=="-library" (
+ echo Configuring to build this component as a dynamic library.
+ echo SOLUTIONS_LIBRARY = yes > config.pri
+)
+
+echo .
+echo This component is now configured.
+echo .
+echo To build the component library (if requested) and example(s),
+echo run qmake and your make or nmake command.
+echo .
+echo To remove or reconfigure, run make (nmake) distclean.
+echo .
+goto EOF
+
+:PrintUsage
+echo Usage: configure.bat [-library]
+echo .
+echo -library: Build the component as a dynamic library (DLL). Default is to
+echo include the component source directly in the application.
+echo A DLL may be preferable for technical or licensing (LGPL) reasons.
+echo .
+goto EOF
+
+
+:EOF
diff --git a/3rd-parties/qtsingleapplication/doc/html/classic.css b/3rd-parties/qtsingleapplication/doc/html/classic.css
new file mode 100644
index 0000000..b8cae8e
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/classic.css
@@ -0,0 +1,284 @@
+BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
+ font-family: Arial, Geneva, Helvetica, sans-serif;
+}
+H1 {
+ text-align: center;
+ font-size: 160%;
+}
+H2 {
+ font-size: 120%;
+}
+H3 {
+ font-size: 100%;
+}
+
+h3.fn,span.fn
+{
+ background-color: #eee;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ddd;
+ font-weight: bold;
+ padding: 6px 0px 6px 10px;
+ margin: 42px 0px 0px 0px;
+}
+
+hr {
+ border: 0;
+ color: #a0a0a0;
+ background-color: #ccc;
+ height: 1px;
+ width: 100%;
+ text-align: left;
+ margin: 34px 0px 34px 0px;
+}
+
+table.valuelist {
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ border-color: #dddddd;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+}
+
+table.indextable {
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+ border-color:#555;
+ font-size: 100%;
+}
+
+table td.largeindex {
+ border-width: 1px 1px 1px 1px;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+ border-color:#555;
+ font-size: 120%;
+}
+
+table.valuelist th {
+ border-width: 1px 1px 1px 2px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #666;
+ color:white;
+ background-color:#666;
+}
+
+th.titleheader {
+ border-width: 1px 0px 1px 0px;
+ padding: 2px;
+ border-style: solid;
+ border-color: #666;
+ color:white;
+ background-color:#555;
+ background-image:url('images/gradient.png')};
+ background-repeat: repeat-x;
+ font-size: 100%;
+}
+
+
+th.largeheader {
+ border-width: 1px 0px 1px 0px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #444;
+ color:white;
+ background-color:#555555;
+ font-size: 120%;
+}
+
+p {
+
+ margin-left: 4px;
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+a:link
+{
+ color: #0046ad;
+ text-decoration: none
+}
+
+a:visited
+{
+ color: #672967;
+ text-decoration: none
+}
+
+a.obsolete
+{
+ color: #661100;
+ text-decoration: none
+}
+
+a.compat
+{
+ color: #661100;
+ text-decoration: none
+}
+
+a.obsolete:visited
+{
+ color: #995500;
+ text-decoration: none
+}
+
+a.compat:visited
+{
+ color: #995500;
+ text-decoration: none
+}
+
+body
+{
+ background: #ffffff;
+ color: black
+}
+
+table.generic, table.annotated
+{
+ border-width: 1px;
+ border-color:#bbb;
+ border-style:solid;
+ border-collapse:collapse;
+}
+
+table td.memItemLeft {
+ width: 180px;
+ padding: 2px 0px 0px 8px;
+ margin: 4px;
+ border-width: 1px;
+ border-color: #E0E0E0;
+ border-style: none;
+ font-size: 100%;
+ white-space: nowrap
+}
+
+table td.memItemRight {
+ padding: 2px 8px 0px 8px;
+ margin: 4px;
+ border-width: 1px;
+ border-color: #E0E0E0;
+ border-style: none;
+ font-size: 100%;
+}
+
+table tr.odd {
+ background: #f0f0f0;
+ color: black;
+}
+
+table tr.even {
+ background: #e4e4e4;
+ color: black;
+}
+
+table.annotated th {
+ padding: 3px;
+ text-align: left
+}
+
+table.annotated td {
+ padding: 3px;
+}
+
+table tr pre
+{
+ padding-top: 0px;
+ padding-bottom: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ border: none;
+ background: none
+}
+
+tr.qt-style
+{
+ background: #96E066;
+ color: black
+}
+
+body pre
+{
+ padding: 0.2em;
+ border: #e7e7e7 1px solid;
+ background: #f1f1f1;
+ color: black
+}
+
+table tr.qt-code pre
+{
+ padding: 0.2em;
+ border: #e7e7e7 1px solid;
+ background: #f1f1f1;
+ color: black
+}
+
+span.preprocessor, span.preprocessor a
+{
+ color: darkblue;
+}
+
+span.comment
+{
+ color: darkred;
+ font-style: italic
+}
+
+span.string,span.char
+{
+ color: darkgreen;
+}
+
+.title
+{
+ text-align: center
+}
+
+.subtitle
+{
+ font-size: 0.8em
+}
+
+.small-subtitle
+{
+ font-size: 0.65em
+}
+
+.qmlitem {
+ padding: 0;
+}
+
+.qmlname {
+ white-space: nowrap;
+}
+
+.qmltype {
+ text-align: center;
+ font-size: 160%;
+}
+
+.qmlproto {
+ background-color: #eee;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ddd;
+ font-weight: bold;
+ padding: 6px 10px 6px 10px;
+ margin: 42px 0px 0px 0px;
+}
+
+.qmlreadonly {
+ float: right;
+ color: red
+}
+
+.qmldoc {
+}
+
+*.qmlitem p {
+}
diff --git a/3rd-parties/qtsingleapplication/doc/html/images/qt-logo.png b/3rd-parties/qtsingleapplication/doc/html/images/qt-logo.png
new file mode 100644
index 0000000..794162f
Binary files /dev/null and b/3rd-parties/qtsingleapplication/doc/html/images/qt-logo.png differ
diff --git a/3rd-parties/qtsingleapplication/doc/html/index.html b/3rd-parties/qtsingleapplication/doc/html/index.html
new file mode 100644
index 0000000..af9dab1
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/index.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+ Single Application
+
+
+
+
+
+
+
+
Single Application
+
+
+Description
+The QtSingleApplication component provides support for applications that can be only started once per user.
+For some applications it is useful or even critical that they are started only once by any user. Future attempts to start the application should activate any already running instance, and possibly perform requested actions, e.g. loading a file, in that instance.
+The QtSingleApplication class provides an interface to detect a running instance, and to send command strings to that instance. For console (non-GUI) applications, the QtSingleCoreApplication variant is provided, which avoids dependency on QtGui .
+
+Classes
+
+
+Examples
+
+
+Tested platforms
+
+Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005
+Qt 4.4, 4.5 / Linux / gcc
+Qt 4.4, 4.5 / MacOS X 10.5 / gcc
+
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-loader.html b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-loader.html
new file mode 100644
index 0000000..6a36632
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-loader.html
@@ -0,0 +1,175 @@
+
+
+
+
+
+ Loading Documents
+
+
+
+
+
+
+
+
Loading Documents
+
+The application in this example loads or prints the documents passed as commandline parameters to further instances of this application.
+
+
+ #include <qtsingleapplication.h>
+ #include <QtCore/QFile>
+ #include <QtGui/QMainWindow>
+ #include <QtGui/QPrinter>
+ #include <QtGui/QPainter>
+ #include <QtGui/QTextEdit>
+ #include <QtGui/QMdiArea>
+ #include <QtCore/QTextStream>
+
+ class MainWindow : public QMainWindow
+ {
+ Q_OBJECT
+ public:
+ MainWindow();
+
+ public slots:
+ void handleMessage(const QString& message);
+
+ signals:
+ void needToShow();
+
+ private:
+ QMdiArea *workspace;
+ };
+The user interface in this application is a QMainWindow subclass with a QMdiArea as the central widget. It implements a slot handleMessage() that will be connected to the messageReceived() signal of the QtSingleApplication class.
+ MainWindow::MainWindow()
+ {
+ workspace = new QMdiArea(this);
+
+ setCentralWidget(workspace);
+ }
+The MainWindow constructor creates a minimal user interface.
+ void MainWindow::handleMessage(const QString& message)
+ {
+ enum Action {
+ Nothing,
+ Open,
+ Print
+ } action;
+
+ action = Nothing;
+ QString filename = message;
+ if (message.toLower().startsWith("/print ")) {
+ filename = filename.mid(7);
+ action = Print;
+ } else if (!message.isEmpty()) {
+ action = Open;
+ }
+ if (action == Nothing) {
+ emit needToShow();
+ return;
+ }
+
+ QFile file(filename);
+ QString contents;
+ if (file.open(QIODevice::ReadOnly))
+ contents = file.readAll();
+ else
+ contents = "[[Error: Could not load file " + filename + "]]";
+
+ QTextEdit *view = new QTextEdit;
+ view->setPlainText(contents);
+
+ switch(action) {
+The handleMessage() slot interprets the message passed in as a filename that can be prepended with /print to indicate that the file should just be printed rather than loaded.
+ case Print:
+ {
+ QPrinter printer;
+ view->print(&printer);
+ delete view;
+ }
+ break;
+
+ case Open:
+ {
+ workspace->addSubWindow(view);
+ view->setWindowTitle(message);
+ view->show();
+ emit needToShow();
+ }
+ break;
+ default:
+ break;
+ };
+ }
+Loading the file will also activate the window.
+ #include "main.moc"
+
+ int main(int argc, char **argv)
+ {
+ QtSingleApplication instance("File loader QtSingleApplication example", argc, argv);
+ QString message;
+ for (int a = 1; a < argc; ++a) {
+ message += argv[a];
+ if (a < argc-1)
+ message += " ";
+ }
+
+ if (instance.sendMessage(message))
+ return 0;
+The main entry point function creates a QtSingleApplication object, and creates a message to send to a running instance of the application. If the message was sent successfully the process exits immediately.
+ MainWindow mw;
+ mw.handleMessage(message);
+ mw.show();
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &mw, SLOT(handleMessage(const QString&)));
+
+ instance.setActivationWindow(&mw, false);
+ QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow()));
+
+ return instance.exec();
+ }
+If the message could not be sent the application starts up. Note that false is passed to the call to setActivationWindow() to prevent automatic activation for every message received, e.g. when the application should just print a file. Instead, the message handling function determines whether activation is requested, and signals that by emitting the needToShow() signal. This is then simply connected directly to QtSingleApplication 's activateWindow() slot.
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-trivial.html b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-trivial.html
new file mode 100644
index 0000000..5e60cfa
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-trivial.html
@@ -0,0 +1,101 @@
+
+
+
+
+
+ A Trivial Example
+
+
+
+
+
+
+
+
A Trivial Example
+
+The application in this example has a log-view that displays messages sent by further instances of the same application.
+The example demonstrates the use of the QtSingleApplication class to detect and communicate with a running instance of the application using the sendMessage() API. The messageReceived() signal is used to display received messages in a QTextEdit log.
+
+
+ #include <qtsingleapplication.h>
+ #include <QtGui/QTextEdit>
+
+ class TextEdit : public QTextEdit
+ {
+ Q_OBJECT
+ public:
+ TextEdit(QWidget *parent = 0)
+ : QTextEdit(parent)
+ {}
+ public slots:
+ void append(const QString &str)
+ {
+ QTextEdit::append(str);
+ }
+ };
+
+ #include "main.moc"
+
+ int main(int argc, char **argv)
+ {
+ QtSingleApplication instance(argc, argv);
+The example has only the main entry point function. A QtSingleApplication object is created immediately.
+ if (instance.sendMessage("Wake up!"))
+ return 0;
+If another instance of this application is already running, sendMessage() will succeed, and this instance just exits immediately.
+ TextEdit logview;
+ logview.setReadOnly(true);
+ logview.show();
+Otherwise the instance continues as normal and creates the user interface.
+ instance.setActivationWindow(&logview);
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &logview, SLOT(append(const QString&)));
+
+ return instance.exec();
+The logview object is also set as the application's activation window. Every time a message is received, the window will be raised and activated automatically.
+The messageReceived() signal is also connected to the QTextEdit 's append() slot. Every message received from further instances of this application will be displayed in the log.
+Finally the event loop is entered.
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-members.html b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-members.html
new file mode 100644
index 0000000..c995ce3
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-members.html
@@ -0,0 +1,235 @@
+
+
+
+
+
+ List of All Members for QtSingleApplication
+
+
+
+
+
+
+
+
List of All Members for QtSingleApplication
+This is the complete list of members for QtSingleApplication , including inherited members.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+connect ( const QObject *, const char *, const QObject *, const char *, Qt::ConnectionType )
+connect ( const QObject *, const char *, const char *, Qt::ConnectionType ) const
+
+
+
+
+
+
+
+
+disconnect ( const QObject *, const char *, const QObject *, const char * )
+disconnect ( const char *, const QObject *, const char * )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+notify ( QObject *, QEvent * )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+setFont ( const QFont &, const char * )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+tr ( const char *, const char *, int )
+trUtf8 ( const char *, const char *, int )
+translate ( const char *, const char *, const char *, Encoding, int )
+translate ( const char *, const char *, const char *, Encoding )
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-obsolete.html b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-obsolete.html
new file mode 100644
index 0000000..0d07dfa
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-obsolete.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Obsolete Members for QtSingleApplication
+
+
+
+
+
+
+
+
Obsolete Members for QtSingleApplication
+The following class members are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.
+
+Public Functions
+
+void initialize ( bool dummy = true ) (obsolete)
+
+
+Member Function Documentation
+ void QtSingleApplication::initialize ( bool dummy = true )
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.dcf b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.dcf
new file mode 100644
index 0000000..d81f87f
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.dcf
@@ -0,0 +1,40 @@
+
+
+
+
+ QtSingleApplication
+ activateWindow
+ activationWindow
+ id
+ isRunning
+ messageReceived
+ sendMessage
+ setActivationWindow
+
+
+
+
+ QtSingleCoreApplication
+ id
+ isRunning
+ messageReceived
+ sendMessage
+
+
+
+
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.html b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.html
new file mode 100644
index 0000000..2754a3b
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.html
@@ -0,0 +1,162 @@
+
+
+
+
+
+ QtSingleApplication Class Reference
+
+
+
+
+
+
+
+
QtSingleApplication Class Reference
+The QtSingleApplication class provides an API to detect and communicate with running instances of an application. More...
+ #include <QtSingleApplication> Inherits QApplication .
+
+
+
+Public Functions
+
+QtSingleApplication ( int & argc , char ** argv , bool GUIenabled = true )
+QtSingleApplication ( const QString & appId , int & argc , char ** argv )
+QtSingleApplication ( int & argc , char ** argv , Type type )
+QtSingleApplication ( Display * dpy , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+QtSingleApplication ( Display * dpy , int & argc , char ** argv , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+QtSingleApplication ( Display * dpy , const QString & appId , int argc , char ** argv , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+QWidget * activationWindow () const
+QString id () const
+bool isRunning ()
+void setActivationWindow ( QWidget * aw , bool activateOnMessage = true )
+
+
+
+
+Public Slots
+
+
+
+
+Signals
+
+
+Additional Inherited Members
+
+
+
+Detailed Description
+The QtSingleApplication class provides an API to detect and communicate with running instances of an application.
+This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead. Another usecase is a client-server system, where the first started instance will assume the role of server, and the later instances will act as clients of that server.
+By default, the full path of the executable file is used to determine whether two processes are instances of the same application. You can also provide an explicit identifier string that will be compared instead.
+The application should create the QtSingleApplication object early in the startup phase, and call isRunning () to find out if another instance of this application is already running. If isRunning () returns false, it means that no other instance is running, and this instance has assumed the role as the running instance. In this case, the application should continue with the initialization of the application user interface before entering the event loop with exec (), as normal.
+The messageReceived () signal will be emitted when the running application receives messages from another instance of the same application. When a message is received it might be helpful to the user to raise the application so that it becomes visible. To facilitate this, QtSingleApplication provides the setActivationWindow () function and the activateWindow () slot.
+If isRunning () returns true, another instance is already running. It may be alerted to the fact that another instance has started by using the sendMessage () function. Also data such as startup parameters (e.g. the name of the file the user wanted this new instance to open) can be passed to the running instance with this function. Then, the application should terminate (or enter client mode).
+If isRunning () returns true, but sendMessage () fails, that is an indication that the running instance is frozen.
+Here's an example that shows how to convert an existing application to use QtSingleApplication. It is very simple and does not make use of all QtSingleApplication's functionality (see the examples for that).
+
+ int main(int argc, char **argv)
+ {
+ QApplication app(argc, argv);
+
+ MyMainWidget mmw;
+ mmw.show();
+ return app.exec();
+ }
+
+
+ int main(int argc, char **argv)
+ {
+ QtSingleApplication app(argc, argv);
+
+ if (app.isRunning())
+ return !app.sendMessage(someDataString);
+
+ MyMainWidget mmw;
+ app.setActivationWindow(&mmw);
+ mmw.show();
+ return app.exec();
+ }
+Once this QtSingleApplication instance is destroyed (normally when the process exits or crashes), when the user next attempts to run the application this instance will not, of course, be encountered. The next instance to call isRunning () or sendMessage () will assume the role as the new running instance.
+For console (non-GUI) applications, QtSingleCoreApplication may be used instead of this class, to avoid the dependency on the QtGui library.
+See also QtSingleCoreApplication .
+
+Member Function Documentation
+ QtSingleApplication::QtSingleApplication ( int & argc , char ** argv , bool GUIenabled = true )
+Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath (). argc , argv , and GUIenabled are passed on to the QAppliation constructor.
+If you are creating a console application (i.e. setting GUIenabled to false), you may consider using QtSingleCoreApplication instead.
+ QtSingleApplication::QtSingleApplication ( const QString & appId , int & argc , char ** argv )
+Creates a QtSingleApplication object with the application identifier appId . argc and argv are passed on to the QAppliation constructor.
+ QtSingleApplication::QtSingleApplication ( int & argc , char ** argv , Type type )
+Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath (). argc , argv , and type are passed on to the QAppliation constructor.
+ QtSingleApplication::QtSingleApplication ( Display * dpy , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+Special constructor for X11, ref. the documentation of QApplication 's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath (). dpy , visual , and cmap are passed on to the QApplication constructor.
+ QtSingleApplication::QtSingleApplication ( Display * dpy , int & argc , char ** argv , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+Special constructor for X11, ref. the documentation of QApplication 's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath (). dpy , argc , argv , visual , and cmap are passed on to the QApplication constructor.
+ QtSingleApplication::QtSingleApplication ( Display * dpy , const QString & appId , int argc , char ** argv , Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
+Special constructor for X11, ref. the documentation of QApplication 's corresponding constructor. The application identifier will be appId . dpy , argc , argv , visual , and cmap are passed on to the QApplication constructor.
+ void QtSingleApplication::activateWindow () [slot]
+De-minimizes, raises, and activates this application's activation window. This function does nothing if no activation window has been set.
+This is a convenience function to show the user that this application instance has been activated when he has tried to start another instance.
+This function should typically be called in response to the messageReceived () signal. By default, that will happen automatically, if an activation window has been set.
+See also setActivationWindow (), messageReceived (), and initialize ().
+QWidget * QtSingleApplication::activationWindow () const
+Returns the applications activation window if one has been set by calling setActivationWindow (), otherwise returns 0.
+See also setActivationWindow ().
+QString QtSingleApplication::id () const
+Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.
+ bool QtSingleApplication::isRunning ()
+Returns true if another instance of this application is running; otherwise false.
+This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).
+See also sendMessage ().
+ void QtSingleApplication::messageReceived ( const QString & message ) [signal]
+This signal is emitted when the current instance receives a message from another instance of this application.
+See also sendMessage (), setActivationWindow (), and activateWindow ().
+ bool QtSingleApplication::sendMessage ( const QString & message , int timeout = 5000 ) [slot]
+Tries to send the text message to the currently running instance. The QtSingleApplication object in the running instance will emit the messageReceived () signal when it receives the message.
+This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.
+See also isRunning () and messageReceived ().
+ void QtSingleApplication::setActivationWindow ( QWidget * aw , bool activateOnMessage = true )
+Sets the activation window of this application to aw . The activation window is the widget that will be activated by activateWindow (). This is typically the application's main window.
+If activateOnMessage is true (the default), the window will be activated automatically every time a message is received, just prior to the messageReceived () signal being emitted.
+See also activationWindow (), activateWindow (), and messageReceived ().
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.index b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.index
new file mode 100644
index 0000000..56052c2
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.index
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.qhp b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.qhp
new file mode 100644
index 0000000..ff42d9d
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.qhp
@@ -0,0 +1,53 @@
+
+
+ com.nokia.qtsolutions.qtsingleapplication_head
+ qdoc
+
+ qt
+ solutions
+ qtsingleapplication
+
+
+ qt
+ solutions
+ qtsingleapplication
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ qtsingleapplication.html
+ index.html
+ qtsingleapplication-example-trivial.html
+ qtsinglecoreapplication.html
+ qtsingleapplication-example-loader.html
+ qtsinglecoreapplication-example-console.html
+ classic.css
+ images/qt-logo.png
+
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-example-console.html b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-example-console.html
new file mode 100644
index 0000000..18a9ae8
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-example-console.html
@@ -0,0 +1,118 @@
+
+
+
+
+
+ A non-GUI example
+
+
+
+
+
+
+
+
A non-GUI example
+
+This example shows how to use the single-application functionality in a console application. It does not require the QtGui library at all.
+The only differences from the GUI application usage demonstrated in the other examples are:
+1) The .pro file should include qtsinglecoreapplication.pri instead of qtsingleapplication.pri
+2) The class name is QtSingleCoreApplication instead of QtSingleApplication .
+3) No calls are made regarding window activation, for obvious reasons.
+console.pro:
+ TEMPLATE = app
+ CONFIG += console
+ SOURCES += main.cpp
+ include(../../src/qtsinglecoreapplication.pri)
+ QT -= gui
+main.cpp:
+
+
+ #include "qtsinglecoreapplication.h"
+ #include <QtCore/QDebug>
+
+ void report(const QString& msg)
+ {
+ qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg));
+ }
+
+ class MainClass : public QObject
+ {
+ Q_OBJECT
+ public:
+ MainClass()
+ : QObject()
+ {}
+
+ public slots:
+ void handleMessage(const QString& message)
+ {
+ report( "Message received: \"" + message + "\"");
+ }
+ };
+
+ int main(int argc, char **argv)
+ {
+ report("Starting up");
+
+ QtSingleCoreApplication app(argc, argv);
+
+ if (app.isRunning()) {
+ QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid()));
+ bool sentok = app.sendMessage(msg, 2000);
+ QString rep("Another instance is running, so I will exit.");
+ rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen.";
+ report(rep);
+ return 0;
+ } else {
+ report("No other instance is running; so I will.");
+ MainClass mainObj;
+ QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
+ &mainObj, SLOT(handleMessage(const QString&)));
+ return app.exec();
+ }
+ }
+
+ #include "main.moc"
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-members.html b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-members.html
new file mode 100644
index 0000000..69fb858
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-members.html
@@ -0,0 +1,126 @@
+
+
+
+
+
+ List of All Members for QtSingleCoreApplication
+
+
+
+
+
+
+
+
List of All Members for QtSingleCoreApplication
+This is the complete list of members for QtSingleCoreApplication , including inherited members.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+connect ( const QObject *, const char *, const QObject *, const char *, Qt::ConnectionType )
+connect ( const QObject *, const char *, const char *, Qt::ConnectionType ) const
+
+
+
+
+
+disconnect ( const QObject *, const char *, const QObject *, const char * )
+disconnect ( const char *, const QObject *, const char * )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+notify ( QObject *, QEvent * )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+tr ( const char *, const char *, int )
+trUtf8 ( const char *, const char *, int )
+translate ( const char *, const char *, const char *, Encoding, int )
+translate ( const char *, const char *, const char *, Encoding )
+
+
+
+
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication.html b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication.html
new file mode 100644
index 0000000..a20cf2f
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication.html
@@ -0,0 +1,98 @@
+
+
+
+
+
+ QtSingleCoreApplication Class Reference
+
+
+
+
+
+
+
+
QtSingleCoreApplication Class Reference
+A variant of the QtSingleApplication class for non-GUI applications. More...
+ #include <QtSingleCoreApplication> Inherits QCoreApplication .
+
+
+
+Public Functions
+
+
+
+
+Public Slots
+
+bool sendMessage ( const QString & message , int timeout = 5000 )
+
+
+
+
+Signals
+
+
+Additional Inherited Members
+
+
+
+Detailed Description
+A variant of the QtSingleApplication class for non-GUI applications.
+This class is a variant of QtSingleApplication suited for use in console (non-GUI) applications. It is an extension of QCoreApplication (instead of QApplication ). It does not require the QtGui library.
+The API and usage is identical to QtSingleApplication , except that functions relating to the "activation window" are not present, for obvious reasons. Please refer to the QtSingleApplication documentation for explanation of the usage.
+A QtSingleCoreApplication instance can communicate to a QtSingleApplication instance if they share the same application id. Hence, this class can be used to create a light-weight command-line tool that sends commands to a GUI application.
+See also QtSingleApplication .
+
+Member Function Documentation
+ QtSingleCoreApplication::QtSingleCoreApplication ( int & argc , char ** argv )
+Creates a QtSingleCoreApplication object. The application identifier will be QCoreApplication::applicationFilePath (). argc and argv are passed on to the QCoreAppliation constructor.
+ QtSingleCoreApplication::QtSingleCoreApplication ( const QString & appId , int & argc , char ** argv )
+Creates a QtSingleCoreApplication object with the application identifier appId . argc and argv are passed on to the QCoreAppliation constructor.
+QString QtSingleCoreApplication::id () const
+Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.
+ bool QtSingleCoreApplication::isRunning ()
+Returns true if another instance of this application is running; otherwise false.
+This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).
+See also sendMessage ().
+ void QtSingleCoreApplication::messageReceived ( const QString & message ) [signal]
+This signal is emitted when the current instance receives a message from another instance of this application.
+See also sendMessage ().
+ bool QtSingleCoreApplication::sendMessage ( const QString & message , int timeout = 5000 ) [slot]
+Tries to send the text message to the currently running instance. The QtSingleCoreApplication object in the running instance will emit the messageReceived () signal when it receives the message.
+This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.
+See also isRunning () and messageReceived ().
+
+
+Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)
+Trademarks
+Qt Solutions
+
+
diff --git a/3rd-parties/qtsingleapplication/doc/images/qt-logo.png b/3rd-parties/qtsingleapplication/doc/images/qt-logo.png
new file mode 100644
index 0000000..794162f
Binary files /dev/null and b/3rd-parties/qtsingleapplication/doc/images/qt-logo.png differ
diff --git a/3rd-parties/qtsingleapplication/doc/index.qdoc b/3rd-parties/qtsingleapplication/doc/index.qdoc
new file mode 100644
index 0000000..796dffe
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/doc/index.qdoc
@@ -0,0 +1,50 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+/*!
+ \page index.html
+ \title Single Application
+
+ \section1 Description
+
+ The QtSingleApplication component provides support
+ for applications that can be only started once per user.
+
+
+
+ For some applications it is useful or even critical that they are started
+ only once by any user. Future attempts to start the application should
+ activate any already running instance, and possibly perform requested
+ actions, e.g. loading a file, in that instance.
+
+ The QtSingleApplication class provides an interface to detect a running
+ instance, and to send command strings to that instance.
+ For console (non-GUI) applications, the QtSingleCoreApplication variant is provided, which avoids dependency on QtGui.
+
+
+
+
+ \section1 Classes
+ \list
+ \i QtSingleApplication \i QtSingleCoreApplication\endlist
+
+ \section1 Examples
+ \list
+ \i \link qtsingleapplication-example-trivial.html A Trivial Example \endlink \i \link qtsingleapplication-example-loader.html Loading Documents \endlink \i \link qtsinglecoreapplication-example-console.html A Non-GUI Example \endlink \endlist
+
+
+
+
+
+
+ \section1 Tested platforms
+ \list
+ \i Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005
+ \i Qt 4.4, 4.5 / Linux / gcc
+ \i Qt 4.4, 4.5 / MacOS X 10.5 / gcc
+ \endlist
+
+
+
+
+*/
diff --git a/3rd-parties/qtsingleapplication/examples/console/console.pro b/3rd-parties/qtsingleapplication/examples/console/console.pro
new file mode 100644
index 0000000..e0390e2
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/console/console.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG += console
+SOURCES += main.cpp
+include(../../src/qtsinglecoreapplication.pri)
+QT -= gui
diff --git a/3rd-parties/qtsingleapplication/examples/console/console.qdoc b/3rd-parties/qtsingleapplication/examples/console/console.qdoc
new file mode 100644
index 0000000..2706e26
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/console/console.qdoc
@@ -0,0 +1,28 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+/*! \page qtsinglecoreapplication-example-console.html
+ \title A non-GUI example
+
+ This example shows how to use the single-application functionality
+ in a console application. It does not require the \c QtGui library
+ at all.
+
+ The only differences from the GUI application usage demonstrated
+ in the other examples are:
+
+ 1) The \c.pro file should include \c qtsinglecoreapplication.pri
+ instead of \c qtsingleapplication.pri
+
+ 2) The class name is \c QtSingleCoreApplication instead of \c
+ QtSingleApplication.
+
+ 3) No calls are made regarding window activation, for obvious reasons.
+
+ console.pro:
+ \quotefile console/console.pro
+
+ main.cpp:
+ \quotefile console/main.cpp
+
+*/
diff --git a/3rd-parties/qtsingleapplication/examples/console/main.cpp b/3rd-parties/qtsingleapplication/examples/console/main.cpp
new file mode 100644
index 0000000..13fd00e
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/console/main.cpp
@@ -0,0 +1,52 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "qtsinglecoreapplication.h"
+#include
+
+
+void report(const QString& msg)
+{
+ qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg));
+}
+
+class MainClass : public QObject
+{
+ Q_OBJECT
+public:
+ MainClass()
+ : QObject()
+ {}
+
+public slots:
+ void handleMessage(const QString& message)
+ {
+ report( "Message received: \"" + message + "\"");
+ }
+};
+
+int main(int argc, char **argv)
+{
+ report("Starting up");
+
+ QtSingleCoreApplication app(argc, argv);
+
+ if (app.isRunning()) {
+ QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid()));
+ bool sentok = app.sendMessage(msg, 2000);
+ QString rep("Another instance is running, so I will exit.");
+ rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen.";
+ report(rep);
+ return 0;
+ } else {
+ report("No other instance is running; so I will.");
+ MainClass mainObj;
+ QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
+ &mainObj, SLOT(handleMessage(const QString&)));
+ return app.exec();
+ }
+}
+
+
+#include "main.moc"
diff --git a/3rd-parties/qtsingleapplication/examples/examples.pro b/3rd-parties/qtsingleapplication/examples/examples.pro
new file mode 100644
index 0000000..36b8fd3
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/examples.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = trivial \
+ loader \
+ console
diff --git a/3rd-parties/qtsingleapplication/examples/loader/file1.qsl b/3rd-parties/qtsingleapplication/examples/loader/file1.qsl
new file mode 100644
index 0000000..50fcd26
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/loader/file1.qsl
@@ -0,0 +1 @@
+File 1
diff --git a/3rd-parties/qtsingleapplication/examples/loader/file2.qsl b/3rd-parties/qtsingleapplication/examples/loader/file2.qsl
new file mode 100644
index 0000000..4475433
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/loader/file2.qsl
@@ -0,0 +1 @@
+File 2
diff --git a/3rd-parties/qtsingleapplication/examples/loader/loader.pro b/3rd-parties/qtsingleapplication/examples/loader/loader.pro
new file mode 100644
index 0000000..3e52586
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/loader/loader.pro
@@ -0,0 +1,6 @@
+greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
+TEMPLATE = app
+
+include(../../src/qtsingleapplication.pri)
+
+SOURCES += main.cpp
diff --git a/3rd-parties/qtsingleapplication/examples/loader/loader.qdoc b/3rd-parties/qtsingleapplication/examples/loader/loader.qdoc
new file mode 100644
index 0000000..1f55026
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/loader/loader.qdoc
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+/*! \page qtsingleapplication-example-loader.html
+ \title Loading Documents
+
+ The application in this example loads or prints the documents
+ passed as commandline parameters to further instances of this
+ application.
+
+ \quotefromfile loader/main.cpp
+ \printuntil };
+ The user interface in this application is a QMainWindow subclass
+ with a QMdiArea as the central widget. It implements a slot
+ \c handleMessage() that will be connected to the messageReceived()
+ signal of the QtSingleApplication class.
+
+ \printuntil }
+ The MainWindow constructor creates a minimal user interface.
+
+ \printto case Print:
+ The handleMessage() slot interprets the message passed in as a
+ filename that can be prepended with \e /print to indicate that
+ the file should just be printed rather than loaded.
+
+ \printto #include
+ Loading the file will also activate the window.
+
+ \printto mw
+ The \c main entry point function creates a QtSingleApplication
+ object, and creates a message to send to a running instance
+ of the application. If the message was sent successfully the
+ process exits immediately.
+
+ \printuntil }
+ If the message could not be sent the application starts up. Note
+ that \c false is passed to the call to setActivationWindow() to
+ prevent automatic activation for every message received, e.g. when
+ the application should just print a file. Instead, the message
+ handling function determines whether activation is requested, and
+ signals that by emitting the needToShow() signal. This is then
+ simply connected directly to QtSingleApplication's
+ activateWindow() slot.
+*/
diff --git a/3rd-parties/qtsingleapplication/examples/loader/main.cpp b/3rd-parties/qtsingleapplication/examples/loader/main.cpp
new file mode 100644
index 0000000..5078490
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/loader/main.cpp
@@ -0,0 +1,115 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow();
+
+public slots:
+ void handleMessage(const QString& message);
+
+signals:
+ void needToShow();
+
+private:
+ QMdiArea *workspace;
+};
+
+MainWindow::MainWindow()
+{
+ workspace = new QMdiArea(this);
+
+ setCentralWidget(workspace);
+}
+
+void MainWindow::handleMessage(const QString& message)
+{
+ enum Action {
+ Nothing,
+ Open,
+ Print
+ } action;
+
+ action = Nothing;
+ QString filename = message;
+ if (message.toLower().startsWith("/print ")) {
+ filename = filename.mid(7);
+ action = Print;
+ } else if (!message.isEmpty()) {
+ action = Open;
+ }
+ if (action == Nothing) {
+ emit needToShow();
+ return;
+ }
+
+ QFile file(filename);
+ QString contents;
+ if (file.open(QIODevice::ReadOnly))
+ contents = file.readAll();
+ else
+ contents = "[[Error: Could not load file " + filename + "]]";
+
+ QTextEdit *view = new QTextEdit;
+ view->setPlainText(contents);
+
+ switch(action) {
+ case Print:
+ {
+ QPrinter printer;
+ view->print(&printer);
+ delete view;
+ }
+ break;
+
+ case Open:
+ {
+ workspace->addSubWindow(view);
+ view->setWindowTitle(message);
+ view->show();
+ emit needToShow();
+ }
+ break;
+ default:
+ break;
+ };
+}
+
+#include "main.moc"
+
+int main(int argc, char **argv)
+{
+ QtSingleApplication instance("File loader QtSingleApplication example", argc, argv);
+ QString message;
+ for (int a = 1; a < argc; ++a) {
+ message += argv[a];
+ if (a < argc-1)
+ message += " ";
+ }
+
+ if (instance.sendMessage(message))
+ return 0;
+
+ MainWindow mw;
+ mw.handleMessage(message);
+ mw.show();
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &mw, SLOT(handleMessage(const QString&)));
+
+ instance.setActivationWindow(&mw, false);
+ QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow()));
+
+ return instance.exec();
+}
diff --git a/3rd-parties/qtsingleapplication/examples/trivial/main.cpp b/3rd-parties/qtsingleapplication/examples/trivial/main.cpp
new file mode 100644
index 0000000..d243cc5
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/trivial/main.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include
+#include
+
+class TextEdit : public QTextEdit
+{
+ Q_OBJECT
+public:
+ TextEdit(QWidget *parent = 0)
+ : QTextEdit(parent)
+ {}
+public slots:
+ void append(const QString &str)
+ {
+ QTextEdit::append(str);
+ }
+};
+
+#include "main.moc"
+
+
+
+int main(int argc, char **argv)
+{
+ QtSingleApplication instance(argc, argv);
+ if (instance.sendMessage("Wake up!"))
+ return 0;
+
+ TextEdit logview;
+ logview.setReadOnly(true);
+ logview.show();
+
+ instance.setActivationWindow(&logview);
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &logview, SLOT(append(const QString&)));
+
+ return instance.exec();
+}
diff --git a/3rd-parties/qtsingleapplication/examples/trivial/trivial.pro b/3rd-parties/qtsingleapplication/examples/trivial/trivial.pro
new file mode 100644
index 0000000..673497a
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/trivial/trivial.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+
+include(../../src/qtsingleapplication.pri)
+
+SOURCES += main.cpp
diff --git a/3rd-parties/qtsingleapplication/examples/trivial/trivial.qdoc b/3rd-parties/qtsingleapplication/examples/trivial/trivial.qdoc
new file mode 100644
index 0000000..4a8640e
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/examples/trivial/trivial.qdoc
@@ -0,0 +1,39 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+/*! \page qtsingleapplication-example-trivial.html
+ \title A Trivial Example
+
+ The application in this example has a log-view that displays
+ messages sent by further instances of the same application.
+
+ The example demonstrates the use of the QtSingleApplication
+ class to detect and communicate with a running instance of
+ the application using the sendMessage() API. The messageReceived()
+ signal is used to display received messages in a QTextEdit log.
+
+ \quotefromfile trivial/main.cpp
+ \printuntil instance
+ The example has only the \c main entry point function.
+ A QtSingleApplication object is created immediately.
+
+ \printuntil return
+ If another instance of this application is already running,
+ sendMessage() will succeed, and this instance just exits
+ immediately.
+
+ \printuntil show()
+ Otherwise the instance continues as normal and creates the
+ user interface.
+
+ \printuntil return instance.exec();
+ The \c logview object is also set as the application's activation
+ window. Every time a message is received, the window will be raised
+ and activated automatically.
+
+ The messageReceived() signal is also connected to the QTextEdit's
+ append() slot. Every message received from further instances of
+ this application will be displayed in the log.
+
+ Finally the event loop is entered.
+*/
diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/3rd-parties/qtsingleapplication/qtlocalpeer.cpp
similarity index 85%
rename from src/QtSingleApplication/qtlocalpeer.cpp
rename to 3rd-parties/qtsingleapplication/qtlocalpeer.cpp
index 7d875d4..a7dd166 100644
--- a/src/QtSingleApplication/qtlocalpeer.cpp
+++ b/3rd-parties/qtsingleapplication/qtlocalpeer.cpp
@@ -45,34 +45,32 @@
#include
#if defined(Q_OS_WIN)
- #include
- #include
- typedef BOOL(WINAPI *PProcessIdToSessionId)(DWORD, DWORD *);
- static PProcessIdToSessionId pProcessIdToSessionId = 0;
+#include
+#include
+typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
+static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif
#if defined(Q_OS_UNIX)
- #include
- #include
- #include
+#include
+#include
+#include
#endif
-namespace QtLP_Private
-{
+namespace QtLP_Private {
#include "qtlockedfile.cpp"
#if defined(Q_OS_WIN)
- #include "qtlockedfile_win.cpp"
+#include "qtlockedfile_win.cpp"
#else
- #include "qtlockedfile_unix.cpp"
+#include "qtlockedfile_unix.cpp"
#endif
}
-const char *QtLocalPeer::ack = "ack";
+const char* QtLocalPeer::ack = "ack";
-QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
+QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
: QObject(parent), id(appId)
{
QString prefix = id;
-
if (id.isEmpty()) {
id = QCoreApplication::applicationFilePath();
#if defined(Q_OS_WIN)
@@ -80,30 +78,28 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
#endif
prefix = id.section(QLatin1Char('/'), -1);
}
-
prefix.remove(QRegExp("[^a-zA-Z]"));
prefix.truncate(6);
+
QByteArray idc = id.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
socketName = QLatin1String("qtsingleapp-") + prefix
+ QLatin1Char('-') + QString::number(idNum, 16);
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) {
QLibrary lib("kernel32");
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
}
-
if (pProcessIdToSessionId) {
DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += QLatin1Char('-') + QString::number(sessionId, 16);
}
-
#else
socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
#endif
- socketName += qgetenv("DISPLAY");
+
server = new QLocalServer(this);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
@@ -116,29 +112,22 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
bool QtLocalPeer::isClient()
{
- if (lockFile.isLocked()) {
+ if (lockFile.isLocked())
return false;
- }
- if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) {
+ if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
return true;
- }
bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
-
// ### Workaround
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
- QFile::remove(QDir::cleanPath(QDir::tempPath()) + QLatin1Char('/') + socketName);
+ QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
res = server->listen(socketName);
}
-
#endif
-
- if (!res) {
+ if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
- }
-
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
return false;
}
@@ -146,22 +135,17 @@ bool QtLocalPeer::isClient()
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
{
- if (!isClient()) {
+ if (!isClient())
return false;
- }
QLocalSocket socket;
bool connOk = false;
-
- for (int i = 0; i < 2; i++) {
+ for(int i = 0; i < 2; i++) {
// Try twice, in case the other instance is just starting up
socket.connectToServer(socketName);
- connOk = socket.waitForConnected(timeout / 2);
-
- if (connOk || i) {
+ connOk = socket.waitForConnected(timeout/2);
+ if (connOk || i)
break;
- }
-
int ms = 250;
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
@@ -170,47 +154,37 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
nanosleep(&ts, NULL);
#endif
}
-
- if (!connOk) {
+ if (!connOk)
return false;
- }
QByteArray uMsg(message.toUtf8());
QDataStream ds(&socket);
ds.writeBytes(uMsg.constData(), uMsg.size());
bool res = socket.waitForBytesWritten(timeout);
-
if (res) {
res &= socket.waitForReadyRead(timeout); // wait for ack
-
- if (res) {
+ if (res)
res &= (socket.read(qstrlen(ack)) == ack);
- }
}
-
return res;
}
void QtLocalPeer::receiveConnection()
{
- QLocalSocket *socket = server->nextPendingConnection();
-
- if (!socket) {
+ QLocalSocket* socket = server->nextPendingConnection();
+ if (!socket)
return;
- }
while (true) {
if (socket->state() == QLocalSocket::UnconnectedState) {
qWarning("QtLocalPeer: Peer disconnected");
delete socket;
+ socket = nullptr;
return;
}
-
- if (socket->bytesAvailable() >= qint64(sizeof(quint32))) {
+ if (socket->bytesAvailable() >= qint64(sizeof(quint32)))
break;
- }
-
socket->waitForReadyRead();
}
@@ -220,24 +194,23 @@ void QtLocalPeer::receiveConnection()
ds >> remaining;
uMsg.resize(remaining);
int got = 0;
- char *uMsgBuf = uMsg.data();
-
+ char* uMsgBuf = uMsg.data();
do {
got = ds.readRawData(uMsgBuf, remaining);
remaining -= got;
uMsgBuf += got;
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
-
if (got < 0) {
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
delete socket;
+ socket = nullptr;
return;
}
-
QString message(QString::fromUtf8(uMsg));
socket->write(ack, qstrlen(ack));
socket->waitForBytesWritten(1000);
socket->waitForDisconnected(1000); // make sure client reads ack
delete socket;
+ socket = nullptr;
Q_EMIT messageReceived(message); //### (might take a long time to return)
}
diff --git a/src/QtSingleApplication/qtlocalpeer.h b/3rd-parties/qtsingleapplication/qtlocalpeer.h
similarity index 96%
rename from src/QtSingleApplication/qtlocalpeer.h
rename to 3rd-parties/qtsingleapplication/qtlocalpeer.h
index 4e63426..1b533b1 100644
--- a/src/QtSingleApplication/qtlocalpeer.h
+++ b/3rd-parties/qtsingleapplication/qtlocalpeer.h
@@ -56,9 +56,7 @@ public:
bool isClient();
bool sendMessage(const QString &message, int timeout);
QString applicationId() const
- {
- return id;
- }
+ { return id; }
Q_SIGNALS:
void messageReceived(const QString &message);
@@ -69,11 +67,11 @@ protected Q_SLOTS:
protected:
QString id;
QString socketName;
- QLocalServer *server;
+ QLocalServer* server;
QtLP_Private::QtLockedFile lockFile;
private:
- static const char *ack;
+ static const char* ack;
};
#endif // QTLOCALPEER_H
diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/3rd-parties/qtsingleapplication/qtlockedfile.cpp
similarity index 99%
rename from src/QtSingleApplication/qtlockedfile.cpp
rename to 3rd-parties/qtsingleapplication/qtlockedfile.cpp
index 2204343..c142a86 100644
--- a/src/QtSingleApplication/qtlockedfile.cpp
+++ b/3rd-parties/qtsingleapplication/qtlockedfile.cpp
@@ -126,7 +126,6 @@ bool QtLockedFile::open(OpenMode mode)
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
return false;
}
-
return QFile::open(mode);
}
diff --git a/src/QtSingleApplication/qtlockedfile.h b/3rd-parties/qtsingleapplication/qtlockedfile.h
similarity index 83%
rename from src/QtSingleApplication/qtlockedfile.h
rename to 3rd-parties/qtsingleapplication/qtlockedfile.h
index e73d39a..84c18e5 100644
--- a/src/QtSingleApplication/qtlockedfile.h
+++ b/3rd-parties/qtsingleapplication/qtlockedfile.h
@@ -43,27 +43,26 @@
#include
#ifdef Q_OS_WIN
- #include
+#include
#endif
#if defined(Q_OS_WIN)
- #if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
- #define QT_QTLOCKEDFILE_EXPORT
- #elif defined(QT_QTLOCKEDFILE_IMPORT)
- #if defined(QT_QTLOCKEDFILE_EXPORT)
- #undef QT_QTLOCKEDFILE_EXPORT
- #endif
- #define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
- #elif defined(QT_QTLOCKEDFILE_EXPORT)
- #undef QT_QTLOCKEDFILE_EXPORT
- #define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
- #endif
+# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
+# define QT_QTLOCKEDFILE_EXPORT
+# elif defined(QT_QTLOCKEDFILE_IMPORT)
+# if defined(QT_QTLOCKEDFILE_EXPORT)
+# undef QT_QTLOCKEDFILE_EXPORT
+# endif
+# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
+# elif defined(QT_QTLOCKEDFILE_EXPORT)
+# undef QT_QTLOCKEDFILE_EXPORT
+# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
+# endif
#else
- #define QT_QTLOCKEDFILE_EXPORT
+# define QT_QTLOCKEDFILE_EXPORT
#endif
-namespace QtLP_Private
-{
+namespace QtLP_Private {
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
{
diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/3rd-parties/qtsingleapplication/qtlockedfile_unix.cpp
similarity index 93%
rename from src/QtSingleApplication/qtlockedfile_unix.cpp
rename to 3rd-parties/qtsingleapplication/qtlockedfile_unix.cpp
index 9e9a5a6..976c1b9 100644
--- a/src/QtSingleApplication/qtlockedfile_unix.cpp
+++ b/3rd-parties/qtsingleapplication/qtlockedfile_unix.cpp
@@ -51,41 +51,31 @@ bool QtLockedFile::lock(LockMode mode, bool block)
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
-
- if (mode == NoLock) {
+
+ if (mode == NoLock)
return unlock();
- }
-
- if (mode == m_lock_mode) {
+
+ if (mode == m_lock_mode)
return true;
- }
- if (m_lock_mode != NoLock) {
+ if (m_lock_mode != NoLock)
unlock();
- }
struct flock fl;
-
fl.l_whence = SEEK_SET;
-
fl.l_start = 0;
-
fl.l_len = 0;
-
fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
-
int cmd = block ? F_SETLKW : F_SETLK;
-
int ret = fcntl(handle(), cmd, &fl);
-
+
if (ret == -1) {
- if (errno != EINTR && errno != EAGAIN) {
+ if (errno != EINTR && errno != EAGAIN)
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
- }
-
return false;
}
+
m_lock_mode = mode;
return true;
}
@@ -98,35 +88,28 @@ bool QtLockedFile::unlock()
return false;
}
- if (!isLocked()) {
+ if (!isLocked())
return true;
- }
struct flock fl;
-
fl.l_whence = SEEK_SET;
-
fl.l_start = 0;
-
fl.l_len = 0;
-
fl.l_type = F_UNLCK;
-
int ret = fcntl(handle(), F_SETLKW, &fl);
-
+
if (ret == -1) {
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
-
+
m_lock_mode = NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
- if (isOpen()) {
+ if (isOpen())
unlock();
- }
}
diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/3rd-parties/qtsingleapplication/qtlockedfile_win.cpp
similarity index 79%
rename from src/QtSingleApplication/qtlockedfile_win.cpp
rename to 3rd-parties/qtsingleapplication/qtlockedfile_win.cpp
index 38500e4..5e21262 100644
--- a/src/QtSingleApplication/qtlockedfile_win.cpp
+++ b/3rd-parties/qtsingleapplication/qtlockedfile_win.cpp
@@ -47,7 +47,7 @@
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
#if QT_VERSION >= 0x050000
- #define QT_WA(unicode, ansi) unicode
+#define QT_WA(unicode, ansi) unicode
#endif
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
@@ -57,36 +57,28 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
mutexname = QString::fromLatin1(MUTEX_PREFIX)
+ fi.absoluteFilePath().toLower();
}
-
QString mname(mutexname);
-
- if (idx >= 0) {
+ if (idx >= 0)
mname += QString::number(idx);
- }
Qt::HANDLE mutex;
-
if (doCreate) {
- QT_WA({ mutex = CreateMutexW(NULL, FALSE, (TCHAR *)mname.utf16()); },
- { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); });
-
+ QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
+ { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
return 0;
}
- } else {
- QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR *)mname.utf16()); },
- { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); });
-
+ }
+ else {
+ QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
+ { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
- if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND)
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
- }
-
return 0;
}
}
-
return mutex;
}
@@ -94,20 +86,16 @@ bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock)
{
Q_ASSERT(mutex);
DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0);
-
switch (res) {
- case WAIT_OBJECT_0:
- case WAIT_ABANDONED:
- return true;
- break;
-
- case WAIT_TIMEOUT:
- break;
-
- default:
- qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed");
+ case WAIT_OBJECT_0:
+ case WAIT_ABANDONED:
+ return true;
+ break;
+ case WAIT_TIMEOUT:
+ break;
+ default:
+ qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed");
}
-
return false;
}
@@ -120,83 +108,61 @@ bool QtLockedFile::lock(LockMode mode, bool block)
return false;
}
- if (mode == NoLock) {
+ if (mode == NoLock)
return unlock();
- }
- if (mode == m_lock_mode) {
+ if (mode == m_lock_mode)
return true;
- }
- if (m_lock_mode != NoLock) {
+ if (m_lock_mode != NoLock)
unlock();
- }
- if (!wmutex && !(wmutex = getMutexHandle(-1, true))) {
+ if (!wmutex && !(wmutex = getMutexHandle(-1, true)))
return false;
- }
- if (!waitMutex(wmutex, block)) {
+ if (!waitMutex(wmutex, block))
return false;
- }
if (mode == ReadLock) {
int idx = 0;
-
for (; idx < MAX_READERS; idx++) {
rmutex = getMutexHandle(idx, false);
-
- if (!rmutex || waitMutex(rmutex, false)) {
+ if (!rmutex || waitMutex(rmutex, false))
break;
- }
-
CloseHandle(rmutex);
}
-
bool ok = true;
-
if (idx >= MAX_READERS) {
qWarning("QtLockedFile::lock(): too many readers");
rmutex = 0;
ok = false;
- } else if (!rmutex) {
- rmutex = getMutexHandle(idx, true);
-
- if (!rmutex || !waitMutex(rmutex, false)) {
- ok = false;
- }
}
-
+ else if (!rmutex) {
+ rmutex = getMutexHandle(idx, true);
+ if (!rmutex || !waitMutex(rmutex, false))
+ ok = false;
+ }
if (!ok && rmutex) {
CloseHandle(rmutex);
rmutex = 0;
}
-
ReleaseMutex(wmutex);
-
- if (!ok) {
+ if (!ok)
return false;
- }
- } else {
+ }
+ else {
Q_ASSERT(rmutexes.isEmpty());
-
for (int i = 0; i < MAX_READERS; i++) {
Qt::HANDLE mutex = getMutexHandle(i, false);
-
- if (mutex) {
+ if (mutex)
rmutexes.append(mutex);
- }
}
-
if (rmutexes.size()) {
DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(),
TRUE, block ? INFINITE : 0);
-
if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) {
- if (res != WAIT_TIMEOUT) {
+ if (res != WAIT_TIMEOUT)
qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed");
- }
-
m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky
unlock();
return false;
@@ -215,20 +181,19 @@ bool QtLockedFile::unlock()
return false;
}
- if (!isLocked()) {
+ if (!isLocked())
return true;
- }
if (m_lock_mode == ReadLock) {
ReleaseMutex(rmutex);
CloseHandle(rmutex);
rmutex = 0;
- } else {
- Q_FOREACH (Qt::HANDLE mutex, rmutexes) {
+ }
+ else {
+ foreach(Qt::HANDLE mutex, rmutexes) {
ReleaseMutex(mutex);
CloseHandle(mutex);
}
-
rmutexes.clear();
ReleaseMutex(wmutex);
}
@@ -239,11 +204,8 @@ bool QtLockedFile::unlock()
QtLockedFile::~QtLockedFile()
{
- if (isOpen()) {
+ if (isOpen())
unlock();
- }
-
- if (wmutex) {
+ if (wmutex)
CloseHandle(wmutex);
- }
}
diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/3rd-parties/qtsingleapplication/qtsingleapplication.cpp
similarity index 84%
rename from src/QtSingleApplication/qtsingleapplication.cpp
rename to 3rd-parties/qtsingleapplication/qtsingleapplication.cpp
index d957182..5878a82 100644
--- a/src/QtSingleApplication/qtsingleapplication.cpp
+++ b/3rd-parties/qtsingleapplication/qtsingleapplication.cpp
@@ -40,15 +40,8 @@
#include "qtsingleapplication.h"
-#include "src/UtilityFunction/utility.h"
#include "qtlocalpeer.h"
#include
-#include
-#include
-#include
-#include
-#include "mainwindow.h"
-#include "tabletwindow.h"
/*!
@@ -144,7 +137,7 @@ void QtSingleApplication::sysInit(const QString &appId)
{
actWin = 0;
peer = new QtLocalPeer(this, appId);
- connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &)));
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
@@ -198,7 +191,7 @@ QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
and \a cmap are passed on to the QApplication constructor.
*/
-QtSingleApplication::QtSingleApplication(Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
+QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, visual, cmap)
{
sysInit();
@@ -224,7 +217,7 @@ QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Q
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
-QtSingleApplication::QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
+QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit(appId);
@@ -249,21 +242,6 @@ bool QtSingleApplication::isRunning()
return peer->isClient();
}
-//bool QtSingleApplication::notify(QObject *obj, QEvent * event)
-//{
-// if (event->type() == QEvent::ActivationChange)
-// // if(QEvent::WindowDeactivate == event->type())//窗口停用
-// {
-// qDebug() << " * 1111111鼠标点击窗口外部事件";
-// if(QApplication::activeWindow() != actWin)
-// {
-// actWin->hide();
-// // ->widgetMakeZero();
-// }
-// }
-// return QApplication::notify(obj, event);
-//}
-
/*!
Tries to send the text \a message to the currently running
@@ -306,15 +284,13 @@ QString QtSingleApplication::id() const
\sa activateWindow(), messageReceived()
*/
-void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage)
+void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
{
actWin = aw;
-
- if (activateOnMessage) {
- connect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow()));
- } else {
- disconnect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow()));
- }
+ if (activateOnMessage)
+ connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
+ else
+ disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
}
@@ -324,7 +300,7 @@ void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessag
\sa setActivationWindow()
*/
-QWidget *QtSingleApplication::activationWindow() const
+QWidget* QtSingleApplication::activationWindow() const
{
return actWin;
}
@@ -347,24 +323,9 @@ QWidget *QtSingleApplication::activationWindow() const
void QtSingleApplication::activateWindow()
{
if (actWin) {
- myDebug() << "单例触发activateWindow";
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- MainWindow *w = qobject_cast(actWin);
- w->windowOption();
-
-// if (this->applicationState() & Qt::ApplicationInactive) {
-// myDebug() << "单例内触发开始菜单显示";
-// actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
-// w->showWindow();
-// } else {
-// myDebug() << "单例内触发开始菜单隐藏";
-// actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized);
-// w->hideWindow();
-// }
- } else {
- TabletWindow *w = qobject_cast(actWin);
- w->showPCMenu();
- }
+ //actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
+ actWin->raise();
+ actWin->activateWindow();
}
}
diff --git a/src/QtSingleApplication/qtsingleapplication.h b/3rd-parties/qtsingleapplication/qtsingleapplication.h
similarity index 75%
rename from src/QtSingleApplication/qtsingleapplication.h
rename to 3rd-parties/qtsingleapplication/qtsingleapplication.h
index 3bbc700..049406f 100644
--- a/src/QtSingleApplication/qtsingleapplication.h
+++ b/3rd-parties/qtsingleapplication/qtsingleapplication.h
@@ -46,19 +46,19 @@
class QtLocalPeer;
#if defined(Q_OS_WIN)
- #if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
- #define QT_QTSINGLEAPPLICATION_EXPORT
- #elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
- #if defined(QT_QTSINGLEAPPLICATION_EXPORT)
- #undef QT_QTSINGLEAPPLICATION_EXPORT
- #endif
- #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
- #elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
- #undef QT_QTSINGLEAPPLICATION_EXPORT
- #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
- #endif
+# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
+# define QT_QTSINGLEAPPLICATION_EXPORT
+# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
+# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
+# undef QT_QTSINGLEAPPLICATION_EXPORT
+# endif
+# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
+# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
+# undef QT_QTSINGLEAPPLICATION_EXPORT
+# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
+# endif
#else
- #define QT_QTSINGLEAPPLICATION_EXPORT
+# define QT_QTSINGLEAPPLICATION_EXPORT
#endif
class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
@@ -71,24 +71,21 @@ public:
#if QT_VERSION < 0x050000
QtSingleApplication(int &argc, char **argv, Type type);
# if defined(Q_WS_X11)
- QtSingleApplication(Display *dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
- QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0);
- QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
+ QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
+ QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
+ QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
# endif // Q_WS_X11
#endif // QT_VERSION < 0x050000
bool isRunning();
QString id() const;
- void setActivationWindow(QWidget *aw, bool activateOnMessage = true);
- QWidget *activationWindow() const;
+ void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
+ QWidget* activationWindow() const;
// Obsolete:
void initialize(bool dummy = true)
- {
- isRunning();
- Q_UNUSED(dummy)
- }
+ { isRunning(); Q_UNUSED(dummy) }
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
@@ -98,8 +95,6 @@ public Q_SLOTS:
Q_SIGNALS:
void messageReceived(const QString &message);
-protected:
- // bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
private:
void sysInit(const QString &appId = QString());
diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/3rd-parties/qtsingleapplication/qtsingleapplication.pri
similarity index 100%
rename from src/QtSingleApplication/qtsingleapplication.pri
rename to 3rd-parties/qtsingleapplication/qtsingleapplication.pri
diff --git a/3rd-parties/qtsingleapplication/qtsingleapplication.pro b/3rd-parties/qtsingleapplication/qtsingleapplication.pro
new file mode 100644
index 0000000..07257c5
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/qtsingleapplication.pro
@@ -0,0 +1,5 @@
+TEMPLATE=subdirs
+CONFIG += ordered
+include(common.pri)
+qtsingleapplication-uselib:SUBDIRS=buildlib
+SUBDIRS+=examples
diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/3rd-parties/qtsingleapplication/qtsinglecoreapplication.cpp
similarity index 96%
rename from src/QtSingleApplication/qtsinglecoreapplication.cpp
rename to 3rd-parties/qtsingleapplication/qtsinglecoreapplication.cpp
index d06a75b..5634537 100644
--- a/src/QtSingleApplication/qtsinglecoreapplication.cpp
+++ b/3rd-parties/qtsingleapplication/qtsinglecoreapplication.cpp
@@ -74,7 +74,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this);
- connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &)));
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
@@ -87,7 +87,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this, appId);
- connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &)));
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/3rd-parties/qtsingleapplication/qtsinglecoreapplication.h
similarity index 99%
rename from src/QtSingleApplication/qtsinglecoreapplication.h
rename to 3rd-parties/qtsingleapplication/qtsinglecoreapplication.h
index 571b37d..b87fffe 100644
--- a/src/QtSingleApplication/qtsinglecoreapplication.h
+++ b/3rd-parties/qtsingleapplication/qtsinglecoreapplication.h
@@ -59,12 +59,13 @@ public:
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
+
Q_SIGNALS:
void messageReceived(const QString &message);
private:
- QtLocalPeer *peer;
+ QtLocalPeer* peer;
};
#endif // QTSINGLECOREAPPLICATION_H
diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/3rd-parties/qtsingleapplication/qtsinglecoreapplication.pri
similarity index 100%
rename from src/QtSingleApplication/qtsinglecoreapplication.pri
rename to 3rd-parties/qtsingleapplication/qtsinglecoreapplication.pri
diff --git a/3rd-parties/qtsingleapplication/src/QtLockedFile b/3rd-parties/qtsingleapplication/src/QtLockedFile
new file mode 100644
index 0000000..16b48ba
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/QtLockedFile
@@ -0,0 +1 @@
+#include "qtlockedfile.h"
diff --git a/3rd-parties/qtsingleapplication/src/QtSingleApplication b/3rd-parties/qtsingleapplication/src/QtSingleApplication
new file mode 100644
index 0000000..d111bf7
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/QtSingleApplication
@@ -0,0 +1 @@
+#include "qtsingleapplication.h"
diff --git a/3rd-parties/qtsingleapplication/src/qtlocalpeer.cpp b/3rd-parties/qtsingleapplication/src/qtlocalpeer.cpp
new file mode 100644
index 0000000..7e99171
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlocalpeer.cpp
@@ -0,0 +1,177 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "qtlocalpeer.h"
+#include
+#include
+#include
+#include
+
+#if defined(Q_OS_WIN)
+#include
+#include
+typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
+static PProcessIdToSessionId pProcessIdToSessionId = 0;
+#endif
+#if defined(Q_OS_UNIX)
+#include
+#include
+#include
+#endif
+
+namespace QtLP_Private {
+#include "qtlockedfile.cpp"
+#if defined(Q_OS_WIN)
+#include "qtlockedfile_win.cpp"
+#else
+#include "qtlockedfile_unix.cpp"
+#endif
+}
+
+const char* QtLocalPeer::ack = "ack";
+
+QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
+ : QObject(parent), id(appId)
+{
+ QString prefix = id;
+ if (id.isEmpty()) {
+ id = QCoreApplication::applicationFilePath();
+#if defined(Q_OS_WIN)
+ id = id.toLower();
+#endif
+ prefix = id.section(QLatin1Char('/'), -1);
+ }
+ prefix.remove(QRegularExpression("[^a-zA-Z]"));
+ prefix.truncate(6);
+
+ QByteArray idc = id.toUtf8();
+ quint16 idNum = qChecksum(idc.constData(), idc.size());
+ socketName = QLatin1String("qtsingleapp-") + prefix
+ + QLatin1Char('-') + QString::number(idNum, 16);
+
+#if defined(Q_OS_WIN)
+ if (!pProcessIdToSessionId) {
+ QLibrary lib("kernel32");
+ pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
+ }
+ if (pProcessIdToSessionId) {
+ DWORD sessionId = 0;
+ pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
+ socketName += QLatin1Char('-') + QString::number(sessionId, 16);
+ }
+#else
+ socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
+#endif
+
+ server = new QLocalServer(this);
+ QString lockName = QDir(QDir::tempPath()).absolutePath()
+ + QLatin1Char('/') + socketName
+ + QLatin1String("-lockfile");
+ lockFile.setFileName(lockName);
+ lockFile.open(QIODevice::ReadWrite);
+}
+
+
+
+bool QtLocalPeer::isClient()
+{
+ if (lockFile.isLocked())
+ return false;
+
+ if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
+ return true;
+
+ bool res = server->listen(socketName);
+#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
+ // ### Workaround
+ if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
+ QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
+ res = server->listen(socketName);
+ }
+#endif
+ if (!res)
+ qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
+ QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
+ return false;
+}
+
+
+bool QtLocalPeer::sendMessage(const QString &message, int timeout)
+{
+ if (!isClient())
+ return false;
+
+ QLocalSocket socket;
+ bool connOk = false;
+ for(int i = 0; i < 2; i++) {
+ // Try twice, in case the other instance is just starting up
+ socket.connectToServer(socketName);
+ connOk = socket.waitForConnected(timeout/2);
+ if (connOk || i)
+ break;
+ int ms = 250;
+#if defined(Q_OS_WIN)
+ Sleep(DWORD(ms));
+#else
+ struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+#endif
+ }
+ if (!connOk)
+ return false;
+
+ QByteArray uMsg(message.toUtf8());
+ QDataStream ds(&socket);
+ ds.writeBytes(uMsg.constData(), uMsg.size());
+ bool res = socket.waitForBytesWritten(timeout);
+ if (res) {
+ res &= socket.waitForReadyRead(timeout); // wait for ack
+ if (res)
+ res &= (socket.read(qstrlen(ack)) == ack);
+ }
+ return res;
+}
+
+
+void QtLocalPeer::receiveConnection()
+{
+ QLocalSocket* socket = server->nextPendingConnection();
+ if (!socket)
+ return;
+
+ while (true) {
+ if (socket->state() == QLocalSocket::UnconnectedState) {
+ qWarning("QtLocalPeer: Peer disconnected");
+ delete socket;
+ return;
+ }
+ if (socket->bytesAvailable() >= qint64(sizeof(quint32)))
+ break;
+ socket->waitForReadyRead();
+ }
+
+ QDataStream ds(socket);
+ QByteArray uMsg;
+ quint32 remaining;
+ ds >> remaining;
+ uMsg.resize(remaining);
+ int got = 0;
+ char* uMsgBuf = uMsg.data();
+ do {
+ got = ds.readRawData(uMsgBuf, remaining);
+ remaining -= got;
+ uMsgBuf += got;
+ } while (remaining && got >= 0 && socket->waitForReadyRead(2000));
+ if (got < 0) {
+ qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
+ delete socket;
+ return;
+ }
+ QString message(QString::fromUtf8(uMsg));
+ socket->write(ack, qstrlen(ack));
+ socket->waitForBytesWritten(1000);
+ socket->waitForDisconnected(1000); // make sure client reads ack
+ delete socket;
+ emit messageReceived(message); //### (might take a long time to return)
+}
diff --git a/3rd-parties/qtsingleapplication/src/qtlocalpeer.h b/3rd-parties/qtsingleapplication/src/qtlocalpeer.h
new file mode 100644
index 0000000..5e6db56
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlocalpeer.h
@@ -0,0 +1,40 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#ifndef QTLOCALPEER_H
+#define QTLOCALPEER_H
+
+#include
+#include
+#include
+
+#include "qtlockedfile.h"
+
+class QtLocalPeer : public QObject
+{
+ Q_OBJECT
+
+public:
+ QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
+ bool isClient();
+ bool sendMessage(const QString &message, int timeout);
+ QString applicationId() const
+ { return id; }
+
+Q_SIGNALS:
+ void messageReceived(const QString &message);
+
+protected Q_SLOTS:
+ void receiveConnection();
+
+protected:
+ QString id;
+ QString socketName;
+ QLocalServer* server;
+ QtLP_Private::QtLockedFile lockFile;
+
+private:
+ static const char* ack;
+};
+
+#endif // QTLOCALPEER_H
diff --git a/3rd-parties/qtsingleapplication/src/qtlockedfile.cpp b/3rd-parties/qtsingleapplication/src/qtlockedfile.cpp
new file mode 100644
index 0000000..78f20bc
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlockedfile.cpp
@@ -0,0 +1,156 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "qtlockedfile.h"
+
+/*!
+ \class QtLockedFile
+
+ \brief The QtLockedFile class extends QFile with advisory locking
+ functions.
+
+ A file may be locked in read or write mode. Multiple instances of
+ \e QtLockedFile, created in multiple processes running on the same
+ machine, may have a file locked in read mode. Exactly one instance
+ may have it locked in write mode. A read and a write lock cannot
+ exist simultaneously on the same file.
+
+ The file locks are advisory. This means that nothing prevents
+ another process from manipulating a locked file using QFile or
+ file system functions offered by the OS. Serialization is only
+ guaranteed if all processes that access the file use
+ QLockedFile. Also, while holding a lock on a file, a process
+ must not open the same file again (through any API), or locks
+ can be unexpectedly lost.
+
+ The lock provided by an instance of \e QtLockedFile is released
+ whenever the program terminates. This is true even when the
+ program crashes and no destructors are called.
+*/
+
+/*! \enum QtLockedFile::LockMode
+
+ This enum describes the available lock modes.
+
+ \value ReadLock A read lock.
+ \value WriteLock A write lock.
+ \value NoLock Neither a read lock nor a write lock.
+*/
+
+/*!
+ Constructs an unlocked \e QtLockedFile object. This constructor
+ behaves in the same way as \e QFile::QFile().
+
+ \sa QFile::QFile()
+*/
+QtLockedFile::QtLockedFile()
+ : QFile()
+{
+#ifdef Q_OS_WIN
+ wmutex = 0;
+ rmutex = 0;
+#endif
+ m_lock_mode = NoLock;
+}
+
+/*!
+ Constructs an unlocked QtLockedFile object with file \a name. This
+ constructor behaves in the same way as \e QFile::QFile(const
+ QString&).
+
+ \sa QFile::QFile()
+*/
+QtLockedFile::QtLockedFile(const QString &name)
+ : QFile(name)
+{
+#ifdef Q_OS_WIN
+ wmutex = 0;
+ rmutex = 0;
+#endif
+ m_lock_mode = NoLock;
+}
+
+/*!
+ Opens the file in OpenMode \a mode.
+
+ This is identical to QFile::open(), with the one exception that the
+ Truncate mode flag is disallowed. Truncation would conflict with the
+ advisory file locking, since the file would be modified before the
+ write lock is obtained. If truncation is required, use resize(0)
+ after obtaining the write lock.
+
+ Returns true if successful; otherwise false.
+
+ \sa QFile::open(), QFile::resize()
+*/
+bool QtLockedFile::open(OpenMode mode)
+{
+ if (mode & QIODevice::Truncate) {
+ qWarning("QtLockedFile::open(): Truncate mode not allowed.");
+ return false;
+ }
+ return QFile::open(mode);
+}
+
+/*!
+ Returns \e true if this object has a in read or write lock;
+ otherwise returns \e false.
+
+ \sa lockMode()
+*/
+bool QtLockedFile::isLocked() const
+{
+ return m_lock_mode != NoLock;
+}
+
+/*!
+ Returns the type of lock currently held by this object, or \e
+ QtLockedFile::NoLock.
+
+ \sa isLocked()
+*/
+QtLockedFile::LockMode QtLockedFile::lockMode() const
+{
+ return m_lock_mode;
+}
+
+/*!
+ \fn bool QtLockedFile::lock(LockMode mode, bool block = true)
+
+ Obtains a lock of type \a mode. The file must be opened before it
+ can be locked.
+
+ If \a block is true, this function will block until the lock is
+ aquired. If \a block is false, this function returns \e false
+ immediately if the lock cannot be aquired.
+
+ If this object already has a lock of type \a mode, this function
+ returns \e true immediately. If this object has a lock of a
+ different type than \a mode, the lock is first released and then a
+ new lock is obtained.
+
+ This function returns \e true if, after it executes, the file is
+ locked by this object, and \e false otherwise.
+
+ \sa unlock(), isLocked(), lockMode()
+*/
+
+/*!
+ \fn bool QtLockedFile::unlock()
+
+ Releases a lock.
+
+ If the object has no lock, this function returns immediately.
+
+ This function returns \e true if, after it executes, the file is
+ not locked by this object, and \e false otherwise.
+
+ \sa lock(), isLocked(), lockMode()
+*/
+
+/*!
+ \fn QtLockedFile::~QtLockedFile()
+
+ Destroys the \e QtLockedFile object. If any locks were held, they
+ are released.
+*/
diff --git a/3rd-parties/qtsingleapplication/src/qtlockedfile.h b/3rd-parties/qtsingleapplication/src/qtlockedfile.h
new file mode 100644
index 0000000..c729bf2
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlockedfile.h
@@ -0,0 +1,60 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#ifndef QTLOCKEDFILE_H
+#define QTLOCKEDFILE_H
+
+#include
+#ifdef Q_OS_WIN
+#include
+#endif
+
+#if defined(Q_OS_WIN)
+# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
+# define QT_QTLOCKEDFILE_EXPORT
+# elif defined(QT_QTLOCKEDFILE_IMPORT)
+# if defined(QT_QTLOCKEDFILE_EXPORT)
+# undef QT_QTLOCKEDFILE_EXPORT
+# endif
+# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
+# elif defined(QT_QTLOCKEDFILE_EXPORT)
+# undef QT_QTLOCKEDFILE_EXPORT
+# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
+# endif
+#else
+# define QT_QTLOCKEDFILE_EXPORT
+#endif
+
+namespace QtLP_Private {
+
+class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
+{
+public:
+ enum LockMode { NoLock = 0, ReadLock, WriteLock };
+
+ QtLockedFile();
+ QtLockedFile(const QString &name);
+ ~QtLockedFile();
+
+ bool open(OpenMode mode);
+
+ bool lock(LockMode mode, bool block = true);
+ bool unlock();
+ bool isLocked() const;
+ LockMode lockMode() const;
+
+private:
+#ifdef Q_OS_WIN
+ Qt::HANDLE wmutex;
+ Qt::HANDLE rmutex;
+ QVector rmutexes;
+ QString mutexname;
+
+ Qt::HANDLE getMutexHandle(int idx, bool doCreate);
+ bool waitMutex(Qt::HANDLE mutex, bool doBlock);
+
+#endif
+ LockMode m_lock_mode;
+};
+}
+#endif
diff --git a/3rd-parties/qtsingleapplication/src/qtlockedfile_unix.cpp b/3rd-parties/qtsingleapplication/src/qtlockedfile_unix.cpp
new file mode 100644
index 0000000..8385d8b
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlockedfile_unix.cpp
@@ -0,0 +1,78 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include
+#include
+#include
+#include
+
+#include "qtlockedfile.h"
+
+bool QtLockedFile::lock(LockMode mode, bool block)
+{
+ if (!isOpen()) {
+ qWarning("QtLockedFile::lock(): file is not opened");
+ return false;
+ }
+
+ if (mode == NoLock)
+ return unlock();
+
+ if (mode == m_lock_mode)
+ return true;
+
+ if (m_lock_mode != NoLock)
+ unlock();
+
+ struct flock fl;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
+ int cmd = block ? F_SETLKW : F_SETLK;
+ int ret = fcntl(handle(), cmd, &fl);
+
+ if (ret == -1) {
+ if (errno != EINTR && errno != EAGAIN)
+ qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
+ return false;
+ }
+
+
+ m_lock_mode = mode;
+ return true;
+}
+
+
+bool QtLockedFile::unlock()
+{
+ if (!isOpen()) {
+ qWarning("QtLockedFile::unlock(): file is not opened");
+ return false;
+ }
+
+ if (!isLocked())
+ return true;
+
+ struct flock fl;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = F_UNLCK;
+ int ret = fcntl(handle(), F_SETLKW, &fl);
+
+ if (ret == -1) {
+ qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
+ return false;
+ }
+
+ m_lock_mode = NoLock;
+ return true;
+}
+
+QtLockedFile::~QtLockedFile()
+{
+ if (isOpen())
+ unlock();
+}
+
diff --git a/3rd-parties/qtsingleapplication/src/qtlockedfile_win.cpp b/3rd-parties/qtsingleapplication/src/qtlockedfile_win.cpp
new file mode 100644
index 0000000..28cf072
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtlockedfile_win.cpp
@@ -0,0 +1,174 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "qtlockedfile.h"
+#include
+#include
+
+#define MUTEX_PREFIX "QtLockedFile mutex "
+// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
+#define MAX_READERS MAXIMUM_WAIT_OBJECTS
+
+#if QT_VERSION >= 0x050000
+#define QT_WA(unicode, ansi) unicode
+#endif
+
+Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
+{
+ if (mutexname.isEmpty()) {
+ QFileInfo fi(*this);
+ mutexname = QString::fromLatin1(MUTEX_PREFIX)
+ + fi.absoluteFilePath().toLower();
+ }
+ QString mname(mutexname);
+ if (idx >= 0)
+ mname += QString::number(idx);
+
+ Qt::HANDLE mutex;
+ if (doCreate) {
+ QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
+ { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
+ if (!mutex) {
+ qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
+ return 0;
+ }
+ }
+ else {
+ QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
+ { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
+ if (!mutex) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
+ return 0;
+ }
+ }
+ return mutex;
+}
+
+bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock)
+{
+ Q_ASSERT(mutex);
+ DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0);
+ switch (res) {
+ case WAIT_OBJECT_0:
+ case WAIT_ABANDONED:
+ return true;
+ break;
+ case WAIT_TIMEOUT:
+ break;
+ default:
+ qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed");
+ }
+ return false;
+}
+
+
+
+bool QtLockedFile::lock(LockMode mode, bool block)
+{
+ if (!isOpen()) {
+ qWarning("QtLockedFile::lock(): file is not opened");
+ return false;
+ }
+
+ if (mode == NoLock)
+ return unlock();
+
+ if (mode == m_lock_mode)
+ return true;
+
+ if (m_lock_mode != NoLock)
+ unlock();
+
+ if (!wmutex && !(wmutex = getMutexHandle(-1, true)))
+ return false;
+
+ if (!waitMutex(wmutex, block))
+ return false;
+
+ if (mode == ReadLock) {
+ int idx = 0;
+ for (; idx < MAX_READERS; idx++) {
+ rmutex = getMutexHandle(idx, false);
+ if (!rmutex || waitMutex(rmutex, false))
+ break;
+ CloseHandle(rmutex);
+ }
+ bool ok = true;
+ if (idx >= MAX_READERS) {
+ qWarning("QtLockedFile::lock(): too many readers");
+ rmutex = 0;
+ ok = false;
+ }
+ else if (!rmutex) {
+ rmutex = getMutexHandle(idx, true);
+ if (!rmutex || !waitMutex(rmutex, false))
+ ok = false;
+ }
+ if (!ok && rmutex) {
+ CloseHandle(rmutex);
+ rmutex = 0;
+ }
+ ReleaseMutex(wmutex);
+ if (!ok)
+ return false;
+ }
+ else {
+ Q_ASSERT(rmutexes.isEmpty());
+ for (int i = 0; i < MAX_READERS; i++) {
+ Qt::HANDLE mutex = getMutexHandle(i, false);
+ if (mutex)
+ rmutexes.append(mutex);
+ }
+ if (rmutexes.size()) {
+ DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(),
+ TRUE, block ? INFINITE : 0);
+ if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) {
+ if (res != WAIT_TIMEOUT)
+ qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed");
+ m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky
+ unlock();
+ return false;
+ }
+ }
+ }
+
+ m_lock_mode = mode;
+ return true;
+}
+
+bool QtLockedFile::unlock()
+{
+ if (!isOpen()) {
+ qWarning("QtLockedFile::unlock(): file is not opened");
+ return false;
+ }
+
+ if (!isLocked())
+ return true;
+
+ if (m_lock_mode == ReadLock) {
+ ReleaseMutex(rmutex);
+ CloseHandle(rmutex);
+ rmutex = 0;
+ }
+ else {
+ foreach(Qt::HANDLE mutex, rmutexes) {
+ ReleaseMutex(mutex);
+ CloseHandle(mutex);
+ }
+ rmutexes.clear();
+ ReleaseMutex(wmutex);
+ }
+
+ m_lock_mode = QtLockedFile::NoLock;
+ return true;
+}
+
+QtLockedFile::~QtLockedFile()
+{
+ if (isOpen())
+ unlock();
+ if (wmutex)
+ CloseHandle(wmutex);
+}
diff --git a/3rd-parties/qtsingleapplication/src/qtsingleapplication.cpp b/3rd-parties/qtsingleapplication/src/qtsingleapplication.cpp
new file mode 100644
index 0000000..a6f4516
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsingleapplication.cpp
@@ -0,0 +1,310 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "qtsingleapplication.h"
+#include "qtlocalpeer.h"
+#include
+
+
+/*!
+ \class QtSingleApplication qtsingleapplication.h
+ \brief The QtSingleApplication class provides an API to detect and
+ communicate with running instances of an application.
+
+ This class allows you to create applications where only one
+ instance should be running at a time. I.e., if the user tries to
+ launch another instance, the already running instance will be
+ activated instead. Another usecase is a client-server system,
+ where the first started instance will assume the role of server,
+ and the later instances will act as clients of that server.
+
+ By default, the full path of the executable file is used to
+ determine whether two processes are instances of the same
+ application. You can also provide an explicit identifier string
+ that will be compared instead.
+
+ The application should create the QtSingleApplication object early
+ in the startup phase, and call isRunning() to find out if another
+ instance of this application is already running. If isRunning()
+ returns false, it means that no other instance is running, and
+ this instance has assumed the role as the running instance. In
+ this case, the application should continue with the initialization
+ of the application user interface before entering the event loop
+ with exec(), as normal.
+
+ The messageReceived() signal will be emitted when the running
+ application receives messages from another instance of the same
+ application. When a message is received it might be helpful to the
+ user to raise the application so that it becomes visible. To
+ facilitate this, QtSingleApplication provides the
+ setActivationWindow() function and the activateWindow() slot.
+
+ If isRunning() returns true, another instance is already
+ running. It may be alerted to the fact that another instance has
+ started by using the sendMessage() function. Also data such as
+ startup parameters (e.g. the name of the file the user wanted this
+ new instance to open) can be passed to the running instance with
+ this function. Then, the application should terminate (or enter
+ client mode).
+
+ If isRunning() returns true, but sendMessage() fails, that is an
+ indication that the running instance is frozen.
+
+ Here's an example that shows how to convert an existing
+ application to use QtSingleApplication. It is very simple and does
+ not make use of all QtSingleApplication's functionality (see the
+ examples for that).
+
+ \code
+ // Original
+ int main(int argc, char **argv)
+ {
+ QApplication app(argc, argv);
+
+ MyMainWidget mmw;
+ mmw.show();
+ return app.exec();
+ }
+
+ // Single instance
+ int main(int argc, char **argv)
+ {
+ QtSingleApplication app(argc, argv);
+
+ if (app.isRunning())
+ return !app.sendMessage(someDataString);
+
+ MyMainWidget mmw;
+ app.setActivationWindow(&mmw);
+ mmw.show();
+ return app.exec();
+ }
+ \endcode
+
+ Once this QtSingleApplication instance is destroyed (normally when
+ the process exits or crashes), when the user next attempts to run the
+ application this instance will not, of course, be encountered. The
+ next instance to call isRunning() or sendMessage() will assume the
+ role as the new running instance.
+
+ For console (non-GUI) applications, QtSingleCoreApplication may be
+ used instead of this class, to avoid the dependency on the QtGui
+ library.
+
+ \sa QtSingleCoreApplication
+*/
+
+
+void QtSingleApplication::sysInit(const QString &appId)
+{
+ actWin = 0;
+ peer = new QtLocalPeer(this, appId);
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
+}
+
+
+/*!
+ Creates a QtSingleApplication object. The application identifier
+ will be QCoreApplication::applicationFilePath(). \a argc, \a
+ argv, and \a GUIenabled are passed on to the QAppliation constructor.
+
+ If you are creating a console application (i.e. setting \a
+ GUIenabled to false), you may consider using
+ QtSingleCoreApplication instead.
+*/
+
+QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled)
+ : QApplication(argc, argv, GUIenabled)
+{
+ sysInit();
+}
+
+
+/*!
+ Creates a QtSingleApplication object with the application
+ identifier \a appId. \a argc and \a argv are passed on to the
+ QAppliation constructor.
+*/
+
+QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
+ : QApplication(argc, argv)
+{
+ sysInit(appId);
+}
+
+#if QT_VERSION < 0x050000
+
+/*!
+ Creates a QtSingleApplication object. The application identifier
+ will be QCoreApplication::applicationFilePath(). \a argc, \a
+ argv, and \a type are passed on to the QAppliation constructor.
+*/
+QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
+ : QApplication(argc, argv, type)
+{
+ sysInit();
+}
+
+
+# if defined(Q_WS_X11)
+/*!
+ Special constructor for X11, ref. the documentation of
+ QApplication's corresponding constructor. The application identifier
+ will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
+ and \a cmap are passed on to the QApplication constructor.
+*/
+QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
+ : QApplication(dpy, visual, cmap)
+{
+ sysInit();
+}
+
+/*!
+ Special constructor for X11, ref. the documentation of
+ QApplication's corresponding constructor. The application identifier
+ will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
+ argv, \a visual, and \a cmap are passed on to the QApplication
+ constructor.
+*/
+QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
+ : QApplication(dpy, argc, argv, visual, cmap)
+{
+ sysInit();
+}
+
+/*!
+ Special constructor for X11, ref. the documentation of
+ QApplication's corresponding constructor. The application identifier
+ will be \a appId. \a dpy, \a argc, \a
+ argv, \a visual, and \a cmap are passed on to the QApplication
+ constructor.
+*/
+QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
+ : QApplication(dpy, argc, argv, visual, cmap)
+{
+ sysInit(appId);
+}
+# endif // Q_WS_X11
+#endif // QT_VERSION < 0x050000
+
+
+/*!
+ Returns true if another instance of this application is running;
+ otherwise false.
+
+ This function does not find instances of this application that are
+ being run by a different user (on Windows: that are running in
+ another session).
+
+ \sa sendMessage()
+*/
+
+bool QtSingleApplication::isRunning()
+{
+ return peer->isClient();
+}
+
+
+/*!
+ Tries to send the text \a message to the currently running
+ instance. The QtSingleApplication object in the running instance
+ will emit the messageReceived() signal when it receives the
+ message.
+
+ This function returns true if the message has been sent to, and
+ processed by, the current instance. If there is no instance
+ currently running, or if the running instance fails to process the
+ message within \a timeout milliseconds, this function return false.
+
+ \sa isRunning(), messageReceived()
+*/
+bool QtSingleApplication::sendMessage(const QString &message, int timeout)
+{
+ return peer->sendMessage(message, timeout);
+}
+
+
+/*!
+ Returns the application identifier. Two processes with the same
+ identifier will be regarded as instances of the same application.
+*/
+QString QtSingleApplication::id() const
+{
+ return peer->applicationId();
+}
+
+
+/*!
+ Sets the activation window of this application to \a aw. The
+ activation window is the widget that will be activated by
+ activateWindow(). This is typically the application's main window.
+
+ If \a activateOnMessage is true (the default), the window will be
+ activated automatically every time a message is received, just prior
+ to the messageReceived() signal being emitted.
+
+ \sa activateWindow(), messageReceived()
+*/
+
+void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
+{
+ actWin = aw;
+ if (activateOnMessage)
+ connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
+ else
+ disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
+}
+
+
+/*!
+ Returns the applications activation window if one has been set by
+ calling setActivationWindow(), otherwise returns 0.
+
+ \sa setActivationWindow()
+*/
+QWidget* QtSingleApplication::activationWindow() const
+{
+ return actWin;
+}
+
+
+/*!
+ De-minimizes, raises, and activates this application's activation window.
+ This function does nothing if no activation window has been set.
+
+ This is a convenience function to show the user that this
+ application instance has been activated when he has tried to start
+ another instance.
+
+ This function should typically be called in response to the
+ messageReceived() signal. By default, that will happen
+ automatically, if an activation window has been set.
+
+ \sa setActivationWindow(), messageReceived(), initialize()
+*/
+void QtSingleApplication::activateWindow()
+{
+ if (actWin) {
+ actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
+ actWin->raise();
+ actWin->activateWindow();
+ }
+}
+
+
+/*!
+ \fn void QtSingleApplication::messageReceived(const QString& message)
+
+ This signal is emitted when the current instance receives a \a
+ message from another instance of this application.
+
+ \sa sendMessage(), setActivationWindow(), activateWindow()
+*/
+
+
+/*!
+ \fn void QtSingleApplication::initialize(bool dummy = true)
+
+ \obsolete
+*/
diff --git a/3rd-parties/qtsingleapplication/src/qtsingleapplication.h b/3rd-parties/qtsingleapplication/src/qtsingleapplication.h
new file mode 100644
index 0000000..f8f6e88
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsingleapplication.h
@@ -0,0 +1,68 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#ifndef QTSINGLEAPPLICATION_H
+#define QTSINGLEAPPLICATION_H
+
+#include
+
+class QtLocalPeer;
+
+#if defined(Q_OS_WIN)
+# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
+# define QT_QTSINGLEAPPLICATION_EXPORT
+# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
+# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
+# undef QT_QTSINGLEAPPLICATION_EXPORT
+# endif
+# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
+# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
+# undef QT_QTSINGLEAPPLICATION_EXPORT
+# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
+# endif
+#else
+# define QT_QTSINGLEAPPLICATION_EXPORT
+#endif
+
+class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
+{
+ Q_OBJECT
+
+public:
+ QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
+ QtSingleApplication(const QString &id, int &argc, char **argv);
+#if QT_VERSION < 0x050000
+ QtSingleApplication(int &argc, char **argv, Type type);
+# if defined(Q_WS_X11)
+ QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
+ QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
+ QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
+# endif // Q_WS_X11
+#endif // QT_VERSION < 0x050000
+
+ bool isRunning();
+ QString id() const;
+
+ void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
+ QWidget* activationWindow() const;
+
+ // Obsolete:
+ void initialize(bool dummy = true)
+ { isRunning(); Q_UNUSED(dummy) }
+
+public Q_SLOTS:
+ bool sendMessage(const QString &message, int timeout = 5000);
+ void activateWindow();
+
+
+Q_SIGNALS:
+ void messageReceived(const QString &message);
+
+
+private:
+ void sysInit(const QString &appId = QString());
+ QtLocalPeer *peer;
+ QWidget *actWin;
+};
+
+#endif // QTSINGLEAPPLICATION_H
diff --git a/3rd-parties/qtsingleapplication/src/qtsingleapplication.pri b/3rd-parties/qtsingleapplication/src/qtsingleapplication.pri
new file mode 100644
index 0000000..6f2bced
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsingleapplication.pri
@@ -0,0 +1,17 @@
+include(../common.pri)
+INCLUDEPATH += $$PWD
+DEPENDPATH += $$PWD
+QT *= network
+greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets
+
+qtsingleapplication-uselib:!qtsingleapplication-buildlib {
+ LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME
+} else {
+ SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp
+ HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
+}
+
+win32 {
+ contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT
+ else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT
+}
diff --git a/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.cpp b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.cpp
new file mode 100644
index 0000000..a3e2b3a
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.cpp
@@ -0,0 +1,112 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "qtsinglecoreapplication.h"
+#include "qtlocalpeer.h"
+
+/*!
+ \class QtSingleCoreApplication qtsinglecoreapplication.h
+ \brief A variant of the QtSingleApplication class for non-GUI applications.
+
+ This class is a variant of QtSingleApplication suited for use in
+ console (non-GUI) applications. It is an extension of
+ QCoreApplication (instead of QApplication). It does not require
+ the QtGui library.
+
+ The API and usage is identical to QtSingleApplication, except that
+ functions relating to the "activation window" are not present, for
+ obvious reasons. Please refer to the QtSingleApplication
+ documentation for explanation of the usage.
+
+ A QtSingleCoreApplication instance can communicate to a
+ QtSingleApplication instance if they share the same application
+ id. Hence, this class can be used to create a light-weight
+ command-line tool that sends commands to a GUI application.
+
+ \sa QtSingleApplication
+*/
+
+/*!
+ Creates a QtSingleCoreApplication object. The application identifier
+ will be QCoreApplication::applicationFilePath(). \a argc and \a
+ argv are passed on to the QCoreAppliation constructor.
+*/
+
+QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
+ : QCoreApplication(argc, argv)
+{
+ peer = new QtLocalPeer(this);
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
+}
+
+
+/*!
+ Creates a QtSingleCoreApplication object with the application
+ identifier \a appId. \a argc and \a argv are passed on to the
+ QCoreAppliation constructor.
+*/
+QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv)
+ : QCoreApplication(argc, argv)
+{
+ peer = new QtLocalPeer(this, appId);
+ connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
+}
+
+
+/*!
+ Returns true if another instance of this application is running;
+ otherwise false.
+
+ This function does not find instances of this application that are
+ being run by a different user (on Windows: that are running in
+ another session).
+
+ \sa sendMessage()
+*/
+
+bool QtSingleCoreApplication::isRunning()
+{
+ return peer->isClient();
+}
+
+
+/*!
+ Tries to send the text \a message to the currently running
+ instance. The QtSingleCoreApplication object in the running instance
+ will emit the messageReceived() signal when it receives the
+ message.
+
+ This function returns true if the message has been sent to, and
+ processed by, the current instance. If there is no instance
+ currently running, or if the running instance fails to process the
+ message within \a timeout milliseconds, this function return false.
+
+ \sa isRunning(), messageReceived()
+*/
+
+bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout)
+{
+ return peer->sendMessage(message, timeout);
+}
+
+
+/*!
+ Returns the application identifier. Two processes with the same
+ identifier will be regarded as instances of the same application.
+*/
+
+QString QtSingleCoreApplication::id() const
+{
+ return peer->applicationId();
+}
+
+
+/*!
+ \fn void QtSingleCoreApplication::messageReceived(const QString& message)
+
+ This signal is emitted when the current instance receives a \a
+ message from another instance of this application.
+
+ \sa sendMessage()
+*/
diff --git a/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.h b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.h
new file mode 100644
index 0000000..1272589
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: BSD-3-Clause
+
+#ifndef QTSINGLECOREAPPLICATION_H
+#define QTSINGLECOREAPPLICATION_H
+
+#include
+
+class QtLocalPeer;
+
+class QtSingleCoreApplication : public QCoreApplication
+{
+ Q_OBJECT
+
+public:
+ QtSingleCoreApplication(int &argc, char **argv);
+ QtSingleCoreApplication(const QString &id, int &argc, char **argv);
+
+ bool isRunning();
+ QString id() const;
+
+public Q_SLOTS:
+ bool sendMessage(const QString &message, int timeout = 5000);
+
+
+Q_SIGNALS:
+ void messageReceived(const QString &message);
+
+
+private:
+ QtLocalPeer* peer;
+};
+
+#endif // QTSINGLECOREAPPLICATION_H
diff --git a/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.pri b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.pri
new file mode 100644
index 0000000..d2d6cc3
--- /dev/null
+++ b/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.pri
@@ -0,0 +1,10 @@
+INCLUDEPATH += $$PWD
+DEPENDPATH += $$PWD
+HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h
+SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp
+
+QT *= network
+
+win32:contains(TEMPLATE, lib):contains(CONFIG, shared) {
+ DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport)
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..15e043a
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,235 @@
+cmake_minimum_required(VERSION 3.16)
+
+project(ukui-menu LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# see https://cmake.org/cmake/help/v3.16/manual/cmake-qt.7.html
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+# 查找qt组件
+find_package(QT NAMES Qt6 Qt5
+ COMPONENTS Core Gui Quick Widgets LinguistTools DBus X11Extras REQUIRED)
+find_package(Qt${QT_VERSION_MAJOR}
+ COMPONENTS Core Gui Quick Widgets LinguistTools DBus X11Extras REQUIRED)
+
+# find kde framework components
+# see: https://api.kde.org/frameworks/index.html > KWindowSystem
+find_package(KF5WindowSystem REQUIRED)
+find_package(Qt5Xdg REQUIRED)
+
+# 查找其他组件
+# see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html
+# see: https://cmake.org/cmake/help/v3.16/command/list.html
+find_package(PkgConfig REQUIRED)
+
+set(UKUI_MENU_EXTERNAL_LIBS "")
+# glib-2.0 gio-unix-2.0 gsettings-qt x11 kysdk-waylandhelper
+set(UKUI_MENU_PC_PKGS glib-2.0 gsettings-qt x11 kysdk-waylandhelper ukui-search)
+
+foreach(external_lib IN ITEMS ${UKUI_MENU_PC_PKGS})
+ pkg_check_modules(${external_lib} REQUIRED ${external_lib})
+ if(${${external_lib}_FOUND})
+ include_directories(${${external_lib}_INCLUDE_DIRS})
+ link_directories(${${external_lib}_LIBRARY_DIRS})
+ list(APPEND UKUI_MENU_EXTERNAL_LIBS ${${external_lib}_LIBRARIES})
+ endif()
+endforeach()
+
+message(STATUS "External libraries found: ${UKUI_MENU_EXTERNAL_LIBS}")
+
+# include single-application
+add_subdirectory(3rd-parties/qtsingleapplication)
+# static lib of single-application.
+set(SingleApplication "qtsingleapplication")
+
+# include文件夹
+include_directories(src)
+include_directories(src/menu)
+include_directories(src/model)
+include_directories(src/appdata)
+include_directories(src/settings)
+include_directories(src/uiconfig)
+include_directories(src/windows)
+include_directories(src/utils)
+include_directories(3rd-parties/qtsingleapplication/src)
+
+# 用于Qt Creator识别自定义qml模块的导入路径
+list(APPEND QML_MODULE_DIRS "${PROJECT_SOURCE_DIR}/qml")
+set(QML_IMPORT_PATH "${QML_MODULE_DIRS}" CACHE STRING "Qt Creator extra qml import paths." FORCE)
+#message(STATUS "QML_IMPORT_PATH: ${QML_IMPORT_PATH}")
+
+# 基础设置
+set(UKUI_MENU_DATA_DIR "/usr/share/ukui-menu")
+set(UKUI_MENU_SO_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-menu")
+set(UKUI_MENU_TRANSLATION_DIR "${UKUI_MENU_DATA_DIR}/translations")
+set(UKUI_MENU_GLOBAL_CONFIG_FILE "${UKUI_MENU_DATA_DIR}/ukui-menu-global-config.conf")
+set(UKUI_MENU_EXTENSION_DIR "${UKUI_MENU_SO_DIR}/extensions")
+set(UKUI_MENU_CONTEXT_MENU_DIR "${UKUI_MENU_SO_DIR}/context-menu")
+
+
+set(UKUI_MENU_LIBRARY_VERSION 1.0.0)
+set(UKUI_MENU_LIBRARY_API_VERSION 1)
+#set(UKUI_MENU_LIBRARY_NAME "ukui-menu${UKUI_MENU_LIBRARY_API_VERSION}")
+set(UKUI_MENU_LIBRARY_NAME "ukui-menu-interface")
+set(PC_INSTALL_DIR "/usr/lib/pkgconfig")
+set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/${UKUI_MENU_LIBRARY_NAME}")
+
+# 子项目
+add_subdirectory(extension/recent-file)
+
+# 宏定义
+add_compile_definitions(UKUI_MENU_TRANSLATION_DIR="${UKUI_MENU_TRANSLATION_DIR}"
+ UKUI_MENU_DATA_DIR="${UKUI_MENU_DATA_DIR}"
+ UKUI_MENU_CONTEXT_MENU_DIR="${UKUI_MENU_CONTEXT_MENU_DIR}"
+ UKUI_MENU_EXTENSION_DIR="${UKUI_MENU_EXTENSION_DIR}"
+ UKUI_MENU_GLOBAL_CONFIG_FILE="${UKUI_MENU_GLOBAL_CONFIG_FILE}"
+ )
+
+# ukui-menu的源码
+set(SOURCE_FILES
+ src/main.cpp
+ src/commons.h src/commons.cpp
+ src/menu-dbus-service.cpp src/menu-dbus-service.h
+ src/ukui-menu-application.cpp src/ukui-menu-application.h
+ src/model/app-model.cpp src/model/app-model.h
+ src/model/label-model.cpp src/model/label-model.h
+ src/model/app-group-model.cpp src/model/app-group-model.h
+ src/model/model-manager.cpp src/model/model-manager.h
+ src/model/folder-model.cpp src/model/folder-model.h
+ src/settings/settings.cpp src/settings/settings.h
+ src/uiconfig/color-helper.cpp src/uiconfig/color-helper.h
+ src/uiconfig/theme-palette.cpp src/uiconfig/theme-palette.h
+ src/windows/menu-main-window.cpp src/windows/menu-main-window.h
+ src/appdata/data-provider-plugin-iface.h
+ src/appdata/app-data-manager.cpp src/appdata/app-data-manager.h
+ src/appdata/app-folder-helper.cpp src/appdata/app-folder-helper.h
+ src/appdata/app-icon-provider.cpp src/appdata/app-icon-provider.h
+ src/appdata/data-provider-manager.cpp src/appdata/data-provider-manager.h
+ src/appdata/plugin/all-app-data-provider.cpp src/appdata/plugin/all-app-data-provider.h
+ src/appdata/plugin/app-search-plugin.cpp src/appdata/plugin/app-search-plugin.h
+ src/appdata/plugin/app-category-plugin.cpp src/appdata/plugin/app-category-plugin.h
+ src/appdata/plugin/app-letter-sort-plugin.cpp src/appdata/plugin/app-letter-sort-plugin.h
+ src/extension/menu-extension.cpp src/extension/menu-extension.h
+ src/extension/extensions/favorite-extension.cpp src/extension/extensions/favorite-extension.h
+ src/utils/app-page-header-utils.cpp src/utils/app-page-header-utils.h
+ src/utils/power-button.cpp src/utils/power-button.h
+ src/utils/app-manager.cpp src/utils/app-manager.h
+ src/menu/menu-manager.cpp src/menu/menu-manager.h
+ src/items/theme-icon.h src/items/theme-icon.cpp
+ )
+
+# library sources
+set(LIBRARY_SOURCES
+ src/data-entity.cpp
+ src/extension/menu-extension-iface.h
+ )
+
+set(LIBRARY_HEADERS_DIR "/usr/include/${UKUI_MENU_LIBRARY_NAME}")
+set(LIBRARY_HEADERS
+ src/data-entity.h
+ src/menu/menu-provider.h
+ src/extension/menu-extension-iface.h
+ )
+
+# qrc文件
+set(QRC_FILES qml/qml.qrc res/res.qrc)
+# desktop file
+set(DESKTOP_FILE data/ukui-menu.desktop)
+set(GSETTING_FILE data/org.ukui.menu.settings.gschema.xml)
+set(GLOBAL_CONFIG_FILE data/ukui-menu-global-config.conf)
+set(DBUS_SERVICE_FILE data/org.ukui.menu.service)
+# data files
+#set(DATA_FILES data/xxx)
+
+# 翻译文件
+file(GLOB TS_FILES "${PROJECT_SOURCE_DIR}/translations/*.ts")
+# 更新翻译并创建.qm文件
+qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
+# see https://cmake.org/cmake/help/v3.16/command/add_custom_command.html
+# add_custom_target(GEN_TS ALL DEPENDS ${TS_FILES})
+# add_custom_target(generate_qm ALL DEPENDS ${QM_FILES})
+
+add_library(${UKUI_MENU_LIBRARY_NAME} SHARED ${LIBRARY_SOURCES})
+set_target_properties(${UKUI_MENU_LIBRARY_NAME} PROPERTIES
+ VERSION ${UKUI_MENU_LIBRARY_VERSION}
+ SOVERSION ${UKUI_MENU_LIBRARY_API_VERSION}
+ )
+target_link_libraries(${UKUI_MENU_LIBRARY_NAME} PRIVATE Qt5::Core)
+
+add_executable(
+ ${PROJECT_NAME}
+ ${QRC_FILES}
+ ${QM_FILES}
+ ${SOURCE_FILES}
+ )
+
+target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>)
+target_link_libraries(${PROJECT_NAME}
+ PRIVATE
+ Qt5::Core
+ Qt5::Gui
+ Qt5::Quick
+ Qt5::Widgets
+ Qt5::DBus
+ Qt5::X11Extras
+ KF5::WindowSystem
+ Qt5Xdg
+ ${SingleApplication}
+ ${UKUI_MENU_EXTERNAL_LIBS}
+ ${UKUI_MENU_LIBRARY_NAME}
+ )
+
+# 安装ukui-menu
+install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "/usr/bin")
+install(TARGETS ${UKUI_MENU_LIBRARY_NAME}
+ EXPORT ${UKUI_MENU_LIBRARY_NAME}
+ PUBLIC_HEADER DESTINATION ${LIBRARY_HEADERS_DIR}
+ LIBRARY DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}"
+ )
+# 安装翻译文件
+install(FILES ${QM_FILES} DESTINATION "${UKUI_MENU_TRANSLATION_DIR}")
+# 安装desktop文件
+install(FILES ${DESKTOP_FILE} DESTINATION "/etc/xdg/autostart")
+install(FILES ${GSETTING_FILE} DESTINATION "/usr/share/glib-2.0/schemas")
+install(FILES ${GLOBAL_CONFIG_FILE} DESTINATION "${UKUI_MENU_DATA_DIR}")
+install(FILES ${DBUS_SERVICE_FILE} DESTINATION "/usr/share/dbus-1/services/")
+install(FILES ${LIBRARY_HEADERS} DESTINATION "${LIBRARY_HEADERS_DIR}")
+install(DIRECTORY "qml/org" DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml")
+
+## 生成开发配置文件
+include(CMakePackageConfigHelpers)
+target_include_directories(${UKUI_MENU_LIBRARY_NAME} PUBLIC $)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake"
+ INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
+)
+
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config-version.cmake
+ VERSION ${UKUI_MENU_LIBRARY_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc"
+ INSTALL_DESTINATION ${PC_INSTALL_DIR}
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}.pc DESTINATION ${PC_INSTALL_DIR})
+
+install(EXPORT ${UKUI_MENU_LIBRARY_NAME}
+ FILE ${UKUI_MENU_LIBRARY_NAME}-targets.cmake
+ DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${UKUI_MENU_LIBRARY_NAME}-config-version.cmake
+ DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
diff --git a/README.md b/README.md
index c0e270c..132b240 100644
--- a/README.md
+++ b/README.md
@@ -1,84 +1,7 @@
# ukui-menu
-![build](https://github.com/ukui/ukui-menu/workflows/Check%20build/badge.svg?branch=master)
-
-An advanced menu for UKUI, providing common and all software mixed sort module, alphabet classification module, functional classification module and search module. Provides favorites and recent file functions, You can fix it to your favorites area by right-clicking the application. Provides two display modes: default window and full-screen window.
-
-# The project structure
-
-## data/img
-
-Provide icon files for the projec.
-
-## src/BackProcess
-
-Background data processing function realization, Includes DBUS, path listening, data acquisition, and search functions.
-
-## src/QtSingleApplication
-
-Singleton pattern processing.
-
-## src/UserInterface
-
-The UI implementation.
-
-## src/UtilityFunction
-
-Implementation of common functions, including database operations.
-
-## translations
-
-Translation files
-
-
-# How to report bugs
-Bugs should be reported to the UKUI bug tracking system:
-
- https://gitee.com/openkylin/ukui-menu/issues
-
-You will need to create an account for yourself.
-
-Please read the HACKING file for information on where to send changes or
-bugfixes for this package.
-
-# How to build
-
-## Preparation
-You can build pre-depends with such command:
-
-`sudo apt install g++ qtbase5-dev qttools5-dev-tools libglib2.0-dev libqt5svg5-dev libqt5x11extras5-dev libgsettings-qt-dev libbamf3-dev libxrandr-dev libxtst-dev libx11-dev libkf5windowsystem-dev libuchardet-dev libpeony-dev libkysdk-waylandhelper-dev libukui-common-dev`
-
-Note: build-depends references the paragraph in debian/control.
-
-## Build from source and test
-
-> git clone https://gitee.com/openkylin/ukui-menu.git
-
-> cd ukui-menu && mkdir build && cd build
-
-> qmake .. && make
-
-> sudo make install
-
-Note: If you want to run ukui-menu, You just need to execute the ukui-menu command at the terminal.
-
-# DBUS interface
-
-BUS Name:org.ukui.menu
-
-path:/org/ukui/menu
-
-Interface:org.ukui.menu
-
-Method name:
-
-GetMenuStatus () <---> Get ukui-menu display hidden status
-
-WinKeyResponse () <---> ukui-menu display hidden state change interface
-
-GetSecurityConfigPath () <---> Get security control profile path
-
-# Configuration file
-
-.config/ukui/Ukuimenu.db
+```c++
+hi, wellcome to new ukui-menu 4.0.0.0.
+```
+### To be continued...
diff --git a/cmake/UkuiPluginTranslationTs.cmake b/cmake/UkuiPluginTranslationTs.cmake
new file mode 100644
index 0000000..eda37b4
--- /dev/null
+++ b/cmake/UkuiPluginTranslationTs.cmake
@@ -0,0 +1,101 @@
+macro(ukui_plugin_translate_ts PLUGIN)
+set(TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translation/${PLUGIN}_zh_CN.ts)
+set(BO_TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translation/${PLUGIN}_bo_CN.ts)
+set(B_QM_FILES ${CMAKE_CURRENT_BINARY_DIR}/translation/)
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/translation/)
+else()
+ execute_process(
+ COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/translation/
+ )
+endif()
+
+if(EXISTS ${TS_FILES})
+ message(STATUS "${TS_FILES} is EXISTS")
+ execute_process(
+ COMMAND lupdate -recursive ${CMAKE_CURRENT_SOURCE_DIR} -target-language zh_CN -ts ${TS_FILES}
+ )
+ execute_process(
+ COMMAND lrelease ${TS_FILES}
+ )
+else()
+ execute_process(
+ COMMAND lupdate -recursive ${CMAKE_CURRENT_SOURCE_DIR} -target-language zh_CN -ts ${TS_FILES}
+ )
+ execute_process(
+ COMMAND lrelease ${TS_FILES}
+ )
+endif()
+
+if(EXISTS ${BO_TS_FILES})
+ message(STATUS "${BO_TS_FILES} is EXISTS")
+ execute_process(
+ COMMAND lupdate -recursive ${CMAKE_CURRENT_SOURCE_DIR} -target-language bo_CN -ts ${BO_TS_FILES}
+ )
+ execute_process(
+ COMMAND lrelease ${BO_TS_FILES}
+ )
+else()
+ execute_process(
+ COMMAND lupdate -recursive ${CMAKE_CURRENT_SOURCE_DIR} -target-language bo_CN -ts ${BO_TS_FILES}
+ )
+ execute_process(
+ COMMAND lrelease ${BO_TS_FILES}
+ )
+endif()
+
+
+if(EXISTS ${B_QM_FILES})
+ message(STATUS "${PLUGIN} buildQM dir is EXISTS")
+else()
+ message(STATUS "${PLUGIN} buildQM dir is not EXISTS")
+ execute_process(
+ COMMAND mkdir ${B_QM_FILES}
+ )
+ message(STATUS "${PLUGIN} buildQM dir is created")
+endif()
+
+set(P_QM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translation/${PLUGIN}_zh_CN.qm)
+set(BO_QM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translation/${PLUGIN}_bo_CN.qm)
+
+if(EXISTS ${P_QM_FILES})
+ message(STATUS "${PLUGIN} proQM file is EXISTS")
+ execute_process(
+ COMMAND cp -f ${P_QM_FILES} ${B_QM_FILES}
+ )
+ execute_process(
+ COMMAND rm -f ${P_QM_FILES}
+ )
+ message(STATUS "${PLUGIN} buildQM file is created")
+else()
+ message(STATUS "${PLUGIN} buildQM file is not EXISTS")
+endif()
+
+if(EXISTS ${BO_QM_FILES})
+ message(STATUS "${PLUGIN} proQM file is EXISTS")
+ execute_process(
+ COMMAND cp -f ${BO_QM_FILES} ${B_QM_FILES}
+ )
+ execute_process(
+ COMMAND rm -f ${BO_QM_FILES}
+ )
+ message(STATUS "${PLUGIN} buildQM file is created")
+else()
+ message(STATUS "${PLUGIN} buildQM file is not EXISTS")
+endif()
+
+if(${PLUGIN} STREQUAL "panel")
+ set(P_QM_INSTALL ${PACKAGE_DATA_DIR}/${PLUGIN}/translation)
+ message(STATUS " panel translation install : ${P_QM_INSTALL}")
+else()
+ set(P_QM_INSTALL ${PACKAGE_DATA_DIR}/plugin-${PLUGIN}/translation)
+ message(STATUS " plugin ${PLUGIN} translation install : ${P_QM_INSTALL}")
+endif()
+
+install(DIRECTORY ${B_QM_FILES}
+ DESTINATION ${P_QM_INSTALL})
+
+ADD_DEFINITIONS(-DQM_INSTALL=\"${P_QM_INSTALL}/${PLUGIN}_zh_CN.qm\")
+ADD_DEFINITIONS(-DBO_QM_INSTALL=\"${P_QM_INSTALL}/${PLUGIN}_bo_CN.qm\")
+ADD_DEFINITIONS(-DPLUGINNAME=\"${PLUGIN}\")
+endmacro()
diff --git a/cmake/ukui-menu-interface-config.cmake.in b/cmake/ukui-menu-interface-config.cmake.in
new file mode 100644
index 0000000..4ec4835
--- /dev/null
+++ b/cmake/ukui-menu-interface-config.cmake.in
@@ -0,0 +1,9 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(Qt@QT_VERSION_MAJOR@Core )
+if(TARGET Qt6::Core)
+ find_dependency(Qt6Core5Compat @REQUIRED_QT_VERSION@)
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/@UKUI_MENU_LIBRARY_NAME@-targets.cmake")
diff --git a/cmake/ukui-menu-interface.pc.in b/cmake/ukui-menu-interface.pc.in
new file mode 100644
index 0000000..b1b7901
--- /dev/null
+++ b/cmake/ukui-menu-interface.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib/@CMAKE_LIBRARY_ARCHITECTURE@
+includedir=${prefix}/include/@UKUI_MENU_LIBRARY_NAME@
+
+Name: @UKUI_MENU_LIBRARY_NAME@
+Description: @UKUI_MENU_LIBRARY_NAME@ lib header files
+URL: https://www.ukui.org/
+Version: @UKUI_MENU_LIBRARY_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -l@UKUI_MENU_LIBRARY_NAME@
diff --git a/data/img/mainviewwidget/.DS_Store b/data/img/mainviewwidget/.DS_Store
deleted file mode 100755
index 5008ddf..0000000
Binary files a/data/img/mainviewwidget/.DS_Store and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-all-2x.png b/data/img/mainviewwidget/DM-all-2x.png
deleted file mode 100644
index 4f8f9d1..0000000
Binary files a/data/img/mainviewwidget/DM-all-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-all.png b/data/img/mainviewwidget/DM-all.png
deleted file mode 100644
index b05d7fa..0000000
Binary files a/data/img/mainviewwidget/DM-all.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-all.svg b/data/img/mainviewwidget/DM-all.svg
deleted file mode 100644
index 71b87f8..0000000
--- a/data/img/mainviewwidget/DM-all.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-arrow-2x.png b/data/img/mainviewwidget/DM-arrow-2x.png
deleted file mode 100644
index 7cd5c35..0000000
Binary files a/data/img/mainviewwidget/DM-arrow-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-arrow.png b/data/img/mainviewwidget/DM-arrow.png
deleted file mode 100644
index 3b4fe22..0000000
Binary files a/data/img/mainviewwidget/DM-arrow.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-arrow.svg b/data/img/mainviewwidget/DM-arrow.svg
deleted file mode 100644
index c3afc32..0000000
--- a/data/img/mainviewwidget/DM-arrow.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-close-2x.png b/data/img/mainviewwidget/DM-close-2x.png
deleted file mode 100644
index 5dbfa4e..0000000
Binary files a/data/img/mainviewwidget/DM-close-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-close.png b/data/img/mainviewwidget/DM-close.png
deleted file mode 100644
index af00370..0000000
Binary files a/data/img/mainviewwidget/DM-close.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-close.svg b/data/img/mainviewwidget/DM-close.svg
deleted file mode 100644
index 8992eda..0000000
--- a/data/img/mainviewwidget/DM-close.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-function-2x.png b/data/img/mainviewwidget/DM-function-2x.png
deleted file mode 100644
index aefcb56..0000000
Binary files a/data/img/mainviewwidget/DM-function-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-function.png b/data/img/mainviewwidget/DM-function.png
deleted file mode 100644
index 82c72ce..0000000
Binary files a/data/img/mainviewwidget/DM-function.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-function.svg b/data/img/mainviewwidget/DM-function.svg
deleted file mode 100644
index 3e1c659..0000000
--- a/data/img/mainviewwidget/DM-function.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-icon-check.png b/data/img/mainviewwidget/DM-icon-check.png
deleted file mode 100644
index 69c4da6..0000000
Binary files a/data/img/mainviewwidget/DM-icon-check.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-check.svg b/data/img/mainviewwidget/DM-icon-check.svg
deleted file mode 100644
index bca4fc6..0000000
--- a/data/img/mainviewwidget/DM-icon-check.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-icon-check@2x.png b/data/img/mainviewwidget/DM-icon-check@2x.png
deleted file mode 100644
index b4a1b70..0000000
Binary files a/data/img/mainviewwidget/DM-icon-check@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-option.svg b/data/img/mainviewwidget/DM-icon-option.svg
deleted file mode 100644
index a1e8d2b..0000000
--- a/data/img/mainviewwidget/DM-icon-option.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-icon-search.png b/data/img/mainviewwidget/DM-icon-search.png
deleted file mode 100644
index c446f1c..0000000
Binary files a/data/img/mainviewwidget/DM-icon-search.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-search.svg b/data/img/mainviewwidget/DM-icon-search.svg
deleted file mode 100644
index 3b4b9c6..0000000
--- a/data/img/mainviewwidget/DM-icon-search.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-icon-search@2x.png b/data/img/mainviewwidget/DM-icon-search@2x.png
deleted file mode 100644
index d7a01d6..0000000
Binary files a/data/img/mainviewwidget/DM-icon-search@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-返回.png b/data/img/mainviewwidget/DM-icon-返回.png
deleted file mode 100644
index eb3ef88..0000000
Binary files a/data/img/mainviewwidget/DM-icon-返回.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-返回.svg b/data/img/mainviewwidget/DM-icon-返回.svg
deleted file mode 100644
index 8bdca67..0000000
--- a/data/img/mainviewwidget/DM-icon-返回.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-icon-返回@2x.png b/data/img/mainviewwidget/DM-icon-返回@2x.png
deleted file mode 100644
index 9830a10..0000000
Binary files a/data/img/mainviewwidget/DM-icon-返回@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-选项.png b/data/img/mainviewwidget/DM-icon-选项.png
deleted file mode 100644
index 9447a80..0000000
Binary files a/data/img/mainviewwidget/DM-icon-选项.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-icon-选项@2x.png b/data/img/mainviewwidget/DM-icon-选项@2x.png
deleted file mode 100644
index c8cd4e1..0000000
Binary files a/data/img/mainviewwidget/DM-icon-选项@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-letter-2x.png b/data/img/mainviewwidget/DM-letter-2x.png
deleted file mode 100644
index 295b068..0000000
Binary files a/data/img/mainviewwidget/DM-letter-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-letter.png b/data/img/mainviewwidget/DM-letter.png
deleted file mode 100644
index 97722c9..0000000
Binary files a/data/img/mainviewwidget/DM-letter.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-letter.svg b/data/img/mainviewwidget/DM-letter.svg
deleted file mode 100644
index 2f6c725..0000000
--- a/data/img/mainviewwidget/DM-letter.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/DM-max-2x.png b/data/img/mainviewwidget/DM-max-2x.png
deleted file mode 100644
index db956e4..0000000
Binary files a/data/img/mainviewwidget/DM-max-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-max.png b/data/img/mainviewwidget/DM-max.png
deleted file mode 100644
index 14aa676..0000000
Binary files a/data/img/mainviewwidget/DM-max.png and /dev/null differ
diff --git a/data/img/mainviewwidget/DM-max.svg b/data/img/mainviewwidget/DM-max.svg
deleted file mode 100644
index 3b820ce..0000000
--- a/data/img/mainviewwidget/DM-max.svg
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg
deleted file mode 100644
index 7188772..0000000
--- a/data/img/mainviewwidget/Development-Checked.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg
deleted file mode 100644
index 842b3e0..0000000
--- a/data/img/mainviewwidget/Development-Disabled.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg
deleted file mode 100644
index a7ede82..0000000
--- a/data/img/mainviewwidget/Development-Enabled.svg
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg
deleted file mode 100644
index 2559f28..0000000
--- a/data/img/mainviewwidget/Development-Normal.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg
deleted file mode 100644
index eed978a..0000000
--- a/data/img/mainviewwidget/Education-Checked.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg
deleted file mode 100644
index 437e60a..0000000
--- a/data/img/mainviewwidget/Education-Disabled.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg
deleted file mode 100644
index e2a7fa5..0000000
--- a/data/img/mainviewwidget/Education-Enabled.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg
deleted file mode 100644
index a49de28..0000000
--- a/data/img/mainviewwidget/Education-Normal.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg
deleted file mode 100644
index 34f5f71..0000000
--- a/data/img/mainviewwidget/Game-Checked.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-画板 1
-
-
-
diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg
deleted file mode 100644
index 589e3a6..0000000
--- a/data/img/mainviewwidget/Game-Disabled.svg
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg
deleted file mode 100644
index f35c5af..0000000
--- a/data/img/mainviewwidget/Game-Enabled.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg
deleted file mode 100644
index 1bd4c1c..0000000
--- a/data/img/mainviewwidget/Game-Normal.svg
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg
deleted file mode 100644
index 539573b..0000000
--- a/data/img/mainviewwidget/Image-Checked.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg
deleted file mode 100644
index 51da5a2..0000000
--- a/data/img/mainviewwidget/Image-Disabled.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg
deleted file mode 100644
index 9f2af3f..0000000
--- a/data/img/mainviewwidget/Image-Enabled.svg
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg
deleted file mode 100644
index 9b10c3a..0000000
--- a/data/img/mainviewwidget/Image-Normal.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg
deleted file mode 100644
index 6b266fd..0000000
--- a/data/img/mainviewwidget/Internet-Checked.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg
deleted file mode 100644
index bedd77b..0000000
--- a/data/img/mainviewwidget/Internet-Disabled.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg
deleted file mode 100644
index 400e81c..0000000
--- a/data/img/mainviewwidget/Internet-Enabled.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg
deleted file mode 100644
index ed6b571..0000000
--- a/data/img/mainviewwidget/Internet-Normal.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg
deleted file mode 100644
index 276bf97..0000000
--- a/data/img/mainviewwidget/Mobile-Checked.svg
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg
deleted file mode 100644
index 8a66fc1..0000000
--- a/data/img/mainviewwidget/Mobile-Disabled.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg
deleted file mode 100644
index 5e5abfd..0000000
--- a/data/img/mainviewwidget/Mobile-Enabled.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg
deleted file mode 100644
index e0da651..0000000
--- a/data/img/mainviewwidget/Mobile-Normal.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg
deleted file mode 100644
index 06c4c76..0000000
--- a/data/img/mainviewwidget/Office-Checked.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg
deleted file mode 100644
index 642c22f..0000000
--- a/data/img/mainviewwidget/Office-Disabled.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg
deleted file mode 100644
index 3d0f11d..0000000
--- a/data/img/mainviewwidget/Office-Enabled.svg
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg
deleted file mode 100644
index 70b76b8..0000000
--- a/data/img/mainviewwidget/Office-Normal.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg
deleted file mode 100644
index 7088d96..0000000
--- a/data/img/mainviewwidget/Others-Checked.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg
deleted file mode 100644
index 50641de..0000000
--- a/data/img/mainviewwidget/Others-Disabled.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg
deleted file mode 100644
index 6c091d6..0000000
--- a/data/img/mainviewwidget/Others-Enabled.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg
deleted file mode 100644
index e8b54c6..0000000
--- a/data/img/mainviewwidget/Others-Normal.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg
deleted file mode 100644
index 52d64a4..0000000
--- a/data/img/mainviewwidget/Social-Checked.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg
deleted file mode 100644
index 802c846..0000000
--- a/data/img/mainviewwidget/Social-Disabled.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg
deleted file mode 100644
index a247050..0000000
--- a/data/img/mainviewwidget/Social-Enabled.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg
deleted file mode 100644
index e6aa91f..0000000
--- a/data/img/mainviewwidget/Social-Normal.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg
deleted file mode 100644
index 5f70918..0000000
--- a/data/img/mainviewwidget/System-Checked.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg
deleted file mode 100644
index 873a990..0000000
--- a/data/img/mainviewwidget/System-Disabled.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg
deleted file mode 100644
index 67094f8..0000000
--- a/data/img/mainviewwidget/System-Enabled.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg
deleted file mode 100644
index 05bf20e..0000000
--- a/data/img/mainviewwidget/System-Normal.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg
deleted file mode 100644
index 011d306..0000000
--- a/data/img/mainviewwidget/Video-Checked.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg
deleted file mode 100644
index 0928626..0000000
--- a/data/img/mainviewwidget/Video-Disabled.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg
deleted file mode 100644
index 56cbf27..0000000
--- a/data/img/mainviewwidget/Video-Enabled.svg
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg
deleted file mode 100644
index f096994..0000000
--- a/data/img/mainviewwidget/Video-Normal.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/all-2x.png b/data/img/mainviewwidget/all-2x.png
deleted file mode 100644
index 15a02b1..0000000
Binary files a/data/img/mainviewwidget/all-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/all.png b/data/img/mainviewwidget/all.png
deleted file mode 100644
index 3e77999..0000000
Binary files a/data/img/mainviewwidget/all.png and /dev/null differ
diff --git a/data/img/mainviewwidget/all.svg b/data/img/mainviewwidget/all.svg
deleted file mode 100644
index 43587e7..0000000
--- a/data/img/mainviewwidget/all.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg
deleted file mode 100644
index 8484963..0000000
--- a/data/img/mainviewwidget/attributeaction.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/close-2x.png b/data/img/mainviewwidget/close-2x.png
deleted file mode 100644
index 100fd90..0000000
Binary files a/data/img/mainviewwidget/close-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/close.png b/data/img/mainviewwidget/close.png
deleted file mode 100644
index ce9b7d3..0000000
Binary files a/data/img/mainviewwidget/close.png and /dev/null differ
diff --git a/data/img/mainviewwidget/close.svg b/data/img/mainviewwidget/close.svg
deleted file mode 100644
index a2ac5ee..0000000
--- a/data/img/mainviewwidget/close.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg
deleted file mode 100644
index 733dfea..0000000
--- a/data/img/mainviewwidget/downarrow-pressed.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg
deleted file mode 100644
index 9feb660..0000000
--- a/data/img/mainviewwidget/downarrow.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/drop-down-2x.png b/data/img/mainviewwidget/drop-down-2x.png
deleted file mode 100644
index a33369b..0000000
Binary files a/data/img/mainviewwidget/drop-down-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/drop-down.png b/data/img/mainviewwidget/drop-down.png
deleted file mode 100644
index bbb6e14..0000000
Binary files a/data/img/mainviewwidget/drop-down.png and /dev/null differ
diff --git a/data/img/mainviewwidget/drop-down.svg b/data/img/mainviewwidget/drop-down.svg
deleted file mode 100644
index 694e97b..0000000
--- a/data/img/mainviewwidget/drop-down.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg
deleted file mode 100644
index ab75e0f..0000000
--- a/data/img/mainviewwidget/fixed.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/full-all-2x.png b/data/img/mainviewwidget/full-all-2x.png
deleted file mode 100644
index 0b9e862..0000000
Binary files a/data/img/mainviewwidget/full-all-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-close-2x.png b/data/img/mainviewwidget/full-close-2x.png
deleted file mode 100644
index 88421f3..0000000
Binary files a/data/img/mainviewwidget/full-close-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-close.png b/data/img/mainviewwidget/full-close.png
deleted file mode 100644
index e0aa44f..0000000
Binary files a/data/img/mainviewwidget/full-close.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-close.svg b/data/img/mainviewwidget/full-close.svg
deleted file mode 100644
index 397d1b9..0000000
--- a/data/img/mainviewwidget/full-close.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/full-drop-down-2x.png b/data/img/mainviewwidget/full-drop-down-2x.png
deleted file mode 100644
index 61353ab..0000000
Binary files a/data/img/mainviewwidget/full-drop-down-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-drop-down.png b/data/img/mainviewwidget/full-drop-down.png
deleted file mode 100644
index cf7dbc2..0000000
Binary files a/data/img/mainviewwidget/full-drop-down.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-drop-down.svg b/data/img/mainviewwidget/full-drop-down.svg
deleted file mode 100644
index 5252b3c..0000000
--- a/data/img/mainviewwidget/full-drop-down.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/full-function-2x.png b/data/img/mainviewwidget/full-function-2x.png
deleted file mode 100644
index 816f16c..0000000
Binary files a/data/img/mainviewwidget/full-function-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-function.png b/data/img/mainviewwidget/full-function.png
deleted file mode 100644
index 8e6f47f..0000000
Binary files a/data/img/mainviewwidget/full-function.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-function.svg b/data/img/mainviewwidget/full-function.svg
deleted file mode 100644
index a0880a5..0000000
--- a/data/img/mainviewwidget/full-function.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/full-letter-2x.png b/data/img/mainviewwidget/full-letter-2x.png
deleted file mode 100644
index a5212da..0000000
Binary files a/data/img/mainviewwidget/full-letter-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-letter.png b/data/img/mainviewwidget/full-letter.png
deleted file mode 100644
index 00aff38..0000000
Binary files a/data/img/mainviewwidget/full-letter.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-letter.svg b/data/img/mainviewwidget/full-letter.svg
deleted file mode 100644
index ee2cc83..0000000
--- a/data/img/mainviewwidget/full-letter.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/full-min-2x.png b/data/img/mainviewwidget/full-min-2x.png
deleted file mode 100644
index 46b8a3c..0000000
Binary files a/data/img/mainviewwidget/full-min-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-min.png b/data/img/mainviewwidget/full-min.png
deleted file mode 100644
index 1016551..0000000
Binary files a/data/img/mainviewwidget/full-min.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-min.svg b/data/img/mainviewwidget/full-min.svg
deleted file mode 100644
index 5bc8fb4..0000000
--- a/data/img/mainviewwidget/full-min.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/full-search-2x.png b/data/img/mainviewwidget/full-search-2x.png
deleted file mode 100644
index 5419253..0000000
Binary files a/data/img/mainviewwidget/full-search-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-search.png b/data/img/mainviewwidget/full-search.png
deleted file mode 100644
index 3603ba3..0000000
Binary files a/data/img/mainviewwidget/full-search.png and /dev/null differ
diff --git a/data/img/mainviewwidget/full-search.svg b/data/img/mainviewwidget/full-search.svg
deleted file mode 100644
index 89c630a..0000000
--- a/data/img/mainviewwidget/full-search.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/fullicon-all.png b/data/img/mainviewwidget/fullicon-all.png
deleted file mode 100644
index 8f6176b..0000000
Binary files a/data/img/mainviewwidget/fullicon-all.png and /dev/null differ
diff --git a/data/img/mainviewwidget/fullicon-all.svg b/data/img/mainviewwidget/fullicon-all.svg
deleted file mode 100644
index a991c98..0000000
--- a/data/img/mainviewwidget/fullicon-all.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/function-2x.png b/data/img/mainviewwidget/function-2x.png
deleted file mode 100644
index ad6c487..0000000
Binary files a/data/img/mainviewwidget/function-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/function.png b/data/img/mainviewwidget/function.png
deleted file mode 100644
index ff17d26..0000000
Binary files a/data/img/mainviewwidget/function.png and /dev/null differ
diff --git a/data/img/mainviewwidget/function.svg b/data/img/mainviewwidget/function.svg
deleted file mode 100644
index da7fb57..0000000
--- a/data/img/mainviewwidget/function.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/icon- search-2x.png b/data/img/mainviewwidget/icon- search-2x.png
deleted file mode 100644
index 8f286b4..0000000
Binary files a/data/img/mainviewwidget/icon- search-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon- search.png b/data/img/mainviewwidget/icon- search.png
deleted file mode 100644
index c2da345..0000000
Binary files a/data/img/mainviewwidget/icon- search.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon- search.svg b/data/img/mainviewwidget/icon- search.svg
deleted file mode 100644
index 1a8d9c7..0000000
--- a/data/img/mainviewwidget/icon- search.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/icon- 返回.png b/data/img/mainviewwidget/icon- 返回.png
deleted file mode 100644
index 94dc40f..0000000
Binary files a/data/img/mainviewwidget/icon- 返回.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon- 返回.svg b/data/img/mainviewwidget/icon- 返回.svg
deleted file mode 100644
index 5217892..0000000
--- a/data/img/mainviewwidget/icon- 返回.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/icon- 返回@2x.png b/data/img/mainviewwidget/icon- 返回@2x.png
deleted file mode 100644
index f3ffab0..0000000
Binary files a/data/img/mainviewwidget/icon- 返回@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon- 选项.png b/data/img/mainviewwidget/icon- 选项.png
deleted file mode 100644
index 5f9e37f..0000000
Binary files a/data/img/mainviewwidget/icon- 选项.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon- 选项.svg b/data/img/mainviewwidget/icon- 选项.svg
deleted file mode 100644
index 5c8b768..0000000
--- a/data/img/mainviewwidget/icon- 选项.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/icon- 选项@2x.png b/data/img/mainviewwidget/icon- 选项@2x.png
deleted file mode 100644
index b6b765d..0000000
Binary files a/data/img/mainviewwidget/icon- 选项@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon-check.png b/data/img/mainviewwidget/icon-check.png
deleted file mode 100644
index 29e9a17..0000000
Binary files a/data/img/mainviewwidget/icon-check.png and /dev/null differ
diff --git a/data/img/mainviewwidget/icon-check.svg b/data/img/mainviewwidget/icon-check.svg
deleted file mode 100644
index b9597ea..0000000
--- a/data/img/mainviewwidget/icon-check.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/icon-check@2x.png b/data/img/mainviewwidget/icon-check@2x.png
deleted file mode 100644
index 5c1a31e..0000000
Binary files a/data/img/mainviewwidget/icon-check@2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg
deleted file mode 100644
index ad7dcbe..0000000
--- a/data/img/mainviewwidget/leftarrow-hover.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg
deleted file mode 100644
index afb5e30..0000000
--- a/data/img/mainviewwidget/leftarrow.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/letter-2x.png b/data/img/mainviewwidget/letter-2x.png
deleted file mode 100644
index edb7493..0000000
Binary files a/data/img/mainviewwidget/letter-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/letter.png b/data/img/mainviewwidget/letter.png
deleted file mode 100644
index 393bf63..0000000
Binary files a/data/img/mainviewwidget/letter.png and /dev/null differ
diff --git a/data/img/mainviewwidget/letter.svg b/data/img/mainviewwidget/letter.svg
deleted file mode 100644
index 368f9fe..0000000
--- a/data/img/mainviewwidget/letter.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg
deleted file mode 100644
index d4a590c..0000000
--- a/data/img/mainviewwidget/lock-fs.svg
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-彩色
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg
deleted file mode 100644
index 1eed7fb..0000000
--- a/data/img/mainviewwidget/lock.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-单色
-
-
diff --git a/data/img/mainviewwidget/max-2x.png b/data/img/mainviewwidget/max-2x.png
deleted file mode 100644
index 7a8d03f..0000000
Binary files a/data/img/mainviewwidget/max-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/max.png b/data/img/mainviewwidget/max.png
deleted file mode 100644
index b1a17ff..0000000
Binary files a/data/img/mainviewwidget/max.png and /dev/null differ
diff --git a/data/img/mainviewwidget/max.svg b/data/img/mainviewwidget/max.svg
deleted file mode 100644
index f6f73fd..0000000
--- a/data/img/mainviewwidget/max.svg
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/power-2x.png b/data/img/mainviewwidget/power-2x.png
deleted file mode 100644
index 926bc59..0000000
Binary files a/data/img/mainviewwidget/power-2x.png and /dev/null differ
diff --git a/data/img/mainviewwidget/power.png b/data/img/mainviewwidget/power.png
deleted file mode 100644
index 6344ca5..0000000
Binary files a/data/img/mainviewwidget/power.png and /dev/null differ
diff --git a/data/img/mainviewwidget/power.svg b/data/img/mainviewwidget/power.svg
deleted file mode 100644
index d83d248..0000000
--- a/data/img/mainviewwidget/power.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg
deleted file mode 100644
index 3fff0c3..0000000
--- a/data/img/mainviewwidget/recent-disabled.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg
deleted file mode 100644
index 1f9e7b0..0000000
--- a/data/img/mainviewwidget/recent-enabled.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg
deleted file mode 100644
index 49ab330..0000000
--- a/data/img/mainviewwidget/recent-gray.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg
deleted file mode 100644
index 963142b..0000000
--- a/data/img/mainviewwidget/recent.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg
deleted file mode 100644
index 976f3c0..0000000
--- a/data/img/mainviewwidget/rightarrow-hover.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg
deleted file mode 100644
index f29a5a4..0000000
--- a/data/img/mainviewwidget/rightarrow.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg
deleted file mode 100644
index 1516f6b..0000000
--- a/data/img/mainviewwidget/search.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/select.svg b/data/img/mainviewwidget/select.svg
deleted file mode 100644
index bddfc1a..0000000
--- a/data/img/mainviewwidget/select.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/selected.svg b/data/img/mainviewwidget/selected.svg
deleted file mode 100644
index c610131..0000000
--- a/data/img/mainviewwidget/selected.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/data/img/mainviewwidget/ukui-search-blue.svg b/data/img/mainviewwidget/ukui-search-blue.svg
deleted file mode 100644
index 4665b8a..0000000
--- a/data/img/mainviewwidget/ukui-search-blue.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- ukui-global search-search-blue
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/data/img/mainviewwidget/ukui-search.svg b/data/img/mainviewwidget/ukui-search.svg
deleted file mode 100644
index e931c1d..0000000
--- a/data/img/mainviewwidget/ukui-search.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- ukui-global search-search
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg
deleted file mode 100644
index 4c3ca77..0000000
--- a/data/img/mainviewwidget/unfixed.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg
deleted file mode 100644
index 91012eb..0000000
--- a/data/img/mainviewwidget/uninstall.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg
deleted file mode 100644
index 44cb179..0000000
--- a/data/img/mainviewwidget/uparrow-pressed.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg
deleted file mode 100644
index 53fb37a..0000000
--- a/data/img/mainviewwidget/uparrow.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg
deleted file mode 100644
index 09afb9e..0000000
--- a/data/img/sidebarwidget/commonuse.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg
deleted file mode 100644
index e39300f..0000000
--- a/data/img/sidebarwidget/computer.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg
deleted file mode 100644
index a64182b..0000000
--- a/data/img/sidebarwidget/control.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-画板 1
-
-
-
diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg
deleted file mode 100644
index ab75e0f..0000000
--- a/data/img/sidebarwidget/fixed.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png
deleted file mode 100644
index 19ee231..0000000
Binary files a/data/img/sidebarwidget/fullusericon.png and /dev/null differ
diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg
deleted file mode 100644
index 9534da3..0000000
--- a/data/img/sidebarwidget/function.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg
deleted file mode 100644
index 63ce322..0000000
--- a/data/img/sidebarwidget/letter.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg
deleted file mode 100644
index 170ebb8..0000000
--- a/data/img/sidebarwidget/lock.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg
deleted file mode 100644
index aa9dd23..0000000
--- a/data/img/sidebarwidget/max.svg
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg
deleted file mode 100644
index 100550a..0000000
--- a/data/img/sidebarwidget/min.svg
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-画板 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg
deleted file mode 100644
index 5184876..0000000
--- a/data/img/sidebarwidget/personal.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-文件系统
-
-
diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg
deleted file mode 100644
index 976f3c0..0000000
--- a/data/img/sidebarwidget/rightarrow.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-画板 1
-
-
diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg
deleted file mode 100644
index a64182b..0000000
--- a/data/img/sidebarwidget/setting.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-画板 1
-
-
-
diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg
deleted file mode 100644
index 020681e..0000000
--- a/data/img/sidebarwidget/shutdown.svg
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg
deleted file mode 100644
index 9023f13..0000000
--- a/data/img/sidebarwidget/trash.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-垃圾桶
-
-
-
diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg
deleted file mode 100644
index 4c3ca77..0000000
--- a/data/img/sidebarwidget/unfixed.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg
deleted file mode 100644
index 4dad569..0000000
--- a/data/img/sidebarwidget/usericon-darkcolor.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg
deleted file mode 100644
index 5f313df..0000000
--- a/data/img/sidebarwidget/usericon-lightcolor.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/data/org.ukui.menu.service b/data/org.ukui.menu.service
new file mode 100644
index 0000000..3a0ea89
--- /dev/null
+++ b/data/org.ukui.menu.service
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.ukui.menu
+Exec=/usr/bin/ukui-menu
diff --git a/data/org.ukui.menu.settings.gschema.xml b/data/org.ukui.menu.settings.gschema.xml
new file mode 100644
index 0000000..8337317
--- /dev/null
+++ b/data/org.ukui.menu.settings.gschema.xml
@@ -0,0 +1,33 @@
+
+
+
+
diff --git a/data/ukui-menu-global-config.conf b/data/ukui-menu-global-config.conf
new file mode 100644
index 0000000..8b6914f
--- /dev/null
+++ b/data/ukui-menu-global-config.conf
@@ -0,0 +1,20 @@
+# can not uninstall "System Apps"
+[System Apps]
+kylin-screenshot.desktop=0
+ukui-notebook.desktop=0
+ukui-clock.desktop=0
+kylin-calculator.desktop=0
+kylin-recorder.desktop=0
+kylin-software-center.desktop=0
+kylin-camera.desktop=0
+biometric-manager.desktop=0
+yhkylin-backup-tools.desktop=0
+box-manager.desktop=0
+ukui-system-monitor.desktop=0
+ksc-defender.desktop=0
+logview.desktop=0
+kylin-service-support.desktop=0
+kylin-user-guide.desktop=0
+ukui-control-center.desktop=0
+peony.desktop=0
+engrampa.desktop=0
diff --git a/data/ukui-menu.desktop b/data/ukui-menu.desktop
new file mode 100644
index 0000000..2f91bdd
--- /dev/null
+++ b/data/ukui-menu.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Name=ukui-menu
+Name[zh_CN]=开始菜单
+Name[tr_TR]=Başlangıç menüsü
+Comment=A simple application launcher
+Comment[zh_CN]=简易的应用程序启动器
+Exec=/usr/bin/ukui-menu %u
+Icon=ukui-menu
+Terminal=false
+Type=Application
+NoDisplay=true
+OnlyShowIn=UKUI
+X-UKUI-AutoRestart=true
+X-UKUI-Autostart-Phase=Application
diff --git a/extension/recent-file/CMakeLists.txt b/extension/recent-file/CMakeLists.txt
new file mode 100644
index 0000000..8c01ac7
--- /dev/null
+++ b/extension/recent-file/CMakeLists.txt
@@ -0,0 +1,49 @@
+project(recent-file-extension LANGUAGES CXX)
+
+cmake_minimum_required(VERSION 3.16)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+find_package(Qt5 COMPONENTS
+ Core Gui Widgets Quick LinguistTools DBus
+ REQUIRED)
+
+include_directories(../../src/extension)
+set(SOURCE recent-file-extension.cpp recent-file-extension.h)
+
+find_package(PkgConfig REQUIRED)
+set(EXTERNAL_LIBS "")
+set(PC_PKGS glib-2.0 gio-unix-2.0)
+
+foreach(lib IN ITEMS ${PC_PKGS})
+ pkg_check_modules(${lib} REQUIRED ${lib})
+ if(${${lib}_FOUND})
+ include_directories(${${lib}_INCLUDE_DIRS})
+ link_directories(${${lib}_LIBRARY_DIRS})
+ list(APPEND EXTERNAL_LIBS ${${lib}_LIBRARIES})
+ endif()
+endforeach()
+
+set(QRC_FILES qml/qml.qrc)
+# 翻译文件
+file(GLOB TS_FILES "translations/*.ts")
+# 更新翻译并创建.qm文件
+qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
+
+set(RECENT_FILE_TRANSLATION_DIR "${UKUI_MENU_TRANSLATION_DIR}/${PROJECT_NAME}")
+add_compile_definitions(RECENT_FILE_TRANSLATION_DIR="${RECENT_FILE_TRANSLATION_DIR}")
+
+add_library(${PROJECT_NAME} SHARED ${SOURCE} ${QM_FILES} ${QRC_FILES})
+target_link_libraries(${PROJECT_NAME} PRIVATE
+ Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Quick Qt5::DBus
+ ${EXTERNAL_LIBS}
+ ${UKUI_MENU_LIBRARY_NAME}
+)
+
+install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION "${UKUI_MENU_EXTENSION_DIR}")
+install(FILES ${QM_FILES} DESTINATION "${RECENT_FILE_TRANSLATION_DIR}")
diff --git a/extension/recent-file/metadata.json b/extension/recent-file/metadata.json
new file mode 100644
index 0000000..9079b7e
--- /dev/null
+++ b/extension/recent-file/metadata.json
@@ -0,0 +1,4 @@
+{
+ "Type": "UKUI_MENU_EXTENSION",
+ "Version": "1.0.0"
+}
diff --git a/extension/recent-file/qml/RecentFileExtension.qml b/extension/recent-file/qml/RecentFileExtension.qml
new file mode 100644
index 0000000..023cbd3
--- /dev/null
+++ b/extension/recent-file/qml/RecentFileExtension.qml
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.0
+import QtQuick.Controls 2.5
+import org.ukui.menu.extension 1.0
+import org.ukui.menu.core 1.0
+import AppControls2 1.0 as AppControls2
+
+UkuiMenuExtension {
+ Component.onCompleted: {
+ recentFileView.model = extensionData.recentFilesModel
+ extensionData.recentFilesModel.updateData()
+ }
+
+ Item {
+ anchors.fill: parent
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onContainsMouseChanged: {
+
+ if (containsMouse) {
+ scrollBar.visible = true
+ }
+ else {
+ scrollBar.visible = false
+ }
+ }
+
+ AppControls2.StyleBackground {
+ anchors.top: parent.top
+ width: parent.width; height: 1
+ useStyleTransparent: false
+ alpha: 0.15
+ paletteRole: Palette.Text
+ visible: recentFileView.contentY > 0
+ z: 1
+ }
+
+ ListView {
+ id: recentFileView
+ anchors.fill: parent
+ anchors.leftMargin: 12
+ spacing: 4
+
+ ScrollBar.vertical: AppControls2.ScrollBar {
+ id: scrollBar
+ visible: false
+ width: 14
+ height: recentFileView.height
+ }
+
+ delegate: AppControls2.StyleBackground {
+ width: ListView.view.width - 18
+ height: 40
+ useStyleTransparent: false
+ alpha: itemArea.pressed ? 1 : itemArea.hovered ? 0.65 : 0
+ radius: 8
+
+ Row {
+ anchors.fill: parent
+ anchors.leftMargin: 4
+ spacing: 12
+
+ Image {
+ width: 32
+ height: 32
+ anchors.verticalCenter: parent.verticalCenter
+ source: model.icon
+ }
+
+ AppControls2.StyleText {
+ width: parent.width - x
+ height: 20
+ anchors.verticalCenter: parent.verticalCenter
+ verticalAlignment: Text.AlignVCenter
+ text: model.name
+ elide: Text.ElideRight
+ }
+ }
+
+ MouseArea {
+ id: itemArea
+ property bool hovered
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: {
+ hovered = true
+ }
+ onExited: {
+ hovered = false
+ }
+ onClicked: {
+ var data = {
+ "url": model.uri,
+ "index": model.index
+ }
+ data["action"] = mouse.button === Qt.RightButton ? "right" : ""
+ send(data)
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/extension/recent-file/qml/qml.qrc b/extension/recent-file/qml/qml.qrc
new file mode 100644
index 0000000..b2a10ac
--- /dev/null
+++ b/extension/recent-file/qml/qml.qrc
@@ -0,0 +1,5 @@
+
+
+ RecentFileExtension.qml
+
+
diff --git a/extension/recent-file/recent-file-extension.cpp b/extension/recent-file/recent-file-extension.cpp
new file mode 100644
index 0000000..280a60d
--- /dev/null
+++ b/extension/recent-file/recent-file-extension.cpp
@@ -0,0 +1,553 @@
+/*
+ * Copyright (C) 2022, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "recent-file-extension.h"
+
+#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
+#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
+#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
+#define FREEDESKTOP_FILEMANAGER_NAME "org.freedesktop.FileManager1"
+#define FREEDESKTOP_FILEMANAGER_PATH "/org/freedesktop/FileManager1"
+#define FREEDESKTOP_FILEMANAGER_INTERFACE "org.freedesktop.FileManager1"
+
+namespace UkuiMenu {
+
+// GVFS 最近文件获取工具
+class GVFSRecentFileData
+{
+public:
+ static int s_queryFileNum;
+ static GFile *s_recentFileRootDir;
+ static GFileMonitor *s_recentFileMonitor;
+ static void loadRecentFileASync(RecentFileProvider *p_recentFileProvider);
+ static void fileMonitor(RecentFileProvider *p_recentFileProvider);
+ static void removeRecentFileByInfoId(const QString &infoId);
+
+private:
+ static GAsyncReadyCallback enumerateFinish(GFile *file, GAsyncResult *res, RecentFileProvider *p_recentFileProvider);
+ static GAsyncReadyCallback parseRecentFiles(GFileEnumerator *enumerator, GAsyncResult *res, RecentFileProvider *p_recentFileProvider);
+ static void fileChangedCallback(GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ RecentFileProvider *p_recentFileProvider);
+};
+
+int GVFSRecentFileData::s_queryFileNum = 100;
+GFile *GVFSRecentFileData::s_recentFileRootDir = g_file_new_for_uri("recent:///");
+GFileMonitor *GVFSRecentFileData::s_recentFileMonitor = nullptr;
+
+void GVFSRecentFileData::fileMonitor(RecentFileProvider *p_recentFileProvider)
+{
+ GError *error = nullptr;
+ s_recentFileMonitor = g_file_monitor_directory(GVFSRecentFileData::s_recentFileRootDir,
+ G_FILE_MONITOR_NONE,
+ nullptr,
+ &error);
+
+ if (error) {
+ qWarning() << "recentFile monitor creat error";
+ g_error_free(error);
+ return;
+ }
+
+ g_signal_connect(s_recentFileMonitor, "changed", G_CALLBACK(fileChangedCallback), p_recentFileProvider);
+}
+
+void GVFSRecentFileData::fileChangedCallback(GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ RecentFileProvider *p_recentFileProvider)
+{
+ Q_UNUSED(monitor);
+ Q_UNUSED(file);
+ Q_UNUSED(other_file);
+
+ switch (event_type) {
+ case G_FILE_MONITOR_EVENT_DELETED:
+ case G_FILE_MONITOR_EVENT_CREATED: {
+ loadRecentFileASync(p_recentFileProvider);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void GVFSRecentFileData::removeRecentFileByInfoId(const QString &infoId)
+{
+ GFile *file = g_file_new_for_uri(infoId.toUtf8().constData());
+ GError *err = nullptr;
+
+ g_file_delete(file, nullptr, &err);
+
+ g_object_unref(file);
+ if (err) {
+ qWarning() << "Recentfile Delete Error";
+ }
+}
+
+void GVFSRecentFileData::loadRecentFileASync(RecentFileProvider *p_recentFileProvider)
+{
+ if (!s_recentFileRootDir) {
+ qWarning() << "Can not find 'recent:///' dir.";
+ return;
+ }
+
+ g_file_enumerate_children_async(s_recentFileRootDir,
+ "*",
+ G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT,
+ nullptr, GAsyncReadyCallback(enumerateFinish),
+ p_recentFileProvider);
+}
+
+GAsyncReadyCallback
+GVFSRecentFileData::enumerateFinish(GFile *file, GAsyncResult *res, RecentFileProvider *p_recentFileProvider)
+{
+ GError *error = nullptr;
+ GFileEnumerator *enumerator = g_file_enumerate_children_finish(file, res, &error);
+ if (error) {
+ qWarning() << "GVFSRecentFileData::enumerateFinish Error:" << error->message;
+ g_error_free(error);
+ return nullptr;
+ }
+
+ g_file_enumerator_next_files_async(enumerator, s_queryFileNum, G_PRIORITY_DEFAULT,
+ nullptr, GAsyncReadyCallback(parseRecentFiles), p_recentFileProvider);
+
+ g_object_unref(enumerator);
+
+ return nullptr;
+}
+
+GAsyncReadyCallback
+GVFSRecentFileData::parseRecentFiles(GFileEnumerator *enumerator, GAsyncResult *res, RecentFileProvider *p_recentFileProvider)
+{
+ GError *error = nullptr;
+ GList *fileList = g_file_enumerator_next_files_finish(enumerator, res, &error);
+ if (error) {
+ qWarning() << "GVFSRecentFileData::parseRecentFiles Error:" << error->message;
+ g_error_free(error);
+ return nullptr;
+ }
+
+ QVector recentFiles;
+ if (!fileList) {
+ p_recentFileProvider->dataProcess(recentFiles);
+ return nullptr;
+ }
+
+ auto listIterator = fileList;
+ while (listIterator) {
+ RecentFile recentFile;
+ GFileInfo *info = static_cast(listIterator->data);
+ GFile *file = g_file_enumerator_get_child(enumerator, info);
+ recentFile.infoId = g_file_get_uri(file);
+ g_object_unref(file);
+
+ char *attribute = g_file_info_get_attribute_as_string(info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
+ if (attribute) {
+ recentFile.uri = attribute;
+ g_free(attribute);
+ }
+
+ const char *fileName = g_file_info_get_display_name(info);
+ if (fileName) {
+ recentFile.name = fileName;
+ }
+
+ // in seconds since the UNIX epoch.
+ recentFile.accessTime = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_ACCESS);
+
+ GIcon *icon = g_file_info_get_icon(info);
+ if (icon) {
+ const gchar* const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
+ if (iconNames) {
+ auto iconNameIterator = iconNames;
+ while(*iconNameIterator) {
+ if(QIcon::hasThemeIcon(*iconNameIterator)) {
+ recentFile.icon = "image://appicon/" + QString(*iconNameIterator);
+ break;
+ } else {
+ ++iconNameIterator;
+ }
+ }
+ }
+ g_object_unref(icon);
+ }
+
+ if (recentFile.icon.isEmpty()) {
+ recentFile.icon = "image://appicon/text-plain";
+ }
+
+ recentFiles.append(recentFile);
+ info = nullptr;
+ listIterator = listIterator->next;
+ }
+ g_list_free(fileList);
+
+ p_recentFileProvider->dataProcess(recentFiles);
+
+ return nullptr;
+}
+
+// RecentFileExtension
+RecentFileExtension::RecentFileExtension(QObject *parent) : MenuExtensionIFace(parent)
+{
+ QString translationFile(QString(RECENT_FILE_TRANSLATION_DIR) + "/recent-file-extension_" + QLocale::system().name() + ".qm");
+ if (QFile::exists(translationFile)) {
+ QTranslator *translator = new QTranslator(this);
+ translator->load(translationFile);
+ QCoreApplication::installTranslator(translator);
+ }
+
+ qRegisterMetaType("RecentFilesModel*");
+ qRegisterMetaType >("QVector");
+
+ m_recentFilesProviderThread = new QThread(this);
+ m_recentFilesModel = new RecentFilesModel(this);
+ m_recentFileProvider = new RecentFileProvider();
+
+ if ((m_recentFilesProviderThread == nullptr) || (m_recentFilesModel == nullptr) || (m_recentFileProvider == nullptr)) {
+ qWarning() << "recentfile construction error" ;
+ return;
+ }
+
+ m_recentFilesProviderThread->start();
+ m_recentFileProvider->moveToThread(m_recentFilesProviderThread);
+
+ connect(this, &RecentFileExtension::loadRecentFiles, m_recentFileProvider, &RecentFileProvider::getRecentData);
+ connect(m_recentFilesModel, &RecentFilesModel::updateRecentData, m_recentFileProvider, &RecentFileProvider::getRecentData);
+ connect(m_recentFileProvider, &RecentFileProvider::dataLoadCompleted, m_recentFilesModel, &RecentFilesModel::updateRecentFiles);
+ connect(this, &RecentFileExtension::openFileASync, m_recentFileProvider, &RecentFileProvider::openFileByGFile);
+
+ m_data.insert("recentFilesModel", QVariant::fromValue(m_recentFilesModel));
+ initFileDbus();
+
+ GVFSRecentFileData::fileMonitor(m_recentFileProvider);
+ Q_EMIT loadRecentFiles();
+}
+
+RecentFileExtension::~RecentFileExtension()
+{
+ if (m_recentFilesProviderThread) {
+ m_recentFilesProviderThread->quit();
+ m_recentFilesProviderThread->wait();
+ }
+
+ if (m_recentFileProvider) {
+ delete m_recentFileProvider;
+ m_recentFileProvider = nullptr;
+ }
+
+ if (GVFSRecentFileData::s_recentFileRootDir) {
+ g_object_unref(GVFSRecentFileData::s_recentFileRootDir);
+ }
+
+ if (GVFSRecentFileData::s_recentFileMonitor) {
+ g_object_unref(GVFSRecentFileData::s_recentFileMonitor);
+ }
+}
+
+int RecentFileExtension::index()
+{
+ return 1;
+}
+
+QString RecentFileExtension::name()
+{
+ return tr("Recent Files");
+}
+
+QUrl RecentFileExtension::url()
+{
+ return {"qrc:///extensions/RecentFileExtension.qml"};
+}
+
+QVariantMap RecentFileExtension::data()
+{
+ return m_data;
+}
+
+void RecentFileExtension::receive(QVariantMap data)
+{
+ QString path = data.value("url").toString();
+ if (data.value("action").toString() == "right") {
+ int index = data.value("index").toInt();
+ creatMenu(path, index);
+ return;
+ }
+ if (!openFile(path)) {
+ Q_EMIT openFileASync(path);
+ }
+}
+
+void RecentFileExtension::initFileDbus()
+{
+ m_appManagerDbusInterface = new QDBusInterface(KYLIN_APP_MANAGER_NAME,
+ KYLIN_APP_MANAGER_PATH,
+ KYLIN_APP_MANAGER_INTERFACE,
+ QDBusConnection::sessionBus());
+
+ m_fileManagerDbusInterface = new QDBusInterface(FREEDESKTOP_FILEMANAGER_NAME,
+ FREEDESKTOP_FILEMANAGER_PATH,
+ FREEDESKTOP_FILEMANAGER_INTERFACE,
+ QDBusConnection::sessionBus());
+
+ if (!m_appManagerDbusInterface) {
+ qWarning() << "recentfile open failed: appmanager dbus does not exists.";
+ }
+ if (!m_fileManagerDbusInterface) {
+ qWarning() << "recentfile directory open failed: filemanager dbus does not exists.";
+ }
+}
+
+bool RecentFileExtension::openFile(const QString &desktopFile)
+{
+ if (m_appManagerDbusInterface != nullptr) {
+ QDBusReply status = m_appManagerDbusInterface->call("LaunchApp", desktopFile);
+ return status;
+ } else {
+ qWarning()<<"LaunchApp is failed,return false";
+ return false;
+ }
+}
+
+void RecentFileExtension::creatMenu(const QString &path, const int &index)
+{
+ QMenu menu;
+
+ QAction open(QIcon::fromTheme("document-open-symbolic"), tr("Open"));
+ QAction remove(QIcon::fromTheme("edit-clear-symbolic"), tr("Remove from list"));
+ QAction clear(QIcon::fromTheme("edit-delete-symbolic"), tr("Clear list"));
+ QAction directory(tr("Open the directory where the file is located"));
+
+ connect(&open, &QAction::triggered, this, [this, path]() {
+ if (!openFile(path)) {
+ Q_EMIT openFileASync(path);
+ }
+ });
+
+ connect(&remove, &QAction::triggered, this, [this, index]() {
+ GVFSRecentFileData::removeRecentFileByInfoId(m_recentFilesModel->getInfoId(index));
+ });
+
+ connect(&clear, &QAction::triggered, this, [this]() {
+ QStringList infoIdList = m_recentFilesModel->getAllInfoId();
+ for (const QString &infoId : infoIdList) {
+ GVFSRecentFileData::removeRecentFileByInfoId(infoId);
+ }
+ });
+
+ connect(&directory, &QAction::triggered, this, [this, path]() {
+ if (!m_fileManagerDbusInterface) { return; }
+ QStringList pathList;
+ pathList.append(path);
+ m_fileManagerDbusInterface->call("ShowFolders", pathList, "arg");
+ });
+
+ menu.addAction(&open);
+ menu.addSeparator();
+ menu.addAction(&remove);
+ menu.addAction(&clear);
+ menu.addSeparator();
+ menu.addAction(&directory);
+ menu.exec(QCursor::pos());
+}
+
+RecentFilesModel::RecentFilesModel(QObject *parent) : QAbstractListModel(parent)
+{
+
+}
+
+int RecentFilesModel::rowCount(const QModelIndex &parent) const
+{
+ return m_recentFileData.count();
+}
+
+QVariant RecentFilesModel::data(const QModelIndex &index, int role) const
+{
+ int row = index.row();
+ if (row < 0 || row >= m_recentFileData.count()) {
+ return {};
+ }
+
+ switch (role) {
+ case UriRole:
+ return m_recentFileData.at(row).uri;
+ case NameRole:
+ return m_recentFileData.at(row).name;
+ case IconRole:
+ return m_recentFileData.at(row).icon;
+ default:
+ break;
+ }
+
+ return {};
+}
+
+QHash RecentFilesModel::roleNames() const
+{
+ QHash names;
+ names.insert(UriRole, "uri");
+ names.insert(NameRole, "name");
+ names.insert(IconRole, "icon");
+ return names;
+}
+
+QString RecentFilesModel::getInfoId(const int &index)
+{
+ return m_recentFileData.at(index).infoId;
+}
+
+QStringList RecentFilesModel::getAllInfoId()
+{
+ QStringList infoIdList;
+ for (const RecentFile &data : m_recentFileData) {
+ infoIdList.append(data.infoId);
+ }
+ return infoIdList;
+}
+
+void RecentFilesModel::updateData()
+{
+ Q_EMIT updateRecentData();
+}
+
+void RecentFilesModel::updateRecentFiles(QVector recentFiles)
+{
+ beginResetModel();
+ m_recentFileData.swap(recentFiles);
+ endResetModel();
+}
+
+RecentFileProvider::RecentFileProvider(QObject *parent) : QObject(parent)
+{
+
+}
+
+void RecentFileProvider::dataProcess(QVector &recentFiles)
+{
+ std::sort(recentFiles.begin(), recentFiles.end(), [](const RecentFile &a, const RecentFile &b) {
+ return a.accessTime > b.accessTime;
+ });
+
+ Q_EMIT dataLoadCompleted(recentFiles);
+}
+
+void RecentFileProvider::getRecentData()
+{
+ GVFSRecentFileData::loadRecentFileASync(this);
+}
+
+void RecentFileProvider::openFileByGFile(const QString &path)
+{
+ GFile *file = g_file_new_for_uri(path.toUtf8().constData());
+ if (!file) {
+ return;
+ }
+
+ GFileInfo *fileInfo = g_file_query_info(file,
+ "standard::*," "time::*," "access::*," "mountable::*," "metadata::*," "trash::*," G_FILE_ATTRIBUTE_ID_FILE,
+ G_FILE_QUERY_INFO_NONE,
+ nullptr,
+ nullptr);
+ if (!fileInfo) {
+ return;
+ }
+
+ QString mimeType(g_file_info_get_content_type(fileInfo));
+ if (mimeType.isEmpty()) {
+ if (g_file_info_has_attribute(fileInfo, "standard::fast-content-type")) {
+ mimeType = g_file_info_get_attribute_string(fileInfo, "standard::fast-content-type");
+ }
+ }
+
+ GError *error = NULL;
+ GAppInfo *info = NULL;
+
+ QString mimeAppsListPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/mimeapps.list";
+ GKeyFile *keyfile = g_key_file_new();
+ gboolean ret = g_key_file_load_from_file(keyfile, mimeAppsListPath.toUtf8(), G_KEY_FILE_NONE, &error);
+
+ if (!ret) {
+ qWarning()<< "load mimeapps list error msg" << error->message;
+ info = g_app_info_get_default_for_type(mimeType.toUtf8().constData(), false);
+ g_error_free(error);
+ }
+ else {
+ gchar *desktopApp = g_key_file_get_string(keyfile, "Default Applications", mimeType.toUtf8(), &error);
+
+ if (NULL != desktopApp) {
+ info = (GAppInfo*)g_desktop_app_info_new(desktopApp);
+ g_free (desktopApp);
+ }
+ else {
+ info = g_app_info_get_default_for_type(mimeType.toUtf8().constData(), false);
+ }
+ }
+
+ g_key_file_free (keyfile);
+
+ if(G_IS_APP_INFO(info)) {
+ bool isSuccess(false);
+ QDBusInterface * appLaunchInterface = new QDBusInterface(KYLIN_APP_MANAGER_NAME,
+ KYLIN_APP_MANAGER_PATH,
+ KYLIN_APP_MANAGER_INTERFACE,
+ QDBusConnection::sessionBus());
+ if(!appLaunchInterface->isValid()) {
+ qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
+ isSuccess = false;
+ }
+ else {
+ appLaunchInterface->setTimeout(10000);
+ QDBusReply reply = appLaunchInterface->call("LaunchDefaultAppWithUrl", path);
+ if(reply.isValid()) {
+ isSuccess = reply;
+ }
+ else {
+ qWarning() << "recentfile used appmanager dbus called failed!";
+ isSuccess = false;
+ }
+ }
+ if(appLaunchInterface) {
+ delete appLaunchInterface;
+ }
+ appLaunchInterface = NULL;
+ if (!isSuccess){
+ QDesktopServices::openUrl(path);
+ }
+ }
+
+ g_object_unref(info);
+}
+
+} // UkuiMenu
diff --git a/extension/recent-file/recent-file-extension.h b/extension/recent-file/recent-file-extension.h
new file mode 100644
index 0000000..e3d4eba
--- /dev/null
+++ b/extension/recent-file/recent-file-extension.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2022, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+#ifndef UKUI_MENU_RECENT_FILE_EXTENSION_H
+#define UKUI_MENU_RECENT_FILE_EXTENSION_H
+
+#include
+#include
+#include
+
+#include "menu-extension-iface.h"
+
+namespace UkuiMenu {
+
+class RecentFile
+{
+public:
+ quint64 accessTime{0};
+ QString uri;
+ QString name;
+ QString icon;
+ QString infoId;
+};
+
+class RecentFileProvider : public QObject
+{
+ Q_OBJECT
+public:
+ explicit RecentFileProvider(QObject *parent = nullptr);
+ void dataProcess(QVector &recentFiles);
+
+public Q_SLOT:
+ void getRecentData();
+ void openFileByGFile(const QString &path);
+
+Q_SIGNALS:
+ void dataLoadCompleted(QVector recentFiles);
+};
+
+
+class RecentFilesModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum RoleMessage {
+ UriRole = Qt::UserRole,
+ NameRole = Qt::UserRole + 1,
+ IconRole = Qt::UserRole + 2,
+ };
+
+ explicit RecentFilesModel(QObject *parent = nullptr);
+ int rowCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ QHash roleNames() const override;
+
+ QString getInfoId(const int &index);
+ QStringList getAllInfoId();
+ Q_INVOKABLE void updateData();
+
+public Q_SLOT:
+ void updateRecentFiles(QVector recentFiles);
+
+private:
+ QVector m_recentFileData;
+
+Q_SIGNALS:
+ void updateRecentData();
+};
+
+
+class RecentFileExtension : public MenuExtensionIFace
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID UKUI_MENU_EXTENSION_IFACE_IID FILE "metadata.json")
+ Q_INTERFACES(UkuiMenu::MenuExtensionIFace)
+public:
+ explicit RecentFileExtension(QObject *parent = nullptr);
+ ~RecentFileExtension() override;
+ int index() override;
+ QString name() override;
+ QUrl url() override;
+ QVariantMap data() override;
+ void receive(QVariantMap data) override;
+
+private:
+ QVector m_recentFile;
+ QVariantMap m_data;
+ QDBusInterface *m_appManagerDbusInterface = nullptr;
+ RecentFilesModel *m_recentFilesModel = nullptr;
+ QThread *m_recentFilesProviderThread = nullptr;
+ RecentFileProvider *m_recentFileProvider = nullptr;
+ QDBusInterface *m_fileManagerDbusInterface = nullptr;
+
+ void initFileDbus();
+ bool openFile(const QString& desktopFile);
+ void creatMenu(const QString &path, const int &index);
+
+Q_SIGNALS:
+ void loadRecentFiles();
+ void openFileASync(const QString &path);
+};
+
+} // UkuiMenu
+
+#endif //UKUI_MENU_RECENT_FILE_EXTENSION_H
diff --git a/extension/recent-file/translations/recent-file-extension_zh_CN.ts b/extension/recent-file/translations/recent-file-extension_zh_CN.ts
new file mode 100644
index 0000000..e17d0fe
--- /dev/null
+++ b/extension/recent-file/translations/recent-file-extension_zh_CN.ts
@@ -0,0 +1,27 @@
+
+
+
+
+ UkuiMenu::RecentFileExtension
+
+ Recent Files
+
+
+
+ Open
+
+
+
+ Remove from list
+
+
+
+ Clear list
+
+
+
+ Open the directory where the file is located
+
+
+
+
diff --git a/main.cpp b/main.cpp
deleted file mode 100644
index c9c0dbf..0000000
--- a/main.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "mainwindow.h"
-#include "tabletwindow.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "utility.h"
-#include "file-utils.h"
-#include
-#include
-#include "ukuistylehelper/ukuistylehelper.h"
-#include "windowmanager/windowmanager.h"
-
-#define UKUI_SERVICE "org.gnome.SessionManager"
-#define UKUI_PATH "/org/gnome/SessionManager"
-#define UKUI_INTERFACE "org.gnome.SessionManager"
-
-#include
-
-int main(int argc, char *argv[])
-{
- initUkuiLog4qt("ukui-menu");
- g_projectCodeName = KDKGetPrjCodeName().c_str();
- g_subProjectCodeName = KDKGetOSRelease("SUB_PROJECT_CODENAME").c_str();
-
- qRegisterMetaType>("QVector");
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
- QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
-#endif
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
- QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
-#endif
- QtSingleApplication app("ukui-menu", argc, argv);
- app.setQuitOnLastWindowClosed(false);
- g_platform = QGuiApplication::platformName();
-
- if (app.isRunning()) {
- app.sendMessage("raise_window_noop");
- return EXIT_SUCCESS;
- }
-
- QTranslator translator;
-
- if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) {
- app.installTranslator(&translator);
- } else {
- myDebug() << "Load translations file" << QLocale() << "failed!";
- }
-
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- FileUtils::loadHanziTable(":/src/BackProcess/Search/pinyinWithoutTone.txt");
- MainWindow w;
- app.setActivationWindow(&w);
-
- w.show();
- w.raise();
-
- if (Style::m_panelPosition == 0) {
- if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
- kdk::WindowManager::setGeometry(w.windowHandle(),QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY +
- Style::m_availableScreenHeight - Style::m_minh - 3, Style::m_minw, Style::m_minh));
- } else {
- w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::m_minh - 3,
- Style::m_minw, Style::m_minh));
- }
- } else if (Style::m_panelPosition == 1) {
- if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
- kdk::WindowManager::setGeometry(w.windowHandle(),QRect(Style::m_primaryScreenX + 4,
- Style::m_primaryScreenY + 4, Style::m_minw, Style::m_minh));
- } else {
- w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::m_minw, Style::m_minh));
- }
-
- } else if (Style::m_panelPosition == 2) {
-
-
- if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
- kdk::WindowManager::setGeometry(w.windowHandle(), QRect(Style::m_primaryScreenX + 4,
- Style::m_primaryScreenY + 4, Style::m_minw, Style::m_minh));
- } else {
- w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::m_minw, Style::m_minh));
- }
- } else {
- if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
- kdk::WindowManager::setGeometry(w.windowHandle(), QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth -
- Style::m_minw - 4, Style::m_primaryScreenY + 4, Style::m_minw, Style::m_minh));
- } else {
- w.setGeometry(QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth - Style::m_minw - 4, Style::m_primaryScreenY + 4,
- Style::m_minw, Style::m_minh));
- }
- }
-
- w.update();
- w.activateWindow();
- w.hide();
- return app.exec();
- } else {
- TabletWindow w;
- app.setActivationWindow(&w);
- centerToScreen(&w);
- w.setAttribute(Qt::WA_TranslucentBackground, true);
- w.setAttribute(Qt::WA_X11NetWmWindowTypeDesktop, false);
- w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
- w.raise();
- w.activateWindow();
- //拉起后通知session
- QDBusInterface interface(UKUI_SERVICE,
- UKUI_PATH,
- UKUI_INTERFACE,
- QDBusConnection::sessionBus());
- interface.call("startupfinished", "ukui-menu", "finish");
- return app.exec();
- }
-}
-
diff --git a/man/ukui-menu.1 b/man/ukui-menu.1
deleted file mode 100755
index 86a91cf..0000000
--- a/man/ukui-menu.1
+++ /dev/null
@@ -1,20 +0,0 @@
-.\" Man page for ukui-menu
-.TH UKUIMENU 1 "17 December 2019" "UKUI Desktop Environment"
-.\" Please adjust this date when revising the manpage.
-.\"
-.SH "NAME"
-ukui-menu \- The tool for the UKUI Desktop Environment
-.SH "SYNOPSIS"
-.B ukui-menu
-.SH "DESCRIPTION"
-The \fBukui-menu\fR program is a part of the ukui-menu, it provides users with graphical interface tools.
-.PP
-This manual page documents the \fBukui-menu\fR command.
-.P
-.SH "BUGS"
-.SS Should you encounter any bugs, they may be reported at:
-https://github.com/explorer-cs/ukui-start-menu/issues
-.SH "AUTHORS"
-.SS This Man Page has been written for the UKUI Desktop Environment by:
-liuhao (2019)
-.SH "SEE ALSO"
diff --git a/qml/AppControls2/App.qml b/qml/AppControls2/App.qml
new file mode 100644
index 0000000..07b5433
--- /dev/null
+++ b/qml/AppControls2/App.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+Rectangle {
+ color: "red";
+ Text {
+ text: "AppControls2"
+ }
+}
diff --git a/qml/AppControls2/AppItem.qml b/qml/AppControls2/AppItem.qml
new file mode 100644
index 0000000..66ec400
--- /dev/null
+++ b/qml/AppControls2/AppItem.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import org.ukui.menu.core 1.0
+
+MouseArea {
+ id: control
+ hoverEnabled: true
+
+ StyleBackground {
+ anchors.fill: parent
+ radius: 4
+ useStyleTransparent: false
+ alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
+ ToolTip.visible: content.textTruncated && control.containsMouse
+ ToolTip.text: name
+
+ IconLabel {
+ id: content
+ anchors.fill: parent
+ iconHeight: 32; iconWidth: iconHeight
+ appName: name; appIcon: icon
+ display: Display.TextBesideIcon
+ spacing: 12
+ }
+ }
+}
diff --git a/qml/AppControls2/FolderIcon.qml b/qml/AppControls2/FolderIcon.qml
new file mode 100644
index 0000000..bc5717e
--- /dev/null
+++ b/qml/AppControls2/FolderIcon.qml
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import org.ukui.menu.core 1.0
+
+StyleBackground {
+ property alias icons: iconGrid.icons
+ property alias rows: iconGrid.rows
+ property alias columns: iconGrid.columns
+ property alias padding: iconGrid.padding
+ property alias spacing: iconGrid.spacing
+
+ paletteRole: Palette.Text
+ useStyleTransparent: false
+
+ Grid {
+ id: iconGrid
+ anchors.fill: parent
+ property string icons: ""
+ property int cellWidth: Math.floor((width - padding*2 - spacing*(columns - 1)) / columns)
+ property int cellHeight: Math.floor((height - padding*2 - spacing*(rows - 1)) / rows)
+ Repeater {
+ model: icons.split(" ").slice(0, rows*columns)
+ delegate: Image {
+ width: iconGrid.cellWidth
+ height: iconGrid.cellHeight
+ source: modelData
+ }
+ }
+ }
+}
diff --git a/qml/AppControls2/FolderItem.qml b/qml/AppControls2/FolderItem.qml
new file mode 100644
index 0000000..06a3e9e
--- /dev/null
+++ b/qml/AppControls2/FolderItem.qml
@@ -0,0 +1,131 @@
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+MouseArea {
+ id: control
+ property bool editStatus: false
+ property bool truncate: false
+ hoverEnabled: true
+ ToolTip.visible: editStatus && truncate && control.containsMouse
+ ToolTip.text: name
+
+ StyleBackground {
+ anchors.fill: parent
+ radius: 4
+ useStyleTransparent: false
+ alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
+
+ RowLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 12
+ spacing: 12
+
+ FolderIcon {
+ rows: 2; columns: 2
+ spacing: 2; padding: 2
+ icons: icon
+ alpha: 0.12; radius: 4
+ Layout.alignment: Qt.AlignVCenter
+ Layout.preferredWidth: 32
+ Layout.preferredHeight: 32
+ }
+
+ Item {
+ id: renameArea
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ Component {
+ id: unEditText
+ StyleText {
+ id: textShow
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignLeft
+ elide: Text.ElideRight
+ text: name
+ Component.onCompleted: {
+ control.truncate = textShow.truncated
+ }
+ }
+ }
+
+ Component {
+ id: editText
+ AppControls2.StyleBackground {
+ radius: 6
+ useStyleTransparent: false
+ alpha: textChange.activeFocus ? 0.04 : 0
+ paletteRole: Palette.Text
+ border.width: 2
+ borderAlpha: textChange.activeFocus ? 1 : 0
+ borderColor: Palette.Highlight
+
+ TextInput {
+ id: textChange
+ text: name
+ clip: true
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ anchors.right: buttonMouseArea.left
+ anchors.rightMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ verticalAlignment: Text.AlignVCenter
+ selectByMouse: true
+ maximumLength: 14
+
+ onEditingFinished: {
+ modelManager.getAppModel().renameFolder(id, text);
+ control.editStatus = false;
+ }
+
+ function updateTextInputColor() {
+ color = themePalette.paletteColor(Palette.Text);
+ selectionColor = themePalette.paletteColor(Palette.Highlight);
+ }
+
+ Component.onCompleted: {
+ updateTextInputColor();
+ themePalette.styleColorChanged.connect(updateTextInputColor);
+ forceActiveFocus();
+ }
+
+ Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor);
+ }
+
+ MouseArea {
+ id: buttonMouseArea
+ hoverEnabled: true
+ width: 16; height: width
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ visible: textChange.activeFocus
+
+ ThemeIcon {
+ anchors.centerIn: parent
+ width: 16; height: width
+ source: "image://appicon/edit-clear-symbolic"
+ }
+
+ onClicked: {
+ textChange.text = name;
+ control.editStatus = false;
+ }
+ }
+
+ }
+
+ }
+
+ Loader {
+ id: editLoader
+ anchors.fill: parent
+ sourceComponent: editStatus ? editText : unEditText
+ }
+ }
+ }
+ }
+}
diff --git a/qml/AppControls2/IconLabel.qml b/qml/AppControls2/IconLabel.qml
new file mode 100644
index 0000000..b9ed242
--- /dev/null
+++ b/qml/AppControls2/IconLabel.qml
@@ -0,0 +1,73 @@
+import QtQuick 2.0
+import org.ukui.menu.core 1.0
+
+Item {
+ id: root
+
+ property int display: Display.TextUnderIcon
+ // 上下布局icon大小为48*48 左右布局icon大小为32*32
+ property int iconHeight: 48
+ property int iconWidth: 48
+ property string appName: ""
+ property string appIcon: ""
+ // 上下布局spacing:0 左右布局spacing:12
+ property int spacing: 2
+ property bool textTruncated: iconText.truncated
+ property bool textHighLight: false
+
+ state: root.display
+
+ states: [
+ State {
+ name: Display.TextBesideIcon
+ PropertyChanges {
+ target: iconImage
+ anchors.verticalCenter: root.verticalCenter
+ anchors.left: root.left
+ anchors.leftMargin: root.spacing
+ }
+ PropertyChanges {
+ target: iconText
+ width: root.width - iconImage.width - root.spacing * 2
+
+ horizontalAlignment: Text.AlignLeft
+ anchors.left: iconImage.right
+ anchors.leftMargin: root.spacing
+ anchors.verticalCenter: root.verticalCenter
+ }
+ },
+ State {
+ name: Display.TextUnderIcon
+ PropertyChanges {
+ target: iconImage
+ anchors.top: root.top
+ anchors.topMargin: (root.height - root.spacing - iconImage.height - iconText.height) / 2
+ anchors.horizontalCenter: root.horizontalCenter
+ }
+ PropertyChanges {
+ target: iconText
+ width: root.width
+
+ horizontalAlignment: Text.AlignHCenter
+ anchors.top: iconImage.bottom
+ anchors.topMargin: root.spacing
+ anchors.horizontalCenter: root.horizontalCenter
+ }
+ }
+ ]
+
+ Image {
+ id: iconImage
+ height: root.iconHeight
+ width: root.iconWidth
+ source: root.appIcon
+ }
+
+ StyleText {
+ id: iconText
+ text: root.appName
+ font.pixelSize: 14
+ elide: Text.ElideRight
+ paletteRole: root.textHighLight ? Palette.HighlightedText : Palette.Text
+ }
+}
diff --git a/qml/AppControls2/LabelItem.qml b/qml/AppControls2/LabelItem.qml
new file mode 100644
index 0000000..2294a46
--- /dev/null
+++ b/qml/AppControls2/LabelItem.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+
+MouseArea {
+ id: control
+ hoverEnabled: true
+ ToolTip.text: qsTr("Open the label selection interface")
+ ToolTip.visible: control.containsMouse
+
+ StyleBackground {
+ anchors.fill: parent
+ radius: 4
+ useStyleTransparent: false
+ alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
+
+ RowLayout {
+ anchors.fill: parent
+ StyleText {
+ Layout.preferredHeight: parent.height
+ Layout.preferredWidth: contentWidth
+ Layout.leftMargin: 12
+
+ horizontalAlignment: Qt.AlignLeft
+ verticalAlignment: Qt.AlignVCenter
+ font.pixelSize: 14
+ font.bold: true
+ text: name
+ }
+
+ Image {
+ visible: control.containsMouse
+ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
+ Layout.preferredWidth: 24
+ Layout.preferredHeight: 24
+ Layout.rightMargin: 16
+ source: "image://appicon/open-menu-symbolic"
+ }
+ }
+ }
+}
diff --git a/qml/AppControls2/RoundButton.qml b/qml/AppControls2/RoundButton.qml
new file mode 100644
index 0000000..72cc3b1
--- /dev/null
+++ b/qml/AppControls2/RoundButton.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+import org.ukui.menu.core 1.0
+
+MouseArea {
+ id: buttonMouseArea
+ hoverEnabled: true
+ property string buttonIcon: ""
+ property alias highlight: themeIcon.highLight
+ property alias autoHighLight: themeIcon.autoHighLight
+
+ StyleBackground {
+ useStyleTransparent: false
+ paletteRole: mainWindow.isFullScreen ? Palette.Light : Palette.Text
+ anchors.fill: parent
+ radius: height / 2
+ alpha: buttonMouseArea.containsPress ? 0.20 : buttonMouseArea.containsMouse ? 0.16 : 0.10
+ }
+
+ ThemeIcon {
+ id: themeIcon
+ anchors.centerIn: parent
+ width: 16; height: width
+ source: buttonIcon
+ }
+}
diff --git a/qml/AppControls2/ScrollBar.qml b/qml/AppControls2/ScrollBar.qml
new file mode 100644
index 0000000..4fe5a4a
--- /dev/null
+++ b/qml/AppControls2/ScrollBar.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.5
+import org.ukui.menu.core 1.0
+
+ScrollBar {
+ id: control
+ padding: (hovered || pressed) ? 3 : 5
+ property bool visual: true
+
+ Behavior on padding {
+ NumberAnimation {
+ duration: 200
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ contentItem: StyleBackground {
+ radius: width / 2
+ useStyleTransparent: false
+ paletteRole: Palette.Text
+ alpha: control.pressed ? 0.28 : control.hovered ? 0.18 : 0.10
+ opacity: ((control.policy === ScrollBar.AlwaysOn || control.size < 1.0 ) && control.visual) ? 1.0 : 0.0
+ }
+}
diff --git a/qml/AppControls2/StyleBackground.qml b/qml/AppControls2/StyleBackground.qml
new file mode 100644
index 0000000..f301abf
--- /dev/null
+++ b/qml/AppControls2/StyleBackground.qml
@@ -0,0 +1,57 @@
+import QtQuick 2.0
+import org.ukui.menu.core 1.0
+
+Rectangle {
+ property bool useStyleTransparent: true
+ property int paletteRole: Palette.Base
+ property int paletteGroup: Palette.Active
+ property int borderColor: Palette.Base
+ property real alpha: 1.0
+ property real borderAlpha: 1.0
+
+ clip: true
+ border.width: 0
+
+ function updateColor() {
+ if (useStyleTransparent) {
+ color = themePalette.paletteColorWithTransparency(paletteRole, paletteGroup)
+ } else {
+ color = themePalette.paletteColorWithCustomTransparency(paletteRole, paletteGroup, alpha)
+ }
+ }
+
+ function updateBorderColor() {
+ border.color = themePalette.paletteColorWithCustomTransparency(borderColor, Palette.Active, borderAlpha)
+ }
+
+ Component.onCompleted: {
+ updateColor()
+ updateBorderColor()
+ themePalette.styleColorChanged.connect(updateColor)
+ themePalette.styleColorChanged.connect(updateBorderColor)
+ }
+ Component.onDestruction: {
+ themePalette.styleColorChanged.disconnect(updateColor)
+ themePalette.styleColorChanged.disconnect(updateBorderColor)
+ }
+
+ onUseStyleTransparentChanged: {
+ updateColor()
+ }
+ onPaletteRoleChanged: {
+ updateColor()
+ }
+ onPaletteGroupChanged: {
+ updateColor()
+ }
+ onAlphaChanged: {
+ updateColor()
+ }
+ onBorderAlphaChanged: {
+ updateBorderColor()
+ }
+ onBorderColorChanged: {
+ updateBorderColor()
+ }
+}
+
diff --git a/qml/AppControls2/StyleText.qml b/qml/AppControls2/StyleText.qml
new file mode 100644
index 0000000..8f23661
--- /dev/null
+++ b/qml/AppControls2/StyleText.qml
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+import org.ukui.menu.core 1.0
+
+Text {
+ property int paletteRole: Palette.Text
+ property real alpha: 1.0
+
+ function updateColor() {
+ color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha)
+ }
+
+ Component.onCompleted: {
+ updateColor()
+ themePalette.styleColorChanged.connect(updateColor)
+ }
+ Component.onDestruction: {
+ themePalette.styleColorChanged.disconnect(updateColor)
+ }
+
+ onPaletteRoleChanged: {
+ updateColor()
+ }
+ onAlphaChanged: {
+ updateColor()
+ }
+}
diff --git a/qml/AppControls2/qmldir b/qml/AppControls2/qmldir
new file mode 100644
index 0000000..4961582
--- /dev/null
+++ b/qml/AppControls2/qmldir
@@ -0,0 +1,10 @@
+module AppControls2
+StyleBackground 1.0 StyleBackground.qml
+StyleText 1.0 StyleText.qml
+ScrollBar 1.0 ScrollBar.qml
+AppItem 1.0 AppItem.qml
+FolderItem 1.0 FolderItem.qml
+LabelItem 1.0 LabelItem.qml
+IconLabel 1.0 IconLabel.qml
+RoundButton 1.0 RoundButton.qml
+FolderIcon 1.0 FolderIcon.qml
diff --git a/qml/AppUI/AppList.qml b/qml/AppUI/AppList.qml
new file mode 100644
index 0000000..58398b7
--- /dev/null
+++ b/qml/AppUI/AppList.qml
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.0
+import QtQml 2.12
+import QtQuick.Controls 2.5
+import QtQuick.Layouts 1.12
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+Item {
+ property string title: ""
+ signal labelItemClicked()
+ signal openFolderPageSignal(string folderId, string folderName);
+
+ function labelSelection(labelId) {
+ appListView.view.positionViewAtIndex(appListView.model.getLabelIndex(labelId), ListView.Beginning)
+ }
+
+ AppListView {
+ id: appListView
+ anchors.fill: parent
+ model: modelManager.getAppModel()
+ delegate: Component {
+ Loader {
+ width: ListView.view ? ListView.view.width : 0
+ height: 40
+ property int index: model.index
+ property int type: model.type
+ property string id: model.id
+ property string name: model.name
+ property string icon: model.icon
+ sourceComponent: {
+ if (type === DataType.Normal) {
+ return appItem;
+ }
+ if (type === DataType.Folder) {
+ return folderItem;
+ }
+ if (type === DataType.Label) {
+ return labelItem;
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: appItem
+ AppControls2.AppItem {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ appListView.model.openMenu(index);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ appManager.launchApp(id);
+ return;
+ }
+ }
+ }
+ }
+
+ Component {
+ id: labelItem
+ AppControls2.LabelItem {
+ onClicked: labelItemClicked();
+ }
+ }
+
+ Component {
+ id: folderItem
+ AppControls2.FolderItem {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ appListView.model.openMenu(index);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ openFolderPageSignal(id, name);
+ return;
+ }
+ }
+ Component.onCompleted: {
+ appListView.model.renameText.connect(toEditText);
+ }
+ Component.onDestruction: {
+ appListView.model.renameText.disconnect(toEditText);
+ }
+
+ function toEditText(idOfIndex){
+ if (id === idOfIndex) {
+ editStatus = true;
+ }
+ }
+ }
+ }
+}
diff --git a/qml/AppUI/AppListView.qml b/qml/AppUI/AppListView.qml
new file mode 100644
index 0000000..7d975ea
--- /dev/null
+++ b/qml/AppUI/AppListView.qml
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Controls 2.12
+import QtQuick.Layouts 1.12
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+MouseArea {
+ id: root
+
+ readonly property alias view: listView
+ property alias model: listView.model
+ property alias delegate: listView.delegate
+
+ hoverEnabled: true
+ clip: true
+
+ AppControls2.StyleBackground {
+ anchors.top: parent.top
+ width: parent.width
+ height: 1
+ useStyleTransparent: false
+ alpha: 0.15
+ paletteRole: Palette.Text
+ visible: listView.contentY > 0
+ }
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+ anchors.leftMargin: 4
+
+ ListView {
+ id: listView
+
+ spacing: 4
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ highlightMoveDuration: 0
+ boundsBehavior: Flickable.StopAtBounds
+ ScrollBar.vertical: listViewScrollBar
+ }
+
+ AppControls2.ScrollBar {
+ id: listViewScrollBar
+
+ Layout.fillHeight: true
+ Layout.preferredWidth: 14
+ visual: root.containsMouse
+ }
+ }
+}
diff --git a/src/UserInterface/RightClickMenu/menubox.cpp b/qml/AppUI/AppPage.qml
similarity index 50%
rename from src/UserInterface/RightClickMenu/menubox.cpp
rename to qml/AppUI/AppPage.qml
index ef40c1d..95f114f 100644
--- a/src/UserInterface/RightClickMenu/menubox.cpp
+++ b/qml/AppUI/AppPage.qml
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
*
* 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
@@ -13,32 +13,34 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-#include "menubox.h"
-#include
-#include
-#include
-#include
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
-MenuBox::MenuBox(QWidget *parent):
- QMenu(parent)
-{
-}
+AppControls2.StyleBackground {
+ paletteRole: Palette.Window
+ radius: 12
-void MenuBox::mousePressEvent(QMouseEvent *event)
-{
- if (!this->actionAt(event->pos())) {
- Q_EMIT sendMainWinActiveSignal(true);
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.topMargin: parent.radius
+ spacing: 0
+
+ AppPageHeader {
+ id: appPageHeader
+ Layout.fillWidth: true
+ Layout.preferredHeight: 40
+ }
+
+ AppPageContent {
+ appPageHeader: appPageHeader
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
}
-
- qDebug() << "void MenuBox::mousePressEvent(QMouseEvent *event)";
- return QMenu::mousePressEvent(event);
}
-
-void MenuBox::hideEvent(QHideEvent *e)
-{
- Q_EMIT sendMainWinActiveSignal(true);
- return QMenu::hideEvent(e);
-}
-
diff --git a/qml/AppUI/AppPageContent.qml b/qml/AppUI/AppPageContent.qml
new file mode 100644
index 0000000..3239804
--- /dev/null
+++ b/qml/AppUI/AppPageContent.qml
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+SwipeView {
+ id: root
+ interactive: false
+ // 5.15
+ // required property AppPageHeader appPageHeader
+ // 5.12
+ property AppPageHeader appPageHeader: null
+
+ Item {
+ id: appListBase
+ AppList {
+ id: appList
+ anchors.fill: parent
+ anchors.leftMargin: 4
+ onLabelItemClicked: {
+ appList.visible = false;
+ selectionPage.viewShowStart();
+ }
+ }
+
+ SelectionPage {
+ id: selectionPage
+ anchors.fill: parent
+ anchors.bottomMargin: 54
+ visible: !appList.visible
+ onViewHideFinished: appList.visible = true
+ onLabelSelected: appList.labelSelection(labelId)
+ }
+ }
+
+ Loader {
+ id: folderPageLoader
+ active: false
+ sourceComponent: Component {
+ AppListView {
+ model: modelManager.getFolderModel()
+ delegate: Component {
+ Loader {
+ width: ListView.view ? ListView.view.width : 0; height: 40
+ property string id: model.id
+ property string name: model.name
+ property string icon: model.icon
+ sourceComponent: AppControls2.AppItem {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ menuManager.showMenu(id);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ appManager.launchApp(id);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ function showFolderPage(folderId, folderName) {
+ active = true;
+ item.model.setFolderId(folderId);
+ appPageHeader.title = folderName;
+ appPageHeader.content = folderPageHeader;
+ root.currentIndex = SwipeView.index;
+ }
+ function hideFolderPage() {
+ root.currentIndex = appListBase.SwipeView.index;
+ appPageHeader.title = appList.title;
+ appPageHeader.content = null;
+ //active = false;
+ }
+
+ Component.onCompleted: {
+ appList.openFolderPageSignal.connect(showFolderPage);
+ }
+ }
+
+ Component {
+ id: folderPageHeader
+ Item {
+ RowLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 12
+ anchors.rightMargin: 30
+ spacing: 2
+
+ ThemeIcon {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.maximumWidth: 16
+ Layout.maximumHeight: 16
+ Layout.alignment: Qt.AlignVCenter
+ source: "image://appicon/ukui-start-symbolic"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: folderPageLoader.hideFolderPage();
+ }
+ }
+
+ EditText {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+ }
+ }
+}
diff --git a/qml/AppUI/AppPageHeader.qml b/qml/AppUI/AppPageHeader.qml
new file mode 100644
index 0000000..986c28f
--- /dev/null
+++ b/qml/AppUI/AppPageHeader.qml
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+import org.ukui.menu.utils 1.0
+
+Item {
+ id: appPageHeaderRoot
+ property string title: ""
+ property Component content: null
+ clip: true
+
+ Loader {
+ anchors.fill: parent
+ property string title: appPageHeaderRoot.title
+ sourceComponent: {
+ return appPageHeaderRoot.content === null ? defaultComponent : appPageHeaderRoot.content
+ }
+ }
+
+ Component {
+ id: defaultComponent
+ Item {
+ id: root
+ state: "normal"
+ states: [
+ State {
+ name: "normal"
+ PropertyChanges { target: searchBar; scale: 0.9; y: -pluginSelectionBar.height }
+ PropertyChanges { target: pluginSelectionBar; scale: 1.0; y: 0 }
+ StateChangeScript { script: pluginSelectMenu.model.reactivateProvider() }
+ },
+ State {
+ name: "search"
+ PropertyChanges { target: searchBar; scale: 1.0; y: 0 }
+ PropertyChanges { target: pluginSelectionBar; scale: 0.9; y: pluginSelectionBar.height }
+ }
+ ]
+
+ transitions:[
+ Transition {
+ to: "normal"
+ SequentialAnimation {
+ NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300 }
+ ScriptAction { script: searchBar.visible = false }
+ }
+ },
+ Transition {
+ to: "search"
+ SequentialAnimation {
+ ScriptAction { script: searchBar.visible = true }
+ NumberAnimation { easing.type: Easing.InOutQuad; properties: "scale,y"; duration: 300}
+ }
+ }
+ ]
+
+ Item {
+ id: searchBar
+ width: parent.width; height: 30
+
+ RowLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 15
+ anchors.rightMargin: 15
+ spacing: 10
+
+ SearchInputBar {
+ id: searchInputBar
+ property string providerId: ""
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ radius: 16
+ onTextChanged: {
+ if (text === "") {
+ pluginSelectMenu.model.reactivateProvider();
+ } else {
+ appPageHeaderUtils.activateProvider(providerId);
+ appPageHeaderUtils.startSearch(text);
+ }
+ }
+ }
+
+ AppControls2.RoundButton {
+ Layout.preferredWidth: parent.height; Layout.preferredHeight: parent.height
+ buttonIcon: "image://appicon/edit-clear-symbolic"
+
+ onClicked: {
+ searchInputBar.clear();
+ root.state = "normal";
+ }
+ }
+ }
+ }
+
+ Item {
+ id: pluginSelectionBar
+ width: parent.width
+ height: parent.height
+ RowLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 16
+ spacing: 12
+ Text {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ verticalAlignment: Qt.AlignVCenter
+ text: appPageHeaderRoot.title
+ font.bold: true
+ }
+
+ ListView {
+ Layout.preferredWidth: childrenRect.width
+ Layout.preferredHeight: 32
+ Layout.maximumWidth: 68
+ Layout.alignment: Qt.AlignVCenter
+
+ clip: true
+ spacing: 4
+ orientation: ListView.Horizontal
+
+ model: appPageHeaderUtils.model(PluginGroup.Button)
+ delegate: AppControls2.RoundButton {
+ width: height; height: ListView.view ? ListView.view.height : 0
+ buttonIcon: model.icon
+ onClicked: {
+ root.state = "search";
+ searchInputBar.providerId = model.id;
+ }
+ }
+ }
+
+ PluginSelectMenu {
+ id: pluginSelectMenu
+ Layout.preferredWidth: childrenRect.width
+ Layout.preferredHeight: 32
+ Layout.maximumHeight: 32
+ Layout.rightMargin: 8
+ Layout.alignment: Qt.AlignVCenter
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/qml/AppUI/EditText.qml b/qml/AppUI/EditText.qml
new file mode 100644
index 0000000..740a0de
--- /dev/null
+++ b/qml/AppUI/EditText.qml
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+Item {
+ id: contain
+ property bool textCenterIn: false
+ property bool editStatus: false
+ property string textEdited: title
+ property bool isFullScreenFolder: false
+
+ Component {
+ id: unEditText
+ AppControls2.StyleText {
+ id: textShow
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: contain.textCenterIn ? Text.AlignHCenter : Text.AlignLeft
+ elide: Text.ElideRight
+ text: contain.textEdited
+ paletteRole: isFullScreenFolder ? Palette.HighlightedText : Palette.Text
+ font.bold: !isFullScreenFolder
+ font.pixelSize: isFullScreenFolder ? 32 : 14
+
+ MouseArea {
+ id: textArea
+ anchors.fill: parent
+ onDoubleClicked: contain.editStatus = true;
+ }
+ }
+ }
+
+ Component {
+ id: editText
+ AppControls2.StyleBackground {
+ radius: 6
+ useStyleTransparent: false
+ alpha: textEdit.activeFocus ? 0.04 : 0
+ paletteRole: Palette.Text
+ border.width: 2
+ borderAlpha: textEdit.activeFocus ? 1 : 0
+ borderColor: Palette.Highlight
+
+ TextInput {
+ id: textEdit
+ clip: true
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ anchors.right: buttonMouseArea.left
+ anchors.rightMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: contain.textCenterIn ? Text.AlignHCenter : Text.AlignLeft
+ text: contain.textEdited
+ selectByMouse: true
+ maximumLength: 14
+ font.bold: !isFullScreenFolder
+ font.pixelSize: isFullScreenFolder ? 32 : 14
+
+ onEditingFinished: {
+ modelManager.getFolderModel().renameFolder(text);
+ contain.textEdited = text;
+ contain.editStatus = false;
+ }
+
+ property int textColor: isFullScreenFolder ? Palette.HighlightedText : Palette.Text
+ function updateTextInputColor() {
+ color = themePalette.paletteColor(textColor);
+ selectionColor = themePalette.paletteColor(Palette.Highlight);
+ }
+
+ Component.onCompleted: {
+ updateTextInputColor();
+ themePalette.styleColorChanged.connect(updateTextInputColor);
+ forceActiveFocus();
+ }
+
+ Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor);
+
+ }
+
+ MouseArea {
+ id: buttonMouseArea
+ hoverEnabled: true
+ width: 16; height: width
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ visible: textEdit.activeFocus
+
+ ThemeIcon {
+ anchors.centerIn: parent
+ width: 16; height: width
+ source: "image://appicon/edit-clear-symbolic"
+ highLight: isFullScreenFolder
+ autoHighLight: !isFullScreenFolder
+ }
+
+ onClicked: {
+ textEdit.text = textEdited;
+ contain.editStatus = false;
+ }
+ }
+ }
+ }
+
+ Loader {
+ id: editLoader
+ anchors.fill: parent
+ sourceComponent: contain.editStatus ? editText : unEditText
+ }
+}
diff --git a/qml/AppUI/FullScreenContent.qml b/qml/AppUI/FullScreenContent.qml
new file mode 100644
index 0000000..f61109f
--- /dev/null
+++ b/qml/AppUI/FullScreenContent.qml
@@ -0,0 +1,478 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Layouts 1.12
+import QtQml.Models 2.12
+import QtQuick.Controls 2.5
+import org.ukui.menu.core 1.0
+import AppControls2 1.0 as AppControls2
+
+RowLayout {
+ id: root
+ clip: true
+ signal openFolderSignal(string folderId, string folderName, int x, int y)
+ signal contentShowFinished()
+ property bool isContentShow: true
+ property int animationDuration: 300
+
+ state: isContentShow ? "contentShow" : "contentHidden"
+ states: [
+ State {
+ name: "contentHidden"
+ PropertyChanges { target: root; opacity: 0; scale: 0.95 }
+ },
+ State {
+ name: "contentShow"
+ PropertyChanges { target: root; opacity: 1; scale: 1 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to:"contentHidden"
+ SequentialAnimation {
+ PropertyAnimation { properties: "opacity, scale"; duration: animationDuration; easing.type: Easing.InOutCubic }
+ ScriptAction { script: root.visible = false }
+ }
+ },
+ Transition {
+ to: "contentShow"
+ SequentialAnimation {
+ PropertyAnimation { properties: "opacity, scale"; duration: animationDuration; easing.type: Easing.InOutCubic }
+ ScriptAction { script: root.contentShowFinished() }
+ }
+ }
+ ]
+
+ Item {
+ Layout.preferredWidth: 145
+ Layout.fillHeight: true
+ Layout.leftMargin: 15
+
+ ListView {
+ id: labelListView
+ signal labelClicked(string labelId)
+ property int maxLabelWidth: count < 20 ? width : 30
+
+ anchors.centerIn: parent
+ width: parent.width
+ height: contentHeight > parent.height ? parent.height : contentHeight
+ interactive: contentHeight > parent.height
+ spacing: 5
+
+ highlightMoveDuration: animationDuration
+ highlight: AppControls2.StyleBackground {
+ width: labelListView.maxLabelWidth; height: 30
+ radius: 4
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ border.width: 1
+ alpha: 0.18; borderAlpha: 0.7
+ borderColor: Palette.HighlightedText
+ }
+ onCountChanged: currentIndex = 0
+
+ model: DelegateModel {
+ groups: DelegateModelGroup {
+ name: "disabledItem"
+ includeByDefault: false
+ }
+
+ items.onChanged: {
+ for (let i = 0; i < items.count;) {
+ let item = items.get(i);
+ if (item.model.isDisable) {
+ items.setGroups(i, 1, "disabledItem");
+ continue;
+ }
+ ++i;
+ }
+ }
+
+ model: modelManager.getLabelModel()
+ delegate: MouseArea {
+ width: labelListView.maxLabelWidth
+ height: 30
+ hoverEnabled: true
+ AppControls2.StyleText {
+ anchors.fill: parent
+ paletteRole: Palette.HighlightedText
+ elide: Text.ElideRight
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: model.displayName
+ }
+ onClicked: {
+ labelListView.currentIndex = DelegateModel.itemsIndex;
+ labelListView.labelClicked(model.id)
+ }
+ }
+ }
+ }
+ }
+
+ Item {
+ id: contentViewBase
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ property int maxColumns: 8
+ property int columns: {
+ let c = Math.floor(width / cellWidth);
+ return c > maxColumns ? maxColumns : c;
+ }
+ property int cellWidth: 220
+ // property int cellWidth: Math.min(Math.floor(width / columns), 220)
+ property int cellHeight: cellWidth
+ property int headerHeight: 30
+
+ Component.onCompleted: {
+ changeView(modelManager.getLabelGroupModel().containLabel);
+ modelManager.getLabelGroupModel().containLabelChanged.connect(changeView);
+ }
+
+ Component.onDestruction: {
+ modelManager.getLabelGroupModel().containLabelChanged.disconnect(changeView);
+ contentViewLoader.sourceComponent = undefined;
+ }
+
+ function changeView(toLabelView) {
+ contentViewLoader.sourceComponent = toLabelView ? labelViewComponent : appViewComponent;
+ }
+
+ Loader {
+ id: contentViewLoader
+ height: parent.height
+ width: contentViewBase.cellWidth * contentViewBase.columns + 2
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ // view id: 1
+ Component {
+ id: appViewComponent
+ GridView {
+ ScrollBar.vertical: fullScreenScrollBar
+ cellWidth: contentViewBase.cellWidth
+ cellHeight: contentViewBase.cellHeight
+ boundsBehavior: Flickable.StopAtBounds
+ model: modelManager.getAppModel()
+
+ delegate: Loader {
+ width: GridView.view.cellWidth
+ height: width
+ property int index: model.index
+ property int type: model.type
+ property string id: model.id
+ property string name: model.name
+ property string icon: model.icon
+ sourceComponent: {
+ if (type === DataType.Normal) {
+ return appComponent;
+ }
+ if (type === DataType.Folder) {
+ return normalFolderComponent;
+ }
+ }
+ }
+
+ Component {
+ id: appComponent
+ Item {
+ MouseArea {
+ anchors.centerIn: parent
+ hoverEnabled: true
+ width: 170; height: width
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ AppControls2.StyleBackground {
+ anchors.fill: parent
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ radius: 16
+ alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
+ AppControls2.IconLabel {
+ anchors.fill: parent
+ iconWidth: 96; iconHeight: 96
+ appName: name; appIcon: icon
+ spacing: 8
+ textHighLight: true
+ }
+ }
+
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ parent.parent.GridView.view.model.openMenu(index);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ parent.parent.GridView.view.model.appClicked(index);
+ return;
+ }
+ }
+ }
+ }
+
+ }
+
+ Component {
+ id: normalFolderComponent
+ Item {
+ MouseArea {
+ anchors.centerIn: parent
+ hoverEnabled: true
+ width: 170; height: width
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ AppControls2.StyleBackground {
+ anchors.fill: parent
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ radius: 16
+ alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
+
+ ColumnLayout {
+ height: 128; width: parent.width
+ anchors.centerIn: parent
+ spacing: 8
+ AppControls2.FolderIcon {
+ id: folderIcon
+ Layout.margins: 5
+ rows: 4; columns: 4
+ spacing: 2; padding: 8
+ icons: icon
+ radius: 16; alpha: 0.25
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: 86; Layout.preferredHeight: 86
+ }
+ AppControls2.StyleText {
+ Layout.fillWidth: true; Layout.fillHeight: true
+ horizontalAlignment: Text.AlignHCenter
+ elide: Text.ElideRight
+ text: name
+ font.pixelSize: 14
+ paletteRole: Palette.HighlightedText
+ }
+ }
+ }
+
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ parent.parent.GridView.view.model.openMenu(index);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ var x = folderIcon.mapToGlobal(0,0).x;
+ var y = folderIcon.mapToGlobal(0,0).y
+ openFolderSignal(id, name, x, y);
+ root.isContentShow = false;
+ opacity = 0;
+ return;
+ }
+ }
+ function resetOpacity() {
+ opacity = 1;
+ }
+ Component.onCompleted: root.contentShowFinished.connect(resetOpacity)
+ Component.onDestruction: root.contentShowFinished.disconnect(resetOpacity)
+ }
+ }
+ }
+ }
+ }
+
+ // view id: 2
+ Component {
+ id: labelViewComponent
+ Flickable {
+ id: labelViewFlickable
+ ScrollBar.vertical: fullScreenScrollBar
+ contentHeight: labelColumn.height
+ flickableDirection: Flickable.VerticalFlick
+ boundsBehavior: Flickable.StopAtBounds
+ interactive: !contentYAnimation.running
+
+ Column {
+ id: labelColumn
+ width: parent.width
+ height: childrenRect.height
+ Repeater {
+ id: labelRepeater
+ model: modelManager.getLabelGroupModel()
+ delegate: GridView {
+ id: labelAppsGridView
+ width: parent.width
+ height: contentHeight
+
+ property int labelIndex: index
+
+ interactive: false
+ cacheBuffer: 50
+ cellWidth: contentViewBase.cellWidth
+ cellHeight: contentViewBase.cellHeight
+
+ header: Item {
+ width: labelAppsGridView.width
+ height: contentViewBase.headerHeight
+ Row {
+ anchors.fill: parent
+ anchors.leftMargin: 67
+ spacing: 15
+ AppControls2.StyleText {
+ id: labelName
+ anchors.verticalCenter: parent.verticalCenter
+ verticalAlignment: Text.AlignVCenter
+ width: contentWidth
+ text: name
+ paletteRole: Palette.HighlightedText
+ }
+
+ AppControls2.StyleBackground {
+ anchors.verticalCenter: parent.verticalCenter
+ useStyleTransparent: false
+ alpha: 0.14
+ paletteRole: Palette.Light
+ height: 1
+ width: parent.width - labelName.width - parent.spacing
+ }
+ }
+ }
+
+ model: extraData
+ delegate: Item {
+ width: GridView.view.cellWidth
+ height: GridView.view.cellHeight
+
+ MouseArea {
+ anchors.centerIn: parent
+ hoverEnabled: true
+ width: 170; height: width
+
+ AppControls2.StyleBackground {
+ anchors.fill: parent
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ radius: 16
+ alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
+ AppControls2.IconLabel {
+ anchors.fill: parent
+ iconWidth: 96; iconHeight: 96
+ appName: modelData.name
+ appIcon: modelData.icon
+ spacing: 8
+ textHighLight: true
+ }
+ }
+
+ onClicked: {
+ //console.log("clicked", Object.keys(model))
+ labelRepeater.model.openApp(labelAppsGridView.labelIndex, model.index);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ onContentYChanged: {
+ if (contentYAnimation.running) {
+ return
+ }
+ if ((contentY + height) === contentHeight) {
+ labelListView.currentIndex = labelRepeater.count - 1
+ return
+ }
+ labelListView.currentIndex = labelColumn.childAt(contentX,contentY).labelIndex
+ }
+
+ NumberAnimation {
+ id: contentYAnimation
+ target: labelViewFlickable
+ property: "contentY"
+ duration: animationDuration
+ onFinished: {
+ labelViewFlickable.returnToBounds();
+ }
+ }
+
+ function scrollerView(labelId) {
+ let labelindex = labelRepeater.model.getLabelIndex(labelId);
+ if (labelindex < 0 || labelindex >= labelRepeater.count) {
+ return;
+ }
+
+ let nextY = labelRepeater.itemAt(labelindex).y;
+ let sh = labelColumn.height - nextY;
+ if (sh < height) {
+ nextY -= (height - sh);
+ }
+
+ contentYAnimation.running = false;
+ if (nextY === contentY) {
+ return;
+ }
+
+ contentYAnimation.from = contentY;
+ contentYAnimation.to = nextY;
+ contentYAnimation.running = true;
+ }
+
+ Component.onCompleted: {
+ labelListView.labelClicked.connect(scrollerView);
+ }
+ Component.onDestruction: {
+ labelListView.labelClicked.disconnect(scrollerView);
+ }
+ }
+ }
+ }
+
+ Item {
+ Layout.preferredWidth: 160
+ Layout.fillHeight: true
+
+ ScrollBar {
+ id: fullScreenScrollBar
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: -24
+ height: 200
+ width: (hovered || pressed) ? 8 : 4
+ padding: 0
+ opacity: fullScreenScrollBar.size < 1.0 ? 1.0 : 0.0
+
+ Behavior on width {
+ NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
+ }
+
+ background: AppControls2.StyleBackground {
+ useStyleTransparent: false
+ paletteRole: Palette.Dark
+ alpha: 0.25
+ radius: width / 2
+ }
+
+ contentItem: AppControls2.StyleBackground {
+ radius: width / 2
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ alpha: fullScreenScrollBar.pressed ? 0.90 : fullScreenScrollBar.hovered ? 0.78 : 0.60
+ }
+ }
+ }
+}
diff --git a/qml/AppUI/FullScreenFolder.qml b/qml/AppUI/FullScreenFolder.qml
new file mode 100644
index 0000000..8329f93
--- /dev/null
+++ b/qml/AppUI/FullScreenFolder.qml
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import org.ukui.menu.core 1.0
+import AppControls2 1.0 as AppControls2
+
+Item {
+ property alias model: folderGridView.model
+ property string folderName: ""
+ property int margins: 20
+ property int folderX: 0
+ property int folderY: 0
+ property bool isFolderOpened: false
+ property int animationDuration: 300
+
+ AppControls2.StyleBackground {
+ id: folderIconBase
+ paletteRole: Palette.Text
+ useStyleTransparent: false
+ property int folderIconSize: 0
+ property int iconSpacing: 0
+ property int imageX: 0
+ property int imageY: 0
+ alpha: 0.25
+
+ state: isFolderOpened ? "folderOpened" : "folderHidden"
+ states: [
+ State {
+ name: "folderOpened"
+ PropertyChanges {
+ target: folderIconBase
+ width: 720; height: folderGridView.viewMaxHeight; radius: 36
+ x: (parent.width - width) / 2; y: (parent.height - height) / 2
+ folderIconSize: 96; iconSpacing: 8
+ imageX: 37; imageY: 17
+ }
+ PropertyChanges { target: folderGridView; anchors.margins: margins }
+ PropertyChanges { target: folderNameText; opacity: 1 }
+ },
+ State {
+ name: "folderHidden"
+ PropertyChanges {
+ target: folderIconBase
+ width: 86; height: width; radius: 16
+ x: parent.parent.mapFromGlobal(folderX, 0).x; y: parent.parent.mapFromGlobal(0, folderY).y
+ folderIconSize: 16; iconSpacing: 0
+ imageX: 0; imageY: 0
+ }
+ PropertyChanges { target: folderGridView; anchors.margins: 8 }
+ PropertyChanges { target: folderNameText; opacity: 0 }
+ }
+ ]
+ transitions: [
+ Transition {
+ to: "folderHidden"
+ SequentialAnimation {
+ ScriptAction { script: folderGridView.positionViewAtBeginning() }
+ ParallelAnimation {
+ PropertyAnimation {
+ duration: animationDuration; easing.type: Easing.InOutCubic
+ properties: "x, y, width, height, folderIconSize, iconSpacing, radius, imageX, imageY, anchors.margins"
+ }
+ PropertyAnimation {
+ duration: animationDuration; easing.type: Easing.OutQuint
+ properties: "opacity"
+ }
+ }
+ ScriptAction { script: parent.active = false }
+ }
+ },
+ Transition {
+ to: "folderOpened"
+ ParallelAnimation {
+ PropertyAnimation {
+ duration: animationDuration; easing.type: Easing.InOutCubic
+ properties: "x, y, width, height, folderIconSize, iconSpacing, radius, imageX, imageY, anchors.margins"
+ }
+ PropertyAnimation {
+ duration: animationDuration; easing.type: Easing.InQuint
+ properties: "opacity"
+ }
+ }
+ }
+ ]
+
+ GridView {
+ id: folderGridView
+ anchors.fill: parent
+ cellHeight: width / 4; cellWidth: cellHeight
+ boundsBehavior: Flickable.StopAtBounds
+ property int viewMaxHeight: Math.ceil(count / 4) * 170 > width ? width + margins*2 : (Math.ceil(count / 4) * 170 + margins*2)
+ model: modelManager.getFolderModel()
+ delegate: MouseArea {
+ hoverEnabled: true
+ width: GridView.view.cellHeight; height: width
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ AppControls2.StyleBackground {
+ anchors.fill: parent
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ radius: 16
+ alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
+
+ Image {
+ id: iconImage
+ source: icon
+ height: folderIconBase.folderIconSize; width: height
+ x: folderIconBase.imageX; y: folderIconBase.imageY
+ }
+
+ AppControls2.StyleText {
+ width: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ anchors.top: iconImage.bottom
+ anchors.topMargin: folderIconBase.iconSpacing
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: name
+ font.pixelSize: 14
+ elide: Text.ElideRight
+ paletteRole: Palette.HighlightedText
+ }
+ }
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ menuManager.showMenu(id);
+ return;
+ }
+ if (mouse.button === Qt.LeftButton) {
+ appManager.launchApp(id);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ EditText {
+ id: folderNameText
+ anchors.bottom: folderGridView.parent.top
+ anchors.bottomMargin: 30
+ anchors.horizontalCenter: folderGridView.parent.horizontalCenter
+ height: 47; width: folderGridView.width
+ textEdited: folderName
+ textCenterIn: true
+ isFullScreenFolder: true
+ }
+}
diff --git a/qml/AppUI/FullScreenFooter.qml b/qml/AppUI/FullScreenFooter.qml
new file mode 100644
index 0000000..54de039
--- /dev/null
+++ b/qml/AppUI/FullScreenFooter.qml
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+import org.ukui.menu.utils 1.0
+
+Row {
+ Layout.fillWidth: true
+ Layout.preferredHeight: 48
+ layoutDirection: Qt.RightToLeft
+
+ AppControls2.StyleBackground {
+ width: 48; height: width
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ alpha: powerButtonArea.containsPress ? 0.25 : powerButtonArea.containsMouse ? 0.12 : 0
+ radius: height / 2
+
+ PowerButton {
+ id: powerButtonBase
+ }
+
+ Image {
+ anchors.centerIn: parent
+ width: Math.floor(parent.width / 2)
+ height: width
+ source: powerButtonBase.icon
+ }
+
+ MouseArea {
+ id: powerButtonArea
+ anchors.fill: parent
+ hoverEnabled: true
+ ToolTip.visible: containsMouse
+ ToolTip.text: powerButtonBase.toolTip
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ property int spacingFromMenu: 8
+
+ onClicked: {
+ var buttonPosition = powerButtonArea.mapToGlobal(width, height);
+ powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x - width - spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
+ }
+ }
+ }
+}
+
diff --git a/qml/AppUI/FullScreenHeader.qml b/qml/AppUI/FullScreenHeader.qml
new file mode 100644
index 0000000..333a4f0
--- /dev/null
+++ b/qml/AppUI/FullScreenHeader.qml
@@ -0,0 +1,64 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.12
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+import org.ukui.menu.utils 1.0
+
+Item {
+ clip: true
+ property alias searchOpacity: searchInputBar.opacity
+ SearchInputBar {
+ id: searchInputBar
+ width: 372; height: 36
+ anchors.centerIn: parent
+ radius: height / 2
+ visible: opacity
+
+ onTextChanged: {
+ if (text === "") {
+ pluginSelectMenu.model.reactivateProvider();
+ } else {
+ appPageHeaderUtils.model(PluginGroup.Button).reactivateProvider();
+ appPageHeaderUtils.startSearch(text);
+ }
+ }
+ Behavior on opacity {
+ NumberAnimation { duration: 300; easing.type: Easing.InOutCubic }
+ }
+ }
+
+ PluginSelectMenu {
+ id: pluginSelectMenu
+ anchors.right: parent.right
+ anchors.rightMargin: 72 // 48+24
+ anchors.verticalCenter: parent.verticalCenter
+ height: 48; width: 72 // 48+16+8
+ spacing: 8
+ }
+
+ AppControls2.StyleBackground {
+ width: 48; height: width
+ radius: 4
+ useStyleTransparent: false
+ paletteRole: Palette.Light
+ alpha: buttonMouseArea.containsPress ? 0.30 : buttonMouseArea.containsMouse ? 0.20 : 0.00
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+
+ ThemeIcon {
+ anchors.centerIn: parent
+ width: parent.width / 2; height: width
+ source: "image://appicon/view-restore-symbolic"
+ highLight: true
+ autoHighLight: false
+ }
+ MouseArea {
+ id: buttonMouseArea
+ hoverEnabled: true
+ anchors.fill: parent
+ onClicked: mainWindow.exitFullScreen()
+ }
+ }
+}
+
diff --git a/qml/AppUI/FullScreenUI.qml b/qml/AppUI/FullScreenUI.qml
new file mode 100644
index 0000000..3c7b95f
--- /dev/null
+++ b/qml/AppUI/FullScreenUI.qml
@@ -0,0 +1,70 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+AppControls2.StyleBackground {
+ paletteRole: Palette.Dark
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (fullScreenContent.visible) {
+ //执行全屏退出操作
+ forceActiveFocus();
+ mainWindow.hide();
+ } else {
+ folderLoader.item.isFolderOpened = false;
+ fullScreenContent.visible = true;
+ fullScreenContent.isContentShow = true;
+ }
+ }
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 35
+ anchors.rightMargin: 35
+
+ FullScreenHeader {
+ id: fullScreenHeader
+ Layout.preferredHeight: 130
+ Layout.fillWidth: true
+ Layout.maximumHeight: 130
+ searchOpacity: fullScreenContent.isContentShow ? 1 : 0
+ }
+
+ Item {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ FullScreenContent {
+ id: fullScreenContent
+ anchors.fill: parent
+ }
+
+ Loader {
+ id: folderLoader
+ active: false
+ anchors.fill: parent
+ sourceComponent: FullScreenFolder {}
+
+ function openFolder(id, name, x, y) {
+ active = true;
+ item.model.setFolderId(id);
+ item.folderName = name;
+ item.folderX = x;
+ item.folderY = y;
+ item.isFolderOpened = true;
+ }
+
+ Component.onCompleted: fullScreenContent.openFolderSignal.connect(openFolder)
+ Component.onDestruction: fullScreenContent.openFolderSignal.disconnect(openFolder)
+ }
+ }
+
+ FullScreenFooter {
+ Layout.preferredHeight: 90
+ Layout.fillWidth: true
+ }
+ }
+}
diff --git a/qml/AppUI/NormalUI.qml b/qml/AppUI/NormalUI.qml
new file mode 100644
index 0000000..d7edef0
--- /dev/null
+++ b/qml/AppUI/NormalUI.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.12
+import QtQuick.Controls 2.0 as QQC2
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+Item {
+ Row {
+ anchors.fill: parent;
+
+ AppPage {
+ width: 300
+ height: parent.height;
+ }
+
+ Sidebar {
+ width: parent.width - 300;
+ height: parent.height;
+ }
+ }
+}
diff --git a/qml/AppUI/PluginSelectMenu.qml b/qml/AppUI/PluginSelectMenu.qml
new file mode 100644
index 0000000..2377be2
--- /dev/null
+++ b/qml/AppUI/PluginSelectMenu.qml
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.12
+
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+import org.ukui.menu.utils 1.0
+
+RowLayout {
+ id: pluginSelectMenuRoot
+ property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
+ spacing: 2
+
+ AppControls2.RoundButton {
+ id: pluginSelectButton
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.maximumWidth: height
+
+ buttonIcon: "image://appicon/ukui-selected"
+ onClicked: pluginSelectMenuRoot.model.autoSwitchProvider();
+ }
+
+ MouseArea {
+ Layout.alignment: Qt.AlignVCenter
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.maximumWidth: 16
+ Layout.maximumHeight: 16
+
+ onClicked: {
+ if(sortMenuSelector.state === "sortMenuClose") {
+ sortMenuSelector.state = "sortMenuOpen";
+ }
+ pluginSelectMenuRoot.model.openMenu(pluginSelectButton.height - y - mouseY + 8);
+ }
+
+ ThemeIcon {
+ id: sortMenuSelector
+ anchors.fill: parent
+ source: "image://appicon/ukui-up-symbolic"
+ opacity: 0.5
+ highLight: mainWindow.isFullScreen
+ state: "sortMenuClose"
+
+ states: [
+ State {
+ name: "sortMenuOpen"
+ PropertyChanges { target: sortMenuSelector; rotation: 0 }
+ },
+ State {
+ name: "sortMenuClose"
+ PropertyChanges { target: sortMenuSelector; rotation: 180 }
+ }
+ ]
+ transitions: [
+ Transition {
+ to: "sortMenuOpen"
+ RotationAnimation { duration: 100; direction: RotationAnimation.Counterclockwise}
+ },
+ Transition {
+ to: "sortMenuClose"
+ RotationAnimation { duration: 100; direction: RotationAnimation.Clockwise }
+ }
+ ]
+
+ Component.onCompleted: {
+ updateProviderIcon();
+ pluginSelectMenuRoot.model.currentIndexChanged.connect(updateProviderIcon);
+ pluginSelectMenuRoot.model.menuClosed.connect(changeMenuStatus);
+ }
+
+ Component.onDestruction: {
+ pluginSelectMenuRoot.model.currentIndexChanged.disconnect(updateProviderIcon);
+ pluginSelectMenuRoot.model.menuClosed.disconnect(changeMenuStatus);
+ }
+
+ function updateProviderIcon() {
+ pluginSelectButton.buttonIcon = pluginSelectMenuRoot.model.currentProviderIcon();
+ }
+
+ function changeMenuStatus() {
+ sortMenuSelector.state = "sortMenuClose";
+ }
+ }
+ }
+}
diff --git a/qml/AppUI/SearchInputBar.qml b/qml/AppUI/SearchInputBar.qml
new file mode 100644
index 0000000..59d2381
--- /dev/null
+++ b/qml/AppUI/SearchInputBar.qml
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Controls 2.5
+import QtQuick.Layouts 1.12
+import org.ukui.menu.core 1.0
+import AppControls2 1.0 as AppControls2
+
+AppControls2.StyleBackground {
+ readonly property string text: textInput.text;
+ function clear() {
+ textInput.clear();
+ }
+ alpha: 0.04
+ useStyleTransparent: false
+ paletteRole: Palette.Text
+ border.width: 1
+ borderAlpha: textInput.activeFocus ? 1 : 0.1
+ borderColor: textInput.activeFocus ? Palette.Highlight : Palette.Base
+
+ Item {
+ id: defaultSearch
+ width: searchIcon.width + defaultText.contentWidth; height: parent.height
+ anchors.horizontalCenter: mainWindow.isFullScreen ? parent.horizontalCenter : undefined
+ anchors.verticalCenter: parent.verticalCenter
+
+ Item {
+ id: searchIcon
+ width: 32; height: 32
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: (parent.height - height) / 2
+
+ ThemeIcon {
+ anchors.centerIn: parent
+ width: parent.height / 2; height: width
+ source: "image://appicon/search-symbolic"
+ highLight: mainWindow.isFullScreen
+ autoHighLight: !mainWindow.isFullScreen
+ }
+ }
+
+
+ AppControls2.StyleText {
+ id: defaultText
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: searchIcon.right
+ text: qsTr("Search App")
+ visible: textInput.contentWidth === 0
+ font.pixelSize: 14
+ paletteRole: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
+ verticalAlignment: TextInput.AlignVCenter
+ alpha: 0.25
+ }
+
+ states: State {
+ when: textInput.activeFocus || !mainWindow.isFullScreen
+ AnchorChanges {
+ target: defaultSearch
+ anchors.left: parent.left
+ anchors.horizontalCenter: undefined
+ }
+ }
+
+ transitions: Transition {
+ AnchorAnimation { duration: 300; easing.type: Easing.InOutCubic }
+ }
+ }
+
+ TextInput {
+ id: textInput
+ clip: true
+ anchors.right: parent.right
+ width: parent.width - searchIcon.width
+ height: parent.height
+ selectByMouse: true
+ verticalAlignment: TextInput.AlignVCenter
+ font.pixelSize: 14
+ focus: parent.visible || mainWindow.isFullScreen
+ onActiveFocusChanged: clear()
+
+ property int textColor: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
+
+ function updateTextInputColor() {
+ color = themePalette.paletteColor(textColor)
+ selectionColor = themePalette.paletteColor(Palette.Highlight)
+ }
+
+ Component.onCompleted: {
+ updateTextInputColor();
+ themePalette.styleColorChanged.connect(updateTextInputColor);
+ }
+
+ onTextColorChanged: updateTextInputColor()
+ Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor)
+ }
+
+ AppControls2.RoundButton {
+ id: clearButton
+ width: 18; height: width
+ anchors.right: parent.right
+ anchors.rightMargin: (parent.height - height) / 2
+ anchors.verticalCenter: parent.verticalCenter
+ visible: mainWindow.isFullScreen && textInput.activeFocus
+ buttonIcon: "image://appicon/edit-clear-symbolic"
+ highlight: true
+ autoHighLight: false
+
+ onClicked: {
+ textInput.clear();
+ textInput.focus = false;
+ }
+ }
+}
diff --git a/qml/AppUI/SelectionPage.qml b/qml/AppUI/SelectionPage.qml
new file mode 100644
index 0000000..eaf00b0
--- /dev/null
+++ b/qml/AppUI/SelectionPage.qml
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQuick.Layouts 1.2
+import org.ukui.menu.core 1.0
+import AppControls2 1.0 as AppControls2
+
+Item {
+ id: root
+ signal viewHideFinished()
+ signal labelSelected(string labelId)
+
+ function viewShowStart() {
+ viewShow.start();
+ }
+
+ ParallelAnimation {
+ id: viewShow
+ NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.5; to: 1.0; duration: 300}
+ NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 0; to: 1.0; duration: 300}
+ }
+
+ ParallelAnimation {
+ id: viewHide
+ NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.0; to: 1.5 ;duration: 300}
+ NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 1.0; to: 0 ;duration: 300}
+ onFinished: {
+ viewHideFinished();
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: viewHide.start();
+ }
+
+ GridView {
+ id: selectionArea
+ anchors.centerIn: parent
+ interactive: false
+ property int itemWidth: 0
+ property int itemHeight: 40
+ cellWidth: itemWidth; cellHeight: itemHeight
+
+ state: count < 20 ? "functionArea" : "AlphabetArea"
+ states: [
+ State {
+ name: "functionArea"
+ PropertyChanges { target: selectionArea; itemWidth: 80; width: itemWidth * 2; height: itemHeight * 7 }
+ },
+ State {
+ name: "AlphabetArea"
+ PropertyChanges { target: selectionArea; itemWidth: 40; width: itemWidth * 5; height: itemHeight * 6 }
+ }
+ ]
+
+ model: modelManager.getLabelModel()
+ onCountChanged: {
+ if (count === 0) {
+ viewHide.start();
+ }
+ }
+
+ delegate: AppControls2.StyleBackground {
+ height: selectionArea.itemHeight; width: selectionArea.itemWidth
+ alpha: (itemMouseArea.containsPress && !model.isDisable) ? 0.82 : (itemMouseArea.containsMouse && !model.isDisable) ? 0.55 : 0.00
+ useStyleTransparent: false
+ radius: 8
+
+ AppControls2.StyleText {
+ anchors.fill: parent
+ text: model.displayName
+ alpha: model.isDisable ? 0.2 : 0.9
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideRight
+ }
+
+ MouseArea {
+ id: itemMouseArea
+ anchors.fill: parent
+ hoverEnabled: !model.isDisable
+ onClicked: {
+ if (!model.isDisable) {
+ viewHide.start();
+ root.labelSelected(model.id);
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml
new file mode 100644
index 0000000..61c4ae5
--- /dev/null
+++ b/qml/AppUI/Sidebar.qml
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQml 2.12
+import QtQuick 2.0
+import QtQuick.Layouts 1.12
+import QtQuick.Controls 2.5
+
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+import org.ukui.menu.utils 1.0
+
+Item {
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.topMargin: 12
+ spacing: 0
+
+ Row {
+ Layout.fillWidth: true
+ Layout.preferredHeight: 40
+ Layout.rightMargin: 12
+
+ ListView {
+ id: extensionListView
+ width: parent.width - 34
+ height: parent.height
+ clip: true
+ orientation: ListView.Horizontal
+ model: extensionManager.extensionModel()
+ delegate: headerDelegate
+
+ function send(data) {
+ if (currentItem !== null) {
+ model.send(currentIndex, data);
+ }
+ }
+
+ onCurrentIndexChanged: {
+ if (currentItem !== null) {
+ currentItem.select();
+ }
+ }
+ }
+
+ AppControls2.StyleBackground {
+ width: 34; height: width
+ radius: 4
+ useStyleTransparent: false
+ alpha: buttonMouseArea.containsPress ? 0.65 : buttonMouseArea.containsMouse ? 0.40 : 0.00
+ ThemeIcon {
+ anchors.centerIn: parent
+ width: parent.width / 2; height: width
+ source: "image://appicon/view-fullscreen-symbolic"
+ MouseArea {
+ id: buttonMouseArea
+ hoverEnabled: true
+ anchors.fill: parent
+ onClicked: mainWindow.isFullScreen = true
+ }
+ }
+ }
+ }
+
+ Item {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ Loader {
+ id: extensionLoader
+ anchors.fill: parent
+ clip: true
+ focus: true
+ onLoaded: {
+ item.send.connect(extensionListView.send);
+ }
+ }
+ }
+
+ Row {
+ Layout.fillWidth: true
+ Layout.preferredHeight: 40
+ Layout.rightMargin: 12
+ layoutDirection: Qt.RightToLeft
+
+ AppControls2.StyleBackground {
+ width: 32
+ height: 32
+ paletteRole: Palette.Base
+ useStyleTransparent: false
+ alpha: powerButtonArea.pressed ? 0.85 : powerButtonArea.hovered ? 0.65 : 0
+ radius: height / 2
+
+ PowerButton {
+ id: powerButtonBase
+ }
+
+ Image {
+ anchors.centerIn: parent
+ width: Math.floor(parent.width / 2)
+ height: width
+ source: powerButtonBase.icon
+ }
+
+ MouseArea {
+ id: powerButtonArea
+ property bool hovered: false
+ anchors.fill: parent
+ hoverEnabled: true
+ ToolTip.visible: hovered
+ ToolTip.text: powerButtonBase.toolTip
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ property int spacingFromMenu: 16
+
+ onClicked: {
+ var buttonPosition = powerButtonArea.mapToGlobal(width, height);
+ powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
+ }
+ onEntered: {
+ hovered = true
+ }
+ onExited: {
+ hovered = false
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: headerDelegate
+
+ Item {
+ property var extensionData: model.data
+ width: 100
+ height: ListView.view ? ListView.view.height : 0
+
+ onExtensionDataChanged: {
+ if (extensionLoader.source === model.url) {
+ extensionLoader.item.extensionData = extensionData;
+ }
+ }
+
+ function select() {
+ if (extensionLoader.source !== model.url) {
+ extensionLoader.setSource(model.url, {extensionData: extensionData});
+ }
+ }
+
+ Text {
+ anchors.fill: parent
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ font.bold: true
+ wrapMode: Text.ElideRight
+
+ color: parent.ListView.isCurrentItem ? "blue" : "black"
+ text: model.name
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ parent.ListView.view.currentIndex = model.index;
+ }
+ }
+ }
+ }
+
+ Component.onCompleted: {
+ if (extensionListView.count > 0) {
+ extensionListView.currentIndex = 0;
+ }
+ }
+}
diff --git a/qml/AppUI/qmldir b/qml/AppUI/qmldir
new file mode 100644
index 0000000..fc4fa7d
--- /dev/null
+++ b/qml/AppUI/qmldir
@@ -0,0 +1,13 @@
+module AppUI
+AppPage 1.0 AppPage.qml
+AppList 1.0 AppList.qml
+Sidebar 1.0 Sidebar.qml
+NormalUI 1.0 NormalUI.qml
+FullScreenUI 1.0 FullScreenUI.qml
+AppPageHeader 1.0 AppPageHeader.qml
+AppListView 1.0 AppListView.qml
+SearchInputBar 1.0 SearchInputBar.qml
+PluginSelectMenu 1.0 PluginSelectMenu.qml
+FullScreenHeader 1.0 FullScreenHeader.qml
+FullScreenContent 1.0 FullScreenContent.qml
+FullScreenFooter 1.0 FullScreenFooter.qml
diff --git a/src/BackProcess/DBus/dbus.cpp b/qml/MenuMainWindow.qml
similarity index 52%
rename from src/BackProcess/DBus/dbus.cpp
rename to qml/MenuMainWindow.qml
index 2dc3aaa..c9b2ec6 100644
--- a/src/BackProcess/DBus/dbus.cpp
+++ b/qml/MenuMainWindow.qml
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
*
* 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
- * (at your option) any later version.
+ * (at your option) 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
@@ -13,34 +13,29 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-#include "dbus.h"
-#include
-#include
-#include "utility.h"
+import QtQuick 2.12
+import org.ukui.menu.core 1.0
-DBus::DBus(QObject *parent) : QObject(parent)
-{
-}
+import AppUI 1.0 as AppUI
-void DBus::ReloadSecurityConfig()
-{
- Q_EMIT sendReloadSignal();
-}
+MenuMainWindow {
+ id: mainWindow
+ visible: true
-QString DBus::GetSecurityConfigPath()
-{
- QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json";
- return path;
-}
+ Component.onCompleted: {
+ console.log("MenuMainWindow Completed.");
+ }
-void DBus::WinKeyResponse()
-{
- Q_EMIT winKeyResponseSignal();
-}
+ onIsFullScreenChanged: {
+ console.log("full screen", isFullScreen)
+ //loader.source = isFullScreen ? "qrc:/qml/FullScreenUI.qml" : "qrc:/qml/NormalUI.qml";
+ }
-bool DBus::GetMenuStatus()
-{
- return g_menuStatus;
+ AppUI.NormalUI {
+ parent: mainWindow.contentItem
+ anchors.fill: parent
+ }
}
diff --git a/qml/extensions/FavoriteExtension.qml b/qml/extensions/FavoriteExtension.qml
new file mode 100644
index 0000000..cf6564f
--- /dev/null
+++ b/qml/extensions/FavoriteExtension.qml
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import QtQml.Models 2.1
+import QtQuick.Controls 2.5
+import org.ukui.menu.core 1.0
+import org.ukui.menu.extension 1.0
+import AppControls2 1.0 as AppControls2
+
+UkuiMenuExtension {
+ Component.onCompleted: {
+ visualModel.model = extensionData.favoriteAppsModel
+ }
+
+ MouseArea {
+ id: viewMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ AppControls2.StyleBackground {
+ anchors.top: parent.top
+ width: parent.width; height: 1
+ useStyleTransparent: false
+ alpha: 0.15
+ paletteRole: Palette.Text
+ visible: favoriteView.contentY > 0
+ z: 1
+ }
+
+ GridView {
+ id: favoriteView
+ anchors.fill: parent
+ anchors.leftMargin: 16
+ anchors.topMargin: 12
+ anchors.bottomMargin: 6
+ clip: true
+ cellWidth: itemHeight + spacing; cellHeight: cellWidth
+ property int exchangedStartIndex: 0
+ property int spacing: 4
+ property int itemHeight: 104
+
+ ScrollBar.vertical: AppControls2.ScrollBar {
+ id: scrollBar
+ visible: viewMouseArea.containsMouse
+ width: 14; height: favoriteView.height
+ }
+
+ displaced: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad; duration: 200 }
+ }
+
+ model: DelegateModel {
+ id: visualModel
+ delegate: DropArea {
+ id: delegateRoot
+ property int visualIndex: DelegateModel.itemsIndex
+ width: favoriteView.cellWidth; height: favoriteView.cellHeight
+ onEntered: visualModel.items.move(drag.source.visualIndex, icon.visualIndex)
+
+ Binding { target: icon; property: "visualIndex"; value: visualIndex }
+
+ AppControls2.StyleBackground {
+ id: icon
+ height: favoriteView.itemHeight; width: height
+ property bool hold: false
+ property int visualIndex: 0
+ x: 0; y: 0
+
+ radius: 8
+ useStyleTransparent: false
+ scale: icon.hold ? 1.1 :1.0
+ alpha: control.containsPress ? 0.75 : control.containsMouse ? 0.6 : 0.40
+
+ Behavior on scale {
+ NumberAnimation { duration: 300; easing.type: Easing.InOutCubic }
+ }
+
+ AppControls2.IconLabel {
+ height: icon.height
+ width: icon.width - 14
+ anchors.centerIn: parent
+ appName: model.name
+ appIcon: model.icon
+ display: Display.TextUnderIcon
+ scale: (control.containsPress && !icon.hold) ? 1.1 : 1.0
+
+ Behavior on scale {
+ NumberAnimation { duration: 300; easing.type: Easing.InOutCubic }
+ }
+ }
+
+ MouseArea {
+ id: control
+ anchors.fill: parent
+ hoverEnabled: true
+ pressAndHoldInterval: 300
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onPressed: {
+ if (mouse.button === Qt.RightButton) {
+ console.log("RightButtononPressed:",mouse.x,mouse.y);
+ }
+ }
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ visualModel.model.openMenu(index)
+ } else if (mouse.button === Qt.LeftButton) {
+ var data = {"id": model.id};
+ send(data);
+ }
+ }
+ onPressAndHold: {
+ if (mouse.button === Qt.LeftButton) {
+ drag.target = icon;
+ icon.hold = true;
+ favoriteView.exchangedStartIndex = icon.visualIndex;
+ }
+ }
+ onReleased: {
+ icon.hold = false;
+ drag.target = null;
+ }
+ }
+
+ onHoldChanged: {
+ if (hold) {
+ favoriteView.interactive = false;
+ } else {
+ favoriteView.interactive = true;
+ visualModel.model.exchangedAppsOrder(favoriteView.exchangedStartIndex, icon.visualIndex);
+ }
+ }
+
+ Drag.active: control.drag.active
+ Drag.source: icon
+ Drag.hotSpot.x: icon.width / 2
+ Drag.hotSpot.y: icon.height / 2
+
+ Drag.onActiveChanged: {
+ if (Drag.active) {
+ icon.parent = favoriteView;
+ } else {
+ iconResetAnimation.start();
+ }
+ }
+ ParallelAnimation {
+ id: iconResetAnimation
+ NumberAnimation { target: icon; property: "x"; to: delegateRoot.x; easing.type: Easing.OutQuad; duration: 300 }
+ NumberAnimation { target: icon; property: "y"; to: delegateRoot.y; easing.type: Easing.OutQuad; duration: 300 }
+
+ onFinished: {
+ icon.parent = delegateRoot;
+ icon.x = 0; icon.y = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/qml/main.qml b/qml/main.qml
new file mode 100644
index 0000000..61453ea
--- /dev/null
+++ b/qml/main.qml
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2023, KylinSoft Co., Ltd.
+ *
+ * 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
+ * (at your option) 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 .
+ *
+ */
+
+import QtQuick 2.12
+import AppUI 1.0 as AppUI
+import AppControls2 1.0 as AppControls2
+import org.ukui.menu.core 1.0
+
+Item {
+ id: root
+ clip: true
+
+ property int animationDuration: menuSetting.get("animationDuration")
+ property double transparency: mainWindow.transparency
+ property bool onComlpeted: false
+
+ Component.onCompleted: {
+ mainWindow.fullScreenChanged.connect(enterFullScreen);
+ mainWindow.beforeFullScreenExited.connect(exitFullScreen);
+ menuSetting.changed.connect(updateAnimationDuration);
+ onComlpeted = true;
+ }
+
+ function enterFullScreen() {
+ if (mainWindow.isFullScreen) {
+ normalHide.start();
+ fullShow.start();
+ enterFullScreenAnimation.start();
+ if (root.transparency <= 0.6) {
+ maskHide.start();
+ }
+ }
+ }
+
+ function exitFullScreen() {
+ normalShow.start();
+ fullHide.start();
+ exitFullScreenAnimation.start();
+ if (root.transparency <= 0.6) {
+ maskShow.start();
+ }
+ }
+
+ function updateAnimationDuration(key) {
+ if (key === "animationDuration") {
+ root.animationDuration = menuSetting.get("animationDuration");
+ }
+ }
+
+ onTransparencyChanged: {
+ if (transparency > 0.6) {
+ backgroundMask.opacity = 1;
+ }
+ }
+
+ QtObject {
+ id: normalScreenGeometry
+ property var normalGeometry: mainWindow.normalScreenSize()
+ property int normalScreenX: normalScreenMargin
+ property int normalScreenY: root.height - normalGeometry.height - normalScreenMargin
+ property int normalScreenMargin: 8
+ property bool isFullScreen: mainWindow.isFullScreen
+
+ onIsFullScreenChanged: {
+ switch (mainWindow.panelPos) {
+ case 0 :
+ normalScreenX = normalScreenMargin;
+ normalScreenY = root.height - normalGeometry.height - normalScreenMargin;
+ break;
+ case 1 :
+ normalScreenX = normalScreenMargin;
+ normalScreenY = normalScreenMargin;
+ break;
+ case 2 :
+ normalScreenX = normalScreenMargin;
+ normalScreenY = normalScreenMargin;
+ break;
+ case 3 :
+ normalScreenX = root.width - normalGeometry.width - normalScreenMargin;
+ normalScreenY = normalScreenMargin;
+ break;
+ default :
+ normalScreenX = normalScreenMargin;
+ normalScreenY = root.height - normalGeometry.height - normalScreenMargin;
+ break;
+ }
+ }
+ }
+
+ AppControls2.StyleBackground {
+ id: backgroundMask
+ // 初始状态默认为normalScreen
+ x: 0; y: 0
+ height: normalScreenGeometry.normalGeometry.height
+ width: normalScreenGeometry.normalGeometry.width
+ radius: 12
+
+ onHeightChanged: {
+ if (root.transparency <= 0.6 && root.onComlpeted) {
+ switch (mainWindow.panelPos) {
+ case 0 :
+ mainWindow.changeWindowBlurRegion(0, root.height - height, width, height);
+ break;
+ case 1 :
+ mainWindow.changeWindowBlurRegion(0, 0, width, height);
+ break;
+ case 2:
+ mainWindow.changeWindowBlurRegion(0, 0, width, height);
+ break;
+ case 3 :
+ mainWindow.changeWindowBlurRegion(root.width - width, 0, width, height);
+ break;
+ default :
+ mainWindow.changeWindowBlurRegion(0, root.height - height, width, height);
+ break;
+ }
+ }
+ }
+
+ NumberAnimation {
+ id: maskHide
+ target: backgroundMask; property: "opacity"
+ from: 1.0; to: 0;
+ duration: root.animationDuration / 4; easing.type: Easing.InOutQuad
+ }
+
+ NumberAnimation {
+ id: maskShow
+ target: backgroundMask; property: "opacity"
+ from: 0; to: 1.0;
+ duration: root.animationDuration * 2; easing.type: Easing.InOutExpo
+ }
+
+ ParallelAnimation {
+ id: enterFullScreenAnimation
+ PropertyAnimation {
+ target: backgroundMask; property: "x"
+ from: normalScreenGeometry.normalScreenX; to: 0
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "y"
+ from: normalScreenGeometry.normalScreenY; to: 0
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "height"
+ from: normalScreenGeometry.normalGeometry.height; to: root.height
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "width"
+ from: normalScreenGeometry.normalGeometry.width; to: root.width
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+
+ onStarted: {
+ fullScreenLoader.active = true;
+ normalScreenLoader.x = normalScreenGeometry.normalScreenX;
+ normalScreenLoader.y = normalScreenGeometry.normalScreenY;
+ }
+ onFinished: {
+ normalScreenLoader.active = false;
+ mainWindow.enableWindowBlur(true);
+ }
+ }
+
+ ParallelAnimation {
+ id: exitFullScreenAnimation
+ PropertyAnimation {
+ target: backgroundMask; property: "x"
+ from: 0; to: normalScreenGeometry.normalScreenX
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "y"
+ from: 0; to: normalScreenGeometry.normalScreenY
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "height"
+ from: root.height; to: normalScreenGeometry.normalGeometry.height
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+ PropertyAnimation {
+ target: backgroundMask; property: "width"
+ from: root.width; to: normalScreenGeometry.normalGeometry.width
+ duration: root.animationDuration; easing.type: Easing.InOutQuad
+ }
+
+ onStarted: {
+ normalScreenLoader.active = true;
+ mainWindow.enableWindowBlur(false);
+
+ }
+ onFinished: {
+ normalScreenLoader.x = 0;
+ normalScreenLoader.y = 0;
+ backgroundMask.x = 0;
+ backgroundMask.y = 0;
+ fullScreenLoader.active = false;
+ mainWindow.isFullScreen = false;
+ }
+ }
+ }
+
+ Loader {
+ id: normalScreenLoader
+ height: normalScreenGeometry.normalGeometry.height; width: normalScreenGeometry.normalGeometry.width
+ sourceComponent: normalComponent
+ NumberAnimation { id: normalShow; target: normalScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
+ NumberAnimation { id: normalHide; target: normalScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
+
+ Component.onCompleted: {
+ active = mainWindow.isFullScreen ? false : true;
+ opacity = mainWindow.isFullScreen ? 0 : 1;
+ }
+ }
+
+ Loader {
+ id: fullScreenLoader
+ anchors.fill: parent
+ sourceComponent: fullSceenComponent
+ NumberAnimation { id: fullShow; target: fullScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
+ NumberAnimation { id: fullHide; target: fullScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
+
+ Component.onCompleted: {
+ active = mainWindow.isFullScreen ? true : false;
+ opacity = mainWindow.isFullScreen ? 1 : 0;
+ }
+ }
+
+ Component {
+ id: fullSceenComponent
+ AppUI.FullScreenUI {}
+ }
+
+ Component {
+ id: normalComponent
+ AppUI.NormalUI {}
+ }
+}
diff --git a/qml/org/ukui/menu/extension/UkuiMenuExtension.qml b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml
new file mode 100644
index 0000000..ef817fe
--- /dev/null
+++ b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Item {
+ property var extensionData;
+ signal send(var data);
+}
diff --git a/qml/org/ukui/menu/extension/qmldir b/qml/org/ukui/menu/extension/qmldir
new file mode 100644
index 0000000..e66de49
--- /dev/null
+++ b/qml/org/ukui/menu/extension/qmldir
@@ -0,0 +1,2 @@
+module org.ukui.menu.extension
+UkuiMenuExtension 1.0 UkuiMenuExtension.qml
diff --git a/qml/qml.qrc b/qml/qml.qrc
new file mode 100644
index 0000000..5210279
--- /dev/null
+++ b/qml/qml.qrc
@@ -0,0 +1,35 @@
+
+
+ main.qml
+ MenuMainWindow.qml
+ AppUI/qmldir
+ AppUI/NormalUI.qml
+ AppUI/FullScreenUI.qml
+ AppUI/AppPage.qml
+ AppUI/Sidebar.qml
+ AppUI/AppList.qml
+ AppUI/FullScreenHeader.qml
+ AppUI/FullScreenContent.qml
+ AppUI/FullScreenFooter.qml
+ AppUI/AppPageHeader.qml
+ AppUI/SearchInputBar.qml
+ AppUI/AppListView.qml
+ AppControls2/qmldir
+ AppControls2/App.qml
+ AppControls2/ScrollBar.qml
+ AppControls2/StyleBackground.qml
+ AppControls2/StyleText.qml
+ AppControls2/IconLabel.qml
+ AppControls2/AppItem.qml
+ AppControls2/LabelItem.qml
+ AppControls2/FolderItem.qml
+ extensions/FavoriteExtension.qml
+ AppControls2/RoundButton.qml
+ AppControls2/FolderIcon.qml
+ AppUI/SelectionPage.qml
+ AppUI/AppPageContent.qml
+ AppUI/PluginSelectMenu.qml
+ AppUI/EditText.qml
+ AppUI/FullScreenFolder.qml
+
+
diff --git a/res.qrc b/res.qrc
deleted file mode 100644
index 47d0ea3..0000000
--- a/res.qrc
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
- data/img/mainviewwidget/all-2x.png
- data/img/mainviewwidget/all.png
- data/img/mainviewwidget/all.svg
- data/img/mainviewwidget/attributeaction.svg
- data/img/mainviewwidget/close-2x.png
- data/img/mainviewwidget/close.png
- data/img/mainviewwidget/close.svg
- data/img/mainviewwidget/Development-Checked.svg
- data/img/mainviewwidget/Development-Disabled.svg
- data/img/mainviewwidget/Development-Enabled.svg
- data/img/mainviewwidget/Development-Normal.svg
- data/img/mainviewwidget/DM-all-2x.png
- data/img/mainviewwidget/DM-all.png
- data/img/mainviewwidget/DM-all.svg
- data/img/mainviewwidget/DM-close-2x.png
- data/img/mainviewwidget/DM-close.png
- data/img/mainviewwidget/DM-close.svg
- data/img/mainviewwidget/DM-function-2x.png
- data/img/mainviewwidget/DM-function.png
- data/img/mainviewwidget/DM-function.svg
- data/img/mainviewwidget/DM-arrow.png
- data/img/mainviewwidget/DM-arrow.svg
- data/img/mainviewwidget/DM-arrow-2x.png
- data/img/mainviewwidget/DM-icon-返回.png
- data/img/mainviewwidget/DM-icon-返回.svg
- data/img/mainviewwidget/DM-icon-返回@2x.png
- data/img/mainviewwidget/DM-icon-选项.png
- data/img/mainviewwidget/DM-icon-选项@2x.png
- data/img/mainviewwidget/DM-icon-check.png
- data/img/mainviewwidget/DM-icon-check.svg
- data/img/mainviewwidget/DM-icon-check@2x.png
- data/img/mainviewwidget/DM-icon-search.png
- data/img/mainviewwidget/DM-icon-search.svg
- data/img/mainviewwidget/DM-icon-search@2x.png
- data/img/mainviewwidget/DM-letter-2x.png
- data/img/mainviewwidget/DM-letter.png
- data/img/mainviewwidget/DM-letter.svg
- data/img/mainviewwidget/DM-max-2x.png
- data/img/mainviewwidget/DM-max.png
- data/img/mainviewwidget/DM-max.svg
- data/img/mainviewwidget/downarrow-pressed.svg
- data/img/mainviewwidget/downarrow.svg
- data/img/mainviewwidget/drop-down-2x.png
- data/img/mainviewwidget/drop-down.png
- data/img/mainviewwidget/drop-down.svg
- data/img/mainviewwidget/Education-Checked.svg
- data/img/mainviewwidget/Education-Disabled.svg
- data/img/mainviewwidget/Education-Enabled.svg
- data/img/mainviewwidget/Education-Normal.svg
- data/img/mainviewwidget/fixed.svg
- data/img/mainviewwidget/full-all-2x.png
- data/img/mainviewwidget/full-close-2x.png
- data/img/mainviewwidget/full-close.png
- data/img/mainviewwidget/full-close.svg
- data/img/mainviewwidget/full-drop-down-2x.png
- data/img/mainviewwidget/full-drop-down.png
- data/img/mainviewwidget/full-drop-down.svg
- data/img/mainviewwidget/full-function-2x.png
- data/img/mainviewwidget/full-function.png
- data/img/mainviewwidget/full-function.svg
- data/img/mainviewwidget/full-letter-2x.png
- data/img/mainviewwidget/full-letter.png
- data/img/mainviewwidget/full-letter.svg
- data/img/mainviewwidget/full-min-2x.png
- data/img/mainviewwidget/full-min.png
- data/img/mainviewwidget/full-min.svg
- data/img/mainviewwidget/full-search-2x.png
- data/img/mainviewwidget/full-search.png
- data/img/mainviewwidget/full-search.svg
- data/img/mainviewwidget/fullicon-all.png
- data/img/mainviewwidget/fullicon-all.svg
- data/img/mainviewwidget/function-2x.png
- data/img/mainviewwidget/function.png
- data/img/mainviewwidget/function.svg
- data/img/mainviewwidget/Game-Checked.svg
- data/img/mainviewwidget/Game-Disabled.svg
- data/img/mainviewwidget/Game-Enabled.svg
- data/img/mainviewwidget/Game-Normal.svg
- data/img/mainviewwidget/icon- 返回.png
- data/img/mainviewwidget/icon- 返回.svg
- data/img/mainviewwidget/icon- 返回@2x.png
- data/img/mainviewwidget/icon- 选项.png
- data/img/mainviewwidget/icon- 选项.svg
- data/img/mainviewwidget/icon- 选项@2x.png
- data/img/mainviewwidget/icon- search-2x.png
- data/img/mainviewwidget/icon- search.png
- data/img/mainviewwidget/icon- search.svg
- data/img/mainviewwidget/icon-check.png
- data/img/mainviewwidget/icon-check.svg
- data/img/mainviewwidget/icon-check@2x.png
- data/img/mainviewwidget/Image-Checked.svg
- data/img/mainviewwidget/Image-Disabled.svg
- data/img/mainviewwidget/Image-Enabled.svg
- data/img/mainviewwidget/Image-Normal.svg
- data/img/mainviewwidget/Internet-Checked.svg
- data/img/mainviewwidget/Internet-Disabled.svg
- data/img/mainviewwidget/Internet-Enabled.svg
- data/img/mainviewwidget/Internet-Normal.svg
- data/img/mainviewwidget/leftarrow-hover.svg
- data/img/mainviewwidget/leftarrow.svg
- data/img/mainviewwidget/letter-2x.png
- data/img/mainviewwidget/letter.png
- data/img/mainviewwidget/letter.svg
- data/img/mainviewwidget/lock-fs.svg
- data/img/mainviewwidget/lock.svg
- data/img/mainviewwidget/max-2x.png
- data/img/mainviewwidget/max.png
- data/img/mainviewwidget/max.svg
- data/img/mainviewwidget/Mobile-Checked.svg
- data/img/mainviewwidget/Mobile-Disabled.svg
- data/img/mainviewwidget/Mobile-Enabled.svg
- data/img/mainviewwidget/Mobile-Normal.svg
- data/img/mainviewwidget/Office-Checked.svg
- data/img/mainviewwidget/Office-Disabled.svg
- data/img/mainviewwidget/Office-Enabled.svg
- data/img/mainviewwidget/Office-Normal.svg
- data/img/mainviewwidget/Others-Checked.svg
- data/img/mainviewwidget/Others-Disabled.svg
- data/img/mainviewwidget/Others-Enabled.svg
- data/img/mainviewwidget/Others-Normal.svg
- data/img/mainviewwidget/power-2x.png
- data/img/mainviewwidget/power.png
- data/img/mainviewwidget/power.svg
- data/img/mainviewwidget/recent-disabled.svg
- data/img/mainviewwidget/recent-enabled.svg
- data/img/mainviewwidget/recent-gray.svg
- data/img/mainviewwidget/recent.svg
- data/img/mainviewwidget/rightarrow-hover.svg
- data/img/mainviewwidget/rightarrow.svg
- data/img/mainviewwidget/search.svg
- data/img/mainviewwidget/select.svg
- data/img/mainviewwidget/selected.svg
- data/img/mainviewwidget/Social-Checked.svg
- data/img/mainviewwidget/Social-Disabled.svg
- data/img/mainviewwidget/Social-Enabled.svg
- data/img/mainviewwidget/Social-Normal.svg
- data/img/mainviewwidget/System-Checked.svg
- data/img/mainviewwidget/System-Disabled.svg
- data/img/mainviewwidget/System-Enabled.svg
- data/img/mainviewwidget/System-Normal.svg
- data/img/mainviewwidget/ukui-search-blue.svg
- data/img/mainviewwidget/ukui-search.svg
- data/img/mainviewwidget/unfixed.svg
- data/img/mainviewwidget/uninstall.svg
- data/img/mainviewwidget/uparrow-pressed.svg
- data/img/mainviewwidget/uparrow.svg
- data/img/mainviewwidget/Video-Checked.svg
- data/img/mainviewwidget/Video-Disabled.svg
- data/img/mainviewwidget/Video-Enabled.svg
- data/img/mainviewwidget/Video-Normal.svg
- data/img/sidebarwidget/commonuse.svg
- data/img/sidebarwidget/computer.svg
- data/img/sidebarwidget/control.svg
- data/img/sidebarwidget/fixed.svg
- data/img/sidebarwidget/fullusericon.png
- data/img/sidebarwidget/function.svg
- data/img/sidebarwidget/letter.svg
- data/img/sidebarwidget/lock.svg
- data/img/sidebarwidget/max.svg
- data/img/sidebarwidget/min.svg
- data/img/sidebarwidget/personal.svg
- data/img/sidebarwidget/rightarrow.svg
- data/img/sidebarwidget/setting.svg
- data/img/sidebarwidget/shutdown.svg
- data/img/sidebarwidget/trash.svg
- data/img/sidebarwidget/unfixed.svg
- data/img/sidebarwidget/usericon-darkcolor.svg
- data/img/sidebarwidget/usericon-lightcolor.svg
- src/BackProcess/Search/pinyinWithoutTone.txt
- src/BackProcess/Search/pinyinWithTone.txt
- data/img/mainviewwidget/DM-icon-option.svg
-
-
diff --git a/res/icon/application-x-desktop.png b/res/icon/application-x-desktop.png
new file mode 100644
index 0000000..2095ab0
Binary files /dev/null and b/res/icon/application-x-desktop.png differ
diff --git a/res/icon/pad_mainpower.svg b/res/icon/pad_mainpower.svg
new file mode 100644
index 0000000..4fb7c20
--- /dev/null
+++ b/res/icon/pad_mainpower.svg
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/res.qrc b/res/res.qrc
new file mode 100644
index 0000000..743f0c5
--- /dev/null
+++ b/res/res.qrc
@@ -0,0 +1,6 @@
+
+
+ icon/application-x-desktop.png
+ icon/pad_mainpower.svg
+
+
diff --git a/src/BackProcess/DBus/dbus-adaptor.cpp b/src/BackProcess/DBus/dbus-adaptor.cpp
deleted file mode 100644
index 9df5c62..0000000
--- a/src/BackProcess/DBus/dbus-adaptor.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file was generated by qdbusxml2cpp version 0.8
- * Command line was: qdbusxml2cpp org.ukui.menu.xml -i dbus.h -a dbus-adaptor
- *
- * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
- *
- * This is an auto-generated file.
- * Do not edit! All changes made to it will be lost.
- */
-
-#include "dbus-adaptor.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/*
- * Implementation of adaptor class MenuAdaptor
- */
-
-MenuAdaptor::MenuAdaptor(QObject *parent)
- : QDBusAbstractAdaptor(parent)
-{
- // constructor
- setAutoRelaySignals(true);
-}
-
-MenuAdaptor::~MenuAdaptor()
-{
- // destructor
-}
-
-QString MenuAdaptor::GetSecurityConfigPath()
-{
- // handle method call org.ukui.menu.GetSecurityConfigPath
- QString out0;
- QMetaObject::invokeMethod(parent(), "GetSecurityConfigPath", Q_RETURN_ARG(QString, out0));
- return out0;
-}
-
-void MenuAdaptor::ReloadSecurityConfig()
-{
- // handle method call org.ukui.menu.ReloadSecurityConfig
- QMetaObject::invokeMethod(parent(), "ReloadSecurityConfig");
-}
-
-void MenuAdaptor::WinKeyResponse()
-{
- // handle method call org.ukui.menu.WinKeyResponse
- QMetaObject::invokeMethod(parent(), "WinKeyResponse");
-}
-
-bool MenuAdaptor::GetMenuStatus()
-{
- bool status;
- QMetaObject::invokeMethod(parent(), "GetMenuStatus", Q_RETURN_ARG(bool, status));
- return status;
-}
diff --git a/src/BackProcess/DBus/dbus-adaptor.h b/src/BackProcess/DBus/dbus-adaptor.h
deleted file mode 100644
index cc29f87..0000000
--- a/src/BackProcess/DBus/dbus-adaptor.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file was generated by qdbusxml2cpp version 0.8
- * Command line was: qdbusxml2cpp org.ukui.menu.xml -i dbus.h -a dbus-adaptor
- *
- * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
- *
- * This is an auto-generated file.
- * This file may have been hand-edited. Look for HAND-EDIT comments
- * before re-generating it.
- */
-
-#ifndef DBUS_ADAPTOR_H
-#define DBUS_ADAPTOR_H
-
-#include
-#include
-#include "dbus.h"
-QT_BEGIN_NAMESPACE
-class QByteArray;
-template class QList;
-template class QMap;
-class QString;
-class QStringList;
-class QVariant;
-QT_END_NAMESPACE
-
-/*
- * Adaptor class for interface org.ukui.menu
- */
-class MenuAdaptor: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.ukui.menu")
- Q_CLASSINFO("D-Bus Introspection", ""
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- " \n"
- "")
-public:
- MenuAdaptor(QObject *parent);
- virtual ~MenuAdaptor();
-
-public: // PROPERTIES
-public Q_SLOTS: // METHODS
- QString GetSecurityConfigPath();
- void ReloadSecurityConfig();
- void WinKeyResponse();
- bool GetMenuStatus();
-Q_SIGNALS: // SIGNALS
-};
-
-#endif
diff --git a/src/BackProcess/DBus/org.ukui.menu.xml b/src/BackProcess/DBus/org.ukui.menu.xml
deleted file mode 100644
index b8dce89..0000000
--- a/src/BackProcess/DBus/org.ukui.menu.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp b/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp
deleted file mode 100644
index 24575bf..0000000
--- a/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "convert_winid_to_desktop.h"
-#include "utility.h"
-#include
-#include
-#include
-
-ConvertWinidToDesktop::ConvertWinidToDesktop(QObject *parent) : QObject(parent)
-{
-}
-
-QString ConvertWinidToDesktop::tranIdToDesktop(WId id)
-{
- KWindowInfo info(id, 0, NET::WM2AllProperties);
- myDebug() << "the pid is :" << info.pid();
- QString desktopName = confirmDesktopFile(info);
- myDebug() << "desktopName is :" << desktopName;
- return desktopName;
-}
-
-QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info)
-{
- QString desktopFilePath = nullptr;
- QDir dir = QDir(DESKTOP_FILE_PATH);
- QFileInfoList list = dir.entryInfoList();
- //跳过 ./ 和 ../ 目录
- list.removeAll(QFile(USR_SHARE_APP_CURRENT));
- list.removeAll(QFile(USR_SHARE_APP_UPER));
-
- //第一种方法:获取点击应用时大部分desktop文件名
- desktopFilePath = searchFromEnviron(info, list);
-
- //第二种方法:比较名字一致性
- if (desktopFilePath.isEmpty()) {
- m_classClass = info.windowClassClass().toLower();
- m_className = info.windowClassName();
-
- //匹配安卓兼容
- if (m_className == "kylin-kmre-window") {
- return searchAndroidApp(info);
- }
-
- QFile file(QString("/proc/%1/status").arg(info.pid()));
- if (file.open(QIODevice::ReadOnly)) {
- char buf[1024];
- qint64 len=file.readLine(buf,sizeof(buf));
- if (len!=-1) {
- m_statusName = QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n");
- }
- }
- desktopFilePath = compareClassName(list);
- }
-
- //第三种方法:比较cmd命令行操作一致性
- if (desktopFilePath.isEmpty()) {
- QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
- if (file.open(QIODevice::ReadOnly)) {
- char buf[1024];
- qint64 len=file.readLine(buf,sizeof(buf));
- if (len!=-1) {
- m_cmdLine = QString::fromLocal8Bit(buf).remove("\n");
- }
- }
- desktopFilePath = compareCmdExec(list);
- }
-
- //第四种方法:匹配部分字段
- if (desktopFilePath.isEmpty()) {
- desktopFilePath = compareLastStrategy(list);
- }
- return desktopFilePath;
-}
-
-QString ConvertWinidToDesktop::searchAndroidApp(KWindowInfo info)
-{
- QDir androidDir = QString(QDir::homePath() + ANDROID_FILE_PATH);
- QFileInfoList androidList = androidDir.entryInfoList();
- androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT);
- androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER);
-
- QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
- file.open(QIODevice::ReadOnly);
- QByteArray cmd = file.readAll();
- file.close();
- QList cmdList = cmd.split('\0');
- for (int i = 0; i < androidList.size(); i++) {
- QFileInfo fileInfo = androidList.at(i);
- QString desktopName = fileInfo.filePath();
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
- desktopName = desktopName.mid(desktopName.lastIndexOf("/") + 1);
- desktopName = desktopName.left(desktopName.lastIndexOf("."));
- if(desktopName == cmdList.at(10)){
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-QString ConvertWinidToDesktop::searchFromEnviron(KWindowInfo info, QFileInfoList list)
-{
- QFile file("/proc/" + QString::number(info.pid()) + "/environ");
- file.open(QIODevice::ReadOnly);
- QByteArray BA = file.readAll();
- file.close();
- QList list_BA = BA.split('\0');
-
- QString desktopFilePath = nullptr;
- for (int i = 0; i < list_BA.length(); i++) {
- if (list_BA.at(i).startsWith("GIO_LAUNCHED_DESKTOP_FILE=")) {
- desktopFilePath = list_BA.at(i);
- desktopFilePath = desktopFilePath.mid(desktopFilePath.indexOf("=") + 1);
- //desktop文件地址需要重写
- desktopFilePath = desktopFilePath.mid(desktopFilePath.lastIndexOf("/") + 1);
- break;
- }
- }
- //desktop文件地址重写
- if (!desktopFilePath.isEmpty()) {
- for (int i = 0; i < list.size(); i++) {
- QFileInfo fileInfo = list.at(i);
- if (fileInfo.filePath() == DESKTOP_FILE_PATH + desktopFilePath) {
- desktopFilePath = fileInfo.filePath();
- return desktopFilePath;
- }
- }
- }
- return desktopFilePath;
-}
-
-QString ConvertWinidToDesktop::compareClassName(QFileInfoList list)
-{
- for (int i = 0; i < list.size(); i++) {
- QFileInfo fileInfo = list.at(i);;
- QString pathDesktopName = fileInfo.filePath();
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
- pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
- pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
- if (pathDesktopName == m_classClass || pathDesktopName == m_className || pathDesktopName == m_statusName) {
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list)
-{
- for (int i = 0; i < list.size(); i++) {
- QString cmd;
- QFileInfo fileInfo = list.at(i);
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
- cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
- QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
-
- if (desktopFileExeName.isEmpty()) {
- continue;
- }
-
- if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) {
- return fileInfo.filePath();
- }
-
- //仅仅是为了适配微信
- desktopFileExeName = "/usr/lib/" + desktopFileExeName;
- if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) {
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-//最后的匹配策略汇总
-QString ConvertWinidToDesktop::compareLastStrategy(QFileInfoList list)
-{
- QString desktopFilePath = compareCmdName(list);
-
- if (desktopFilePath.isEmpty()) {
- desktopFilePath = compareDesktopClass(list);
- }
-
- if (desktopFilePath.isEmpty()) {
- desktopFilePath = containsName(list);
- }
- return desktopFilePath;
-}
-
-QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list)
-{
- for (int i = 0; i < list.size(); i++) {
- QString cmd;
- QFileInfo fileInfo = list.at(i);
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
- cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
- QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
-
- if (desktopFileExeName.isEmpty()) {
- continue;
- }
-
- if (desktopFileExeName.startsWith(m_className) || desktopFileExeName.endsWith(m_className)) {
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-QString ConvertWinidToDesktop::compareDesktopClass(QFileInfoList list)
-{
- for (int i = 0; i < list.size(); i++) {
- QFileInfo fileInfo = list.at(i);
- QString pathDesktopName = fileInfo.filePath();
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
- pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
- pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
-
- if (pathDesktopName.startsWith(m_className) || pathDesktopName.endsWith(m_className)) {
- return fileInfo.filePath();
- }
- else if (m_className.startsWith(pathDesktopName) || m_className.endsWith(pathDesktopName)) {
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-QString ConvertWinidToDesktop::containsName(QFileInfoList list)
-{
- for (int i = 0; i < list.size(); i++) {
- QString cmd;
- QFileInfo fileInfo = list.at(i);
- QString pathDesktopName = fileInfo.filePath();
-
- if (!fileInfo.filePath().endsWith(".desktop")) {
- continue;
- }
-
- cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
- QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
-
- pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
- pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
-
- if (pathDesktopName.contains(m_className) || desktopFileExeName.contains(m_className)) {
- return fileInfo.filePath();
- }
- }
- return nullptr;
-}
-
-//执行头文件中宏定义写好的终端指令获取对应的Exec字段
-QString ConvertWinidToDesktop::getDesktopFileName(QString cmd)
-{
- char name[200];
- FILE *fp1 = NULL;
- if ((fp1 = popen(cmd.toStdString().data(), "r")) == NULL) {
- return QString();
- }
- memset(name, 0, sizeof(name));
- fgets(name, sizeof(name), fp1);
- pclose(fp1);
- return QString(name);
-}
-
-ConvertWinidToDesktop::~ConvertWinidToDesktop()
-{
-}
diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.h b/src/BackProcess/FileWatcher/convert_winid_to_desktop.h
deleted file mode 100644
index 92e0521..0000000
--- a/src/BackProcess/FileWatcher/convert_winid_to_desktop.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef CONVERTDESKTOPTOWINID_H
-#define CONVERTDESKTOPTOWINID_H
-
-#include
-#include
-#include
-
-#define DESKTOP_FILE_PATH "/usr/share/applications/"
-#define USR_SHARE_APP_CURRENT "/usr/share/applications/."
-#define USR_SHARE_APP_UPER "/usr/share/applications/.."
-#define PEONY_TRASH "/usr/share/applications/peony-trash.desktop"
-#define PEONY_COMUTER "/usr/share/applications/peony-computer.desktop"
-#define PEONY_HOME "/usr/share/applications/peony-home.desktop"
-#define PEONY_MAIN "/usr/share/applications/peony.desktop"
-
-#define GET_DESKTOP_EXEC_NAME_MAIN "cat %s | awk '{if($1~\"Exec=\")if($2~\"\%\"){print $1} else print}' | cut -d '=' -f 2"
-#define ANDROID_FILE_PATH "/.local/share/applications/"
-#define ANDROID_APP_CURRENT "/.local/share/applications/."
-#define ANDROID_APP_UPER "/.local/share/applications/.."
-
-
-/**
- * @brief The ConvertWinidToDesktop class
- * 需要实现的功能,desktop文件与windowId的转换
- * 传入(int)WindowId,转化为desktop文件的路径
- */
-
-class ConvertWinidToDesktop : public QObject
-{
- Q_OBJECT
-public:
- explicit ConvertWinidToDesktop(QObject *parent = nullptr);
- ~ConvertWinidToDesktop();
-
- QString tranIdToDesktop(WId id);
-
-private:
- QString m_classClass = nullptr;
- QString m_className = nullptr;
- QString m_statusName = nullptr;
- QString m_cmdLine = nullptr;
-
- QString confirmDesktopFile(KWindowInfo info);
- QString searchFromEnviron(KWindowInfo info, QFileInfoList list);
- QString searchAndroidApp(KWindowInfo info);
- QString compareClassName(QFileInfoList list);
- QString compareCmdExec(QFileInfoList list);
- QString compareLastStrategy(QFileInfoList list);
- QString compareCmdName(QFileInfoList list);
- QString compareDesktopClass(QFileInfoList list);
- QString containsName(QFileInfoList list);
- QString getDesktopFileName(QString cmd);
-};
-
-#endif // CONVERTDESKTOPTOWINID_H
diff --git a/src/BackProcess/FileWatcher/desktop_watcher.cpp b/src/BackProcess/FileWatcher/desktop_watcher.cpp
deleted file mode 100644
index 5e2cf10..0000000
--- a/src/BackProcess/FileWatcher/desktop_watcher.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "desktop_watcher.h"
-#include
-#include
-
-DesktopWatcher::DesktopWatcher()
-{
- //监控.desktop文件目录
- m_fileWatcher = new QFileSystemWatcher;
- m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications")
- << QString(QDir::homePath() + "/.local/share/applications/")
- << QString("/var/lib/snapd/desktop/applications/")
- << QString("/var/lib/flatpak/exports/share/applications/"));
- connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &DesktopWatcher::directoryChangedSlot);
- // m_recentFile = new QFileSystemWatcher;
- // m_recentFile->addPath(QString(QDir::homePath()+"/.local/share/recently-used.xbel"));
- // connect(m_recentFile,&QFileSystemWatcher::fileChanged,this,[=](){
- // m_recentFile->addPath(QDir::homePath()+"/.local/share/recently-used.xbel");
- // Q_EMIT updateRecentList();});
- m_directoryChangedThread = new DirectoryChangedThread;
- connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &DesktopWatcher::requestUpdateSlot);
-}
-
-DesktopWatcher::~DesktopWatcher()
-{
-}
-
-/**
- * desktop文件目录改变信号槽
- */
-void DesktopWatcher::directoryChangedSlot(const QString &path)
-{
- QEventLoop loop;
- QTimer::singleShot(100, &loop, SLOT(quit()));
- loop.exec();
- m_directoryChangedThread->start();
-}
-
-void DesktopWatcher::requestUpdateSlot()
-{
- m_directoryChangedThread->quit();
- Q_EMIT directoryChangedSignal();
-}
diff --git a/src/BackProcess/FileWatcher/desktop_watcher.h b/src/BackProcess/FileWatcher/desktop_watcher.h
deleted file mode 100644
index 9b6f9c3..0000000
--- a/src/BackProcess/FileWatcher/desktop_watcher.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef DESKTOPWATCHER_H
-#define DESKTOPWATCHER_H
-#include
-#include "directory_changed_thread.h"
-
-
-class DesktopWatcher : public QObject
-{
- Q_OBJECT
-public:
- DesktopWatcher();
- ~DesktopWatcher();
-
-public:
-Q_SIGNALS:
- /**
- * @brief Desktop file directory change signal
- */
- void directoryChangedSignal();
- void updateRecentList();
-
-public Q_SLOTS:
-
- void directoryChangedSlot(const QString &path);
- void requestUpdateSlot();
-
-private:
- QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status
-// QFileSystemWatcher *m_recentFile=nullptr;
- DirectoryChangedThread *m_directoryChangedThread = nullptr;
-};
-
-#endif // DESKTOPWATCHER_H
diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.cpp b/src/BackProcess/FileWatcher/directory_changed_thread.cpp
deleted file mode 100644
index b96a470..0000000
--- a/src/BackProcess/FileWatcher/directory_changed_thread.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "directory_changed_thread.h"
-#include
-#include
-#include "utility.h"
-
-DirectoryChangedThread::DirectoryChangedThread()
-{
- m_ukuiMenuInterface = new UkuiMenuInterface;
-}
-
-DirectoryChangedThread::~DirectoryChangedThread()
-{
- if (m_ukuiMenuInterface) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
-}
-
-void DirectoryChangedThread::run()
-{
- closeDataBase("DirectoryChangedThread");
- openDataBase("DirectoryChangedThread");
- QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath();
-
- if (desktopfpList.size() > UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装
- for (int i = 0; i < desktopfpList.count(); i++) {
- if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) {
- QFileInfo fileInfo(desktopfpList.at(i));
- QString desktopfn = fileInfo.fileName();
- updateDataBaseTableRecent(desktopfn);
- break;
- }
- }
- } else { //软件卸载
- for (int i = 0; i < UkuiMenuInterface::desktopfpVector.size(); i++) {
- if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) {
- QString desktopfp = UkuiMenuInterface::appInfoVector.at(i).at(0);
- QFileInfo fileInfo(desktopfp);
- QString desktopfn = fileInfo.fileName();
- deleteAppRecord(desktopfn);
- break;
- }
- }
- }
-
- myDebug() << "DirectoryChangedThread::run()";
- UkuiMenuInterface::appInfoVector.clear();
- UkuiMenuInterface::alphabeticVector.clear();
- UkuiMenuInterface::functionalVector.clear();
- UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector();
- UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification();
- UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification();
- Q_EMIT requestUpdateSignal();
-}
diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.h b/src/BackProcess/FileWatcher/directory_changed_thread.h
deleted file mode 100644
index 7e29038..0000000
--- a/src/BackProcess/FileWatcher/directory_changed_thread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef DIRECTORYCHANGEDTHREAD_H
-#define DIRECTORYCHANGEDTHREAD_H
-#include
-#include
-#include
-#include "ukuimenuinterface.h"
-
-class DirectoryChangedThread: public QThread
-{
- Q_OBJECT
-public:
- DirectoryChangedThread();
- ~DirectoryChangedThread();
- void run();
-
-private:
- UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
-
-Q_SIGNALS:
- /**
- * @brief Request update signal
- */
- void requestUpdateSignal();
-
-};
-
-#endif // DIRECTORYCHANGEDTHREAD_H
diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.cpp b/src/BackProcess/FileWatcher/software_database_update_thread.cpp
deleted file mode 100644
index 9c50f44..0000000
--- a/src/BackProcess/FileWatcher/software_database_update_thread.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "software_database_update_thread.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include "src/UtilityFunction/utility.h"
-
-#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db"
-
-SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread()
-{
-
-}
-
-SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread()
-{
-
-}
-
-void SoftwareDatabaseUpdateThread::run()
-{
- QSqlDatabase db;
- db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase");
- db.setDatabaseName(DATABASENAME);
- if (false == db.open()){
- myDebug() << db.lastError().text();
- }
-
- QSqlQuery sql(db);
-
- QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data());
- QJsonObject jsonObject = jsonDocument.object();
- QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray();
-
- int number = 0;
- db.transaction();
-
- Q_FOREACH(QJsonValue jsonValue, jsonArray){
- QJsonObject arrObject = jsonValue.toObject();
- QString execline = QString("replace into appCategory values(\"%0\", \"%1\", \"%2\")")
- .arg(arrObject[arrObject.keys()[0]].toString())
- .arg(arrObject[arrObject.keys()[1]].toString())
- .arg(arrObject[arrObject.keys()[2]].toString());
- sql.exec(execline);
-
- ++number;
- if (number % 5000 == 0) {
- db.commit();
- db.transaction();
- }
- }
- db.commit();
-
- myDebug() << "数据库已经更新";
- Q_EMIT updateDatabaseSignal();
-
-}
-
-void SoftwareDatabaseUpdateThread::getDatabaseList(QString category)
-{
- this->m_category = category;
-}
diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.h b/src/BackProcess/FileWatcher/software_database_update_thread.h
deleted file mode 100644
index 2914339..0000000
--- a/src/BackProcess/FileWatcher/software_database_update_thread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef SOFTWAREDATABASEUPDATETHREAD_H
-#define SOFTWAREDATABASEUPDATETHREAD_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class SoftwareDatabaseUpdateThread:public QThread
-{
- Q_OBJECT
-public:
- SoftwareDatabaseUpdateThread();
- ~SoftwareDatabaseUpdateThread();
- void run();
- void getDatabaseList(QString category);
-Q_SIGNALS:
- void updateDatabaseSignal();
-
-private:
- QString m_category;
-};
-
-#endif // SOFTWAREDATABASEUPDATETHREAD_H
diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp
deleted file mode 100644
index 7c7ee4a..0000000
--- a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "tablet_directorychanged_thread.h"
-#include
-#include
-#include
-#include "tabletlistview.h"
-#include
-#include
-
-TabletDirectoryChangedThread::TabletDirectoryChangedThread()
-{
- m_ukuiMenuInterface = new UkuiMenuInterface;
- QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini";
- m_setting = new QSettings(path, QSettings::IniFormat);
-}
-
-TabletDirectoryChangedThread::~TabletDirectoryChangedThread()
-{
- if (m_ukuiMenuInterface) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
-
- if (m_setting) {
- delete m_setting;
- m_setting = nullptr;
- }
-}
-
-
-void TabletDirectoryChangedThread::run()
-{
- QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath();
- myDebug() << "应用列表desktopfpList" << desktopfpList.size() << desktopfpList;
- myDebug() << "应用列表desktopfpVector" << UkuiMenuInterface::desktopfpVector.size() << UkuiMenuInterface::desktopfpVector;
- QString m_desktopfp;
-
- for (int i = 0; i < desktopfpList.count(); i++) {
- myDebug() << desktopfpList.at(i) << "是否存在于已安装应用列表中" <<
- UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i)));
-
- if (!UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i)))) {
- m_desktopfp = desktopfpList.at(i);
- myDebug() << "安装应用" << m_desktopfp;
- //获取当前时间戳
- QDateTime dt = QDateTime::currentDateTime();
- int datetime = dt.toTime_t();
- QString str = desktopfpList.at(i).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- QString desktopfn = str;
- m_setting->beginGroup("recentapp");
- m_setting->setValue(desktopfn, datetime);
- m_setting->sync();
- m_setting->endGroup();
- //wgx
- m_setting->beginGroup("application");
- QStringList applist = m_setting->allKeys();
- int appnum = m_setting->allKeys().count();
- int maxindex = 0;
- int minindex = 0;
-
- for (int i = 0; i < appnum; i++) {
- if (m_setting->value(applist.at(i)).toInt() > maxindex) {
- maxindex = m_setting->value(applist.at(i)).toInt();
- }
-
- if(m_setting->value(applist.at(i)).toInt() <= minindex) {
- minindex = m_setting->value(applist.at(i)).toInt();
- }
- }
-
- if (desktopfn.contains("small-plugin-manage")){
- m_setting->setValue(desktopfn,minindex-1);
- } else {
- m_setting->setValue(desktopfn,maxindex+1);
- }
-
- m_setting->sync();
- m_setting->endGroup();
- //
- QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfpList.at(i));
- syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", iconstr.toLocal8Bit().data());
- syslog(LOG_LOCAL0 | LOG_DEBUG, "软件安装desktop文件名:%s", desktopfn.toLocal8Bit().data());
-
- Q_FOREACH(QString path, QIcon::themeSearchPaths()) {
- syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", path.toLocal8Bit().data());
- }
- }
- }
-
- for (int i = 0; i < UkuiMenuInterface::desktopfpVector.count(); i++) {
- if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) {
- QString desktopfp = UkuiMenuInterface::desktopfpVector.at(i);
- QFileInfo fileInfo(desktopfp);
- QString desktopfn = fileInfo.fileName();
- myDebug() << "卸载" << desktopfn;
- m_setting->beginGroup("lockapplication");
- m_setting->remove(desktopfn);
- m_setting->sync();
- m_setting->endGroup();
- m_setting->beginGroup("application");
-
- if (!m_setting->contains(desktopfn)) {
- m_setting->sync();
- m_setting->endGroup();
- continue;
- }
-
- int val = m_setting->value(desktopfn).toInt();
- myDebug() << "卸载val" << val;
- m_setting->remove(desktopfn);
- QStringList desktopfnList = m_setting->allKeys();
-
- for (int i = 0; i < desktopfnList.count(); i++) {
- if (m_setting->value(desktopfnList.at(i)).toInt() > val) {
- m_setting->setValue(desktopfnList.at(i), m_setting->value(desktopfnList.at(i)).toInt() - 1);
- }
- }
-
- m_setting->sync();
- m_setting->endGroup();
- m_setting->beginGroup("recentapp");
- m_setting->remove(desktopfn);
- m_setting->sync();
- m_setting->endGroup();
- syslog(LOG_LOCAL0 | LOG_DEBUG, "软件卸载desktop文件名:%s", desktopfn.toLocal8Bit().data());
- QDBusInterface iface("com.ukui.panel.desktop",
- "/",
- "com.ukui.panel.desktop",
- QDBusConnection::sessionBus());
- iface.call("RemoveFromTaskbar", desktopfp);
- }
- }
-
- UkuiMenuInterface::appInfoVector.clear();
- UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector();
- Q_EMIT requestUpdateSignal(m_desktopfp);
-}
diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h
deleted file mode 100644
index 6939333..0000000
--- a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef TABLETDIRECTORYCHANGEDTHREAD_H
-#define TABLETDIRECTORYCHANGEDTHREAD_H
-#include
-#include
-#include
-#include "ukuimenuinterface.h"
-#include
-#include
-
-class TabletDirectoryChangedThread: public QThread
-{
- Q_OBJECT
-public:
- TabletDirectoryChangedThread();
- ~TabletDirectoryChangedThread();
- void run();
-
-private:
- UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
- QSettings *m_setting = nullptr;
- TabletListView *m_listView = nullptr;
- QStandardItemModel *listmodel = nullptr;
-
- int index = 0;
-
-Q_SIGNALS:
- /**
- * @brief Request update signal
- */
- void requestUpdateSignal(QString desktopfp);
- void deleteAppSignal();
-
-};
-
-#endif // DIRECTORYCHANGEDTHREAD_H
diff --git a/src/BackProcess/Interface/currenttime_interface.cpp b/src/BackProcess/Interface/currenttime_interface.cpp
deleted file mode 100644
index ea71b88..0000000
--- a/src/BackProcess/Interface/currenttime_interface.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "currenttime_interface.h"
-#include
-#define TIME_FORMAT "org.ukui.control-center.panel.plugins"
-#define TIME_FORMAT_KEY "hoursystem"
-#include
-#include
-
-CurrentTimeInterface::CurrentTimeInterface()
-{
- //获得语言环境
- dateTime = new QDateTime;
- myTimer = new QTimer();
- myTimer->start(1000);
-
- if (QGSettings::isSchemaInstalled(TIME_FORMAT)) {
- timeSetting = new QGSettings(TIME_FORMAT);
-
- if (timeSetting->keys().contains(TIME_FORMAT_KEY) && timeSetting->keys().contains("date")) {
- timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString();
- timeSlash = timeSetting->get("date").toString();
- getDateTime(timeFormat);
- connect(timeSetting, &QGSettings::changed, this, [ = ](const QString & key) {
- if (key == "hoursystem") {
- timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString();
- getDateTime(timeFormat);
- } else if (key == "date") {
- timeSlash = timeSetting->get("date").toString();
-
- if (timeSlash == "en") {
- currentDate = currentDate.replace("/", "-");
- } else {
- currentDate = currentDate.replace("-", "/");
- }
- }
- });
- }
- }
-
- connect(myTimer, &QTimer::timeout, [this]() {
- getDateTime(timeFormat);
- });
-}
-
-CurrentTimeInterface::~CurrentTimeInterface()
-{
- if (myTimer) {
- delete myTimer;
- }
-
- if (timeSetting) {
- delete timeSetting;
- }
-
- if (dateTime) {
- delete dateTime;
- }
-
- myTimer = nullptr;
- timeSetting = nullptr;
- dateTime = nullptr;
-}
-
-void CurrentTimeInterface::getDateTime(QString timeFormat)
-{
- if (timeFormat == "12") {
- twelveHourTime();
- } else if (timeFormat == "24") {
- twentyFourHourTime();
- }
-
- if (timeSlash == "cn") {
- currentDate = currentDate.replace("-", "/");
- }
-}
-
-//12制小时时间
-void CurrentTimeInterface::twelveHourTime()
-{
- currentTime = dateTime->currentDateTime().time().toString("hh:mm AP").split(" ").first();
- currentDate = dateTime->currentDateTime().date().toString("ddd MM-dd");
- currentWeek = dateTime->currentDateTime().time().toString("AP");
-}
-
-//24小时制时间
-void CurrentTimeInterface::twentyFourHourTime()
-{
- currentTime = dateTime->currentDateTime().time().toString("hh:mm");
- currentDate = dateTime->currentDateTime().date().toString("MM-dd");
- currentWeek = dateTime->currentDateTime().date().toString("ddd");
-}
diff --git a/src/BackProcess/Interface/currenttime_interface.h b/src/BackProcess/Interface/currenttime_interface.h
deleted file mode 100644
index 80c318f..0000000
--- a/src/BackProcess/Interface/currenttime_interface.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef CURRENTTIMEINTERFACE_H
-#define CURRENTTIMEINTERFACE_H
-#include
-#include
-#include
-#include
-#include
-#include
-
-class CurrentTimeInterface : public QObject
-{
- Q_OBJECT
-public:
- CurrentTimeInterface();
- ~CurrentTimeInterface();
-
- QString currentTime;
- QString currentWeek;
- QString currentDate;
-
-protected:
- void twelveHourTime();
- void twentyFourHourTime();
- void getDateTime(QString timeFormat);
-
-private:
- QDateTime *dateTime;
- QTimer *myTimer;
- QGSettings *timeSetting = nullptr;
- QString timeFormat;
- QString timeSlash;
-
-};
-
-#endif // CURRENTTIMEINTERFACE_H
diff --git a/src/BackProcess/Interface/ukui_chineseletter.cpp b/src/BackProcess/Interface/ukui_chineseletter.cpp
deleted file mode 100644
index a5a8956..0000000
--- a/src/BackProcess/Interface/ukui_chineseletter.cpp
+++ /dev/null
@@ -1,6251 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "ukui_chineseletter.h"
-#include
-#include
-
-UkuiChineseLetter::UkuiChineseLetter()
-{
-}
-
-bool UkuiChineseLetter::In(wchar_t start, wchar_t end, wchar_t code)
-{
- if (code >= start && code <= end) {
- return true;
- }
-
- return false;
-}
-
-char UkuiChineseLetter::Convert(int n)//此方法有缺陷,只能识别一级字库中的汉字
-{
- /*
- * GB2312码范围 (B0A1-F7FE)
- * HiByte (B0-F7) LoByte (A1-FE)
- *
- * GBK编码范围 (8140-FEFE)
- * 包含三大部分
- * 1.汉字区
- * a. GB2312汉字区。即GBK/2
- * b. GB13000.1扩充汉字区。包括GBK/3(CJK汉字)和GBK/4(CJK汉字和增补汉字)
- * 2.图形符号区
- * a. GB2312非汉字区。即GBK/1 A1A1-A9FE。还有10个小写罗马数字和GB12345增补符号
- * b. GB13000.1扩充非汉字区。即GBK/5 A840-A9A0非汉字符号、结构符...
- * 3.用户自定义区
- *
- */
- if (In(0xB0A1, 0xB0C4, n)) {
- return 'A';
- }
-
- if (In(0XB0C5, 0XB2C0, n)) {
- return 'B';
- }
-
- if (In(0xB2C1, 0xB4ED, n)) {
- return 'C';
- }
-
- if (In(0xB4EE, 0xB6E9, n)) {
- return 'D';
- }
-
- if (In(0xB6EA, 0xB7A1, n)) {
- return 'E';
- }
-
- if (In(0xB7A2, 0xB8c0, n)) {
- return 'F';
- }
-
- if (In(0xB8C1, 0xB9FD, n)) {
- return 'G';
- }
-
- if (In(0xB9FE, 0xBBF6, n)) {
- return 'H';
- }
-
- if (In(0xBBF7, 0xBFA5, n)) {
- return 'J';
- }
-
- if (In(0xBFA6, 0xC0AB, n)) {
- return 'K';
- }
-
- if (In(0xC0AC, 0xC2E7, n)) {
- return 'L';
- }
-
- if (In(0xC2E8, 0xC4C2, n)) {
- return 'M';
- }
-
- if (In(0xC4C3, 0xC5B5, n)) {
- return 'N';
- }
-
- if (In(0xC5B6, 0xC5BD, n)) {
- return 'O';
- }
-
- if (In(0xC5BE, 0xC6D9, n)) {
- return 'P';
- }
-
- if (In(0xC6DA, 0xC8BA, n)) {
- return 'Q';
- }
-
- if (In(0xC8BB, 0xC8F5, n)) {
- return 'R';
- }
-
- if (In(0xC8F6, 0xCBF0, n)) {
- return 'S';
- }
-
- if (In(0xCBFA, 0xCDD9, n)) {
- return 'T';
- }
-
- if (In(0xCDDA, 0xCEF3, n)) {
- return 'W';
- }
-
- if (In(0xCEF4, 0xD1B8, n)) {
- return 'X';
- }
-
- if (In(0xD1B9, 0xD4D0, n)) {
- return 'Y';
- }
-
- if (In(0xD4D1, 0xD7F9, n)) {
- return 'Z';
- }
-
- if (In(0x00, 0x7f, n)) {
- return n;
- }
-
- return '\0';
-}
-
-QString UkuiChineseLetter::getFirstLetter(const QString &src)
-{
- // wchar_t wchr = 0;
- // QString firstLetter;
- // if(src.size() > 0)
- // {
- // QString str = src.at(0);
- // QTextCodec* pCodec = QTextCodec::codecForName("gb2312");
- // if(!pCodec) return QChar(' ');
- // QByteArray arr = pCodec->fromUnicode(str);
- // if(arr.size() == 1)
- // {
- // wchr = arr.at(0) & 0xff;
- // }
- // else if(arr.size() == 2)
- // {
- // wchr = (arr.at(0) & 0xff) << 8;
- // wchr |= (arr.at(1) & 0xff);
- // }
- // else
- // {
- //// qDebug() << "unknown word";
- // }
- // char c = Convert(wchr);
- // if(c != 0)
- // {
- // firstLetter.append(c);
- // }
- // }
- QString appnamePy = getPinyins(src);
-
- if (!appnamePy.isEmpty()) {
- return QString(appnamePy.at(0));
- } else {
- return QString();
- }
-}
-
-QString UkuiChineseLetter::getFirstLetters(const QString &src)
-{
- QString firstLetters;
-
- for (int i = 0; i < src.length(); i++) {
- QString str = src.at(i);
- QTextCodec *pCodec = QTextCodec::codecForName("gb2312");
-
- if (!pCodec) {
- return QChar(' ');
- }
-
- QByteArray arr = pCodec->fromUnicode(str);
- wchar_t wchr = 0;
-
- if (arr.size() == 1) {
- wchr = arr.at(0) & 0xff;
- } else if (arr.size() == 2) {
- wchr = (arr.at(0) & 0xff) << 8;
- wchr |= (arr.at(1) & 0xff);
- } else {
- //qDebug() << "unknown word";
- }
-
- char c = Convert(wchr);
-
- if (c != 0) {
- firstLetters.append(c);
- }
- }
-
- return firstLetters;
-}
-
-QString UkuiChineseLetter::getFirstLettersAll(const QString &src)
-{
- QString pinyins;
-
- for (int i = 0; i < src.length(); i++) {
- QString str = src.at(i);
- QTextCodec *pCodec = QTextCodec::codecForName("gb2312");
-
- if (!pCodec) {
- return QChar(' ');
- }
-
- QByteArray arr = pCodec->fromUnicode(str);
- unsigned char high = 0;
- unsigned char low = 0;
- int code = 0;
-
- if (arr.size() == 1) {
- high = 0;
- low = arr.at(0) & 0xff;
- } else if (arr.size() == 2) {
- high = arr.at(0) & 0xff;
- low = arr.at(1) & 0xff;
- }
-
- if (high < 0xa1 || low < 0xa1) {
- continue;
- } else {
- code = (high - 0xa0) * 100 + low - 0xa0;
- }
-
- pinyins += getPinyin(code).at(0);
- }
-
- return pinyins;
-}
-
-
-QString UkuiChineseLetter::getPinyins(const QString &text)
-{
- QString pinyins;
-
- for (int i = 0; i < text.length(); i++) {
- QChar c = text.at(i);
-
- if ((c >= 0 && c <= 127)) {
- pinyins += c.toUpper();
- continue;
- }
-
- QString str = text.at(i);
- QTextCodec *pCodec = QTextCodec::codecForName("gb2312");
-
- if (!pCodec) {
- return QChar(' ');
- }
-
- QByteArray arr = pCodec->fromUnicode(str);
- unsigned char high = 0;
- unsigned char low = 0;
- int code = 0;
-
- if (arr.size() == 1) {
- high = 0;
- low = arr.at(0) & 0xff;
- } else if (arr.size() == 2) {
- high = arr.at(0) & 0xff;
- low = arr.at(1) & 0xff;
- }
-
- if (high < 0xa1 || low < 0xa1) {
- continue;
- } else {
- code = (high - 0xa0) * 100 + low - 0xa0;
- }
-
- pinyins += getPinyin(code);
- }
-
- return pinyins;
-}
-
-
-QString UkuiChineseLetter::getPinyin(int code)//此方法可以获取所有汉字的拼音
-{
- QString pinyin;
-
- switch (code) {
- case 6325:
- case 6436:
- case 7571:
- case 7925:
- pinyin = "A";
- break;
-
- case 6263:
- case 6440:
- case 7040:
- case 7208:
- case 7451:
- case 7733:
- case 7945:
- case 8616:
- pinyin = "AI";
- break;
-
- case 5847:
- case 5991:
- case 6278:
- case 6577:
- case 6654:
- case 7281:
- case 7907:
- case 8038:
- case 8786:
- pinyin = "AN";
- break;
- pinyin = "ANG";
- break;
-
- case 5974:
- case 6254:
- case 6427:
- case 6514:
- case 6658:
- case 6959:
- case 7033:
- case 7081:
- case 7365:
- case 8190:
- case 8292:
- case 8643:
- case 8701:
- case 8773:
- pinyin = "AO";
- break;
-
- case 6056:
- case 6135:
- case 6517:
- case 7857:
- case 8446:
- case 8649:
- case 8741:
- pinyin = "BA";
- break;
-
- case 6267:
- case 6334:
- case 7494:
- pinyin = "BAI";
- break;
-
- case 5870:
- case 5964:
- case 7851:
- case 8103:
- case 8113:
- case 8418:
- pinyin = "BAN";
- break;
-
- case 6182:
- case 6826:
- pinyin = "BANG";
- break;
-
- case 6165:
- case 7063:
- case 7650:
- case 8017:
- case 8157:
- case 8532:
- case 8621:
- pinyin = "BAO";
- break;
-
- case 5635:
- case 5873:
- case 5893:
- case 5993:
- case 6141:
- case 6703:
- case 7753:
- case 8039:
- case 8156:
- case 8645:
- case 8725:
- pinyin = "BEI";
- break;
-
- case 5946:
- case 5948:
- case 7458:
- case 7928:
- pinyin = "BEN";
- break;
-
- case 6452:
- case 7420:
- pinyin = "BENG";
- break;
-
- case 5616:
- case 5734:
- case 6074:
- case 6109:
- case 6221:
- case 6333:
- case 6357:
- case 6589:
- case 6656:
- case 6725:
- case 6868:
- case 6908:
- case 6986:
- case 6994:
- case 7030:
- case 7052:
- case 7221:
- case 7815:
- case 7873:
- case 7985:
- case 8152:
- case 8357:
- case 8375:
- case 8387:
- case 8416:
- case 8437:
- case 8547:
- case 8734:
- pinyin = "BI";
- break;
-
- case 5650:
- case 5945:
- case 6048:
- case 6677:
- case 6774:
- case 7134:
- case 7614:
- case 7652:
- case 7730:
- case 7760:
- case 8125:
- case 8159:
- case 8289:
- case 8354:
- case 8693:
- pinyin = "BIAN";
- break;
-
- case 7027:
- case 7084:
- case 7609:
- case 7613:
- case 7958:
- case 7980:
- case 8106:
- case 8149:
- case 8707:
- case 8752:
- pinyin = "BIAO";
- break;
-
- case 8531:
- pinyin = "BIE";
- break;
-
- case 5747:
- case 6557:
- case 7145:
- case 7167:
- case 7336:
- case 7375:
- case 7587:
- case 7957:
- case 8738:
- case 8762:
- pinyin = "BIN";
- break;
-
- case 5787:
- case 5891:
- case 6280:
- pinyin = "BING";
- break;
-
- case 5781:
- case 6403:
- case 6636:
- case 7362:
- case 7502:
- case 7771:
- case 7864:
- case 8030:
- case 8404:
- case 8543:
- case 8559:
- pinyin = "BO";
- break;
-
- case 6318:
- case 6945:
- case 7419:
- case 7446:
- case 7848:
- case 7863:
- case 8519:
- pinyin = "BU";
- break;
-
- case 6474:
- case 7769:
- pinyin = "CA";
- break;
- pinyin = "CAI";
- break;
-
- case 6978:
- case 7078:
- case 7218:
- case 8451:
- case 8785:
- pinyin = "CAN";
- break;
-
- case 5687:
- pinyin = "CANG";
- break;
-
- case 6448:
- case 6878:
- case 8309:
- case 8429:
- pinyin = "CAO";
- break;
-
- case 6692:
- pinyin = "CE";
- break;
-
- case 6515:
- case 6825:
- pinyin = "CEN";
- break;
-
- case 6465:
- pinyin = "CENG";
- break;
-
- case 6639:
- case 6766:
- case 7017:
- case 7230:
- case 7311:
- case 7322:
- case 7363:
- case 7942:
- case 7979:
- case 8135:
- pinyin = "CHA";
- break;
-
- case 5713:
- case 7846:
- case 8091:
- case 8218:
- pinyin = "CHAI";
- break;
-
- case 5770:
- case 5838:
- case 6159:
- case 6667:
- case 6893:
- case 6904:
- case 6981:
- case 7031:
- case 7086:
- case 7472:
- case 7688:
- case 7966:
- case 8324:
- case 8580:
- pinyin = "CHAN";
- break;
-
- case 5686:
- case 5943:
- case 6041:
- case 6137:
- case 6660:
- case 6568:
- case 6749:
- case 7029:
- case 7047:
- case 7438:
- case 7509:
- case 8680:
- pinyin = "CHANG";
- break;
-
- case 6687:
- case 7443:
- case 8173:
- pinyin = "CHAO";
- break;
-
- case 5969:
- case 7726:
- pinyin = "CHE";
- break;
-
- case 5840:
- case 5863:
- case 6251:
- case 6433:
- case 6923:
- case 7201:
- case 7320:
- case 7755:
- case 8619:
- pinyin = "CHEN";
- break;
-
- case 5609:
- case 5984:
- case 7239:
- case 7263:
- case 7583:
- case 7810:
- case 7881:
- case 7905:
- case 8146:
- case 8241:
- case 8508:
- pinyin = "CHENG";
- break;
-
- case 5749:
- case 6015:
- case 6061:
- case 6319:
- case 6374:
- case 6420:
- case 6445:
- case 6633:
- case 7042:
- case 7523:
- case 7787:
- case 8023:
- case 8101:
- case 8161:
- case 8231:
- case 8304:
- case 8355:
- case 8388:
- case 8489:
- case 8556:
- case 8746:
- pinyin = "CHI";
- break;
-
- case 6091:
- case 6671:
- case 6731:
- case 8409:
- case 8430:
- pinyin = "CHONG";
- break;
-
- case 5717:
- case 6492:
- case 6716:
- case 8112:
- case 8637:
- pinyin = "CHOU";
- break;
-
- case 5601:
- case 5927:
- case 6680:
- case 6732:
- case 7109:
- case 7238:
- case 7290:
- case 7343:
- case 8150:
- case 8260:
- case 8573:
- case 8777:
- pinyin = "CHU";
- break;
-
- case 6285:
- case 6408:
- case 7590:
- case 8563:
- pinyin = "CHUAI";
- break;
-
- case 6622:
- case 6955:
- case 7516:
- case 7843:
- case 8413:
- pinyin = "CHUAN";
- break;
-
- case 6675:
- pinyin = "CHUANG";
- break;
-
- case 5879:
- case 7302:
- case 7319:
- pinyin = "CHUI";
- break;
-
- case 6127:
- case 8040:
- case 8277:
- pinyin = "CHUN";
- break;
-
- case 7401:
- case 8554:
- case 8626:
- pinyin = "CHUO";
- break;
- pinyin = "CI";
- break;
-
- case 6075:
- case 6358:
- case 7684:
- case 8043:
- case 8457:
- pinyin = "4337 伺";
- break;
-
- case 6042:
- case 6840:
- case 7085:
- case 7193:
- case 7214:
- case 7240:
- pinyin = "CONG";
- break;
-
- case 7308:
- case 7403:
- case 7577:
- pinyin = "COU";
- break;
-
- case 6180:
- case 6562:
- case 6607:
- case 7367:
- case 8501:
- case 8530:
- case 8577:
- pinyin = "CU";
- break;
-
- case 5764:
- case 6305:
- case 7664:
- case 7973:
- pinyin = "CUAN";
- break;
-
- case 6718:
- case 6145:
- case 6393:
- case 7213:
- case 7333:
- case 7505:
- case 8631:
- pinyin = "CUI";
- break;
-
- case 6666:
- case 8169:
- pinyin = "CUN";
- break;
-
- case 5640:
- case 6547:
- case 7566:
- case 7917:
- case 7983:
- case 8078:
- case 8526:
- case 8567:
- pinyin = "CUO";
- break;
-
- case 6239:
- case 6353:
- case 6410:
- case 6682:
- case 7007:
- case 8155:
- case 8346:
- case 8716:
- case 8718:
- pinyin = "DA";
- break;
-
- case 6004:
- case 6316:
- case 6523:
- case 6942:
- case 7110:
- case 7173:
- case 8776:
- pinyin = "DAI";
- break;
-
- case 5757:
- case 6144:
- case 6402:
- case 7373:
- case 7470:
- case 7781:
- case 8067:
- case 8087:
- case 8185:
- case 8376:
- pinyin = "DAN";
- break;
-
- case 5852:
- case 5942:
- case 6148:
- case 6920:
- case 7724:
- case 7885:
- case 8141:
- pinyin = "DANG";
- break;
-
- case 6322:
- case 6665:
- case 7514:
- case 8478:
- pinyin = "DAO";
- break;
-
- case 7929:
- pinyin = "DE";
- break;
-
- case 6466:
- case 6556:
- case 7413:
- case 7767:
- case 7975:
- case 8403:
- pinyin = "DENG";
- break;
-
- case 5621:
- case 5765:
- case 5814:
- case 5848:
- case 5901:
- case 5970:
- case 6122:
- case 6454:
- case 7023:
- case 7116:
- case 7260:
- case 7306:
- case 7475:
- case 7738:
- case 7758:
- case 7791:
- case 7965:
- case 8438:
- case 8730:
- pinyin = "DI";
- break;
-
- case 6439:
- pinyin = "DIA";
- break;
-
- case 5871:
- case 5967:
- case 6559:
- case 7172:
- case 7868:
- case 8116:
- case 8118:
- case 8401:
- case 8558:
- pinyin = "DIAN";
- break;
-
- case 7886:
- case 8585:
- case 8684:
- pinyin = "DIAO";
- break;
-
- case 5976:
- case 6006:
- case 6273:
- case 6409:
- case 7526:
- case 8012:
- case 8183:
- case 8562:
- case 8688:
- pinyin = "DIE";
- break;
-
- case 5674:
- case 6404:
- case 7164:
- case 7575:
- case 7754:
- case 7814:
- case 8059:
- case 8184:
- case 8490:
- pinyin = "DING";
- break;
-
- case 7891:
- pinyin = "DIU";
- break;
-
- case 5977:
- case 6343:
- case 6520:
- case 6528:
- case 7517:
- case 7543:
- case 7556:
- case 7747:
- case 8020:
- pinyin = "DONG";
- break;
-
- case 6190:
- case 8128:
- case 8229:
- case 8391:
- pinyin = "DOU";
- break;
-
- case 6022:
- case 6429:
- case 6834:
- case 7292:
- case 7525:
- case 8328:
- case 8338:
- case 8739:
- case 8782:
- pinyin = "DU";
- break;
-
- case 7318:
- case 7649:
- case 8393:
- pinyin = "DUAN";
- break;
-
- case 7701:
- case 7713:
- case 7752:
- pinyin = "DUI";
- break;
-
- case 6771:
- case 7632:
- case 7727:
- case 7766:
- case 7779:
- case 7970:
- case 8527:
- pinyin = "DUN";
- break;
-
- case 6345:
- case 6365:
- case 6785:
- case 7122:
- case 7876:
- case 8154:
- case 8566:
- pinyin = "DUO";
- break;
-
- case 5612:
- case 5832:
- case 5844:
- case 5949:
- case 6035:
- case 6113:
- case 6164:
- case 6332:
- case 6721:
- case 6977:
- case 7025:
- case 7378:
- case 7581:
- case 7916:
- case 7941:
- case 8042:
- case 8206:
- case 8689:
- pinyin = "E";
- break;
-
- case 6176:
- case 6284:
- pinyin = "EN";
- break;
-
- case 5706:
- case 6939:
- case 7177:
- case 7879:
- case 8025:
- case 8660:
- pinyin = "ER";
- break;
-
- case 5950:
- case 7732:
- pinyin = "FA";
- break;
-
- case 6212:
- case 6232:
- case 6506:
- case 7283:
- case 7660:
- case 7818:
- case 8576:
- pinyin = "FAN";
- break;
-
- case 5890:
- case 7242:
- case 7853:
- case 8419:
- case 8648:
- pinyin = "FANG";
- break;
-
- case 6032:
- case 6584:
- case 6713:
- case 6839:
- case 6990:
- case 7119:
- case 7328:
- case 7572:
- case 7619:
- case 7673:
- case 7948:
- case 8082:
- case 8267:
- case 8385:
- case 8468:
- case 8613:
- case 8678:
- pinyin = "FEI";
- break;
-
- case 5739:
- case 6915:
- case 7291:
- case 8687:
- case 8787:
- pinyin = "FEN";
- break;
-
- case 5726:
- case 5926:
- case 6155:
- case 6384:
- case 6767:
- case 7731:
- pinyin = "FENG";
- break;
- pinyin = "FO";
- break;
-
- case 8330:
- pinyin = "FOU";
- break;
-
- case 5775:
- case 5776:
- case 5914:
- case 6029:
- case 6062:
- case 6119:
- case 6142:
- case 6252:
- case 6327:
- case 6505:
- case 6686:
- case 6870:
- case 6985:
- case 7058:
- case 7066:
- case 7106:
- case 7108:
- case 7285:
- case 7471:
- case 7680:
- case 7741:
- case 7774:
- case 7775:
- case 7823:
- case 7991:
- case 8005:
- case 8222:
- case 8261:
- case 8280:
- case 8283:
- case 8479:
- case 8535:
- case 8538:
- case 8654:
- case 8691:
- pinyin = "FU";
- break;
-
- case 6246:
- case 7056:
- case 7057:
- case 7424:
- case 7837:
- pinyin = " GA";
- break;
-
- case 5604:
- case 5875:
- case 5982:
- case 7414:
- case 7464:
- pinyin = "GAI";
- break;
-
- case 5965:
- case 6053:
- case 6247:
- case 6306:
- case 6779:
- case 6838:
- case 6887:
- case 7104:
- case 7347:
- case 7426:
- case 7723:
- case 8065:
- case 8491:
- pinyin = "GAN";
- break;
-
- case 7716:
- case 7824:
- case 8364:
- pinyin = "GANG";
- break;
-
- case 5626:
- case 5830:
- case 5912:
- case 6227:
- case 7141:
- case 7332:
- case 7334:
- case 7429:
- case 7915:
- pinyin = "GAO";
- break;
-
- case 5610:
- case 5678:
- case 5933:
- case 5957:
- case 6010:
- case 6435:
- case 7092:
- case 7501:
- case 7585:
- case 7749:
- case 7951:
- case 8143:
- case 8220:
- case 8420:
- case 8732:
- pinyin = "GE";
- break;
- pinyin = "GEI";
- break;
-
- case 5608:
- case 6102:
- case 6371:
- case 8462:
- pinyin = "GEN";
- break;
-
- case 6376:
- case 6657:
- case 7114:
- case 8665:
- pinyin = "GENG";
- break;
-
- case 7178:
- case 7537:
- case 8228:
- case 8601:
- pinyin = "GONG";
- break;
-
- case 5694:
- case 5824:
- case 6524:
- case 6960:
- case 7037:
- case 7135:
- case 7259:
- case 7477:
- case 7616:
- case 8349:
- case 8384:
- case 8724:
- pinyin = "GOU";
- break;
-
- case 5637:
- case 5812:
- case 6152:
- case 6536:
- case 6773:
- case 7284:
- case 7379:
- case 7484:
- case 7486:
- case 7591:
- case 7617:
- case 7813:
- case 7825:
- case 7860:
- case 7932:
- case 8019:
- case 8083:
- case 8233:
- case 8494:
- case 8593:
- case 8681:
- case 8729:
- pinyin = "GU";
- break;
-
- case 5652:
- case 5820:
- case 6341:
- case 7273:
- case 7550:
- case 8027:
- pinyin = "GUA";
- break;
- pinyin = "GUAI";
- break;
-
- case 5736:
- case 6124:
- case 6272:
- case 6842:
- case 7834:
- case 8057:
- case 8170:
- case 8704:
- pinyin = "GUAN";
- break;
-
- case 6359:
- case 6578:
- case 7270:
- case 7555:
- pinyin = "GUANG";
- break;
-
- case 5648:
- case 5659:
- case 6649:
- case 7003:
- case 7277:
- case 7433:
- case 7448:
- case 8007:
- case 8394:
- case 8657:
- case 8712:
- pinyin = "GUI";
- break;
-
- case 5782:
- case 7121:
- case 7762:
- case 8671:
- pinyin = "GUN";
- break;
-
- case 5769:
- case 6266:
- case 6335:
- case 6494:
- case 6538:
- case 6603:
- case 7304:
- case 7529:
- case 8188:
- case 8268:
- case 8269:
- pinyin = "GUO";
- break;
-
- case 7894:
- pinyin = "HA";
- break;
-
- case 6443:
- case 7560:
- case 8516:
- pinyin = "HAI";
- break;
-
- case 5885:
- case 6153:
- case 6294:
- case 6759:
- case 6911:
- case 7447:
- case 7642:
- case 8192:
- case 8205:
- case 8232:
- case 8793:
- pinyin = "HAN";
- break;
-
- case 6776:
- case 7112:
- case 8194:
- pinyin = "HANG";
- break;
-
- case 6179:
- case 6222:
- case 6438:
- case 6467:
- case 6909:
- case 6916:
- case 7427:
- case 8009:
- case 8211:
- case 8226:
- pinyin = "HAO";
- break;
-
- case 5813:
- case 5932:
- case 5954:
- case 6432:
- case 6756:
- case 7434:
- case 7833:
- case 8202:
- case 8234:
- case 8471:
- pinyin = "HE";
- break;
- pinyin = "HEI";
- break;
- pinyin = "HEN";
- break;
-
- case 6231:
- case 7181:
- case 7276:
- pinyin = "HENG";
- break;
-
- case 5768:
- case 5774:
- case 5807:
- case 6106:
- case 6214:
- case 6216:
- case 6740:
- case 6792:
- pinyin = "HONG";
- break;
-
- case 6009:
- case 6565:
- case 6943:
- case 8090:
- case 8383:
- case 8455:
- case 8655:
- case 8731:
- pinyin = "HOU";
- break;
-
- case 5792:
- case 6392:
- case 6481:
- case 6518:
- case 6609:
- case 6679:
- case 6717:
- case 6816:
- case 6879:
- case 7190:
- case 7346:
- case 7385:
- case 7618:
- case 7635:
- case 7646:
- case 7670:
- case 7672:
- case 7679:
- case 8013:
- case 8032:
- case 8041:
- case 8055:
- case 8343:
- case 8513:
- case 8590:
- pinyin = "HU";
- break;
-
- case 7072:
- case 7275:
- case 7725:
- case 7892:
- pinyin = "HUA";
- break;
-
- case 8555:
- pinyin = "HUAI";
- break;
-
- case 5928:
- case 6140:
- case 6307:
- case 6487:
- case 6621:
- case 6801:
- case 6829:
- case 6881:
- case 6930:
- case 6953:
- case 7157:
- case 7944:
- case 8673:
- case 8763:
- pinyin = "HUAN";
- break;
-
- case 5882:
- case 6569:
- case 6850:
- case 6874:
- case 6956:
- case 7211:
- case 7533:
- case 8105:
- case 8308:
- case 8382:
- case 8692:
- pinyin = "HUANG";
- break;
-
- case 5822:
- case 6078:
- case 6086:
- case 6205:
- case 6352:
- case 6360:
- case 6425:
- case 6736:
- case 6807:
- case 6811:
- case 6971:
- case 7132:
- case 7185:
- case 7445:
- case 7703:
- case 8219:
- case 8319:
- case 8766:
- pinyin = "HUI";
- break;
-
- case 5827:
- case 6638:
- case 6752:
- case 6867:
- pinyin = "HUN";
- break;
-
- case 5669:
- case 6229:
- case 6311:
- case 6475:
- case 6623:
- case 7856:
- case 7933:
- case 7976:
- case 8175:
- case 8322:
- pinyin = "HUO";
- break;
-
- case 5629:
- case 5632:
- case 5662:
- case 5705:
- case 5742:
- case 5952:
- case 6024:
- case 6033:
- case 6193:
- case 6210:
- case 6265:
- case 6320:
- case 6350:
- case 6383:
- case 6507:
- case 6553:
- case 6809:
- case 6976:
- case 7087:
- case 7160:
- case 7165:
- case 7314:
- case 7374:
- case 7410:
- case 7411:
- case 7469:
- case 7473:
- case 7487:
- case 7620:
- case 7722:
- case 7831:
- case 7990:
- case 8002:
- case 8104:
- case 8217:
- case 8337:
- case 8339:
- case 8463:
- case 8550:
- case 8611:
- case 8661:
- case 8674:
- case 8757:
- case 8768:
- pinyin = "JI";
- break;
-
- case 5704:
- case 5903:
- case 6171:
- case 6521:
- case 6804:
- case 6940:
- case 7176:
- case 7409:
- case 7546:
- case 7702:
- case 7882:
- case 7956:
- case 8072:
- case 8142:
- case 8244:
- case 8353:
- case 8434:
- case 8542:
- pinyin = "JIA";
- break;
-
- case 5752:
- case 5841:
- case 5857:
- case 6149:
- case 6183:
- case 6286:
- case 6853:
- case 6931:
- case 6932:
- case 7144:
- case 7237:
- case 7305:
- case 7407:
- case 7415:
- case 7480:
- case 7489:
- case 7506:
- case 7576:
- case 7790:
- case 7921:
- case 8047:
- case 8148:
- case 8340:
- case 8469:
- case 8534:
- case 8561:
- case 8668:
- case 8721:
- pinyin = "JIAN";
- break;
-
- case 6092:
- case 6814:
- case 7113:
- case 7154:
- case 7481:
- case 7768:
- case 8180:
- case 8461:
- case 8488:
- pinyin = "JIANG";
- break;
-
- case 5714:
- case 5753:
- case 6020:
- case 6090:
- case 6256:
- case 6461:
- case 6572:
- case 7015:
- case 7524:
- case 8008:
- case 8052:
- case 8252:
- case 8520:
- case 8551:
- case 8662:
- pinyin = "JIAO";
- break;
-
- case 5806:
- case 5821:
- case 6255:
- case 6414:
- case 7028:
- case 7061:
- case 7278:
- case 7757:
- case 8060:
- case 8201:
- case 8227:
- case 8441:
- case 8658:
- case 8726:
- pinyin = "JIE";
- break;
-
- case 5865:
- case 6103:
- case 6132:
- case 6468:
- case 6643:
- case 6659:
- case 7138:
- case 7210:
- case 7340:
- case 7465:
- case 7478:
- case 8138:
- pinyin = "JIN";
- break;
-
- case 5751:
- case 5869:
- case 6128:
- case 6616:
- case 6729:
- case 6794:
- case 6941:
- case 6982:
- case 7026:
- case 7534:
- case 7554:
- case 7570:
- case 7626:
- pinyin = "JIANG";
- break;
-
- case 6936:
- case 7671:
- pinyin = "JIONG";
- break;
-
- case 5754:
- case 6417:
- case 6746:
- case 7249:
- case 7274:
- case 8015:
- case 8053:
- case 8481:
- case 8761:
- pinyin = "JIU";
- break;
-
- case 5738:
- case 5810:
- case 6036:
- case 6058:
- case 6076:
- case 6268:
- case 6965:
- case 6980:
- case 7202:
- case 7307:
- case 7316:
- case 7323:
- case 7357:
- case 7381:
- case 7488:
- case 7611:
- case 7850:
- case 7924:
- case 8022:
- case 8132:
- case 8153:
- case 8482:
- case 8522:
- case 8565:
- case 8620:
- case 8634:
- case 8722:
- pinyin = "JU";
- break;
-
- case 5918:
- case 6590:
- case 6824:
- case 7280:
- case 7835:
- case 7935:
- case 7952:
- case 8633:
- pinyin = "JUAN";
- break;
-
- case 5642:
- case 5667:
- case 5860:
- case 5939:
- case 6207:
- case 6421:
- case 6457:
- case 6469:
- case 6540:
- case 6617:
- case 7062:
- case 7169:
- case 7286:
- case 7351:
- case 7663:
- case 7967:
- case 8574:
- case 8591:
- pinyin = "JUE";
- break;
-
- case 6260:
- case 8168:
- case 8362:
- case 8769:
- pinyin = "JUN";
- break;
-
- case 5671:
- case 6339:
- case 7544:
- pinyin = "KA";
- break;
-
- case 5660:
- case 5978:
- case 6160:
- case 6673:
- case 6693:
- case 7888:
- case 7920:
- case 7939:
- pinyin = "KAI";
- break;
-
- case 5709:
- case 6108:
- case 7412:
- case 7772:
- case 7811:
- pinyin = "KAN";
- break;
-
- case 5688:
- case 6742:
- case 7854:
- pinyin = "KANG";
- break;
-
- case 6974:
- case 7264:
- case 7491:
- case 7877:
- pinyin = "KAO";
- break;
-
- case 6430:
- case 6519:
- case 6701:
- case 6859:
- case 7076:
- case 7128:
- case 7170:
- case 7380:
- case 7520:
- case 7807:
- case 7861:
- case 7930:
- case 7993:
- case 8066:
- case 8129:
- case 8204:
- case 8282:
- case 8733:
- pinyin = "KE";
- break;
-
- case 8144:
- pinyin = "KEN";
- break;
-
- case 7912:
- pinyin = "KENG";
- break;
-
- case 5737:
- case 6539:
- case 8377:
- pinyin = "KONG";
- break;
-
- case 6050:
- case 6202:
- case 6321:
- case 7778:
- case 8356:
- pinyin = "KOU";
- break;
-
- case 5658:
- case 6005:
- case 6423:
- case 7111:
- case 8728:
- pinyin = "KU";
- break;
-
- case 5708:
- pinyin = "KUA";
- break;
-
- case 5665:
- case 5906:
- case 6364:
- case 6586:
- case 7558:
- pinyin = "KUAI";
- break;
-
- case 8737:
- pinyin = "KUAN";
- break;
-
- case 5818:
- case 5831:
- case 5887:
- case 5959:
- case 6237:
- case 6349:
- case 7094:
- case 7460:
- pinyin = "KUANG";
- break;
-
- case 5624:
- case 5649:
- case 5771:
- case 6162:
- case 6281:
- case 6413:
- case 6416:
- case 6720:
- case 6951:
- case 7450:
- case 7805:
- case 8606:
- case 8743:
- pinyin = "KUI";
- break;
-
- case 6204:
- case 6245:
- case 6458:
- case 6618:
- case 6928:
- case 7152:
- case 7841:
- case 8051:
- pinyin = "LIAO";
- break;
-
- case 5793:
- case 5988:
- case 6270:
- case 6354:
- case 6803:
- case 8483:
- case 8581:
- case 8764:
- pinyin = "LIE";
- break;
-
- case 6194:
- case 6388:
- case 6555:
- case 6662:
- case 6733:
- case 6964:
- case 7361:
- case 7405:
- case 7602:
- case 7812:
- case 8452:
- case 8579:
- case 8775:
- pinyin = "LIN";
- break;
-
- case 5925:
- case 6063:
- case 6342:
- case 6482:
- case 6786:
- case 7117:
- case 7258:
- case 7289:
- case 7418:
- case 8186:
- case 8240:
- case 8465:
- case 8676:
- pinyin = "LING";
- break;
-
- case 6815:
- case 6962:
- case 7082:
- case 7124:
- case 7628:
- case 7654:
- case 7919:
- case 7954:
- case 8050:
- case 8644:
- pinyin = "LIU";
- break;
-
- case 5966:
- case 6055:
- case 6781:
- case 7171:
- case 7248:
- case 7542:
- case 7735:
- case 8110:
- pinyin = "LONG";
- break;
-
- case 5745:
- case 6168:
- case 6422:
- case 6548:
- case 7946:
- case 8092:
- case 8179:
- case 8287:
- case 8735:
- pinyin = "LOU";
- break;
-
- case 6744:
- case 7321:
- case 7586:
- case 7918:
- case 7989:
- case 8158:
- pinyin = "Lü";
- break;
-
- case 5968:
- case 6303:
- case 6464:
- case 6782:
- case 6843:
- case 6885:
- case 6954:
- case 7220:
- case 7251:
- case 7354:
- case 7391:
- case 7404:
- case 7510:
- case 7545:
- case 7969:
- case 8021:
- case 8056:
- case 8392:
- case 8421:
- case 8652:
- pinyin = "LU";
- break;
-
- case 5785:
- case 7014:
- case 7279:
- case 8029:
- case 8639:
- pinyin = "LUAN";
- break;
- pinyin = "LǖE";
- break;
- pinyin = "LUN";
- break;
-
- case 5732:
- case 5789:
- case 6093:
- case 6259:
- case 6291:
- case 6604:
- case 6788:
- case 6880:
- case 7183:
- case 7301:
- case 7565:
- case 7961:
- case 8107:
- case 8635:
- pinyin = "LUO";
- break;
-
- case 6328:
- pinyin = "M";
- break;
-
- case 6373:
- case 6579:
- case 7054:
- case 7231:
- case 8301:
- pinyin = "MA";
- break;
-
- case 5929:
- case 6104:
- case 8618:
- pinyin = "MAI";
- break;
-
- case 6012:
- case 6503:
- case 7147:
- case 7655:
- case 7960:
- case 8209:
- case 8293:
- case 8709:
- case 8720:
- pinyin = "MAN";
- break;
-
- case 5888:
- case 6861:
- case 7743:
- case 8294:
- pinyin = "MANG";
- break;
-
- case 5783:
- case 6066:
- case 6525:
- case 6787:
- case 7203:
- case 7436:
- case 7483:
- case 7503:
- case 7624:
- case 7714:
- case 7806:
- case 8317:
- case 8754:
- pinyin = "MAO";
- break;
-
- case 6114:
- case 6550:
- case 6613:
- case 6828:
- case 6856:
- case 7325:
- case 7949:
- case 8044:
- case 8139:
- case 8740:
- pinyin = "MEI";
- break;
-
- case 6249:
- case 7643:
- case 7715:
- case 7845:
- pinyin = "MEN";
- break;
-
- case 5934:
- case 6189:
- case 6211:
- case 6734:
- case 7592:
- case 7770:
- case 8221:
- case 8276:
- case 8323:
- case 8427:
- case 8431:
- pinyin = "MENG";
- break;
-
- case 5634:
- case 5855:
- case 6234:
- case 6368:
- case 6455:
- case 6608:
- case 6772:
- case 6921:
- case 6984:
- case 7563:
- case 7682:
- case 8445:
- case 8767:
- case 8771:
- pinyin = "MI";
- break;
-
- case 6770:
- case 6837:
- case 6847:
- case 7579:
- case 7777:
- pinyin = "MIAN";
- break;
-
- case 6387:
- case 6967:
- case 7131:
- case 7149:
- case 7234:
- case 7721:
- case 7780:
- case 8037:
- pinyin = "MIAO";
- break;
-
- case 5631:
- case 6367:
- case 8326:
- case 8390:
- pinyin = "MIE";
- break;
-
- case 6069:
- case 6526:
- case 6741:
- case 6793:
- case 7137:
- case 7168:
- case 7175:
- case 7710:
- case 8710:
- case 8628:
- pinyin = "MIN";
- break;
-
- case 5804:
- case 6088:
- case 6873:
- case 7452:
- case 7808:
- case 8504:
- pinyin = "MING";
- break;
- pinyin = "MIU";
- break;
-
- case 5851:
- case 6052:
- case 6175:
- case 6641:
- case 7038:
- case 7366:
- case 7950:
- case 7987:
- case 8102:
- case 8182:
- case 8586:
- case 8588:
- case 8765:
- pinyin = "MO";
- break;
-
- case 5716:
- case 6372:
- case 7788:
- case 8254:
- case 8290:
- case 8642:
- pinyin = "MOU";
- break;
-
- case 5679:
- case 5973:
- case 6057:
- case 6769:
- case 7504:
- case 7866:
- pinyin = "MU";
- break;
-
- case 6437:
- pinyin = "N";
- break;
-
- case 6264:
- case 7539:
- case 7953:
- case 8136:
- pinyin = "NA";
- break;
-
- case 5630:
- case 6021:
- case 6133:
- case 7245:
- pinyin = "NAI";
- break;
-
- case 6411:
- case 6478:
- case 6479:
- case 7310:
- case 7578:
- case 8279:
- case 8486:
- pinyin = "NAN";
- break;
-
- case 6313:
- case 6476:
- case 6646:
- case 7457:
- pinyin = "NANG";
- break;
-
- case 5611:
- case 5981:
- case 6346:
- case 6614:
- case 7207:
- case 7748:
- case 7883:
- case 8245:
- pinyin = "NAO";
- break;
-
- case 5811:
- pinyin = "NE";
- break;
- pinyin = "NEI";
- break;
-
- case 7705:
- pinyin = "NEN";
- break;
- pinyin = "NENG";
- break;
-
- case 5703:
- case 5972:
- case 6605:
- case 6685:
- case 7439:
- case 7627:
- case 7711:
- case 7794:
- case 7874:
- case 8682:
- pinyin = "NI";
- break;
-
- case 5605:
- case 5994:
- case 7393:
- case 8004:
- case 8651:
- case 8683:
- pinyin = "NIAN";
- break;
- pinyin = "NIANG";
- break;
-
- case 6064:
- case 7053:
- case 7569:
- case 8433:
- pinyin = "NIAO";
- break;
-
- case 5877:
- case 6233:
- case 6431:
- case 8208:
- case 8411:
- case 8570:
- pinyin = "NIE";
- break;
- pinyin = "NIN";
- break;
-
- case 5690:
- case 6344:
- case 6924:
- case 8187:
- pinyin = "NING";
- break;
-
- case 6580:
- case 6678:
- case 7004:
- pinyin = "NIU";
- break;
-
- case 5715:
- case 6370:
- pinyin = "NONG";
- break;
-
- case 8181:
- pinyin = "NOU";
- break;
-
- case 6983:
- case 7032:
- case 7059:
- case 7069:
- pinyin = "NU";
- break;
-
- case 7704:
- case 7847:
- case 8412:
- pinyin = "Nǖ";
- break;
- pinyin = "NUAN";
- break;
- pinyin = "NUE";
- break;
-
- case 5748:
- case 6289:
- case 6386:
- case 7927:
- pinyin = "NUO";
- break;
-
- case 6424:
- case 6462:
- pinyin = "O";
- break;
-
- case 5809:
- case 6670:
- case 7417:
- case 8178:
- pinyin = "OU";
- break;
-
- case 6166:
- case 7243:
- case 8365:
- pinyin = "PA";
- break;
-
- case 5729:
- case 6169:
- case 6363:
- pinyin = "PAI";
- break;
-
- case 6761:
- case 6790:
- case 8140:
- case 8165:
- case 8320:
- case 8571:
- pinyin = "PAN";
- break;
-
- case 6561:
- case 6872:
- case 6944:
- case 8306:
- pinyin = "PANG";
- break;
-
- case 6243:
- case 6583:
- case 6650:
- case 7567:
- case 8069:
- pinyin = "PAO";
- break;
-
- case 6446:
- case 6490:
- case 7623:
- case 7934:
- case 8512:
- case 8612:
- pinyin = "PEI";
- break;
-
- case 6852:
- pinyin = "PEN";
- break;
-
- case 6001:
- case 6456:
- case 6681:
- case 8318:
- pinyin = "PENG";
- break;
-
- case 5607:
- case 5682:
- case 5880:
- case 5892:
- case 5915:
- case 5960:
- case 6017:
- case 6037:
- case 6308:
- case 6472:
- case 6647:
- case 6836:
- case 7039:
- case 7102:
- case 7233:
- case 7422:
- case 7802:
- case 7828:
- case 7875:
- case 8117:
- case 8166:
- case 8223:
- case 8271:
- case 8589:
- pinyin = "PI";
- break;
-
- case 5850:
- case 7073:
- case 7490:
- case 7561:
- case 8470:
- case 8568:
- pinyin = "PIAN";
- break;
-
- case 5666:
- case 6449:
- case 7046:
- case 7146:
- case 7372:
- case 7809:
- case 8310:
- pinyin = "PIAO";
- break;
-
- case 6054:
- case 7513:
- pinyin = "PIE";
- break;
-
- case 7041:
- case 6253:
- case 7016:
- case 7315:
- case 7482:
- case 8213:
- pinyin = "PIN";
- break;
-
- case 5723:
- case 7019:
- case 7250:
- case 8650:
- pinyin = "PING";
- break;
-
- case 5647:
- case 5922:
- case 7174:
- case 7839:
- case 7862:
- case 8011:
- case 8345:
- pinyin = "PO";
- break;
-
- case 5786:
- case 6269:
- pinyin = "POU";
- break;
-
- case 5773:
- case 6459:
- case 6863:
- case 6907:
- case 7217:
- case 7511:
- case 7968:
- case 7972:
- case 8575:
- pinyin = "PU";
- break;
-
- case 5633:
- case 5725:
- case 5963:
- case 6027:
- case 6046:
- case 6089:
- case 6129:
- case 6134:
- case 6161:
- case 6213:
- case 6366:
- case 6450:
- case 6508:
- case 6510:
- case 6764:
- case 6831:
- case 7075:
- case 7118:
- case 7187:
- case 7189:
- case 7229:
- case 7271:
- case 7342:
- case 7440:
- case 7605:
- case 7687:
- case 7712:
- case 7751:
- case 8193:
- case 8251:
- case 8264:
- case 8475:
- case 8476:
- case 8572:
- case 8702:
- case 8772:
- pinyin = "QI";
- break;
-
- case 6154:
- case 8736:
- pinyin = "QIA";
- break;
-
- case 5727:
- case 5761:
- case 5868:
- case 6023:
- case 6045:
- case 6071:
- case 6271:
- case 6509:
- case 6705:
- case 6727:
- case 6925:
- case 6926:
- case 6929:
- case 7155:
- case 7293:
- case 7541:
- case 7709:
- case 7852:
- case 8215:
- case 8373:
- pinyin = "QIAN";
- break;
-
- case 6762:
- case 7045:
- case 7341:
- case 7408:
- case 7633:
- case 7926:
- case 7947:
- case 7974:
- case 8163:
- case 8262:
- case 8439:
- case 8536:
- pinyin = "QIANG";
- break;
-
- case 5668:
- case 5829:
- case 5859:
- case 6081:
- case 6529:
- case 6724:
- case 6730:
- case 7352:
- case 7745:
- case 8546:
- case 8719:
- pinyin = "QIAO";
- break;
-
- case 5907:
- case 6711:
- case 7010:
- case 7492:
- case 7938:
- case 8370:
- pinyin = "QIE";
- break;
-
- case 6043:
- case 6276:
- case 6336:
- case 6426:
- case 6463:
- case 6858:
- case 7353:
- case 7923:
- case 8291:
- case 8432:
- pinyin = "QIN";
- break;
-
- case 6060:
- case 6485:
- case 7349:
- case 7764:
- case 8263:
- case 8332:
- case 8368:
- case 8605:
- case 8675:
- case 8784:
- pinyin = "QING";
- break;
-
- case 5886:
- case 6068:
- case 8123:
- case 8243:
- case 8344:
- case 8528:
- case 8638:
- pinyin = "QIONG";
- break;
-
- case 5720:
- case 5947:
- case 6576:
- case 6848:
- case 6947:
- case 6957:
- case 7317:
- case 7468:
- case 8216:
- case 8239:
- case 8288:
- case 8435:
- case 8460:
- case 8690:
- case 8792:
- pinyin = "QIU";
- break;
-
- case 5816:
- case 5930:
- case 6201:
- case 6230:
- case 6511:
- case 6573:
- case 6754:
- case 7219:
- case 7479:
- case 7512:
- case 7552:
- case 7678:
- case 7765:
- case 8119:
- case 8248:
- case 8329:
- case 8480:
- case 8636:
- case 8781:
- pinyin = "QU";
- break;
-
- case 5825:
- case 6085:
- case 6710:
- case 7125:
- case 7390:
- case 7816:
- case 7893:
- case 8273:
- case 8360:
- case 8760:
- pinyin = "QUAN";
- break;
-
- case 6755:
- case 6758:
- case 7708:
- pinyin = "QUE";
- break;
-
- case 6950:
- pinyin = "QUN";
- break;
-
- case 6059:
- case 8237:
- case 8755:
- pinyin = "RAN";
- break;
-
- case 7692:
- case 8006:
- pinyin = "RANG";
- break;
-
- case 6073:
- case 7012:
- case 7267:
- pinyin = "RAO";
- break;
- pinyin = "RE";
- break;
-
- case 5680:
- case 6083:
- case 6156:
- case 6631:
- case 7377:
- case 7994:
- case 8137:
- pinyin = "REN";
- break;
- pinyin = "RENG";
- break;
- pinyin = "RI";
- break;
-
- case 6541:
- case 6585:
- case 7337:
- case 7532:
- case 8278:
- pinyin = "RONG";
- break;
-
- case 8459:
- case 8569:
- case 8723:
- pinyin = "ROU";
- break;
-
- case 6174:
- case 6224:
- case 6473:
- case 6818:
- case 6865:
- case 6906:
- case 7140:
- case 7908:
- case 8164:
- case 8212:
- pinyin = "RU";
- break;
-
- case 7535:
- pinyin = "RUAN";
- break;
-
- case 6039:
- case 6208:
- case 7236:
- case 7803:
- case 8224:
- pinyin = "RUI";
- break;
- pinyin = "RUN";
- break;
-
- case 5728:
- case 8372:
- pinyin = "RUO";
- break;
-
- case 5606:
- case 5677:
- case 7493:
- case 7559:
- case 7610:
- pinyin = "SA";
- break;
-
- case 6471:
- pinyin = "SAI";
- break;
-
- case 6644:
- case 7507:
- case 8454:
- pinyin = "SAN";
- break;
-
- case 6290:
- case 7763:
- case 8210:
- pinyin = "SANG";
- break;
-
- case 6003:
- case 7150:
- case 7156:
- case 7593:
- case 8094:
- case 8694:
- pinyin = "SAO";
- break;
- pinyin = "SE";
- break;
- pinyin = "SEN";
- break;
- pinyin = "SENG";
- break;
-
- case 6394:
- case 7606:
- case 7901:
- case 8080:
- case 8436:
- case 8614:
- case 8672:
- pinyin = "SHA";
- break;
-
- case 8507:
- pinyin = "SHAI";
- break;
-
- case 5663:
- case 5808:
- case 5923:
- case 5979:
- case 6047:
- case 6890:
- case 7009:
- case 7051:
- case 7083:
- case 7594:
- case 7844:
- case 8062:
- case 8321:
- case 8414:
- case 8539:
- case 8713:
- pinyin = "SHAN";
- break;
-
- case 5980:
- case 7120:
- case 7368:
- case 7656:
- case 8592:
- pinyin = "SHANG";
- break;
-
- case 5931:
- case 6070:
- case 6891:
- case 7228:
- case 8366:
- case 8425:
- pinyin = "SHAO";
- break;
-
- case 5639:
- case 5760:
- case 6606:
- case 6860:
- case 7608:
- case 7820:
- case 8774:
- pinyin = "SHE";
- break;
-
- case 5837:
- case 6123:
- case 6351:
- case 6841:
- case 7309:
- case 7547:
- case 7982:
- case 8255:
- pinyin = "SHEN";
- break;
-
- case 6551:
- case 7441:
- case 7782:
- case 8347:
- pinyin = "SHENG";
- break;
-
- case 5854:
- case 5985:
- case 6110:
- case 6173:
- case 6317:
- case 7388:
- case 7459:
- case 7634:
- case 7870:
- case 8307:
- case 8334:
- case 8363:
- case 8525:
- case 8669:
- case 8685:
- pinyin = "SHI";
- break;
-
- case 6587:
- case 7123:
- case 8428:
- pinyin = "SHOU";
- break;
-
- case 5731:
- case 5951:
- case 6136:
- case 6283:
- case 6780:
- case 6888:
- case 7013:
- case 7508:
- case 7582:
- case 7988:
- pinyin = "SHU";
- break;
-
- case 6407:
- pinyin = "SHUA";
- break;
-
- case 8316:
- pinyin = "SHUAI";
- break;
-
- case 6737:
- case 6844:
- pinyin = "SHUAN";
- break;
-
- case 7055:
- pinyin = "SHUANG";
- break;
- pinyin = "SHUI";
- break;
- pinyin = "SHUN";
- break;
-
- case 6184:
- case 6287:
- case 6989:
- case 7335:
- case 7869:
- pinyin = "SHUO";
- break;
-
- case 5643:
- case 5778:
- case 5944:
- case 6348:
- case 6765:
- case 6784:
- case 6889:
- case 7006:
- case 7065:
- case 7133:
- case 7675:
- case 7940:
- case 8024:
- case 8174:
- case 8247:
- case 8351:
- pinyin = "SI";
- break;
-
- case 5801:
- case 6131:
- case 6534:
- case 6552:
- case 6676:
- case 6704:
- case 6833:
- case 8121:
- pinyin = "SONG";
- break;
-
- case 5937:
- case 6220:
- case 6418:
- case 6453:
- case 6640:
- case 6849:
- case 7612:
- case 7804:
- case 7943:
- case 8284:
- pinyin = "SOU";
- break;
-
- case 5777:
- case 5853:
- case 6188:
- case 6428:
- case 6726:
- case 6819:
- case 8389:
- case 8602:
- case 8653:
- pinyin = "SU";
- break;
-
- case 6601:
- pinyin = "SUAN";
- break;
-
- case 5839:
- case 6120:
- case 6901:
- case 6968:
- case 7661:
- case 7785:
- case 7801:
- pinyin = "SUI";
- break;
-
- case 6105:
- case 6588:
- case 6624:
- case 7330:
- case 8632:
- pinyin = "SUN";
- break;
-
- case 6379:
- case 6434:
- case 6442:
- case 7022:
- case 7288:
- case 7792:
- case 8440:
- pinyin = "SUO";
- break;
-
- case 6743:
- case 6866:
- case 6961:
- case 7329:
- case 7719:
- case 7872:
- case 8533:
- case 8703:
- pinyin = "TA";
- break;
-
- case 5902:
- case 6223:
- case 6330:
- case 7070:
- case 7536:
- case 7638:
- case 7849:
- case 8544:
- case 8656:
- pinyin = "TAI";
- break;
-
- case 5916:
- case 6903:
- case 7428:
- case 7694:
- case 7867:
- case 7936:
- case 8191:
- pinyin = "TAN";
- break;
-
- case 5746:
- case 6491:
- case 6871:
- case 7209:
- case 7344:
- case 7906:
- case 7959:
- case 8177:
- case 8305:
- case 8311:
- case 8442:
- case 8517:
- pinyin = "TANG";
- break;
-
- case 5627:
- case 6391:
- case 6812:
- case 7226:
- case 7666:
- pinyin = "TAO";
- break;
- pinyin = "1845 餐";
- break;
-
- case 6315:
- case 7693:
- case 7911:
- pinyin = "TE";
- break;
-
- case 7588:
- pinyin = "TENG";
- break;
-
- case 5735:
- case 6709:
- case 6949:
- case 7130:
- case 8035:
- case 8151:
- case 8514:
- pinyin = "TI";
- break;
-
- case 6261:
- case 6735:
- case 6757:
- case 7369:
- case 7817:
- pinyin = "TIAN";
- break;
-
- case 5712:
- case 7686:
- case 8127:
- case 8272:
- case 8352:
- case 8448:
- case 8622:
- case 8670:
- case 8756:
- pinyin = "TIAO";
- break;
-
- case 6138:
- case 8749:
- pinyin = "TIE";
- break;
-
- case 6080:
- case 6167:
- case 7035:
- case 7272:
- case 7890:
- case 8249:
- case 8610:
- pinyin = "TING";
- break;
-
- case 5701:
- case 5758:
- case 6077:
- case 6444:
- case 6690:
- case 6892:
- case 7737:
- pinyin = "TONG";
- break;
-
- case 7855:
- case 7822:
- case 8727:
- pinyin = "TOU";
- break;
-
- case 6002:
- case 6117:
- case 6143:
- case 7842:
- case 8509:
- pinyin = "TU";
- break;
-
- case 6250:
- case 6972:
- pinyin = "TUAN";
- break;
-
- case 7653:
- pinyin = "TUI";
- break;
-
- case 5759:
- case 6629:
- case 7453:
- case 7564:
- pinyin = "TUN";
- break;
-
- case 5617:
- case 5702:
- case 5971:
- case 6653:
- case 6791:
- case 7256:
- case 7262:
- case 7350:
- case 7740:
- case 8374:
- case 8502:
- case 8541:
- case 8630:
- pinyin = "TUO";
- break;
-
- case 5684:
- case 7020:
- case 7580:
- pinyin = "WA";
- break;
- pinyin = "WAI";
- break;
-
- case 5664:
- case 6025:
- case 6150:
- case 7093:
- case 7126:
- case 7194:
- case 7568:
- case 7821:
- case 8274:
- pinyin = "WAN";
- break;
-
- case 5672:
- case 6244:
- case 6715:
- case 7394:
- case 8745:
- pinyin = "WANG";
- break;
-
- case 5743:
- case 5835:
- case 5881:
- case 5883:
- case 6158:
- case 6217:
- case 6488:
- case 6501:
- case 6543:
- case 6545:
- case 6611:
- case 6612:
- case 6739:
- case 6777:
- case 6802:
- case 6822:
- case 6952:
- case 7024:
- case 7166:
- case 7224:
- case 7406:
- case 7631:
- case 7648:
- case 8084:
- case 8426:
- case 8659:
- pinyin = "WEI";
- break;
-
- case 5656:
- case 6751:
- case 6775:
- case 7223:
- case 8609:
- pinyin = "WEN";
- break;
-
- case 6178:
- case 6219:
- pinyin = "WENG";
- break;
-
- case 5733:
- case 6111:
- case 6502:
- case 6855:
- case 7531:
- case 7750:
- case 8627:
- pinyin = "WO";
- break;
-
- case 5603:
- case 5685:
- case 5867:
- case 5889:
- case 5956:
- case 6044:
- case 6377:
- case 6648:
- case 6668:
- case 6672:
- case 6820:
- case 6927:
- case 6935:
- case 6992:
- case 7036:
- case 7080:
- case 7227:
- case 7485:
- case 7641:
- case 8036:
- case 8045:
- case 8077:
- case 8258:
- case 8640:
- case 8789:
- pinyin = "WU";
- break;
-
- case 5750:
- case 5766:
- case 5884:
- case 5913:
- case 6130:
- case 6163:
- case 6191:
- case 6241:
- case 6381:
- case 6567:
- case 6630:
- case 6750:
- case 6827:
- case 6832:
- case 6979:
- case 7050:
- case 7184:
- case 7356:
- case 7456:
- case 7474:
- case 7604:
- case 7668:
- case 7689:
- case 7691:
- case 8010:
- case 8122:
- case 8265:
- case 8303:
- case 8312:
- case 8410:
- case 8424:
- case 8443:
- case 8449:
- case 8466:
- case 8521:
- case 8791:
- pinyin = "XI";
- break;
-
- case 6340:
- case 6582:
- case 6958:
- case 7206:
- case 7252:
- case 7744:
- case 8093:
- case 8333:
- case 8779:
- pinyin = "XIA";
- break;
-
- case 5794:
- case 5823:
- case 6040:
- case 6118:
- case 6226:
- case 6513:
- case 6593:
- case 6963:
- case 7021:
- case 7515:
- case 7662:
- case 7676:
- case 8034:
- case 8079:
- case 8225:
- case 8358:
- case 8444:
- case 8503:
- case 8548:
- case 8549:
- case 8617:
- pinyin = "XIAN";
- break;
-
- case 6028:
- case 6157:
- case 6635:
- case 6652:
- case 7088:
- case 7129:
- case 8313:
- case 8663:
- case 8747:
- pinyin = "XIANG";
- break;
-
- case 6356:
- case 6537:
- case 6876:
- case 6948:
- case 7071:
- case 7115:
- case 7241:
- case 7253:
- case 8257:
- case 8367:
- case 8379:
- case 8744:
- pinyin = "XIAO";
- break;
-
- case 5741:
- case 5784:
- case 5936:
- case 5938:
- case 6215:
- case 6302:
- case 6619:
- case 6661:
- case 6845:
- case 6912:
- case 6966:
- case 7105:
- case 7151:
- case 7331:
- case 7339:
- case 8583:
- pinyin = "XIE";
- break;
-
- case 5622:
- case 6016:
- case 7431:
- case 7607:
- case 8646:
- pinyin = "XIN";
- break;
-
- case 5874:
- case 6084:
- case 6309:
- case 6712:
- case 7742:
- pinyin = "XING";
- break;
-
- case 6026:
- pinyin = "XIONG";
- break;
-
- case 6361:
- case 6522:
- case 6642:
- case 6651:
- case 6869:
- case 8028:
- case 8587:
- case 8759:
- pinyin = "XIU";
- break;
-
- case 5828:
- case 5935:
- case 5955:
- case 6203:
- case 6810:
- case 6851:
- case 7179:
- case 7282:
- case 7667:
- case 7776:
- case 8167:
- case 8458:
- case 8515:
- pinyin = "XU";
- break;
-
- case 5756:
- case 5846:
- case 6170:
- case 6279:
- case 6789:
- case 6854:
- case 6886:
- case 7215:
- case 7324:
- case 7449:
- case 7637:
- case 7651:
- case 7759:
- case 7871:
- case 7964:
- case 8071:
- pinyin = "XUAN";
- break;
-
- case 5842:
- case 7720:
- case 8529:
- case 8708:
- pinyin = "XUE";
- break;
-
- case 5767:
- case 5908:
- case 5987:
- case 6087:
- case 6101:
- case 6206:
- case 6225:
- case 6530:
- case 6563:
- case 6620:
- case 6694:
- case 6813:
- case 6817:
- case 7454:
- case 8131:
- case 8524:
- case 8664:
- pinyin = "XUN";
- break;
-
- case 5683:
- case 5975:
- case 6275:
- case 6512:
- case 6934:
- case 7011:
- case 7180:
- case 7266:
- case 7518:
- case 7728:
- case 7793:
- case 8073:
- pinyin = "YA";
- break;
-
- case 5641:
- case 5645:
- case 5718:
- case 5740:
- case 5780:
- case 5861:
- case 5917:
- case 5919:
- case 6030:
- case 6146:
- case 6535:
- case 6691:
- case 6738:
- case 6753:
- case 6846:
- case 6857:
- case 6991:
- case 7044:
- case 7192:
- case 7360:
- case 7444:
- case 7557:
- case 7645:
- case 7827:
- case 8359:
- case 8506:
- case 8742:
- case 8748:
- case 8790:
- pinyin = "YAN";
- break;
-
- case 6564:
- case 6683:
- case 7630:
- case 7640:
- case 7706:
- case 8253:
- case 8717:
- pinyin = "YANG";
- break;
-
- case 5618:
- case 5619:
- case 6326:
- case 6542:
- case 6570:
- case 7159:
- case 7182:
- case 7235:
- case 7387:
- case 7455:
- case 7540:
- case 7902:
- case 8046:
- case 8126:
- case 8477:
- case 8705:
- pinyin = "YAO";
- break;
-
- case 5644:
- case 5843:
- case 5894:
- case 6262:
- case 7442:
- case 7639:
- case 7884:
- pinyin = "YE";
- break;
-
- case 5655:
- case 5657:
- case 5670:
- case 5693:
- case 5711:
- case 5817:
- case 5961:
- case 5992:
- case 6018:
- case 6051:
- case 6072:
- case 6218:
- case 6236:
- case 6240:
- case 6258:
- case 6314:
- case 6329:
- case 6355:
- case 6362:
- case 6441:
- case 6470:
- case 6527:
- case 6558:
- case 6602:
- case 6634:
- case 6688:
- case 6689:
- case 6708:
- case 6884:
- case 6938:
- case 7068:
- case 7143:
- case 7376:
- case 7383:
- case 7461:
- case 7629:
- case 7658:
- case 7784:
- case 7838:
- case 7955:
- case 7978:
- case 8074:
- case 8089:
- case 8115:
- case 8120:
- case 8270:
- case 8415:
- case 8464:
- case 8472:
- case 8493:
- case 8780:
- pinyin = "YI";
- break;
-
- case 5623:
- case 5920:
- case 5983:
- case 6007:
- case 6065:
- case 6337:
- case 6419:
- case 6594:
- case 6625:
- case 6806:
- case 7519:
- case 7887:
- case 8111:
- case 8230:
- case 8615:
- case 8624:
- pinyin = "YIN";
- break;
-
- case 5788:
- case 5911:
- case 6067:
- case 6094:
- case 6126:
- case 6151:
- case 6186:
- case 6292:
- case 6451:
- case 6663:
- case 6862:
- case 6875:
- case 6913:
- case 7188:
- case 7212:
- case 7326:
- case 7584:
- case 8048:
- case 8108:
- case 8203:
- case 8331:
- pinyin = "YING";
- break;
-
- case 6401:
- pinyin = "YO";
- break;
-
- case 5724:
- case 5953:
- case 6013:
- case 6415:
- case 6728:
- case 7163:
- case 7962:
- case 8014:
- case 8711:
- case 8751:
- pinyin = "YONG";
- break;
-
- case 5653:
- case 5692:
- case 5707:
- case 6112:
- case 6115:
- case 6121:
- case 6347:
- case 6483:
- case 6922:
- case 7254:
- case 7364:
- case 7527:
- case 7880:
- case 8064:
- case 8236:
- case 8242:
- case 8286:
- case 8647:
- case 8778:
- case 8788:
- pinyin = "YOU";
- break;
-
- case 5614:
- case 5625:
- case 5681:
- case 5722:
- case 5836:
- case 5845:
- case 6139:
- case 6187:
- case 6277:
- case 6484:
- case 6486:
- case 6546:
- case 6592:
- case 6632:
- case 6637:
- case 6655:
- case 6748:
- case 6987:
- case 6993:
- case 7005:
- case 7090:
- case 7204:
- case 7437:
- case 7476:
- case 7573:
- case 7603:
- case 7622:
- case 7647:
- case 7659:
- case 7718:
- case 7858:
- case 8033:
- case 8054:
- case 8085:
- case 8086:
- case 8130:
- case 8133:
- case 8266:
- case 8285:
- case 8336:
- case 8407:
- case 8408:
- case 8607:
- case 8625:
- pinyin = "YU";
- break;
-
- case 5989:
- case 6011:
- case 6282:
- case 6768:
- case 7034:
- case 7205:
- case 7358:
- case 7528:
- case 7783:
- case 8016:
- case 8302:
- case 8378:
- case 8629:
- pinyin = "YUAN";
- break;
-
- case 5763:
- case 6914:
- case 7348:
- case 7530:
- case 7865:
- pinyin = "YUE";
- break;
-
- case 5909:
- case 6031:
- case 6581:
- case 6702:
- case 6719:
- case 7101:
- case 7225:
- case 7370:
- case 7432:
- case 7521:
- case 7657:
- pinyin = "YUN";
- break;
-
- case 6257:
- case 6338:
- pinyin = "ZA";
- break;
-
- case 6544:
- case 7162:
- pinyin = "ZAI";
- break;
-
- case 7222:
- case 7435:
- case 8402:
- case 8456:
- case 8485:
- case 8641:
- pinyin = "ZAN";
- break;
-
- case 6242:
- case 7064:
- case 7416:
- pinyin = "ZANG";
- break;
-
- case 6380:
- pinyin = "ZAO";
- break;
-
- case 5638:
- case 8369:
- case 5651:
- case 6385:
- case 6493:
- case 6937:
- case 7430:
- case 8348:
- case 8423:
- pinyin = "ZE";
- break;
- pinyin = "ZEI";
- break;
-
- case 5858:
- pinyin = "ZEN";
- break;
-
- case 7153:
- case 7421:
- case 7832:
- case 7913:
- pinyin = "ZENG";
- break;
-
- case 6610:
- case 6274:
- case 6324:
- case 6369:
- case 6378:
- case 7736:
- case 8068:
- case 8238:
- case 8794:
- pinyin = "ZHA";
- break;
-
- case 7746:
- case 8109:
- pinyin = "ZHAI";
- break;
-
- case 5862:
- case 6288:
- case 7625:
- pinyin = "ZHAN";
- break;
-
- case 5675:
- case 5921:
- case 6504:
- case 6554:
- case 6615:
- case 7049:
- case 7216:
- case 8315:
- pinyin = "ZHANG";
- break;
-
- case 5815:
- case 7294:
- case 7840:
- case 8341:
- pinyin = "ZHAO";
- break;
-
- case 5856:
- case 6301:
- case 7247:
- case 7392:
- case 7761:
- case 8049:
- case 8162:
- case 8256:
- case 8487:
- pinyin = "ZHE";
- break;
-
- case 5958:
- case 6172:
- case 6805:
- case 7139:
- case 7269:
- case 7327:
- case 7384:
- case 7466:
- case 7551:
- case 7562:
- case 7685:
- case 7819:
- case 8001:
- case 8018:
- case 8380:
- pinyin = "ZHEN";
- break;
-
- case 5826:
- case 6531:
- case 6571:
- case 7859:
- case 7903:
- case 8361:
- pinyin = "ZHENG";
- break;
-
- case 5620:
- case 5876:
- case 5904:
- case 5990:
- case 6038:
- case 6293:
- case 6489:
- case 6669:
- case 6973:
- case 6975:
- case 7079:
- case 7246:
- case 7255:
- case 7257:
- case 7268:
- case 7382:
- case 7389:
- case 7462:
- case 7553:
- case 7589:
- case 7677:
- case 7683:
- case 7773:
- case 7984:
- case 8026:
- case 8075:
- case 8246:
- case 8474:
- case 8505:
- case 8537:
- case 8557:
- case 8560:
- case 8584:
- case 8603:
- pinyin = "ZHI";
- break;
-
- case 5803:
- case 7981:
- case 8314:
- case 8417:
- case 8564:
- pinyin = "ZHONG";
- break;
-
- case 6107:
- case 6390:
- case 7008:
- case 7091:
- case 7107:
- case 7548:
- case 7756:
- case 8406:
- case 8492:
- pinyin = "ZHOU";
- break;
-
- case 5689:
- case 5710:
- case 5905:
- case 6049:
- case 6079:
- case 6808:
- case 6830:
- case 6883:
- case 7244:
- case 7338:
- case 7345:
- case 7636:
- case 7889:
- case 8070:
- case 8081:
- case 8335:
- case 8371:
- case 8422:
- case 8467:
- case 8578:
- case 8770:
- pinyin = "ZHU";
- break;
- pinyin = "ZHUA";
- break;
- pinyin = "ZHUAI";
- break;
-
- case 6389:
- case 6645:
- case 8207:
- pinyin = "ZHUAN";
- break;
-
- case 5755:
- pinyin = "ZHUANG";
- break;
-
- case 6723:
- case 7077:
- case 7136:
- pinyin = "ZHUI";
- break;
-
- case 7538:
- case 8124:
- pinyin = "ZHUN";
- break;
-
- case 5730:
- case 5834:
- case 6310:
- case 6823:
- case 6835:
- case 6910:
- case 7644:
- case 7690:
- case 7729:
- case 7977:
- pinyin = "ZHUO";
- break;
-
- case 5849:
- case 6549:
- case 7002:
- case 7060:
- case 7127:
- case 7287:
- case 7402:
- case 7463:
- case 7707:
- case 7786:
- case 7937:
- case 7986:
- case 8172:
- case 8342:
- case 8450:
- case 8484:
- case 8594:
- case 8604:
- case 8623:
- case 8686:
- case 8758:
- pinyin = "ZI";
- break;
-
- case 5744:
- case 7574:
- case 8453:
- pinyin = "ZONG";
- break;
-
- case 5833:
- case 5878:
- case 5924:
- case 7067:
- case 8677:
- pinyin = "ZOU";
- break;
-
- case 5762:
- case 6147:
- case 7963:
- pinyin = "ZU";
- break;
-
- case 6312:
- case 7158:
- case 8582:
- pinyin = "ZUAN";
- break;
-
- case 6209:
- pinyin = "ZUI";
- break;
-
- case 6304:
- case 7355:
- case 8714:
- pinyin = "ZUN";
- break;
-
- case 5872:
- case 6382:
- case 6460:
- case 6684:
- case 7549:
- case 7681:
- pinyin = "ZUO";
- break;
-
- default:
- if (code >= 1601 && code <= 1602) {
- pinyin = "A";
- break;
- }
-
- if (code >= 1603 && code <= 1615) {
- pinyin = "AI";
- break;
- }
-
- if (code >= 1616 && code <= 1624) {
- pinyin = "AN";
- break;
- }
-
- if (code >= 1625 && code <= 1627) {
- pinyin = "ANG";
- break;
- }
-
- if (code >= 1628 && code <= 1636) {
- pinyin = "AO";
- break;
- }
-
- if (code >= 1637 && code <= 1654) {
- pinyin = "BA";
- break;
- }
-
- if (code >= 1655 && code <= 1662) {
- pinyin = "BAI";
- break;
- }
-
- if (code >= 1663 && code <= 1677) {
- pinyin = "BAN";
- break;
- }
-
- if (code >= 1678 && code <= 1689) {
- pinyin = "BANG";
- break;
- }
-
- if (code >= 1690 && code <= 1712) {
- pinyin = "BAO";
- break;
- }
-
- if (code >= 1713 && code <= 1727) {
- pinyin = "BEI";
- break;
- }
-
- if (code >= 1728 && code <= 1731) {
- pinyin = "BEN";
- break;
- }
-
- if (code >= 1732 && code <= 1737) {
- pinyin = "BENG";
- break;
- }
-
- if (code > 1738 && code <= 1761) {
- pinyin = "BI";
- break;
- }
-
- if (code >= 1762 && code <= 1773) {
- pinyin = "BIAN";
- break;
- }
-
- if (code >= 1774 && code <= 1777) {
- pinyin = "BIAO";
- break;
- }
-
- if (code >= 1778 && code <= 1781) {
- pinyin = "BIE";
- break;
- }
-
- if (code >= 1782 && code <= 1787) {
- pinyin = "BIN";
- break;
- }
-
- if (code >= 1788 && code <= 1794) {
- pinyin = "BING";
- break;
- }
-
- if (code >= 1801 && code <= 1802) {
- pinyin = "BING";
- break;
- }
-
- if (code >= 1803 && code <= 1821) {
- pinyin = "BO";
- break;
- }
-
- if (code >= 1822 && code <= 1832) {
- pinyin = "BU";
- break;
- }
-
- if (code == 1833) {
- pinyin = "CA";
- break;
- }
-
- if (code >= 1834 && code <= 1844) {
- pinyin = "CAI";
- break;
- }
-
- if (code >= 1845 && code <= 1851) {
- pinyin = "CAN";
- break;
- }
-
- if (code >= 1852 && code <= 1856) {
- pinyin = "CANG";
- break;
- }
-
- if (code >= 1857 && code <= 1861) {
- pinyin = "CAO";
- break;
- }
-
- if (code >= 1862 && code <= 1866) {
- pinyin = "CE";
- break;
- }
-
- if (code >= 1867 && code <= 1868) {
- pinyin = "CENG";
- break;
- }
-
- if (code >= 1869 && code <= 1879) {
- pinyin = "CHA";
- break;
- }
-
- if (code >= 1880 && code <= 1882) {
- pinyin = "CHAI";
- break;
- }
-
- if (code >= 1883 && code <= 1892) {
- pinyin = "CHAN";
- break;
- }
-
- if (code >= 1893 && code <= 1911) {
- pinyin = "CHANG";
- break;
- }
-
- if (code >= 1912 && code <= 1920) {
- pinyin = "CHAO";
- break;
- }
-
- if (code >= 1921 && code <= 1926) {
- pinyin = "CHE";
- break;
- }
-
- if (code >= 1927 && code <= 1936) {
- pinyin = "CHEN";
- break;
- }
-
- if (code >= 1937 && code <= 1951) {
- pinyin = "CHENG";
- break;
- }
-
- if (code >= 1952 && code <= 1967) {
- pinyin = "CHI";
- break;
- }
-
- if (code >= 1968 && code <= 1972) {
- pinyin = "CHONG";
- break;
- }
-
- if (code >= 1973 && code <= 1984) {
- pinyin = "CHOU";
- break;
- }
-
- if (code >= 1985 && code <= 2006) {
- pinyin = "CHU";
- break;
- }
-
- if (code == 2007) {
- pinyin = "CHUAI";
- break;
- }
-
- if (code >= 2008 && code <= 2014) {
- pinyin = "CHUAN";
- break;
- }
-
- if (code >= 2015 && code <= 2020) {
- pinyin = "CHUANG";
- break;
- }
-
- if (code >= 2021 && code <= 2025) {
- pinyin = "CHUI";
- break;
- }
-
- if (code >= 2026 && code <= 2032) {
- pinyin = "CHUN";
- break;
- }
-
- if (code >= 2033 && code <= 2034) {
- pinyin = "CHUO";
- break;
- }
-
- if (code >= 2035 && code <= 2046) {
- pinyin = "CI";
- break;
- }
-
- if (code >= 2047 && code <= 2052) {
- pinyin = "CONG";
- break;
- }
-
- if (code >= 2054 && code <= 2057) {
- pinyin = "CU";
- break;
- }
-
- if (code >= 2058 && code <= 2060) {
- pinyin = "CUAN";
- break;
- }
-
- if (code >= 2061 && code <= 2068) {
- pinyin = "CUI";
- break;
- }
-
- if (code >= 2069 && code <= 2071) {
- pinyin = "CUN";
- break;
- }
-
- if (code >= 2072 && code <= 2077) {
- pinyin = "CUO";
- break;
- }
-
- if (code >= 2078 && code <= 2083) {
- pinyin = "DA";
- break;
- }
-
- if (code >= 2084 && code <= 2094) {
- pinyin = "DAI";
- break;
- }
-
- if (code >= 2102 && code <= 2116) {
- pinyin = "DAN";
- break;
- }
-
- if (code >= 2117 && code <= 2121) {
- pinyin = "DANG";
- break;
- }
-
- if (code >= 2122 && code <= 2133) {
- pinyin = "DAO";
- break;
- }
-
- if (code >= 2134 && code <= 2136) {
- pinyin = "DE";
- break;
- }
-
- if (code >= 2137 && code <= 2143) {
- pinyin = "DENG";
- break;
- }
-
- if (code >= 2144 && code <= 2162) {
- pinyin = "DI";
- break;
- }
-
- if (code >= 2163 && code <= 2178) {
- pinyin = "DIAN";
- break;
- }
-
- if (code >= 2179 && code <= 2187) {
- pinyin = "DIAO";
- break;
- }
-
- if (code >= 2188 && code <= 2194) {
- pinyin = "DIE";
- break;
- }
-
- if (code >= 2201 && code <= 2209) {
- pinyin = "DING";
- break;
- }
-
- if (code == 2210) {
- pinyin = "DIU";
- break;
- }
-
- if (code >= 2211 && code <= 2220) {
- pinyin = "DONG";
- break;
- }
-
- if (code >= 2221 && code <= 2227) {
- pinyin = "DOU";
- break;
- }
-
- if (code >= 2228 && code <= 2242) {
- pinyin = "DU";
- break;
- }
-
- if (code >= 2243 && code <= 2248) {
- pinyin = "DUAN";
- break;
- }
-
- if (code >= 2249 && code <= 2252) {
- pinyin = "DUI";
- break;
- }
-
- if (code >= 2253 && code <= 2261) {
- pinyin = "DUN";
- break;
- }
-
- if (code >= 2262 && code <= 2273) {
- pinyin = "DUO";
- break;
- }
-
- if (code >= 2274 && code <= 2286) {
- pinyin = "E";
- break;
- }
-
- if (code == 2287) {
- pinyin = "EN";
- break;
- }
-
- if (code >= 2288 && code <= 2231) {
- pinyin = "ER";
- break;
- }
-
- if (code >= 2302 && code <= 2309) {
- pinyin = "FA";
- break;
- }
-
- if (code >= 2310 && code <= 2326) {
- pinyin = "FAN";
- break;
- }
-
- if (code >= 2327 && code <= 2337) {
- pinyin = "FANG";
- break;
- }
-
- if (code >= 2338 && code <= 2349) {
- pinyin = "FEI";
- break;
- }
-
- if (code >= 2350 && code <= 2364) {
- pinyin = "FEN";
- break;
- }
-
- if (code >= 2365 && code <= 2379) {
- pinyin = "FENG";
- break;
- }
-
- if (code == 2380) {
- pinyin = "FO";
- break;
- }
-
- if (code == 2381) {
- pinyin = "FOU";
- break;
- }
-
- if (code >= 2382 && code <= 2432) {
- pinyin = "FU";
- break;
- }
-
- if (code >= 2435 && code <= 2440) {
- pinyin = "GAI";
- break;
- }
-
- if (code >= 2441 && code <= 2451) {
- pinyin = "GAN";
- break;
- }
-
- if (code >= 2452 && code <= 2460) {
- pinyin = "GANG";
- break;
- }
-
- if (code >= 2461 && code <= 2470) {
- pinyin = "GAO";
- break;
- }
-
- if (code >= 2471 && code <= 2487) {
- pinyin = "GE";
- break;
- }
-
- if (code == 2488) {
- pinyin = "GEI";
- break;
- }
-
- if (code >= 2489 && code <= 2490) {
- pinyin = "GEN";
- break;
- }
-
- if (code >= 2491 && code <= 2503) {
- pinyin = "GENG";
- break;
- }
-
- if (code >= 2504 && code <= 2518) {
- pinyin = "GONG";
- break;
- }
-
- if (code >= 2519 && code <= 2527) {
- pinyin = "GOU";
- break;
- }
-
- if (code >= 2528 && code <= 2545) {
- pinyin = "GU";
- break;
- }
-
- if (code >= 2546 && code <= 2551) {
- pinyin = "GUA";
- break;
- }
-
- if (code >= 2552 && code <= 2554) {
- pinyin = "GUAI";
- break;
- }
-
- if (code >= 2555 && code <= 2565) {
- pinyin = "GUAN";
- break;
- }
-
- if (code >= 2566 && code <= 2568) {
- pinyin = "GUANG";
- break;
- }
-
- if (code >= 2569 && code <= 2584) {
- pinyin = "GUI";
- break;
- }
-
- if (code >= 2585 && code <= 2587) {
- pinyin = "GUN";
- break;
- }
-
- if (code >= 2588 && code <= 2593) {
- pinyin = "GUO";
- break;
- }
-
- if (code == 2594) {
- pinyin = "HA";
- break;
- }
-
- if (code >= 2601 && code <= 2607) {
- pinyin = "HAI";
- break;
- }
-
- if (code >= 2608 && code <= 2626) {
- pinyin = "HAN";
- break;
- }
-
- if (code >= 2627 && code <= 2629) {
- pinyin = "HANG";
- break;
- }
-
- if (code >= 2630 && code <= 2638) {
- pinyin = "HAO";
- break;
- }
-
- if (code >= 2639 && code <= 2656) {
- pinyin = "HE";
- break;
- }
-
- if (code >= 2657 && code <= 2658) {
- pinyin = "HEI";
- break;
- }
-
- if (code >= 2659 && code <= 2662) {
- pinyin = "HEN";
- break;
- }
-
- if (code >= 2663 && code <= 2667) {
- pinyin = "HENG";
- break;
- }
-
- if (code >= 2668 && code <= 2676) {
- pinyin = "HONG";
- break;
- }
-
- if (code >= 2677 && code <= 2683) {
- pinyin = "HOU";
- break;
- }
-
- if (code >= 2684 && code <= 2707) {
- pinyin = "HU";
- break;
- }
-
- if (code >= 2708 && code <= 2716) {
- pinyin = "HUA";
- break;
- }
-
- if (code >= 2717 && code <= 2721) {
- pinyin = "HUAI";
- break;
- }
-
- if (code >= 2722 && code <= 2735) {
- pinyin = "HUAN";
- break;
- }
-
- if (code >= 2736 && code <= 2749) {
- pinyin = "HUANG";
- break;
- }
-
- if (code >= 2750 && code <= 2770) {
- pinyin = "HUI";
- break;
- }
-
- if (code >= 2771 && code <= 2776) {
- pinyin = "HUN";
- break;
- }
-
- if (code >= 2777 && code <= 2786) {
- pinyin = "HUO";
- break;
- }
-
- if (code >= 2787 && code <= 2845) {
- pinyin = "JI";
- break;
- }
-
- if (code >= 2846 && code <= 2862) {
- pinyin = "JIA";
- break;
- }
-
- if (code >= 2863 && code <= 2908) {
- pinyin = "JIAN";
- break;
- }
-
- if (code >= 2909 && code <= 2921) {
- pinyin = "JIANG";
- break;
- }
-
- if (code >= 2922 && code <= 2949) {
- pinyin = "JIAO";
- break;
- }
-
- if (code >= 2950 && code <= 2976) {
- pinyin = "JIE";
- break;
- }
-
- if (code >= 2977 && code <= 3002) {
- pinyin = "JIN";
- break;
- }
-
- if (code >= 3003 && code <= 3027) {
- pinyin = "JING";
- break;
- }
-
- if (code >= 3028 && code <= 3029) {
- pinyin = "JIONG";
- break;
- }
-
- if (code >= 3030 && code <= 3046) {
- pinyin = "JIU";
- break;
- }
-
- if (code >= 3047 && code <= 3071) {
- pinyin = "JU";
- break;
- }
-
- if (code >= 3072 && code <= 3078) {
- pinyin = "JUAN";
- break;
- }
-
- if (code >= 3079 && code <= 3088) {
- pinyin = "JUE";
- break;
- }
-
- if (code >= 3089 && code <= 3105) {
- pinyin = "JUN";
- break;
- }
-
- if (code >= 3106 && code <= 3109) {
- pinyin = "KA";
- break;
- }
-
- if (code >= 3110 && code <= 3114) {
- pinyin = "KAI";
- break;
- }
-
- if (code >= 3115 && code <= 3120) {
- pinyin = "KAN";
- break;
- }
-
- if (code >= 3121 && code <= 3127) {
- pinyin = "KANG";
- break;
- }
-
- if (code >= 3128 && code <= 3131) {
- pinyin = "KAO";
- break;
- }
-
- if (code >= 3132 && code <= 3146) {
- pinyin = "KE";
- break;
- }
-
- if (code >= 3147 && code <= 3150) {
- pinyin = "KEN";
- break;
- }
-
- if (code >= 3151 && code <= 3152) {
- pinyin = "KENG";
- break;
- }
-
- if (code >= 3153 && code <= 3156) {
- pinyin = "KONG";
- break;
- }
-
- if (code >= 3157 && code <= 3160) {
- pinyin = "KOU";
- break;
- }
-
- if (code >= 3161 && code <= 3167) {
- pinyin = "KU";
- break;
- }
-
- if (code >= 3168 && code <= 3172) {
- pinyin = "KUA";
- break;
- }
-
- if (code >= 3173 && code <= 3176) {
- pinyin = "KUAI";
- break;
- }
-
- if (code >= 3177 && code <= 3178) {
- pinyin = "KUAN";
- break;
- }
-
- if (code >= 3179 && code <= 3186) {
- pinyin = "KUANG";
- break;
- }
-
- if (code >= 3187 && code <= 3203) {
- pinyin = "KUI";
- break;
- }
-
- if (code >= 3204 && code <= 3207) {
- pinyin = "KUN";
- break;
- }
-
- if (code >= 3208 && code <= 3211) {
- pinyin = "KUO";
- break;
- }
-
- if (code >= 3212 && code <= 3218) {
- pinyin = "LA";
- break;
- }
-
- if (code >= 3219 && code <= 3221) {
- pinyin = "LAI";
- break;
- }
-
- if (code >= 3222 && code <= 3236) {
- pinyin = "LAN";
- break;
- }
-
- if (code >= 3237 && code <= 3243) {
- pinyin = "LANG";
- break;
- }
-
- if (code >= 3244 && code <= 3252) {
- pinyin = "LAO";
- break;
- }
-
- if (code >= 3253 && code <= 3254) {
- pinyin = "LE";
- break;
- }
-
- if (code >= 3255 && code <= 3265) {
- pinyin = "LEI";
- break;
- }
-
- if (code >= 3266 && code <= 3268) {
- pinyin = "LENG";
- break;
- }
-
- if (code >= 3269 && code <= 3308) {
- pinyin = "LI";
- }
-
- if (code == 3309) {
- pinyin = "LIA";
- break;
- }
-
- if (code >= 3310 && code <= 3323) {
- pinyin = "LIAN";
- break;
- }
-
- if (code >= 3324 && code <= 3334) {
- pinyin = "LIANG";
- break;
- }
-
- if (code >= 3335 && code <= 3347) {
- pinyin = "LIAO";
- break;
- }
-
- if (code >= 3348 && code <= 3352) {
- pinyin = "LIE";
- break;
- }
-
- if (code >= 3353 && code <= 3363) {
- pinyin = "LIN";
- break;
- }
-
- if (code >= 3364 && code <= 3378) {
- pinyin = "LING";
- break;
- }
-
- if (code >= 3379 && code <= 3389) {
- pinyin = "LIU";
- break;
- }
-
- if (code >= 3390 && code <= 3404) {
- pinyin = "LONG";
- break;
- }
-
- if (code >= 3405 && code <= 3410) {
- pinyin = "LOU";
- break;
- }
-
- if (code >= 3411 && code <= 3444) {
- pinyin = "LU";
- break;
- }
-
- if (code >= 3445 && code <= 3450) {
- pinyin = "LUAN";
- break;
- }
-
- if (code >= 3451 && code <= 3452) {
- pinyin = "LUE";
- break;
- }
-
- if (code >= 3453 && code <= 3459) {
- pinyin = "LUN";
- break;
- }
-
- if (code >= 3460 && code <= 3471) {
- pinyin = "LUO";
- break;
- }
-
- if (code >= 3472 && code <= 3480) {
- pinyin = "MA";
- break;
- }
-
- if (code >= 3481 && code <= 3486) {
- pinyin = "MAI";
- break;
- }
-
- if (code >= 3487 && code <= 3501) {
- pinyin = "MAN";
- break;
- }
-
- if (code >= 3502 && code <= 3507) {
- pinyin = "MANG";
- break;
- }
-
- if (code >= 3508 && code <= 3519) {
- pinyin = "MAO";
- break;
- }
-
- if (code == 3520) {
- pinyin = "ME";
- break;
- }
-
- if (code >= 3521 && code <= 3536) {
- pinyin = "MEI";
- break;
- }
-
- if (code >= 3537 && code <= 3539) {
- pinyin = "MEN";
- break;
- }
-
- if (code >= 3540 && code <= 3547) {
- pinyin = "MENG";
- break;
- }
-
- if (code >= 3548 && code <= 3561) {
- pinyin = "MI";
- }
-
- if (code >= 3562 && code <= 3570) {
- pinyin = "MIAN";
- break;
- }
-
- if (code >= 3571 && code <= 3578) {
- pinyin = "MIAO";
- break;
- }
-
- if (code >= 3579 && code <= 3580) {
- pinyin = "MIE";
- break;
- }
-
- if (code >= 3581 && code <= 3586) {
- pinyin = "MIN";
- break;
- }
-
- if (code >= 3587 && code <= 3592) {
- pinyin = "MING";
- break;
- }
-
- if (code == 3593) {
- pinyin = "MIU";
- break;
- }
-
- if (code >= 3594 && code <= 3616) {
- pinyin = "MO";
- break;
- }
-
- if (code >= 3617 && code <= 3619) {
- pinyin = "MOU";
- break;
- }
-
- if (code >= 3620 && code <= 3634) {
- pinyin = "MU";
- break;
- }
-
- if (code >= 3635 && code <= 3641) {
- pinyin = "NA";
- break;
- }
-
- if (code >= 3642 && code <= 3646) {
- pinyin = "NAI";
- break;
- }
-
- if (code >= 3647 && code <= 3649) {
- pinyin = "NAN";
- break;
- }
-
- if (code == 3650) {
- pinyin = "NANG";
- break;
- }
-
- if (code >= 3651 && code <= 3655) {
- pinyin = "NAO";
- break;
- }
-
- if (code == 3656) {
- pinyin = "NE";
- break;
- }
-
- if (code >= 3657 && code <= 3658) {
- pinyin = "NEI";
- break;
- }
-
- if (code == 3659) {
- pinyin = "NEN";
- break;
- }
-
- if (code == 3660) {
- pinyin = "NENG";
- break;
- }
-
- if (code >= 3661 && code <= 3671) {
- pinyin = "NI";
- break;
- }
-
- if (code >= 3672 && code <= 3678) {
- pinyin = "NIAN";
- break;
- }
-
- if (code >= 3679 && code <= 3680) {
- pinyin = "NIANG";
- break;
- }
-
- if (code >= 3681 && code <= 3682) {
- pinyin = "NIAO";
- break;
- }
-
- if (code >= 3683 && code <= 3689) {
- pinyin = "NIE";
- break;
- }
-
- if (code == 3690) {
- pinyin = "NIN";
- break;
- }
-
- if (code >= 3691 && code <= 3702) {
- pinyin = "NING";
- break;
- }
-
- if (code >= 3703 && code <= 3706) {
- pinyin = "NIU";
- break;
- }
-
- if (code >= 3707 && code <= 3710) {
- pinyin = "NONG";
- break;
- }
-
- if (code >= 3711 && code <= 3714) {
- pinyin = "NU";
- break;
- }
-
- if (code == 3715) {
- pinyin = "NUAN";
- break;
- }
-
- if (code >= 3716 && code <= 3717) {
- pinyin = "NUE";
- break;
- }
-
- if (code >= 3718 && code <= 3721) {
- pinyin = "NUO";
- break;
- }
-
- if (code == 3722) {
- pinyin = "O";
- break;
- }
-
- if (code >= 3723 && code <= 3729) {
- pinyin = "OU";
- break;
- }
-
- if (code >= 3730 && code <= 3735) {
- pinyin = "PA";
- break;
- }
-
- if (code >= 3736 && code <= 3741) {
- pinyin = "PAI";
- break;
- }
-
- if (code >= 3742 && code <= 3749) {
- pinyin = "PAN";
- break;
- }
-
- if (code >= 3750 && code <= 3754) {
- pinyin = "PANG";
- break;
- }
-
- if (code >= 3755 && code <= 3761) {
- pinyin = "PAO";
- break;
- }
-
- if (code >= 3762 && code <= 3770) {
- pinyin = "PEI";
- break;
- }
-
- if (code >= 3771 && code <= 3772) {
- pinyin = "PEN";
- break;
- }
-
- if (code >= 3773 && code <= 3786) {
- pinyin = "PENG";
- break;
- }
-
- if (code >= 3787 && code <= 3809) {
- pinyin = "PI";
- break;
- }
-
- if (code >= 3810 && code <= 3813) {
- pinyin = "PIAN";
- break;
- }
-
- if (code >= 3814 && code <= 3817) {
- pinyin = "PIAO";
- break;
- }
-
- if (code >= 3818 && code <= 3819) {
- pinyin = "PIE";
- break;
- }
-
- if (code >= 3820 && code <= 3824) {
- pinyin = "PIN";
- break;
- }
-
- if (code >= 3825 && code <= 3833) {
- pinyin = "PING";
- break;
- }
-
- if (code >= 3834 && code <= 3841) {
- pinyin = "PO";
- break;
- }
-
- if (code == 3842) {
- pinyin = "POU";
- break;
- }
-
- if (code >= 3843 && code <= 3857) {
- pinyin = "PU";
- break;
- }
-
- if (code >= 3858 && code <= 3893) {
- pinyin = "QI";
- break;
- }
-
- if (code == 3894 || (code >= 3901 && code <= 3902)) {
- pinyin = "QIA";
- break;
- }
-
- if (code >= 3903 && code <= 3924) {
- pinyin = "QIAN";
- break;
- }
-
- if (code >= 3925 && code <= 3932) {
- pinyin = "QIANG";
- break;
- }
-
- if (code >= 3933 && code <= 3947) {
- pinyin = "QIAO";
- break;
- }
-
- if (code >= 3948 && code <= 3952) {
- pinyin = "QIE";
- break;
- }
-
- if (code >= 3953 && code <= 3963) {
- pinyin = "QIN";
- break;
- }
-
- if (code >= 3964 && code <= 3976) {
- pinyin = "QING";
- break;
- }
-
- if (code >= 3977 && code <= 3978) {
- pinyin = "QIONG";
- break;
- }
-
- if (code >= 3979 && code <= 3986) {
- pinyin = "QIU";
- break;
- }
-
- if (code >= 3987 && code <= 4005) {
- pinyin = "QU";
- break;
- }
-
- if (code >= 4006 && code <= 4016) {
- pinyin = "QUAN";
- break;
- }
-
- if (code >= 4017 && code <= 4024) {
- pinyin = "QUE";
- break;
- }
-
- if (code >= 4025 && code <= 4026) {
- pinyin = "QUN";
- break;
- }
-
- if (code >= 4027 && code <= 4030) {
- pinyin = "RAN";
- break;
- }
-
- if (code >= 4031 && code <= 4035) {
- pinyin = "RANG";
- }
-
- if (code >= 4036 && code <= 4038) {
- pinyin = "RAO";
- break;
- }
-
- if (code >= 4039 && code <= 4040) {
- pinyin = "RE";
- break;
- }
-
- if (code >= 4041 && code <= 4050) {
- pinyin = "REN";
- break;
- }
-
- if (code >= 4051 && code <= 4052) {
- pinyin = "RENG";
- break;
- }
-
- if (code == 4053) {
- pinyin = "RI";
- break;
- }
-
- if (code >= 4054 && code <= 4063) {
- pinyin = "RONG";
- break;
- }
-
- if (code >= 4064 && code <= 4066) {
- pinyin = "ROU";
- break;
- }
-
- if (code >= 4067 && code <= 4076) {
- pinyin = "RU";
- break;
- }
-
- if (code >= 4077 && code <= 4078) {
- pinyin = "RUAN";
- break;
- }
-
- if (code >= 4079 && code <= 4081) {
- pinyin = "RUI";
- break;
- }
-
- if (code >= 4082 && code <= 4083) {
- pinyin = "RUN";
- break;
- }
-
- if (code >= 4084 && code <= 4085) {
- pinyin = "RUO";
- break;
- }
-
- if (code >= 4086 && code <= 4088) {
- pinyin = "SA";
- break;
- }
-
- if (code >= 4089 && code <= 4092) {
- pinyin = "SAI";
- break;
- }
-
- if (code >= 4093 && code <= 4094) {
- pinyin = "SAN";
- break;
- }
-
- if (code >= 4101 && code <= 4102) {
- pinyin = "SAN";
- break;
- }
-
- if (code >= 4103 && code <= 4105) {
- pinyin = "SANG";
- break;
- }
-
- if (code >= 4106 && code <= 4109) {
- pinyin = "SAO";
- break;
- }
-
- if (code >= 4110 && code <= 4112) {
- pinyin = "SE";
- break;
- }
-
- if (code == 4113) {
- pinyin = "SEN";
- }
-
- if (code == 4114) {
- pinyin = "SENG";
- break;
- }
-
- if (code >= 4115 && code <= 4123) {
- pinyin = "SHA";
- break;
- }
-
- if (code >= 4124 && code <= 4125) {
- pinyin = "SHAI";
- break;
- }
-
- if (code >= 4126 && code <= 4141) {
- pinyin = "SHAN";
- break;
- }
-
- if (code >= 4142 && code <= 4149) {
- pinyin = "SHANG";
- break;
- }
-
- if (code >= 4150 && code <= 4160) {
- pinyin = "SHAO";
- break;
- }
-
- if (code >= 4161 && code <= 4172) {
- pinyin = "SHE";
- break;
- }
-
- if (code >= 4173 && code <= 4188) {
- pinyin = "SHEN";
- break;
- }
-
- if (code >= 4189 && code <= 4205) {
- pinyin = "SHENG";
- break;
- }
-
- if (code >= 4206 && code <= 4252) {
- pinyin = "SHI";
- break;
- }
-
- if (code >= 4253 && code <= 4262) {
- pinyin = "SHOU";
- break;
- }
-
- if (code >= 4263 && code <= 4301) {
- pinyin = "SHU";
- break;
- }
-
- if (code >= 4302 && code <= 4303) {
- pinyin = "SHUA";
- break;
- }
-
- if (code >= 4304 && code <= 4307) {
- pinyin = "SHUAI";
- break;
- }
-
- if (code >= 4308 && code <= 4309) {
- pinyin = "SHUAN";
- break;
- }
-
- if (code >= 4310 && code <= 4312) {
- pinyin = "SHUANG";
- break;
- }
-
- if (code >= 4313 && code <= 4316) {
- pinyin = "SHUI";
- break;
- }
-
- if (code >= 4317 && code <= 4320) {
- pinyin = "SHUN";
- break;
- }
-
- if (code >= 4321 && code <= 4324) {
- pinyin = "SHUO";
- break;
- }
-
- if (code >= 4325 && code <= 4340) {
- pinyin = "SI";
- break;
- }
-
- if (code >= 4341 && code <= 4348) {
- pinyin = "SONG";
- break;
- }
-
- if (code >= 4349 && code <= 4352) {
- pinyin = "SOU";
- break;
- }
-
- if (code >= 4353 && code <= 4364) {
- pinyin = "SU";
- break;
- }
-
- if (code >= 4365 && code <= 4367) {
- pinyin = "SUAN";
- break;
- }
-
- if (code >= 4368 && code <= 4378) {
- pinyin = "SUI";
- break;
- }
-
- if (code >= 4379 && code <= 4381) {
- pinyin = "SUN";
- break;
- }
-
- if (code >= 4382 && code <= 4389) {
- pinyin = "SUO";
- break;
- }
-
- if (code >= 4390 && code <= 4404) {
- pinyin = "TA";
- break;
- }
-
- if (code >= 4405 && code <= 4413) {
- pinyin = "TAI";
- break;
- }
-
- if (code >= 4414 && code <= 4431) {
- pinyin = "TAN";
- break;
- }
-
- if (code >= 4432 && code <= 4444) {
- pinyin = "TANG";
- break;
- }
-
- if (code >= 4445 && code <= 4455) {
- pinyin = "TAO";
- break;
- }
-
- if (code == 4456) {
- pinyin = "TE";
- break;
- }
-
- if (code >= 4457 && code <= 4460) {
- pinyin = "TENG";
- break;
- }
-
- if (code >= 4461 && code <= 4475) {
- pinyin = "TI";
- break;
- }
-
- if (code >= 4476 && code <= 4483) {
- pinyin = "TIAN";
- break;
- }
-
- if (code >= 4484 && code <= 4488) {
- pinyin = "TIAO";
- break;
- }
-
- if (code >= 4489 && code <= 4491) {
- pinyin = "TIE";
- break;
- }
-
- if (code >= 4492 && code <= 4507) {
- pinyin = "TING";
- break;
- }
-
- if (code >= 4508 && code <= 4520) {
- pinyin = "TONG";
- break;
- }
-
- if (code >= 4521 && code <= 4524) {
- pinyin = "TOU";
- break;
- }
-
- if (code >= 4525 && code <= 4535) {
- pinyin = "TU";
- break;
- }
-
- if (code >= 4536 && code <= 4537) {
- pinyin = "TUAN";
- break;
- }
-
- if (code >= 4538 && code <= 4543) {
- pinyin = "TUI";
- break;
- }
-
- if (code >= 4544 && code <= 4546) {
- pinyin = "TUN";
- break;
- }
-
- if (code >= 4547 && code <= 4557) {
- pinyin = "TUO";
- break;
- }
-
- if (code >= 4558 && code <= 4564) {
- pinyin = "WA";
- break;
- }
-
- if (code >= 4565 && code <= 4566) {
- pinyin = "WAI";
- break;
- }
-
- if (code >= 4567 && code <= 4583) {
- pinyin = "WAN";
- break;
- }
-
- if (code >= 4584 && code <= 4593) {
- pinyin = "WANG";
- break;
- }
-
- if (code >= 4594 && code <= 4632) {
- pinyin = "WEI";
- break;
- }
-
- if (code >= 4633 && code <= 4642) {
- pinyin = "WEN";
- break;
- }
-
- if (code >= 4643 && code <= 4645) {
- pinyin = "WENG";
- break;
- }
-
- if (code >= 4646 && code <= 4654) {
- pinyin = "WO";
- break;
- }
-
- if (code >= 4655 && code <= 4683) {
- pinyin = "WU";
- break;
- }
-
- if (code >= 4684 && code <= 4724) {
- pinyin = "XI";
- break;
- }
-
- if (code >= 4725 && code <= 4737) {
- pinyin = "XIA";
- break;
- }
-
- if (code >= 4738 && code <= 4763) {
- pinyin = "XIAN";
- break;
- }
-
- if (code >= 4764 && code <= 4783) {
- pinyin = "XIANG";
- break;
- }
-
- if (code >= 4784 && code <= 4807) {
- pinyin = "XIAO";
- break;
- }
-
- if (code >= 4809 && code <= 4828) {
- pinyin = "XIE";
- break;
- }
-
- if (code >= 4829 && code <= 4838) {
- pinyin = "XIN";
- break;
- }
-
- if (code >= 4839 && code <= 4853) {
- pinyin = "XING";
- break;
- }
-
- if (code >= 4854 && code <= 4860) {
- pinyin = "XIONG";
- break;
- }
-
- if (code >= 4861 && code <= 4869) {
- pinyin = "XIU";
- break;
- }
-
- if (code >= 4870 && code <= 4888) {
- pinyin = "XU";
- break;
- }
-
- if (code >= 4889 && code <= 4904) {
- pinyin = "XUAN";
- break;
- }
-
- if (code >= 4905 && code <= 4910) {
- pinyin = "XUE";
- break;
- }
-
- if (code >= 4911 && code <= 4924) {
- pinyin = "XUN";
- break;
- }
-
- if (code >= 4925 && code <= 4940) {
- pinyin = "YA";
- break;
- }
-
- if (code >= 4941 && code <= 4973) {
- pinyin = "YAN";
- break;
- }
-
- if (code >= 4974 && code <= 4990) {
- pinyin = "YANG";
- break;
- }
-
- if (code >= 4991 && code <= 5011) {
- pinyin = "YAO";
- break;
- }
-
- if (code >= 5012 && code <= 5026) {
- pinyin = "YE";
- break;
- }
-
- if (code >= 5027 && code <= 5079) {
- pinyin = "YI";
- break;
- }
-
- if (code >= 5080 && code <= 5101) {
- pinyin = "YIN";
- break;
- }
-
- if (code >= 5102 && code <= 5119) {
- pinyin = "YING";
- break;
- }
-
- if (code == 5120) {
- pinyin = "YO";
- break;
- }
-
- if (code >= 5121 && code <= 5135) {
- pinyin = "YONG";
- break;
- }
-
- if (code >= 5136 && code <= 5155) {
- pinyin = "YOU";
- break;
- }
-
- if (code >= 5156 && code <= 5206) {
- pinyin = "YU";
- break;
- }
-
- if (code >= 5207 && code <= 5226) {
- pinyin = "YUAN";
- break;
- }
-
- if (code >= 5227 && code <= 5236) {
- pinyin = "YUE";
- break;
- }
-
- if (code >= 5237 && code <= 5248) {
- pinyin = "YUN";
- break;
- }
-
- if (code >= 5249 && code <= 5251) {
- pinyin = "ZA";
- break;
- }
-
- if (code >= 5252 && code <= 5258) {
- pinyin = "ZAI";
- break;
- }
-
- if (code >= 5259 && code <= 5262) {
- pinyin = "ZAN";
- break;
- }
-
- if (code >= 5263 && code <= 5265) {
- pinyin = "ZANG";
- break;
- }
-
- if (code >= 5266 && code <= 5279) {
- pinyin = "ZAO";
- break;
- }
-
- if (code >= 5280 && code <= 5283) {
- pinyin = "ZE";
- break;
- }
-
- if (code == 5284) {
- pinyin = "ZEI";
- break;
- }
-
- if (code == 5285) {
- pinyin = "ZEN";
- break;
- }
-
- if (code >= 5286 && code <= 5289) {
- pinyin = "ZENG";
- break;
- }
-
- if (code >= 5290 && code <= 5309) {
- pinyin = "ZHA";
- break;
- }
-
- if (code >= 5310 && code <= 5315) {
- pinyin = "ZHAI";
- break;
- }
-
- if (code >= 5316 && code <= 5332) {
- pinyin = "ZHAN";
- break;
- }
-
- if (code >= 5333 && code <= 5347) {
- pinyin = "ZHANG";
- break;
- }
-
- if (code >= 5348 && code <= 5357) {
- pinyin = "ZHAO";
- break;
- }
-
- if (code >= 5358 && code <= 5367) {
- pinyin = "ZHE";
- break;
- }
-
- if (code >= 5368 && code <= 5383) {
- pinyin = "ZHEN";
- break;
- }
-
- if (code >= 5384 && code <= 5404) {
- pinyin = "ZHENG";
- break;
- }
-
- if (code >= 5405 && code <= 5447) {
- pinyin = "ZHI";
- break;
- }
-
- if (code >= 5448 && code <= 5458) {
- pinyin = "ZHONG";
- break;
- }
-
- if (code >= 5459 && code <= 5472) {
- pinyin = "ZHOU";
- break;
- }
-
- if (code >= 5473 && code <= 5504) {
- pinyin = "ZHU";
- break;
- }
-
- if (code >= 5505 && code <= 5506) {
- pinyin = "ZHUA";
- break;
- }
-
- if (code == 5507) {
- pinyin = "ZHUAI";
- break;
- }
-
- if (code >= 5508 && code <= 5513) {
- pinyin = "ZHUAN";
- break;
- }
-
- if (code >= 5514 && code <= 5520) {
- pinyin = "ZHUANG";
- break;
- }
-
- if (code >= 5521 && code <= 5526) {
- pinyin = "ZHUI";
- break;
- }
-
- if (code >= 5527 && code <= 5528) {
- pinyin = "ZHUN";
- break;
- }
-
- if (code >= 5529 && code <= 5539) {
- pinyin = "ZHUO";
- break;
- }
-
- if (code >= 5540 && code <= 5554) {
- pinyin = "ZI";
- break;
- }
-
- if (code >= 5555 && code <= 5561) {
- pinyin = "ZONG";
- break;
- }
-
- if (code >= 5562 && code <= 5565) {
- pinyin = "ZOU";
- break;
- }
-
- if (code >= 5566 && code <= 5573) {
- pinyin = "ZU";
- break;
- }
-
- if (code >= 5574 && code <= 5575) {
- pinyin = "ZUAN";
- break;
- }
-
- if (code >= 5576 && code <= 5579) {
- pinyin = "ZUI";
- break;
- }
-
- if (code >= 5580 && code <= 5581) {
- pinyin = "ZUN";
- break;
- }
-
- if (code >= 5582 && code <= 5589) {
- pinyin = "ZUO";
- break;
- }
- }
-
- if (pinyin.isEmpty()) {
- pinyin = " ";
- }
-
- return pinyin;
-}
-
diff --git a/src/BackProcess/Interface/ukui_chineseletter.h b/src/BackProcess/Interface/ukui_chineseletter.h
deleted file mode 100644
index 6b4d501..0000000
--- a/src/BackProcess/Interface/ukui_chineseletter.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef UKUICHINESELETTER_H
-#define UKUICHINESELETTER_H
-#include
-
-
-class UkuiChineseLetter
-{
-public:
- UkuiChineseLetter();
- static bool In(wchar_t start, wchar_t end, wchar_t code);
-
- static char Convert(int n);
-
- // 获取第一个汉字的首字母
- static QString getFirstLetter(const QString &src);
-
- // 获取所有汉字的首字母
- static QString getFirstLetters(const QString &src);
-
- static QString getFirstLettersAll(const QString &src);
-
- // 获取一个汉字编码的汉语拼音
- static QString getPinyin(int code);
-
- // 获取所有汉字的汉语拼音
- static QString getPinyins(const QString &text);
-};
-
-#endif // UKUICHINESELETTER_H
diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp
deleted file mode 100644
index d7438fb..0000000
--- a/src/BackProcess/Interface/ukuimenuinterface.cpp
+++ /dev/null
@@ -1,1655 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#include "ukuimenuinterface.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "ukui_chineseletter.h"
-
-UkuiMenuInterface::UkuiMenuInterface()
-{
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- } else {
- QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini";
- setting = new QSettings(path, QSettings::IniFormat);
- QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini";
- syssetting = new QSettings(syspath, QSettings::IniFormat);
- }
-}
-
-QVector UkuiMenuInterface::appInfoVector = QVector();
-QVector UkuiMenuInterface::desktopfpVector = QVector();
-QVector UkuiMenuInterface::collectAppVector = QVector();
-QVector UkuiMenuInterface::alphabeticVector = QVector();
-QVector UkuiMenuInterface::functionalVector = QVector();
-QVector UkuiMenuInterface::allAppVector = QVector();
-QStringList UkuiMenuInterface::androidDesktopfnList = QStringList();
-QVector UkuiMenuInterface::tencentInitVector = QVector();
-QVector UkuiMenuInterface::customizedVector = QVector();
-QVector UkuiMenuInterface::thirdPartyVector = QVector();
-QVector UkuiMenuInterface::applicationVector = QVector();
-
-UkuiMenuInterface::~UkuiMenuInterface()
-{
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- } else {
- if (setting) {
- delete setting;
- }
-
- if (syssetting) {
- delete syssetting;
- }
-
- setting = nullptr;
- syssetting = nullptr;
- }
-}
-
-QStringList UkuiMenuInterface::getFunctionClassName()
-{
- QStringList functionList;
- functionList.append(QObject::tr("Office"));
- functionList.append(QObject::tr("Development"));
- functionList.append(QObject::tr("Image"));
- functionList.append(QObject::tr("Video"));
- functionList.append(QObject::tr("Internet"));
- functionList.append(QObject::tr("Game"));
- functionList.append(QObject::tr("Education"));
- functionList.append(QObject::tr("Social"));
- functionList.append(QObject::tr("System"));
- functionList.append(QObject::tr("Safe"));
- functionList.append(QObject::tr("Others"));
- return functionList;
-}
-//文件递归查询
-void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath)
-{
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- QDir dir(_filePath);
-
- if (!dir.exists()) {
- return;
- }
-
- dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
- dir.setSorting(QDir::DirsFirst);
- QFileInfoList list = dir.entryInfoList();
-
- if (list.size() < 1) {
- return;
- }
-
- int i = 0;
-
- //递归算法的核心部分
- do {
- QFileInfo fileInfo = list.at(i);
- //如果是文件夹,递归
- bool isDir = fileInfo.isDir();
-
- if (isDir) {
- recursiveSearchFile(fileInfo.filePath());
- } else {
- //过滤后缀不是.desktop的文件
- QString filePathStr = fileInfo.filePath();
-
- if (!filePathStr.endsWith(".desktop")) {
- i++;
- continue;
- }
-
- QByteArray fpbyte = filePathStr.toLocal8Bit();
- char *filepath = fpbyte.data();
-
- if (0 != access(filepath, R_OK)) { //判断文件是否可读
- i++;
- continue;
- }
-
- keyfile = g_key_file_new();
-
- if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) {
- return;
- }
-
- char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr);
-
- if (ret_1 != nullptr) {
- QString str = QString::fromLocal8Bit(ret_1);
-
- if (str.contains("true")) {
- g_key_file_free(keyfile);
- i++;
- continue;
- }
- }
-
- char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr);
-
- if (ret_2 != nullptr) {
- QString str = QString::fromLocal8Bit(ret_2);
-
- if (str.contains("UKUI")) {
- g_key_file_free(keyfile);
- i++;
- continue;
- }
- }
-
- //过滤LXQt、KDE
- char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr);
-
- if (ret != nullptr) {
- QString str = QString::fromLocal8Bit(ret);
-
- if (str.contains("LXQt") || str.contains("KDE")) {
- g_key_file_free(keyfile);
- i++;
- continue;
- }
- }
-
- g_key_file_free(keyfile);
- m_filePathList.append(filePathStr);
- }
-
- i++;
- } while (i < list.size());
- } else {
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QDir dir(_filePath);
-
- if (!dir.exists()) {
- return;
- }
-
- dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
- dir.setSorting(QDir::DirsFirst);
- QFileInfoList list = dir.entryInfoList();
- list.removeAll(QFileInfo("/usr/share/applications/screensavers"));
-
- if (list.size() < 1) {
- return;
- }
-
- int i = 0;
-
- //递归算法的核心部分
- do {
- QFileInfo fileInfo = list.at(i);
- //如果是文件夹,递归
- bool isDir = fileInfo.isDir();
-
- if (isDir) {
- recursiveSearchFile(fileInfo.filePath());
- } else {
- //过滤后缀不是.desktop的文件
- QString filePathStr = fileInfo.filePath();
-
- if (!filePathStr.endsWith(".desktop")) {
- i++;
- continue;
- }
-
- QByteArray fpbyte = filePathStr.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr);
-
- if (ret_1 != nullptr) {
- QString str = QString::fromLocal8Bit(ret_1);
-
- if (str.contains("true")) {
- i++;
- continue;
- }
- }
-
- char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr);
-
- if (ret_2 != nullptr) {
- QString str = QString::fromLocal8Bit(ret_2);
-
- if (str.contains("UKUI")) {
- i++;
- continue;
- }
- }
-
- //过滤LXQt、KDE
- char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr);
-
- if (ret != nullptr) {
- QString str = QString::fromLocal8Bit(ret);
-
- if (str.contains("LXQt") || str.contains("KDE")) {
- i++;
- continue;
- }
- }
-
- //过滤中英文名为空的情况
- QLocale cn;
- QString language = cn.languageToString(cn.language());
-
- if (QString::compare(language, "Chinese") == 0) {
- char *nameCh = g_key_file_get_string(keyfile, "Desktop Entry", "Name[zh_CN]", nullptr);
- char *nameEn = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr);
-
- if (QString::fromLocal8Bit(nameCh).isEmpty() && QString::fromLocal8Bit(nameEn).isEmpty()) {
- i++;
- continue;
- }
- } else {
- char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr);
-
- if (QString::fromLocal8Bit(name).isEmpty()) {
- i++;
- continue;
- }
- }
-
- m_filePathList.append(filePathStr);
- }
-
- i++;
- } while (i < list.size());
-
- g_key_file_free(keyfile);
- }
-}
-
-//获取系统desktop文件路径
-QStringList UkuiMenuInterface::getDesktopFilePath()
-{
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- m_filePathList.clear();
- QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json";
- QFile file(jsonPath);
-
- if (file.exists()) {
- file.open(QIODevice::ReadOnly);
- QByteArray readBy = file.readAll();
- QJsonParseError error;
- QJsonDocument readDoc = QJsonDocument::fromJson(readBy, &error);
-
- if (!readDoc.isNull() && error.error == QJsonParseError::NoError) {
- QJsonObject obj = readDoc.object().value("ukui-menu").toObject();
-
- if (obj.value("mode").toString() == "whitelist") {
- QJsonArray blArray = obj.value("whitelist").toArray();
- QJsonArray enArray = blArray.at(0).toObject().value("entries").toArray();
-
- for (int index = 0; index < enArray.size(); index++) {
- QJsonObject obj = enArray.at(index).toObject();
- m_filePathList.append(obj.value("path").toString());
- // qDebug()< reply = desktopfpListiface.call("GetDesktopAppList",username);
- //1、获取系统应用列表
- //filePathList;
- QStringList ifFileDesktopList;
- /*新的应用列表*/
- myDebug() << "sysapplistnum初始化默认应用列表" << m_filePathList.count();
-
- for (int i = 0; i < m_filePathList.count(); i++) { //过滤 得到真实存在的应用
- QString tmp = m_filePathList.at(i);
- QFileInfo fileInfo(tmp);
-
- if (!fileInfo.isFile()) { //判断是否存在
- //qDebug()<beginGroup("ukui-menu-sysapplist");
- int sysapplistnum = syssetting->allKeys().count();
- syssetting->sync();
- syssetting->endGroup();
- //qDebug()<<"sysapplistnum初始化默认应用列表3"<beginGroup("ukui-menu-sysapplist");
- myDebug() << "isnottencent" << str;
- syssetting->setValue(str, 0);
- syssetting->sync();
- syssetting->endGroup();
- }
- }/*else{
-
- //用户隔离/etc/skel/桌面
- QString tmp=QString("%1%2").arg("/usr/share/applications/").arg(str);
- QString appid=getTencentAppid(tmp);
- qDebug()<<"appid"< UkuiMenuInterface::createAppInfoVector()
-{
- desktopfpVector.clear();
- QVector appInfoVector;
- QVector vector;
- vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公
- vector.append(QStringList() << "develop" << "Development"); //1开发
- vector.append(QStringList() << "graphic" << "Graphics"); //2图像
- vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音
- vector.append(QStringList() << "network" << "Network"); //4网络
- vector.append(QStringList() << "game" << "Game"); //5游戏
- vector.append(QStringList() << "education" << "Education"); //6教育
- vector.append(QStringList() << "social" << "Messaging"); //7社交
- vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统
- vector.append(QStringList() << "safe"); //9安全
- vector.append(QStringList() << "others"); //10其他
- QStringList desktopfpList = getDesktopFilePath();
- QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase");
- QSqlQuery sql(db);
-
- for (int i = 0; i < desktopfpList.count(); i++) {
- QStringList appInfoList;
- QString desktopfp = desktopfpList.at(i);
- QString name = getAppName(desktopfpList.at(i));
-
- if (!name.isEmpty()) {
- QString englishName = getAppEnglishName(desktopfpList.at(i));
- QString letter = getAppNameInitial(desktopfpList.at(i));
- QString letters = getAppNameInitials(desktopfpList.at(i));
- desktopfpVector.append(desktopfp);
- appInfoList << desktopfp << name << englishName << letter << letters;
-
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- QString desktopfpExecName = getAppExec(desktopfpList.at(i));
- desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1);
- desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" "));
- sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName));
-
- if (sql.next()) {
- for (int j = 0; j < vector.size(); j++) {
- if (vector.at(j).contains(sql.value(0).toString())) {
- appInfoList.append(QString::number(j));
- }
- }
-
- appInfoVector.append(appInfoList);
- continue;
- }
- }
-
- bool is_owned = false;
-
- for (int j = 0; j < vector.size(); j++) {
- if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类
- is_owned = true;
- appInfoList.append(QString::number(j));
- }
- }
-
- if (!is_owned) { //该应用无对应分类
- appInfoList.append(QString::number(10));
- }
-
- appInfoVector.append(appInfoList);
- }
- }
-
- return appInfoVector;
-}
-//获取tencent应用名
-QString UkuiMenuInterface::getTencentAppid(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *Appid = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Appid", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(Appid);
-}
-//获取应用名称
-QString UkuiMenuInterface::getAppName(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr);
- QString namestr = QString::fromLocal8Bit(name);
- g_key_file_free(keyfile);
- return namestr;
-}
-//获取英应用英文名
-QString UkuiMenuInterface::getAppEnglishName(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr);
- QString namestr = QString::fromLocal8Bit(name);
- return namestr;
-}
-//获取应用分类
-QString UkuiMenuInterface::getAppCategories(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(category);
-}
-//获取应用图标
-QString UkuiMenuInterface::getAppIcon(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(icon);
-}
-//获取应用命令
-QString UkuiMenuInterface::getAppExec(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(exec);
-}
-//获取应用注释
-QString UkuiMenuInterface::getAppComment(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *comment = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Comment", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(comment);
-}
-//获取应用类型
-QString UkuiMenuInterface::getAppType(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *type = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Type", nullptr, nullptr);
- g_key_file_free(keyfile);
- return QString::fromLocal8Bit(type);
-}
-bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2)
-{
- QLocale local;
- QString language = local.languageToString(local.language());
-
- if (QString::compare(language, "Chinese") == 0) {
- local = QLocale(QLocale::Chinese);
- } else {
- local = QLocale(QLocale::English);
- }
-
- QCollator collator(local);
-
- if (collator.compare(arg_1.at(1), arg_2.at(1)) < 0) {
- return true;
- } else {
- return false;
- }
-}
-bool UkuiMenuInterface::initAppIni()
-{
- if (false) {
- QVector appInitVector;
- QVector tencentInitVectorList;
- QVector customizedVectorList;
- QVector thirdPartyVectorList;
- QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop";
- QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop";
- QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop";
- QVector precise_practiceVector;
- QStringList math;
- QStringList english;
- QStringList chainese;
- setting->beginGroup("application");
- QStringList desktopfnList = setting->allKeys();
- setting->endGroup();
-
- if (desktopfnList.count() == 0) {
- for (int i = 0; i < appInfoVector.count(); i++) {
- //qDebug()<<"appInfoVector"<beginGroup("tencent");
-
- for (int i = 0; i < tencentInitVectorList.count(); i++) {
- QString str = tencentInitVectorList.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- //qDebug()<setValue(str, i);
- }
-
- setting->sync();
- setting->endGroup();
- // int a=tencentInitVectorList.count();
- setting->beginGroup("customized");
-
- for (int i = 0; i < customizedVectorList.count(); i++) {
- QString str = customizedVectorList.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i);
- }
-
- setting->sync();
- setting->endGroup();
- // int b=customizedVector.count();
- setting->beginGroup("thirdParty");
-
- for (int i = 0; i < thirdPartyVectorList.count(); i++) {
- QString str = thirdPartyVectorList.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i);
- }
-
- setting->sync();
- setting->endGroup();
- // int c=thirdPartyVectorList.count();
- setting->beginGroup("application");
-
- for (int i = 0; i < appInitVector.count(); i++) { //赋值
- QString str = appInitVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i);
- }
-
- setting->sync();
- setting->endGroup();
- return 1;
- }
-
- return 0;
- } else {
- QVector appInitVector;
- QVector tencentInitVector;
- QVector customizedVector;
- QVector thirdPartyVector;
- QVector preorderAppVector;
- QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop";
- QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop";
- QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop";
- QString smallPluginManage = "/usr/share/applications/small-plugin-manage.desktop";
- QVector precise_practiceVector;
- QStringList math;
- QStringList english;
- QStringList chainese;
- setting->beginGroup("application");
- QStringList desktopfnList = setting->allKeys();
- setting->endGroup();
-
- if (desktopfnList.count() == 0) {
- for (int i = 0; i < desktopfpVector.count(); i++) {
- //qDebug()<<"appInfoVector"<beginGroup("application");
-
- for (int i = 0; i < preorderAppVector.count(); i++) {
- QString str = preorderAppVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- //qDebug()<setValue(str, i);
- }
-
- int firstVectorCount = preorderAppVector.count();
-
- for (int i = 0; i < tencentInitVector.count(); i++) {
- QString str = tencentInitVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- //qDebug()<setValue(str, i + firstVectorCount);
- }
-
- int a = tencentInitVector.count();
-
- for (int i = 0; i < customizedVector.count(); i++) {
- QString str = customizedVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i + a);
- }
-
- int b = customizedVector.count();
-
- for (int i = 0; i < thirdPartyVector.count(); i++) {
- QString str = thirdPartyVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i + a + b);
- }
-
- int c = thirdPartyVector.count();
-
- for (int i = 0; i < appInitVector.count(); i++) { //赋值
- QString str = appInitVector.at(i).at(0).section(' ', 0, 0);
- QStringList list = str.split('/');
- str = list[list.size() - 1];
- setting->setValue(str, i + a + b + c);
- }
-
- int d = appInitVector.count();
- setting->setValue("kylin-user-guide.desktop", a + b + c + d);
- setting->sync();
- setting->endGroup();
- return 1;
- }
-
- return 0;
- }
-}
-QVector UkuiMenuInterface::getAllClassification()
-{
- QVector allAppVector;
- QVector commonVector;
- QVector appVector;
- allAppVector.clear();
- commonVector.clear();
- appVector.clear();
- commonVector = getCommonUseApp();
- int index = 0;
-
- Q_FOREACH(QString desktopfp, desktopfpVector) {
- if (!commonVector.contains(desktopfp)) {
- appVector.append(appInfoVector.at(index));
- }
-
- index++;
- }
-
- qSort(appVector.begin(), appVector.end(), cmpApp);
-
- Q_FOREACH(QString desktopfp, commonVector) {
- allAppVector.append(desktopfp);
- }
-
- for (int index = 0; index < appVector.size(); index++) {
- allAppVector.append(appVector.at(index).at(0));
- }
-
- return allAppVector;
-}
-QVector UkuiMenuInterface::getCommonUseApp()
-{
- // QDateTime dt=QDateTime::currentDateTime();
- // int currentDateTime=dt.toTime_t();
- // int nDaySec=24*60*60;
- // setting->beginGroup("datetime");
- // QStringList dateTimeKeys=setting->allKeys();
- // QStringList timeOutKeys;
- // timeOutKeys.clear();
- // for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4)
- // {
- // timeOutKeys.append(dateTimeKeys.at(i));
- // }
- // }
- // setting->endGroup();
- // for(int i=0;ibeginGroup("application");
- // setting->remove(timeOutKeys.at(i));
- // setting->sync();
- // setting->endGroup();
- // setting->beginGroup("datetime");
- // setting->remove(timeOutKeys.at(i));
- // setting->sync();
- // setting->endGroup();
- // }
- // setting->beginGroup("lockapplication");
- // QStringList lockdesktopfnList=setting->allKeys();
- // for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt();
- // int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt();
- // if(value_1 > value_2)
- // {
- // QString tmp=lockdesktopfnList.at(j);
- // lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1));
- // lockdesktopfnList.replace(j+1,tmp);
- // }
- // }
- // setting->endGroup();
- // setting->beginGroup("application");
- // QStringList desktopfnList=setting->allKeys();
- // for(int i=0;ivalue(desktopfnList.at(j)).toInt();
- // int value_2=setting->value(desktopfnList.at(j+1)).toInt();
- // if(value_1 < value_2)
- // {
- // QString tmp=desktopfnList.at(j);
- // desktopfnList.replace(j,desktopfnList.at(j+1));
- // desktopfnList.replace(j+1,tmp);
- // }
- // }
- // setting->endGroup();
- // QVector data;
- // Q_FOREACH(QString desktopfn,lockdesktopfnList)
- // {
- // QString desktopfp;
- // if(androidDesktopfnList.contains(desktopfn))
- // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn);
- // else
- // desktopfp=QString("/usr/share/applications/"+desktopfn);
- // QFileInfo fileInfo(desktopfp);
- // if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp))
- // continue;
- // data.append(desktopfp);
- // }
- // Q_FOREACH(QString desktopfn,desktopfnList)
- // {
- // QString desktopfp;
- // if(androidDesktopfnList.contains(desktopfn))
- // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn);
- // else
- // desktopfp=QString("/usr/share/applications/"+desktopfn);
- // QFileInfo fileInfo(desktopfp);
- // if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp))
- // continue;
- // data.append(desktopfp);
- // }
- if (!g_projectCodeName.contains("V10SP1-edu")) {
- QVector data;
-
- Q_FOREACH(QString desktopfn, getLockAppList()) {
- QString desktopfp;
-
- if (androidDesktopfnList.contains(desktopfn)) {
- desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn);
- } else {
- desktopfp = QString("/usr/share/applications/" + desktopfn);
- }
-
- QFileInfo fileInfo(desktopfp);
-
- if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) {
- continue;
- }
-
- data.append(desktopfp);
- }
-
- Q_FOREACH(QString desktopfn, getUnlockAllList()) {
- QString desktopfp;
-
- if (androidDesktopfnList.contains(desktopfn)) {
- desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn);
- } else {
- desktopfp = QString("/usr/share/applications/" + desktopfn);
- }
-
- QFileInfo fileInfo(desktopfp);
-
- if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) {
- continue;
- }
-
- data.append(desktopfp);
- }
-
- return data;
- }
-}
-
-QVector UkuiMenuInterface::sortDesktopList(QString group)
-{
- setting->beginGroup(group);
- QStringList desktopfnList = setting->allKeys();
-
- for (int i = 0; i < desktopfnList.count() - 1; i++)
- for (int j = 0; j < desktopfnList.count() - 1 - i; j++) { //冒泡排序常用的应用从大到小排列desktopfnList
- int value_1 = setting->value(desktopfnList.at(j)).toInt();
- int value_2 = setting->value(desktopfnList.at(j + 1)).toInt();
-
- if (value_1 > value_2) {
- QString tmp = desktopfnList.at(j);
- desktopfnList.replace(j, desktopfnList.at(j + 1));
- desktopfnList.replace(j + 1, tmp);
- }
- }
-
- setting->sync();
- setting->endGroup();
- QVector data;
-
- Q_FOREACH(QString desktopfn, desktopfnList) {
- QString desktopfp;
-
- if (androidDesktopfnList.contains(desktopfn)) {
- desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn);
- } else {
- desktopfp = QString("/usr/share/applications/" + desktopfn);
- }
-
- data.append(desktopfp);
- }
-
- return data;
-}
-QVector UkuiMenuInterface::getCollectApp()
-{
- QVector data;
-
- Q_FOREACH(QString desktopfn, getCollectAppList()) {
- QString desktopfp;
-
- if (androidDesktopfnList.contains(desktopfn)) {
- desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn);
- } else {
- desktopfp = QString("/usr/share/applications/" + desktopfn);
- }
-
- QFileInfo fileInfo(desktopfp);
-
- if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) {
- continue;
- }
-
- data.append(desktopfp);
- }
-
- return data;
-}
-QVector UkuiMenuInterface::getLockApp()
-{
- setting->beginGroup("lockapplication");
- QStringList lockdesktopfnList = setting->allKeys();
-
- for (int i = 0; i < lockdesktopfnList.count() - 1; i++) //冒泡排序锁住的应用从小到大排列lockdesktopfnList
- for (int j = 0; j < lockdesktopfnList.count() - 1 - i; j++) {
- int value_1 = setting->value(lockdesktopfnList.at(j)).toInt();
- int value_2 = setting->value(lockdesktopfnList.at(j + 1)).toInt();
-
- if (value_1 > value_2) {
- QString tmp = lockdesktopfnList.at(j);
- lockdesktopfnList.replace(j, lockdesktopfnList.at(j + 1));
- lockdesktopfnList.replace(j + 1, tmp);
- }
- }
-
- setting->endGroup();
- QVector data;
-
- Q_FOREACH(QString desktopfn, lockdesktopfnList) {
- QString desktopfp;
- // if(androidDesktopfnList.contains(desktopfn))//如果锁的应用在安卓列表
- // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn);
- // else
- desktopfp = QString("/usr/share/applications/" + desktopfn);
- // QFileInfo fileInfo(desktopfp);
- // if(!fileInfo.isFile())//判断是否存在
- // continue;
- data.append(desktopfp);//加入data
- }
-
- return data;
-}
-QVector UkuiMenuInterface::getAlphabeticClassification()
-{
- QVector data;
- QStringList appnameList;
- appnameList.clear();
- QVector appVector[27];
- int index = 0;
-
- while (index < appInfoVector.size()) {
- QString appname = appInfoVector.at(index).at(1);
- QString appnamepy = UkuiChineseLetter::getPinyins(appname);
-
- if (!appnamepy.isEmpty()) {
- char c = appnamepy.at(0).toLatin1();
-
- switch (c) {
- case 'A':
- appVector[0].append(appInfoVector.at(index));
- break;
-
- case 'B':
- appVector[1].append(appInfoVector.at(index));
- break;
-
- case 'C':
- appVector[2].append(appInfoVector.at(index));
- break;
-
- case 'D':
- appVector[3].append(appInfoVector.at(index));
- break;
-
- case 'E':
- appVector[4].append(appInfoVector.at(index));
- break;
-
- case 'F':
- appVector[5].append(appInfoVector.at(index));
- break;
-
- case 'G':
- appVector[6].append(appInfoVector.at(index));
- break;
-
- case 'H':
- appVector[7].append(appInfoVector.at(index));
- break;
-
- case 'I':
- appVector[8].append(appInfoVector.at(index));
- break;
-
- case 'J':
- appVector[9].append(appInfoVector.at(index));
- break;
-
- case 'K':
- appVector[10].append(appInfoVector.at(index));
- break;
-
- case 'L':
- appVector[11].append(appInfoVector.at(index));
- break;
-
- case 'M':
- appVector[12].append(appInfoVector.at(index));
- break;
-
- case 'N':
- appVector[13].append(appInfoVector.at(index));
- break;
-
- case 'O':
- appVector[14].append(appInfoVector.at(index));
- break;
-
- case 'P':
- appVector[15].append(appInfoVector.at(index));
- break;
-
- case 'Q':
- appVector[16].append(appInfoVector.at(index));
- break;
-
- case 'R':
- appVector[17].append(appInfoVector.at(index));
- break;
-
- case 'S':
- appVector[18].append(appInfoVector.at(index));
- break;
-
- case 'T':
- appVector[19].append(appInfoVector.at(index));
- break;
-
- case 'U':
- appVector[20].append(appInfoVector.at(index));
- break;
-
- case 'V':
- appVector[21].append(appInfoVector.at(index));
- break;
-
- case 'W':
- appVector[22].append(appInfoVector.at(index));
- break;
-
- case 'X':
- appVector[23].append(appInfoVector.at(index));
- break;
-
- case 'Y':
- appVector[24].append(appInfoVector.at(index));
- break;
-
- case 'Z':
- appVector[25].append(appInfoVector.at(index));
- break;
-
- default:
- appVector[26].append(appInfoVector.at(index));
- break;
- }
- }
-
- index++;
- }
-
- for (int i = 0; i < 26; i++) {
- QStringList desktopfpList;
- desktopfpList.clear();
- qSort(appVector[i].begin(), appVector[i].end(), cmpApp);
-
- for (int j = 0; j < appVector[i].size(); j++) {
- desktopfpList.append(appVector[i].at(j).at(0));
- }
-
- data.append(desktopfpList);
- }
-
- QVector otherVector;
- QVector numberVector;
-
- for (int i = 0; i < appVector[26].count(); i++) {
- QString appname = appVector[26].at(i).at(2);
- QChar c = appname.at(0);
-
- if (c < 48 || (c > 57 && c < 65) || c > 90) {
- otherVector.append(appVector[26].at(i));
- } else {
- numberVector.append(appVector[26].at(i));
- }
- }
-
- qSort(otherVector.begin(), otherVector.end(), cmpApp);
- qSort(numberVector.begin(), numberVector.end(), cmpApp);
- QStringList otherfpList;
- otherfpList.clear();
-
- for (int i = 0; i < otherVector.size(); i++) {
- otherfpList.append(otherVector.at(i).at(0));
- }
-
- QStringList numberfpList;
- numberfpList.clear();
-
- for (int i = 0; i < numberVector.size(); i++) {
- numberfpList.append(numberVector.at(i).at(0));
- }
-
- data.append(otherfpList);
- data.append(numberfpList);
- return data;
-}
-QVector UkuiMenuInterface::getFunctionalClassification()
-{
- QVector appVector[11];
- int index = 0;
-
- while (index < appInfoVector.size()) {
- int count = appInfoVector.at(index).size() - 5;
-
- for (int i = 0; i < count; i++) {
- int category = appInfoVector.at(index).at(5 + i).toInt();
-
- switch (category) {
- case 0:
- appVector[0].append(appInfoVector.at(index));
- break;
-
- case 1:
- appVector[1].append(appInfoVector.at(index));
- break;
-
- case 2:
- appVector[2].append(appInfoVector.at(index));
- break;
-
- case 3:
- appVector[3].append(appInfoVector.at(index));
- break;
-
- case 4:
- appVector[4].append(appInfoVector.at(index));
- break;
-
- case 5:
- appVector[5].append(appInfoVector.at(index));
- break;
-
- case 6:
- appVector[6].append(appInfoVector.at(index));
- break;
-
- case 7:
- appVector[7].append(appInfoVector.at(index));
- break;
-
- case 8:
- appVector[8].append(appInfoVector.at(index));
- break;
-
- case 9:
- appVector[9].append(appInfoVector.at(index));
- break;
-
- case 10:
- appVector[10].append(appInfoVector.at(index));
- break;
-
- default:
- break;
- }
- }
-
- index++;
- }
-
- QVector data;
- data.clear();
-
- for (int i = 0; i < 11; i++) {
- QStringList desktopfpList;
- desktopfpList.clear();
- qSort(appVector[i].begin(), appVector[i].end(), cmpApp);
-
- for (int j = 0; j < appVector[i].size(); j++) {
- desktopfpList.append(appVector[i].at(j).at(0));
- }
-
- data.append(desktopfpList);
- }
-
- return data;
-}
-bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList categorylist)
-{
- QString category = getAppCategories(desktopfp);
- int index;
-
- for (index = 0; index < categorylist.count(); index++) {
- if (category.contains(categorylist.at(index), Qt::CaseInsensitive)) {
- return true;
- }
- }
-
- if (index == categorylist.count()) {
- return false;
- }
-
- return false;
-}
-void UkuiMenuInterface::getAndroidApp()
-{
- androidDesktopfnList.clear();
- QVector androidVector;
- androidVector.clear();
- QString path = QDir::homePath() + "/.local/share/applications/";
- QDir dir(path);
-
- if (!dir.exists()) {
- return;
- }
-
- dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
- dir.setSorting(QDir::DirsFirst);
- QFileInfoList list = dir.entryInfoList();
-
- if (list.size() < 1) {
- return;
- }
-
- int i = 0;
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
-
- do {
- QFileInfo fileInfo = list.at(i);
-
- if (!fileInfo.isFile()) {
- i++;
- continue;
- }
-
- //过滤后缀不是.desktop的文件
- QString filePathStr = fileInfo.filePath();
-
- if (!filePathStr.endsWith(".desktop")) {
- i++;
- continue;
- }
-
- QByteArray fpbyte = filePathStr.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr);
-
- if (ret_1 != nullptr) {
- // QString str=QString::fromLocal8Bit(ret_1);
- // if(!str.contains("Android"))
- // {
- // i++;
- // continue;
- // }
- // else
- // {
- m_filePathList.append(filePathStr);
- androidDesktopfnList.append(fileInfo.fileName());
- // }
- }
-
- i++;
- } while (i < list.size());
-
- g_key_file_free(keyfile);
-}
-QString UkuiMenuInterface::getAppNameInitials(QString desktopfp)
-{
- QString firstLetters;
- QString appname = getAppName(desktopfp);
- QStringList appnamestr = appname.split(" ");
- QString letters;
-
- Q_FOREACH(QString name, appnamestr) {
- letters.clear();
- letters = UkuiChineseLetter::getFirstLettersAll(name);
-
- if (letters.isEmpty()) {
- letters = UkuiChineseLetter::getFirstLetter(name);
- }
-
- firstLetters.append(letters);
- }
-
- return firstLetters;
-}
-QString UkuiMenuInterface::getAppNameInitial(QString desktopfp)
-{
- return UkuiChineseLetter::getFirstLetter(getAppName(desktopfp));
-}
-//获取应用拼音
-QString UkuiMenuInterface::getAppNamePinyin(QString appname)
-{
- return UkuiChineseLetter::getPinyins(appname);
-}
-bool UkuiMenuInterface::checkKreApp(QString desktopfp)
-{
- GError **error = nullptr;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GKeyFile *keyfile = g_key_file_new();
- QByteArray fpbyte = desktopfp.toLocal8Bit();
- char *filepath = fpbyte.data();
- g_key_file_load_from_file(keyfile, filepath, flags, error);
- char *value = g_key_file_get_locale_string(keyfile, "Desktop Entry", "environment", nullptr, nullptr);
- g_key_file_free(keyfile);
-
- if (!value) {
- return false;
- } else if (QString::compare(QString::fromLocal8Bit(value), "kre-environment") == 0) {
- return true;
- }
-
- return false;
-}
-//获取指定类型应用列表
-QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr)
-{
- QByteArray categorybyte = categorystr.toLocal8Bit();
- char *category = categorybyte.data();
- QStringList desktopfpList = getDesktopFilePath();
- QStringList appnameList;
- appnameList.clear();
-
- for (int index = 0; index < desktopfpList.count(); index++) {
- QString appcategorystr = getAppCategories(desktopfpList.at(index));
-
- if (!appcategorystr.isEmpty()) {
- QByteArray appcategorybyte = appcategorystr.toLocal8Bit();
- char *appcategory = appcategorybyte.data();
- int len = static_cast(strlen(appcategory) - 6);
-
- for (int i = 0; i < len; i++) {
- if (strncmp(appcategory + i, category, strlen(category)) == 0) {
- QString appname = getAppName(desktopfpList.at(index));
-
- if (QString::compare(appname, "访问提示") == 0) {
- appnameList.append(appname);
- }
-
- break;
- }
- }
- }
- }
-
- return appnameList;
-}
diff --git a/src/BackProcess/Interface/ukuimenuinterface.h b/src/BackProcess/Interface/ukuimenuinterface.h
deleted file mode 100644
index 38ed9c2..0000000
--- a/src/BackProcess/Interface/ukuimenuinterface.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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
- * (at your option) 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 .
- */
-
-#ifndef UKUIMENUINTERFACE_H
-#define UKUIMENUINTERFACE_H
-#include
-#include
-#include
-#include
-#include