diff --git a/debian/.debhelper/generated/ukui-menu/installed-by-dh_installdocs b/debian/.debhelper/generated/ukui-menu/installed-by-dh_installdocs new file mode 100644 index 0000000..e69de29 diff --git a/debian/.debhelper/ukui-menu/dbgsym-build-ids b/debian/.debhelper/ukui-menu/dbgsym-build-ids new file mode 100644 index 0000000..a0a162f --- /dev/null +++ b/debian/.debhelper/ukui-menu/dbgsym-build-ids @@ -0,0 +1 @@ +c655bb8f0b2024dadcce069ee514fb4b60026151 f2bc5d6ae801b3aa68379f09464170e37a7bad5f \ No newline at end of file diff --git a/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/control b/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/control new file mode 100644 index 0000000..ed41a3c --- /dev/null +++ b/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/control @@ -0,0 +1,13 @@ +Package: ukui-menu-dbgsym +Package-Type: ddeb +Source: ukui-menu +Version: 1.0.0-1 +Auto-Built-Package: debug-symbols +Architecture: amd64 +Maintainer: Kylin Team +Installed-Size: 4428 +Depends: ukui-menu (= 1.0.0-1) +Section: debug +Priority: optional +Description: debug symbols for ukui-menu +Build-Ids: c655bb8f0b2024dadcce069ee514fb4b60026151 f2bc5d6ae801b3aa68379f09464170e37a7bad5f diff --git a/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/md5sums b/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/md5sums new file mode 100644 index 0000000..f2f4e79 --- /dev/null +++ b/debian/.debhelper/ukui-menu/dbgsym-root/DEBIAN/md5sums @@ -0,0 +1,3 @@ +56992fe5433d38d3c23b4795a4144b8f usr/lib/debug/.build-id/c6/55bb8f0b2024dadcce069ee514fb4b60026151.debug +533eb8b8dd6cfd291a4c9b56e7106721 usr/lib/debug/.build-id/f2/bc5d6ae801b3aa68379f09464170e37a7bad5f.debug +d6477b51563640c4abe98f4003a1e120 usr/lib/debug/.dwz/x86_64-linux-gnu/ukui-menu.debug diff --git a/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/c6/55bb8f0b2024dadcce069ee514fb4b60026151.debug b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/c6/55bb8f0b2024dadcce069ee514fb4b60026151.debug new file mode 100644 index 0000000..bf09b57 Binary files /dev/null and b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/c6/55bb8f0b2024dadcce069ee514fb4b60026151.debug differ diff --git a/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/f2/bc5d6ae801b3aa68379f09464170e37a7bad5f.debug b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/f2/bc5d6ae801b3aa68379f09464170e37a7bad5f.debug new file mode 100644 index 0000000..c9991c0 Binary files /dev/null and b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.build-id/f2/bc5d6ae801b3aa68379f09464170e37a7bad5f.debug differ diff --git a/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.dwz/x86_64-linux-gnu/ukui-menu.debug b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.dwz/x86_64-linux-gnu/ukui-menu.debug new file mode 100644 index 0000000..e83618a Binary files /dev/null and b/debian/.debhelper/ukui-menu/dbgsym-root/usr/lib/debug/.dwz/x86_64-linux-gnu/ukui-menu.debug differ diff --git a/debian/changelog b/debian/changelog index c4f111d..a723fea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,146 +1,5 @@ -ukui-menu (3.0.0-1) unstable; urgency=medium +ukui-menu (1.0.0-1) unstable; urgency=medium - * New upstream release. + * Initial release (Closes: #nnnn) - -- handsome_feng Wed, 26 Aug 2020 20:18:25 +0800 - -ukui-menu (2.0.8-1) unstable; urgency=medium - - * New upstream release. - - -- handsome_feng Wed, 15 Jul 2020 20:16:14 +0800 - -ukui-menu (2.0.7-1) unstable; urgency=medium - - * New upstream release. - - -- handsome_feng Mon, 06 Jul 2020 14:57:00 +0800 - -ukui-menu (2.0.6-1) unstable; urgency=medium - - * New upstream bugfix release. - - Fix that the 'recent' page is empty. (LP: #1870954) - - Fix the focus issue. - - Fix the issues when change primary screen. - * debian/control: - - Add bamfdaemon to depends and libbamf3-dev to build-depends. - - -- handsome_feng Mon, 13 Apr 2020 15:47:37 +0800 - -ukui-menu (2.0.5-1) unstable; urgency=medium - - * New upstream bugfix release. - - Fix startup failure when panel profile does not exist. - - Fix the icon dragging problem. - - Fix that right-click menu popup abnormally. - - Fix the wrong position when switch from fullscreen to normal mode. - * debian/watch: - - Update to monitor upstream org.tar.gz file. - - -- handsome_feng Tue, 07 Apr 2020 10:54:28 +0800 - -ukui-menu (2.0.4-1) unstable; urgency=medium - - * New upstream bugfix release. - - Fix the icon problem with newly installed software. - - Fix the crash during software installation and uninstallation. - - Not hardcode the font name. - - -- handsome_feng Mon, 30 Mar 2020 11:21:48 +0800 - -ukui-menu (2.0.3-1) unstable; urgency=medium - - * New upstream bugfix release. - - Get the panel position to avoid popup at wrong place. - - Fix the stuck when scroll the area. - - Fix the focus issue. - - Fix the display problem of 'recent app" bar. - - Adjust the style of right-click menu. - - -- handsome_feng Sat, 14 Mar 2020 14:33:14 +0800 - -ukui-menu (2.0.1-1) unstable; urgency=medium - - * New upstream release. - - Migrate from python to qt. - * debian/control: - - Bump Standards-Versions to 4.5.0. - * debian/{control,compat}: - - Use debhelper-compat notation. - - -- handsome_feng Sat, 08 Feb 2020 15:51:47 +0800 - -ukui-menu (1.1.12-1) unstable; urgency=medium - - * Remove the duplicated timed-shutdown.py file. - - -- handsome_feng Mon, 19 Aug 2019 14:57:14 +0800 - -ukui-menu (1.1.11-1) unstable; urgency=medium - - * Upload to unstable. - * Add network detection for feedback. - * Update some labels. - * Update tr.po. - * debian/control: - - Bump standards-version to 4.4.0. - - -- handsome_feng Wed, 07 Aug 2019 09:52:56 +0800 - -ukui-menu (1.1.10-1) experimental; urgency=medium - - * Update the default icon of user face. - * Fix the error when show popup menu. - * Change the timing of update recent files. - - -- handsome_feng Thu, 21 Mar 2019 17:29:11 +0800 - -ukui-menu (1.1.9-1) unstable; urgency=medium - - * Add transparency effect. - * Add a shutdown timer. - * Deal with the situation when get_desktop_file_path is None. - * Update the code of keybinding. - * Update the icon of start menu. - * Bump standards-version to 4.3.0. - - -- handsome_feng Fri, 04 Jan 2019 14:27:45 +0800 - -ukui-menu (1.1.7-2) unstable; urgency=medium - - * Debian/control: - - Remove gvfs-open. (Closes: 906326) - - -- handsome_feng Fri, 16 Nov 2018 17:04:47 +0800 - -ukui-menu (1.1.7-1) unstable; urgency=medium - - * Skip 'Education' for 'Normal Menu'. - * Add fr.po, pt.po, ru.po, es.po. - * Update start.svg. - * Deal with filename which contain '&'. - - -- handsome_feng Wed, 07 Nov 2018 12:55:21 +0800 - -ukui-menu (1.1.5-1) UNRELEASED; urgency=medium - - * Use mate-terminal instead of gnome-terminal. - * Port to python3. - * Update for ukui-panel. - * Add support for resize the menu icon. - * Add right-click menu for recent files. - * Add feedback window. - - -- handsome_feng Mon, 17 Sep 2018 16:11:00 +0800 - -ukui-menu (1.0.2-2) unstable; urgency=medium - - * Use tracker.d.o team address (Closes: #899863) - - -- Aron Xu Mon, 09 Jul 2018 14:47:31 +0800 - -ukui-menu (1.0.2-1) unstable; urgency=medium - - * Initial release (Closes: #872967) - - -- Aron Xu Sat, 26 Aug 2017 14:57:14 +0800 + -- wangguixi Tue, 01 Sep 2020 15:39:23 +0800 diff --git a/debian/copyright b/debian/copyright index 3a0edea..7c28d89 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,14 +1,15 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: ukui-menu -Upstream-Contact: liuhao -Source: https://github.com/ukui/ukui-menu +Upstream-Contact: +Source: Files: * -Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. +Copyright: + License: GPL-3.0+ Files: debian/* -Copyright: 2019 liuhao +Copyright: 2020 wangguixi License: GPL-3.0+ License: GPL-3.0+ @@ -27,3 +28,12 @@ License: GPL-3.0+ . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/source/format b/debian/source/format index 163aaf8..89ae9db 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/debian/ukui-menu-tablet.manpages b/debian/ukui-menu-tablet.manpages new file mode 100644 index 0000000..f0b6699 --- /dev/null +++ b/debian/ukui-menu-tablet.manpages @@ -0,0 +1 @@ +pad/man/ukui-menu-tablet.1 diff --git a/debian/ukui-menu.manpages b/debian/ukui-menu.manpages index f054a53..c83865b 100644 --- a/debian/ukui-menu.manpages +++ b/debian/ukui-menu.manpages @@ -1 +1 @@ -man/ukui-menu.1 +pc/man/ukui-menu.1 diff --git a/debian/ukui-menu/DEBIAN/conffiles b/debian/ukui-menu/DEBIAN/conffiles new file mode 100644 index 0000000..e9a7d63 --- /dev/null +++ b/debian/ukui-menu/DEBIAN/conffiles @@ -0,0 +1,2 @@ +/etc/xdg/autostart/ukui-menu-tablet.desktop +/etc/xdg/autostart/ukui-menu.desktop diff --git a/debian/ukui-menu/DEBIAN/control b/debian/ukui-menu/DEBIAN/control new file mode 100644 index 0000000..1e54158 --- /dev/null +++ b/debian/ukui-menu/DEBIAN/control @@ -0,0 +1,14 @@ +Package: ukui-menu +Version: 1.0.0-1 +Architecture: amd64 +Maintainer: Kylin Team +Installed-Size: 821 +Depends: libbamf3-2 (>= 0.2.20), libc6 (>= 2.14), libgcc-s1 (>= 3.0), libglib2.0-0 (>= 2.36), libgsettings-qt1 (>= 0.1+14.04.20140408), libkf5windowsystem5 (>= 4.96.0), libqt5core5a (>= 5.12.2), libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.8.0) | libqt5gui5-gles (>= 5.8.0), libqt5network5 (>= 5.0.2), libqt5svg5 (>= 5.6.0~beta), libqt5widgets5 (>= 5.11.0~rc1), libstdc++6 (>= 5), libx11-6, libxtst6, accountsservice, libqt5x11extras5, bamfdaemon, libxrandr2 +Section: x11 +Priority: optional +Homepage: https://github.com/ukui/ukui-menu +Description: Advanced ukui menu + UKUI menu provides start menu development library and advanced + graphical user interface. + . + The package contains executable file. diff --git a/debian/ukui-menu/DEBIAN/md5sums b/debian/ukui-menu/DEBIAN/md5sums new file mode 100644 index 0000000..0235912 --- /dev/null +++ b/debian/ukui-menu/DEBIAN/md5sums @@ -0,0 +1,7 @@ +f6136f143060286a826370d04c9dacb6 usr/bin/ukui-menu +7cda052dd3291dddd2fca69231c36557 usr/bin/ukui-menu-tablet +c66659d4929aa96ee8a1d187f1563a72 usr/share/doc/ukui-menu/changelog.Debian.gz +ac948457fd37306fddb054f80fdbe9fd usr/share/doc/ukui-menu/copyright +bcebcf42735c6849bdecbb77451021dd usr/share/ukui-menu/translations/ukui-menu_bo.qm +9d6b1e9f3ae7b9fa63b3142ba5ae721f usr/share/ukui-menu/translations/ukui-menu_tr.qm +bec92e1eb95297c57f15f7768b1146e9 usr/share/ukui-menu/translations/ukui-menu_zh_CN.qm diff --git a/debian/ukui-menu/etc/xdg/autostart/ukui-menu-tablet.desktop b/debian/ukui-menu/etc/xdg/autostart/ukui-menu-tablet.desktop new file mode 100644 index 0000000..b113434 --- /dev/null +++ b/debian/ukui-menu/etc/xdg/autostart/ukui-menu-tablet.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=ukui-menu-tablet +comment=ukui-menu +Comment[zh_CN]=开始菜单 +Comment[tr_TR]=Başlangıç menüsü +Exec=/usr/bin/ukui-menu-tablet +Terminal=false +Type=Application +Icon=ukui-menu +X-UKUI-AutoRestart=true +OnlyShowIn=UKUI +X-UKUI-Autostart-Phase=Application +NoDisplay=true diff --git a/ukui-menu.desktop b/debian/ukui-menu/etc/xdg/autostart/ukui-menu.desktop similarity index 100% rename from ukui-menu.desktop rename to debian/ukui-menu/etc/xdg/autostart/ukui-menu.desktop diff --git a/debian/ukui-menu/usr/bin/ukui-menu b/debian/ukui-menu/usr/bin/ukui-menu new file mode 100755 index 0000000..2d6fba8 Binary files /dev/null and b/debian/ukui-menu/usr/bin/ukui-menu differ diff --git a/debian/ukui-menu/usr/bin/ukui-menu-tablet b/debian/ukui-menu/usr/bin/ukui-menu-tablet new file mode 100755 index 0000000..13c8a92 Binary files /dev/null and b/debian/ukui-menu/usr/bin/ukui-menu-tablet differ diff --git a/debian/ukui-menu/usr/share/doc/ukui-menu/changelog.Debian.gz b/debian/ukui-menu/usr/share/doc/ukui-menu/changelog.Debian.gz new file mode 100644 index 0000000..4cdd09d Binary files /dev/null and b/debian/ukui-menu/usr/share/doc/ukui-menu/changelog.Debian.gz differ diff --git a/debian/ukui-menu/usr/share/doc/ukui-menu/copyright b/debian/ukui-menu/usr/share/doc/ukui-menu/copyright new file mode 100644 index 0000000..7c28d89 --- /dev/null +++ b/debian/ukui-menu/usr/share/doc/ukui-menu/copyright @@ -0,0 +1,39 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ukui-menu +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: GPL-3.0+ + +Files: debian/* +Copyright: 2020 wangguixi +License: GPL-3.0+ + +License: GPL-3.0+ + 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 package 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 . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/ukui-menu/usr/share/ukui-menu/translations/ukui-menu_bo.qm b/debian/ukui-menu/usr/share/ukui-menu/translations/ukui-menu_bo.qm new file mode 100644 index 0000000..be651ee --- /dev/null +++ b/debian/ukui-menu/usr/share/ukui-menu/translations/ukui-menu_bo.qm @@ -0,0 +1 @@ + git clone https://github.com/ukui/ukui-menu-tablet + +> cd ukui-menu-tablet && mkdir build && cd build + +> qmake .. && make + +> sudo make install + +Note: If you want to run ukui-menu-tablet, You just need to execute the ukui-menu-tablet command at the terminal. diff --git a/pad/img.qrc b/pad/img.qrc new file mode 100644 index 0000000..e6e4899 --- /dev/null +++ b/pad/img.qrc @@ -0,0 +1,6 @@ + + + img/search.svg + img/search.png + + diff --git a/pad/img/search.png b/pad/img/search.png new file mode 100755 index 0000000..17f2c9c Binary files /dev/null and b/pad/img/search.png differ diff --git a/data/img/mainviewwidget/search.svg b/pad/img/search.svg similarity index 100% rename from data/img/mainviewwidget/search.svg rename to pad/img/search.svg diff --git a/pad/main.cpp b/pad/main.cpp new file mode 100755 index 0000000..82f09e5 --- /dev/null +++ b/pad/main.cpp @@ -0,0 +1,59 @@ +#include "mainwindow.h" +#include +#include +#include +#include +#include +#include +#define TABLED_SCHEMA "org.ukui.SettingsDaemon.plugins.tablet-mode" + +int main(int argc, char *argv[]) +{ +// QApplication a(argc, argv); + + + + //单例 + QtSingleApplication a("ukui-menu-tablet", argc, argv); + if(a.isRunning()) + { + a.sendMessage("raise_window_noop"); + return EXIT_SUCCESS; + } + + MainWindow w; + // w.removeEventFilter(QMoveEvent); + a.setActivationWindow(&w);//单例 + + + int x=QApplication::primaryScreen()->geometry().x(); + int y=QApplication::primaryScreen()->geometry().y(); + w.setGeometry(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-46); + + QTranslator translator; + if(QLocale().language()==QLocale::Chinese) + { + translator.load(":/translation/tr_zh.qm"); + a.installTranslator(&translator); + } + + QGSettings* tabletMode= new QGSettings(TABLED_SCHEMA); + bool res = tabletMode->get("tablet-mode").toBool(); + qDebug()< +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#define TABLED_SCHEMA "org.ukui.SettingsDaemon.plugins.tablet-mode" + + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + + setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + // setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + this->resize(QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-46); + this->setAttribute(Qt::WA_TranslucentBackground,true); + this->setAutoFillBackground(false); + this->setFocusPolicy(Qt::ClickFocus); + this->setProperty("useStyleWindowManager",false); + m_frame=new QFrame; + this->setCentralWidget(m_frame); + + + //获取数据 + UkuiMenuInterface m_ukuiMenuInterface; + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface.createAppInfoVector(); + UkuiMenuInterface::allAppVector=m_ukuiMenuInterface.getAllApp(); + + //左侧 + leftWidget=new QWidget; + leftWidget->setFixedSize(511,QApplication::primaryScreen()->geometry().height()-46); + leftLayout=new QVBoxLayout(); + //左主 + leftWidget->setLayout(leftLayout); + leftLayout->setContentsMargins(111,96,0,0); + + //右侧界面 + m_CommonUseWidget=new FullCommonUseWidget(); + + QHBoxLayout *mainLayout =new QHBoxLayout(); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0,0,0,0); + m_frame->setLayout(mainLayout); + mainLayout->addWidget(leftWidget); + mainLayout->addWidget(m_CommonUseWidget); + + + //获取系统背景图片 gsettings get org.mate.background picture-filename + QGSettings* gsetting=new QGSettings(QString("org.mate.background").toLocal8Bit()); + QString iconPath =gsetting->get("picture-filename").toString(); + + m_frame->setAutoFillBackground(true); + QPixmap pixmap = QPixmap(iconPath).scaled(this->size()); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(pixmap)); + m_frame->setPalette(palette); + + QPropertyAnimation *animation = new QPropertyAnimation(m_frame->window(), "windowOpacity"); + animation->setDuration(500); + animation->setStartValue(0); + animation->setEndValue(1); + animation->start(); + connect(animation,&QPropertyAnimation::finished,this,&MainWindow::displayMainViewSlot); + + //平板 + tabletMode=new QGSettings(TABLED_SCHEMA); + connect(tabletMode,&QGSettings::changed,[this] (const QString &key) { + bool res = tabletMode->get("tablet-mode").toBool(); + qDebug()<hide(); + else + this->show(); + + }); + + + //监控.desktop文件目录 + m_fileWatcher=new QFileSystemWatcher; + m_fileWatcher->addPaths(QStringList()<<"/usr/share/applications"); + connect(m_fileWatcher,&QFileSystemWatcher::directoryChanged,this,&MainWindow::directoryChangedSlot); + m_directoryChangedThread=new DirectoryChangedThread; + connect(this,&MainWindow::sendDirectoryPath,m_directoryChangedThread,&DirectoryChangedThread::recvDirectoryPath); + connect(m_directoryChangedThread,&DirectoryChangedThread::requestUpdateSignal,this,&MainWindow::requestUpdateSlot); + connect(m_directoryChangedThread,&DirectoryChangedThread::deleteAppSignal,this,&MainWindow::requestDeleteAppSlot); + + +} + +MainWindow::~MainWindow() +{ + delete m_ukuiMenuInterface; + delete m_fileWatcher; + delete m_directoryChangedThread; +} + +void MainWindow::directoryChangedSlot() +{ + Q_EMIT sendDirectoryPath(QString("/usr/share/applications")); + m_directoryChangedThread->start(); + +} +void MainWindow::requestUpdateSlot(QString desktopfp) +{ + m_directoryChangedThread->quit(); + m_CommonUseWidget->updateListView(desktopfp); +} + +void MainWindow::requestDeleteAppSlot() +{ + m_directoryChangedThread->quit(); + m_CommonUseWidget->deleteAppListView(); +} + +void MainWindow::displayMainViewSlot() +{ + //加载左侧界面 + leftWidgetDisplay(); + //右侧界面填充数据 + m_CommonUseWidget->fillAppList(); +} + +void MainWindow::leftWidgetDisplay() +{ + //左上 + leftUpWidget=new QWidget; + leftUpWidget->setFixedSize(400,96); + leftUpLayout=new QHBoxLayout(); + leftUpWidget->setLayout(leftUpLayout); + leftUpLayout->setContentsMargins(0,0,0,0); + + //左下 + downWidget=new QWidget; + downWidget->setFixedSize(400,56); + + + //左上左 + upLeftWidget=new QWidget; + upLeftWidget->setFixedSize(263,96); + upLeftLayout=new QHBoxLayout(); + upLeftWidget->setLayout(upLeftLayout); + upLeftLayout->setContentsMargins(0,0,0,0); + // upLeftWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); + + //左上右 + upRightWidget=new QWidget; + upRightWidget->setFixedSize(170,100); + upRightLayout=new QVBoxLayout(); + upRightWidget->setLayout(upRightLayout); + upRightLayout->setContentsMargins(8,8,0,0); + // upRightWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); + + //左下 + downLayout=new QVBoxLayout(); + downWidget->setLayout(downLayout); + + //左侧控件 + timeLabel=new QLabel(); + weekLabel=new QLabel(); + dateLabel=new QLabel(); + + //搜索 + searchEdit=new QLineEdit(); + searchEdit->setPlaceholderText(tr("Search your application、file")); + QAction* searchAction =new QAction(); + searchAction->setIcon(QIcon(":/img/search.png")); + searchEdit->addAction(searchAction,QLineEdit::LeadingPosition); + searchEdit->setStyleSheet("border-radius:10px;"); + searchEdit->setFocusPolicy(Qt::ClickFocus); + connect(searchEdit, &QLineEdit::returnPressed, this, &MainWindow::obtainSearchResult); + + + dateTime = new QDateTime; + timer = new QTimer(this); + + //获得语言环境 + QLocale currentlocale = QLocale::system(); + QLocale::setDefault(QLocale(currentlocale.language(),currentlocale.country())); + locale = new QLocale; + + + downLayout->addWidget(searchEdit); + + leftLayout->addWidget(leftUpWidget); + leftLayout->addWidget((downWidget)); + leftLayout->addStretch(); + + leftUpLayout->addWidget(upLeftWidget); + leftUpLayout->addWidget(upRightWidget); + + upLeftLayout->addWidget(timeLabel); + upRightLayout->addWidget(weekLabel); + upRightLayout->addWidget(dateLabel); + weekLabel->setAlignment(Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignBottom); + dateLabel->setAlignment(Qt::AlignCenter); + + timeLabel->setStyleSheet("border:0px;background:transparent;font-size:96px;color:white;"); + dateLabel->setStyleSheet("border:0px;background:transparent;font-size:38px;color:white;"); + weekLabel->setStyleSheet("border:0px;background:transparent;font-size:38px;color:white;"); + + + timeLabel->setText(locale->toString(dateTime->currentDateTime().time(),"hh:mm")); + dateLabel->setText(locale->toString(dateTime->currentDateTime().date(),"MM-dd")); + weekLabel->setText(locale->toString(dateTime->currentDateTime().date(),"dddd")); +// timeLabel->setText(dateTime->currentDateTime().toString("hh:mm")); +// dateLabel->setText(dateTime->currentDateTime().toString("MM-dd")); +// weekLabel->setText(dateTime->currentDateTime().toString("dddd")); + + + + connect(timer,&QTimer::timeout,[this] () { + timeLabel->setText(locale->toString(dateTime->currentDateTime().time(),"hh:mm")); + dateLabel->setText(locale->toString(dateTime->currentDateTime().date(),"MM-dd")); + weekLabel->setText(locale->toString(dateTime->currentDateTime().date(),"dddd")); + + }); + + timer->start(30000); +} + +void MainWindow::obtainSearchResult() +{ + //获取搜索框内容 + QString searchContent= searchEdit->text(); + QProcess p; + p.setProgram(QString("peony")); + p.setArguments(QStringList()< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/UtilityFunction/fulllistview.h" +#include "src/UtilityFunction/fullcommonusewidget.h" +#include "src/MainViewWidget/directorychangedthread.h" +#include +#include +#include +#include + + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + void widgetMakeZero(); + void leftWidgetDisplay(); +// void searchAppSlot(QString arg); + + +private: + QDateTime* dateTime; + QTimer* timer; + QLocale* locale; + + + QFrame *m_frame=nullptr; + + QWidget * rightWidget; + QHBoxLayout* mainLayout; + + //左侧 + QWidget* leftWidget=nullptr; + QWidget* leftUpWidget=nullptr; + QWidget* upLeftWidget=nullptr; + QWidget* downWidget=nullptr; + + + QVBoxLayout* leftLayout; + QHBoxLayout* leftUpLayout; + QVBoxLayout* downLayout; + + QHBoxLayout* upLeftLayout; + QVBoxLayout* upRightLayout; + + + QLabel* timeLabel; + QLabel* weekLabel; + QLabel* dateLabel; + QLineEdit* searchEdit; + QAction* searchAction; + + //右侧 + QWidget* upRightWidget=nullptr; + QHBoxLayout* rightLayout; + FullCommonUseWidget* m_CommonUseWidget=nullptr; + FullListView* m_listView=nullptr; + QStandardItemModel* listmodel=nullptr; + + //监控 + QFileSystemWatcher* m_fileWatcher=nullptr; + DirectoryChangedThread* m_directoryChangedThread=nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + + //记录应用显示位置 + QSettings* m_setting=nullptr; + QGSettings* m_gsetting=nullptr; + + // + QGSettings* gsetting; + QPropertyAnimation *animation; + + QGSettings* tabletMode=nullptr; + QString searchContent; + +public Q_SLOTS: + + void directoryChangedSlot(); + //void iconThemeChangeSlot(QString key); + void requestUpdateSlot(QString desktopfp); + void requestDeleteAppSlot(); + void displayMainViewSlot(); + void obtainSearchResult(); + +Q_SIGNALS: + +// void directoryChangedSignal(); + void sendDirectoryPath(QString arg); + +}; + + +#endif // MAINWINDOW_H diff --git a/pad/man/ukui-menu-tablet.1 b/pad/man/ukui-menu-tablet.1 new file mode 100644 index 0000000..408962c --- /dev/null +++ b/pad/man/ukui-menu-tablet.1 @@ -0,0 +1,20 @@ +.\" Man page for ukui-menu-tablet +.TH UKUIMENUTABLET 1 "17 December 2019" "UKUI Desktop Environment" +.\" Please adjust this date when revising the manpage. +.\" +.SH "NAME" +ukui-menu-tablet \- The tool for the UKUI Desktop Environment +.SH "SYNOPSIS" +.B ukui-menu-tablet +.SH "DESCRIPTION" +The \fBukui-menu-tablet\fR program is a part of the ukui-menu, it provides users with graphical interface tools. +.PP +This manual page documents the \fBukui-menu-tablet\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: +chentong (2019) +.SH "SEE ALSO" diff --git a/pad/menu.pro b/pad/menu.pro new file mode 100755 index 0000000..d2fc2dc --- /dev/null +++ b/pad/menu.pro @@ -0,0 +1,74 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2020-08-17T11:42:29 +# +#------------------------------------------------- + +QT += core gui dbus + + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +include(src/QtSingleApplication/qtsingleapplication.pri) +TARGET = ukui-menu-tablet +TEMPLATE = app +target.path = /usr/bin + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + src/Interface/ukuichineseletter.cpp \ + src/Interface/ukuimenuinterface.cpp \ + src/UtilityFunction/fullcommonusewidget.cpp \ + src/UtilityFunction/fullitemdelegate.cpp \ + src/UtilityFunction/fulllistview.cpp \ + src/MainViewWidget/directorychangedthread.cpp + + + +HEADERS += \ + mainwindow.h \ + src/Interface/ukuichineseletter.h \ + src/Interface/ukuimenuinterface.h \ + src/UtilityFunction/fullcommonusewidget.h \ + src/UtilityFunction/fullitemdelegate.h \ + src/UtilityFunction/fulllistview.h \ + src/Style/style.h \ + src/MainViewWidget/directorychangedthread.h + + + +PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt +CONFIG += no_keywords link_pkgconfig + +desktop_file.files= + +RESOURCES += \ + img.qrc \ + translation.qrc + +TRANSLATIONS +=\ + translation/tr_en.ts \ + translation/tr_zh.ts \ + translation/tr_zh.qm + + +desktop_file.files = ukui-menu-tablet.desktop +desktop_file.path = /etc/xdg/autostart + +INSTALLS += \ + target desktop_file + + + diff --git a/src/Interface/ukuichineseletter.cpp b/pad/src/Interface/ukuichineseletter.cpp old mode 100644 new mode 100755 similarity index 100% rename from src/Interface/ukuichineseletter.cpp rename to pad/src/Interface/ukuichineseletter.cpp diff --git a/src/Interface/ukuichineseletter.h b/pad/src/Interface/ukuichineseletter.h old mode 100644 new mode 100755 similarity index 100% rename from src/Interface/ukuichineseletter.h rename to pad/src/Interface/ukuichineseletter.h diff --git a/pad/src/Interface/ukuimenuinterface.cpp b/pad/src/Interface/ukuimenuinterface.cpp new file mode 100755 index 0000000..1276cda --- /dev/null +++ b/pad/src/Interface/ukuimenuinterface.cpp @@ -0,0 +1,775 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "ukuichineseletter.h" + +UkuiMenuInterface::UkuiMenuInterface() +{ +} + +QVector UkuiMenuInterface::appInfoVector=QVector(); +QVector UkuiMenuInterface::desktopfpVector=QVector(); +QVector UkuiMenuInterface::alphabeticVector=QVector(); +QVector UkuiMenuInterface::functionalVector=QVector(); +QVector UkuiMenuInterface::allAppVector=QVector(); +QStringList UkuiMenuInterface::androidDesktopfnList=QStringList(); + +UkuiMenuInterface::~UkuiMenuInterface() +{ +} + +//文件递归查询 +void UkuiMenuInterface::recursiveSearchFile(const QString& _filePath) +{ + 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; + } + } + + filePathList.append(filePathStr); + } + i++; + + } while(i < list.size()); + + g_key_file_free(keyfile); + +} + +//获取系统desktop文件路径 +QStringList UkuiMenuInterface::getDesktopFilePath() +{ + filePathList.clear(); +// getAndroidApp(); + recursiveSearchFile("/usr/share/applications/"); + + filePathList.removeAll("/usr/share/applications/software-properties-livepatch.desktop"); + filePathList.removeAll("/usr/share/applications/mate-color-select.desktop"); + filePathList.removeAll("/usr/share/applications/blueman-adapters.desktop"); + // filePathList.removeAll("/usr/share/applications/blueman-manager.desktop"); + filePathList.removeAll("/usr/share/applications/mate-user-guide.desktop"); + filePathList.removeAll("/usr/share/applications/nm-connection-editor.desktop"); + filePathList.removeAll("/usr/share/applications/debian-uxterm.desktop"); + filePathList.removeAll("/usr/share/applications/debian-xterm.desktop"); + filePathList.removeAll("/usr/share/applications/im-config.desktop"); + filePathList.removeAll("/usr/share/applications/fcitx.desktop"); + filePathList.removeAll("/usr/share/applications/fcitx-configtool.desktop"); + filePathList.removeAll("/usr/share/applications/onboard-settings.desktop"); + filePathList.removeAll("/usr/share/applications/info.desktop"); + filePathList.removeAll("/usr/share/applications/ukui-power-preferences.desktop"); + filePathList.removeAll("/usr/share/applications/ukui-power-statistics.desktop"); + filePathList.removeAll("/usr/share/applications/software-properties-drivers.desktop"); + filePathList.removeAll("/usr/share/applications/software-properties-gtk.desktop"); + filePathList.removeAll("/usr/share/applications/gnome-session-properties.desktop"); + filePathList.removeAll("/usr/share/applications/org.gnome.font-viewer.desktop"); + filePathList.removeAll("/usr/share/applications/xdiagnose.desktop"); + filePathList.removeAll("/usr/share/applications/gnome-language-selector.desktop"); + filePathList.removeAll("/usr/share/applications/mate-notification-properties.desktop"); + filePathList.removeAll("/usr/share/applications/transmission-gtk.desktop"); + filePathList.removeAll("/usr/share/applications/mpv.desktop"); + filePathList.removeAll("/usr/share/applications/system-config-printer.desktop"); + filePathList.removeAll("/usr/share/applications/org.gnome.DejaDup.desktop"); + filePathList.removeAll("/usr/share/applications/yelp.desktop"); + filePathList.removeAll("/usr/share/applications/peony-computer.desktop"); + filePathList.removeAll("/usr/share/applications/peony-home.desktop"); + filePathList.removeAll("/usr/share/applications/peony-trash.desktop"); + filePathList.removeAll("/usr/share/applications/peony.desktop"); + + //v10 + filePathList.removeAll("/usr/share/applications/mate-about.desktop"); + filePathList.removeAll("/usr/share/applications/time.desktop"); + filePathList.removeAll("/usr/share/applications/network.desktop"); + filePathList.removeAll("/usr/share/applications/shares.desktop"); + filePathList.removeAll("/usr/share/applications/mate-power-statistics.desktop"); + filePathList.removeAll("/usr/share/applications/display-im6.desktop"); + filePathList.removeAll("/usr/share/applications/display-im6.q16.desktop"); + filePathList.removeAll("/usr/share/applications/openjdk-8-policytool.desktop"); + filePathList.removeAll("/usr/share/applications/kylin-io-monitor.desktop"); + filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop"); + filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop"); + + return filePathList; +} + +//创建应用信息容器 +QVector UkuiMenuInterface::createAppInfoVector() +{ + desktopfpVector.clear(); + QVector appInfoVector; + QVector vector; + vector.append(QStringList()<<"Android");//0安卓 + vector.append(QStringList()<<"Network");//1网络 + vector.append(QStringList()<<"Messaging");//2社交 + vector.append(QStringList()<<"Audio"<<"Video");//3影音 + vector.append(QStringList()<<"Development");//4开发 + vector.append(QStringList()<<"Graphics");//5图像 + vector.append(QStringList()<<"Game");//6游戏 + vector.append(QStringList()<<"Office"<<"Calculator"<<"Spreadsheet"<<"Presentation"<<"WordProcessor"<<"TextEditor");//7办公 + vector.append(QStringList()<<"Education");//8教育 + vector.append(QStringList()<<"System"<<"Settings"<<"Security");//9系统 + + QStringList desktopfpList=getDesktopFilePath(); + + for(int i=0;i UkuiMenuInterface::getAllApp() +{ + QVector allAppVector; + QVector allAppVectorList; + + allAppVector.clear(); + allAppVectorList.clear(); + + for(int index=0;index UkuiMenuInterface::getAlphabeticClassification() +{ + QVector data; + QStringList appnameList; + appnameList.clear(); + QVector appVector[27]; + int index=0; + while(index otherVector; + QVector numberVector; + for(int i=0;i57 && 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 UkuiMenuInterface::getFunctionalClassification() +{ + QVector appVector[11]; + int index=0; + while(index 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 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 + { + 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); +} + +//获取指定类型应用列表 +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(strlen(appcategory)-6); + for(int i=0;i(getuid()); +// QDBusInterface iface("org.freedesktop.Accounts", +// "/org/freedesktop/Accounts", +// "org.freedesktop.Accounts", +// QDBusConnection::systemBus()); +// QDBusReplyobjPath=iface.call("FindUserById",uid); + +// QDBusInterface useriface("org.freedesktop.Accounts", +// objPath.value().path(), +// "org.freedesktop.DBus.Properties", +// QDBusConnection::systemBus()); +// QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","IconFile"); +// QString iconstr=var.value().toString(); +// return iconstr; +} + +QString UkuiMenuInterface::getUserName() +{ +// qint64 uid=static_cast(getuid()); +// QDBusInterface iface("org.freedesktop.Accounts", +// "/org/freedesktop/Accounts", +// "org.freedesktop.Accounts", +// QDBusConnection::systemBus()); +// QDBusReply objPath=iface.call("FindUserById",uid); +// QDBusInterface useriface("org.freedesktop.Accounts", +// objPath.value().path(), +// "org.freedesktop.DBus.Properties", +// QDBusConnection::systemBus()); +// QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","UserName"); +// QString name=var.value().toString(); +// return name; +} diff --git a/src/Interface/ukuimenuinterface.h b/pad/src/Interface/ukuimenuinterface.h old mode 100644 new mode 100755 similarity index 96% rename from src/Interface/ukuimenuinterface.h rename to pad/src/Interface/ukuimenuinterface.h index 4f2d498..60eb98c --- a/src/Interface/ukuimenuinterface.h +++ b/pad/src/Interface/ukuimenuinterface.h @@ -25,15 +25,12 @@ #include #include #include -#include class UkuiMenuInterface { private: QStringList filePathList; // QStringList androidDesktopfnList; - QSettings* setting=nullptr; - protected: void recursiveSearchFile(const QString& _filePath);//遍历/usr/share/applications/文件夹 QStringList getSpecifiedCategoryAppList(QString categorystr);//获取指定类型应用列表 @@ -65,7 +62,6 @@ class UkuiMenuInterface QVector getAlphabeticClassification();//获取字母分类 QVector getFunctionalClassification();//获取功能分类 - QVector getCommonUseApp();//获取常用App QVector getAllApp(); void getAndroidApp();//获取安卓应用 static bool cmpApp(QStringList &arg_1,QStringList &arg_2); diff --git a/pad/src/MainViewWidget/directorychangedthread.cpp b/pad/src/MainViewWidget/directorychangedthread.cpp new file mode 100755 index 0000000..4ce3a75 --- /dev/null +++ b/pad/src/MainViewWidget/directorychangedthread.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/UtilityFunction/fulllistview.h" +#include "src/UtilityFunction/fullcommonusewidget.h" +#include + +DirectoryChangedThread::DirectoryChangedThread() +{ + m_ukuiMenuInterface=new UkuiMenuInterface; + QString path=QDir::homePath()+"/.config/ukui/ukui-menu-panel.ini"; + setting=new QSettings(path,QSettings::IniFormat); + +} + +DirectoryChangedThread::~DirectoryChangedThread() +{ + delete m_ukuiMenuInterface; +} + +void DirectoryChangedThread::run() +{ +// if(this->m_path=="/usr/share/applications") +// { + + QStringList desktopfpList=m_ukuiMenuInterface->getDesktopFilePath(); + if(desktopfpList.size() > UkuiMenuInterface::desktopfpVector.size())//有新的应用安装 + { + QString m_desktopfp; + + for(int i=0;ibeginGroup("position"); + setting->setValue(desktopfn,setting->childKeys().count()); + setting->sync(); + 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()); + + break; + } + + } + + QFileInfo fileInfo(m_desktopfp); + if(fileInfo.isFile() && fileInfo.exists()) + { + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); + Q_EMIT requestUpdateSignal(m_desktopfp); + } + } + else//软件卸载 + { + // + for(int i=0;ibeginGroup("position"); + int app_position=setting->value(desktopfn).toInt(); + setting->remove(desktopfn); + setting->sync(); + setting->endGroup(); + + syslog(LOG_LOCAL0 | LOG_DEBUG ,"软件卸载desktop文件名:%s",desktopfn.toLocal8Bit().data()); + + setting->beginGroup("position"); + + //qDebug() << app_position; + + for (int index = 0; index < desktopfpList.size(); index++) { + + QFileInfo fileInfos(desktopfpList.at(index)); + QString app_name=fileInfos.fileName(); + + int po=setting->value(app_name).toInt(); + // qDebug() << app_name << po; + if(po>app_position) + { + + setting->setValue(app_name,--po); + // qDebug() << app_name << setting->value(desktopfn).toInt(); + // qDebug() << "achieve"; + } + } + setting->sync(); + setting->endGroup(); + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + iface.call("RemoveFromTaskbar",desktopfp); + break; + + } + } + + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); + Q_EMIT deleteAppSignal(); + } +// } + +} +void DirectoryChangedThread::recvDirectoryPath(QString arg) +{ + this->m_path.clear(); + this->m_path=arg; +} diff --git a/pad/src/MainViewWidget/directorychangedthread.h b/pad/src/MainViewWidget/directorychangedthread.h new file mode 100755 index 0000000..a90a57f --- /dev/null +++ b/pad/src/MainViewWidget/directorychangedthread.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" +#include +#include + +class DirectoryChangedThread: public QThread +{ + Q_OBJECT +public: + DirectoryChangedThread(); + ~DirectoryChangedThread(); + void run(); + +private: + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + QString m_path; + QSettings* setting=nullptr; + FullListView* m_listView=nullptr; + QStandardItemModel* listmodel=nullptr; + + int index=0; + +public Q_SLOTS: + /** + * @brief Receive the changed directory + * @param arg: Desktop file directory + */ + void recvDirectoryPath(QString arg); + +Q_SIGNALS: + /** + * @brief Request update signal + */ + void requestUpdateSignal(QString desktopfp); + void deleteAppSignal(); + +}; + +#endif // DIRECTORYCHANGEDTHREAD_H diff --git a/src/QtSingleApplication/QtLockedFile b/pad/src/QtSingleApplication/QtLockedFile similarity index 100% rename from src/QtSingleApplication/QtLockedFile rename to pad/src/QtSingleApplication/QtLockedFile diff --git a/src/QtSingleApplication/QtSingleApplication b/pad/src/QtSingleApplication/QtSingleApplication similarity index 100% rename from src/QtSingleApplication/QtSingleApplication rename to pad/src/QtSingleApplication/QtSingleApplication diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/pad/src/QtSingleApplication/qtlocalpeer.cpp similarity index 100% rename from src/QtSingleApplication/qtlocalpeer.cpp rename to pad/src/QtSingleApplication/qtlocalpeer.cpp diff --git a/src/QtSingleApplication/qtlocalpeer.h b/pad/src/QtSingleApplication/qtlocalpeer.h similarity index 100% rename from src/QtSingleApplication/qtlocalpeer.h rename to pad/src/QtSingleApplication/qtlocalpeer.h diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/pad/src/QtSingleApplication/qtlockedfile.cpp similarity index 100% rename from src/QtSingleApplication/qtlockedfile.cpp rename to pad/src/QtSingleApplication/qtlockedfile.cpp diff --git a/src/QtSingleApplication/qtlockedfile.h b/pad/src/QtSingleApplication/qtlockedfile.h similarity index 100% rename from src/QtSingleApplication/qtlockedfile.h rename to pad/src/QtSingleApplication/qtlockedfile.h diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/pad/src/QtSingleApplication/qtlockedfile_unix.cpp similarity index 100% rename from src/QtSingleApplication/qtlockedfile_unix.cpp rename to pad/src/QtSingleApplication/qtlockedfile_unix.cpp diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/pad/src/QtSingleApplication/qtlockedfile_win.cpp similarity index 100% rename from src/QtSingleApplication/qtlockedfile_win.cpp rename to pad/src/QtSingleApplication/qtlockedfile_win.cpp diff --git a/pad/src/QtSingleApplication/qtsingleapplication.cpp b/pad/src/QtSingleApplication/qtsingleapplication.cpp new file mode 100644 index 0000000..a39a3f6 --- /dev/null +++ b/pad/src/QtSingleApplication/qtsingleapplication.cpp @@ -0,0 +1,352 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsingleapplication.h" +#include "qtlocalpeer.h" +#include +#include +#include +#include +#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->show(); +// 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/src/QtSingleApplication/qtsingleapplication.h b/pad/src/QtSingleApplication/qtsingleapplication.h similarity index 100% rename from src/QtSingleApplication/qtsingleapplication.h rename to pad/src/QtSingleApplication/qtsingleapplication.h diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/pad/src/QtSingleApplication/qtsingleapplication.pri similarity index 100% rename from src/QtSingleApplication/qtsingleapplication.pri rename to pad/src/QtSingleApplication/qtsingleapplication.pri diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/pad/src/QtSingleApplication/qtsinglecoreapplication.cpp similarity index 100% rename from src/QtSingleApplication/qtsinglecoreapplication.cpp rename to pad/src/QtSingleApplication/qtsinglecoreapplication.cpp diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/pad/src/QtSingleApplication/qtsinglecoreapplication.h similarity index 100% rename from src/QtSingleApplication/qtsinglecoreapplication.h rename to pad/src/QtSingleApplication/qtsinglecoreapplication.h diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/pad/src/QtSingleApplication/qtsinglecoreapplication.pri similarity index 100% rename from src/QtSingleApplication/qtsinglecoreapplication.pri rename to pad/src/QtSingleApplication/qtsinglecoreapplication.pri diff --git a/src/Style/style.cpp b/pad/src/Style/style.cpp old mode 100644 new mode 100755 similarity index 100% rename from src/Style/style.cpp rename to pad/src/Style/style.cpp diff --git a/src/Style/style.h b/pad/src/Style/style.h old mode 100644 new mode 100755 similarity index 98% rename from src/Style/style.h rename to pad/src/Style/style.h index c1f6e64..d8ce933 --- a/src/Style/style.h +++ b/pad/src/Style/style.h @@ -21,10 +21,10 @@ #include #include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include #include diff --git a/pad/src/UtilityFunction/fullcommonusewidget.cpp b/pad/src/UtilityFunction/fullcommonusewidget.cpp new file mode 100755 index 0000000..43ff0b6 --- /dev/null +++ b/pad/src/UtilityFunction/fullcommonusewidget.cpp @@ -0,0 +1,159 @@ +#include "fullcommonusewidget.h" +#include +#include "src/Style/style.h" +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/UtilityFunction/fulllistview.h" + + +FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : QWidget(parent) +{ + QString path=QDir::homePath()+"/.config/ukui/ukui-menu-panel.ini"; + setting=new QSettings(path,QSettings::IniFormat); + initUi(); +} + +QVector FullCommonUseWidget::keyVector=QVector(); +QVector FullCommonUseWidget::keyValueVector=QVector(); + +void FullCommonUseWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAutoFillBackground(false); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setStyleSheet("border:1px solid #ff0000;background:transparent;"); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setFixedSize(1409,QApplication::primaryScreen()->geometry().height()-46); + + QHBoxLayout* mainLayout=new QHBoxLayout; + mainLayout->setContentsMargins(105,96,0,0); + this->setLayout(mainLayout); + m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); + mainLayout->addItem(m_spaceItem); + + m_ukuiMenuInterface=new UkuiMenuInterface; + + initAppListWidget(); +// fillAppList(); +} + +void FullCommonUseWidget::initAppListWidget() +{ + m_listView=new FullListView(this,0); + m_listView->setFixedSize(this->width()-105,this->height()-96); + + QHBoxLayout *mainLayout=qobject_cast(this->layout()); + mainLayout->insertWidget(1,m_listView); + connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication); + // connect(m_listView,&FullListView::sendUpdateAppListSignal,this,&FullCommonUseWidget::updateListViewSlot); + + +} + +void FullCommonUseWidget::fillAppList() +{ + m_data.clear(); + keyVector.clear(); + keyValueVector.clear(); + if(!setting->childGroups().contains("position")) + { + Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) + m_data.append(desktopfp); + m_listView->addData(m_data); + + setting->beginGroup("position"); + for (int index = 0; index < m_data.size(); index++) { + + // QString data_info = m_data.at(index).split("\/").last(); + + QFileInfo fileInfo(m_data.at(index)); + QString desktopfn=fileInfo.fileName(); + setting->setValue(desktopfn,index); + setting->sync(); + } + + setting->endGroup(); + } + else + { + setting->beginGroup("position"); + QStringList keyList=setting->childKeys(); + Q_FOREACH(QString desktopfn,keyList) + { + keyVector.append(desktopfn); + keyValueVector.append(setting->value(desktopfn).toInt()); + } + setting->endGroup(); + qSort(keyList.begin(),keyList.end(),cmpApp); + + Q_FOREACH(QString desktopfn,keyList) + m_data.append("/usr/share/applications/"+desktopfn); + m_listView->addData(m_data); + + } + + +} + +bool FullCommonUseWidget::cmpApp(QString &arg_1, QString &arg_2) +{ + if(keyValueVector.at(keyVector.indexOf(arg_1)) < keyValueVector.at(keyVector.indexOf(arg_2))) + return true; + else + return false; +} + + +/** + * 执行应用程序 + */ +void FullCommonUseWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); + g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); + g_object_unref(desktopAppInfo); +} + +/** + * 更新应用列表 + */ +void FullCommonUseWidget::updateListViewSlot() +{ +// updateListView(); +} + +void FullCommonUseWidget::updateListView(QString desktopfp) +{ +// m_data.clear(); +// Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllApp()) +// m_data.append(desktopfp); +// m_listView->updateData(m_data); + m_listView->insertData(desktopfp); + +} + +FullCommonUseWidget::~FullCommonUseWidget() +{ + delete m_ukuiMenuInterface; +} +void FullCommonUseWidget::deleteAppListView() +{ + m_data.clear(); + keyVector.clear(); + keyValueVector.clear(); + + setting->beginGroup("position"); + QStringList keyList=setting->childKeys(); + Q_FOREACH(QString desktopfn,keyList) + { + keyVector.append(desktopfn); + keyValueVector.append(setting->value(desktopfn).toInt()); + } + setting->endGroup(); + qSort(keyList.begin(),keyList.end(),cmpApp); + + Q_FOREACH(QString desktopfn,keyList) + m_data.append("/usr/share/applications/"+desktopfn); + m_listView->addData(m_data); +} diff --git a/pad/src/UtilityFunction/fullcommonusewidget.h b/pad/src/UtilityFunction/fullcommonusewidget.h new file mode 100755 index 0000000..e805641 --- /dev/null +++ b/pad/src/UtilityFunction/fullcommonusewidget.h @@ -0,0 +1,79 @@ +#ifndef FullCommonUseWidget_H +#define FullCommonUseWidget_H + +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/Style/style.h" +#include "src/UtilityFunction/fulllistview.h" +#include +#include +#include + + +class FullCommonUseWidget : public QWidget +{ + Q_OBJECT +public: + explicit FullCommonUseWidget(QWidget *parent = nullptr); + ~FullCommonUseWidget(); + + /** + * @brief Update application list + */ + void updateListView(QString desktopfp); + + void deleteAppListView(); + + /** + * @brief fill application list + */ + void fillAppList(); + + +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + FullListView* m_listView=nullptr; + QStringList m_data; + QSpacerItem *m_spaceItem=nullptr; + QSettings* setting; + static QVector keyVector; + static QVector keyValueVector; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Initialize the application list interface + */ + void initAppListWidget(); + + static bool cmpApp(QString &arg_1,QString &arg_2); + + +public Q_SLOTS: + /** + * @brief Open the application + * @param arg: Desktop file path + */ + void execApplication(QString desktopfp); + /** + * @brief Update the application list slot function + */ + void updateListViewSlot(); + +Q_SIGNALS: + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + void sendSortApplistSignal(); +}; + +#endif // FullCommonUseWidget_H diff --git a/pad/src/UtilityFunction/fullitemdelegate.cpp b/pad/src/UtilityFunction/fullitemdelegate.cpp new file mode 100755 index 0000000..e7b3216 --- /dev/null +++ b/pad/src/UtilityFunction/fullitemdelegate.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + +FullItemDelegate::FullItemDelegate(QObject *parent, int module): + QStyledItemDelegate(parent) +{ + this->module=module; + pUkuiMenuInterface=new UkuiMenuInterface; +} + +FullItemDelegate::~FullItemDelegate() +{ + delete pUkuiMenuInterface; +} + +void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + + if(index.isValid()) + { + painter->save(); + QStyleOptionViewItem viewOption(option);//用来在视图中画一个item + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height()); + + //QPainterPath画圆角矩形 + const qreal radius = 4; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + + painter->setOpacity(1); + QString desktopfp=index.data(Qt::DisplayRole).value(); + QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) + icon=QIcon(iconstr); + else + { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon=QIcon::fromTheme(iconstr); + if(icon.isNull()) + { + if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else + icon=QIcon::fromTheme(QString("application-x-desktop")); + } + } + + QString appname=pUkuiMenuInterface->getAppName(desktopfp); + + QRect iconRect; + QRect textRect; + iconRect=QRect(rect.x()+32, + rect.y(), + 86, + 86); + icon.paint(painter,iconRect); + + textRect=QRect(rect.x(), + iconRect.bottom(), + rect.width(), + rect.height()-iconRect.height()); + + //富文本处理 +// QFontMetrics fm=painter->fontMetrics(); +// QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width(),Qt::TextShowMnemonic); +// painter->setPen(QPen(Qt::white)); +// painter->drawText(textRect,Qt::AlignHCenter |Qt::AlignTop,appnameElidedText); + + //文本换行 + painter->setPen(QPen(Qt::white)); + painter->drawText(textRect,Qt::TextWordWrap | Qt::AlignCenter, appname); + + painter->restore(); + + } +} + +QSize FullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(150,150); +} diff --git a/pad/src/UtilityFunction/fullitemdelegate.h b/pad/src/UtilityFunction/fullitemdelegate.h new file mode 100755 index 0000000..43904a3 --- /dev/null +++ b/pad/src/UtilityFunction/fullitemdelegate.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Style/style.h" +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/Style/style.h" + +class FullItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + FullItemDelegate(QObject* parent,int module); + ~FullItemDelegate(); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + int module=0; + UkuiMenuInterface* pUkuiMenuInterface=nullptr; + +protected: + // bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); +}; + +#endif // FULLITEMDELEGATE_H diff --git a/pad/src/UtilityFunction/fulllistview.cpp b/pad/src/UtilityFunction/fulllistview.cpp new file mode 100755 index 0000000..2f4e9fd --- /dev/null +++ b/pad/src/UtilityFunction/fulllistview.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + +FullListView::FullListView(QWidget *parent, int module): + QListView(parent) +{ + this->module=module; + initWidget(); + pUkuiMenuInterface=new UkuiMenuInterface; +} + +FullListView::~FullListView() +{ + delete pUkuiMenuInterface; +} + +void FullListView::initWidget() +{ + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_TranslucentBackground); + this->setViewMode(QListView::IconMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setMouseTracking(true); + this->setFocusPolicy(Qt::NoFocus); +// this->setMovement(QListView::Static); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + this->setGridSize(QSize(201,188)); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + //connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot); + connect(this,&FullListView::clicked,this,&FullListView::onClicked); +} + +void FullListView::addData(QStringList data) +{ + listmodel=new QStandardItemModel(this); + this->setModel(listmodel); + Q_FOREACH(QString desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); + listmodel->appendRow(item); + } + m_delegate= new FullItemDelegate(this,module); + this->setItemDelegate(m_delegate); +} + +void FullListView::updateData(QStringList data) +{ + listmodel->clear(); + Q_FOREACH(QString desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); + listmodel->appendRow(item); + } +} + +void FullListView::insertData(QString desktopfp) +{ + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); + listmodel->appendRow(item); +} + +void FullListView::onClicked(QModelIndex index) +{ + QVariant var = listmodel->data(index, Qt::DisplayRole); + if(var.isValid()) + { + QString desktopfp=var.value(); + QFileInfo fileInfo(desktopfp); + QString desktopfn=fileInfo.fileName(); + Q_EMIT sendItemClickedSignal(desktopfp); + + } +} + + + diff --git a/pad/src/UtilityFunction/fulllistview.h b/pad/src/UtilityFunction/fulllistview.h new file mode 100755 index 0000000..5d4119b --- /dev/null +++ b/pad/src/UtilityFunction/fulllistview.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/RightClickMenu/rightclickmenu.h" +#include "src/Interface/ukuimenuinterface.h" +#include +#include +#include +#include +#include "fullitemdelegate.h" +#include "src/Style/style.h" + +class FullListView : public QListView +{ + Q_OBJECT +public: + FullListView(QWidget *parent,int module); + ~FullListView(); + + void addData(QStringList data);//字母排序模块添加数据 + void updateData(QStringList data); + void insertData(QString desktopfp); + +protected: + void initWidget(); + +private: + FullItemDelegate* m_delegate=nullptr; + QStandardItemModel* listmodel=nullptr; + int module=0; + + // RightClickMenu* menu=nullptr;//右键菜单 + QStringList data; + + UkuiMenuInterface* pUkuiMenuInterface=nullptr; + +private Q_SLOTS: + void onClicked(QModelIndex index);//点击item + //void rightClickedSlot(const QPoint &pos);//右键菜单 + +Q_SIGNALS: + void sendItemClickedSignal(QString arg);//发送item点击信号 + void sendHideMainWindowSignal(); + void sendUpdateAppListSignal(); + + +}; + +#endif // FULLLISTVIEW_H diff --git a/pad/translation.qrc b/pad/translation.qrc new file mode 100644 index 0000000..15078be --- /dev/null +++ b/pad/translation.qrc @@ -0,0 +1,7 @@ + + + translation/tr_en.ts + translation/tr_zh.qm + translation/tr_zh.ts + + diff --git a/pad/translation/tr_en.ts b/pad/translation/tr_en.ts new file mode 100644 index 0000000..72bbd8b --- /dev/null +++ b/pad/translation/tr_en.ts @@ -0,0 +1,12 @@ + + + + + MainWindow + + + Search your application、file + + + + diff --git a/pad/translation/tr_zh.qm b/pad/translation/tr_zh.qm new file mode 100644 index 0000000..f3fc1af Binary files /dev/null and b/pad/translation/tr_zh.qm differ diff --git a/pad/translation/tr_zh.ts b/pad/translation/tr_zh.ts new file mode 100644 index 0000000..4ad251d --- /dev/null +++ b/pad/translation/tr_zh.ts @@ -0,0 +1,13 @@ + + + + + MainWindow + + + Search your application、file + 搜索你的文件、应用 + 搜索你的文件、应用 + + + diff --git a/pad/ukui-menu-tablet.desktop b/pad/ukui-menu-tablet.desktop new file mode 100644 index 0000000..b113434 --- /dev/null +++ b/pad/ukui-menu-tablet.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=ukui-menu-tablet +comment=ukui-menu +Comment[zh_CN]=开始菜单 +Comment[tr_TR]=Başlangıç menüsü +Exec=/usr/bin/ukui-menu-tablet +Terminal=false +Type=Application +Icon=ukui-menu +X-UKUI-AutoRestart=true +OnlyShowIn=UKUI +X-UKUI-Autostart-Phase=Application +NoDisplay=true diff --git a/pc/COPYING b/pc/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/pc/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/pc/NEWS b/pc/NEWS new file mode 100644 index 0000000..452d6e2 --- /dev/null +++ b/pc/NEWS @@ -0,0 +1,7 @@ +### ukui-menu 2.0.0 + + * Rewrite the project using Qt. + +### ukui-menu 1.0.0 + + * Fork from mate-menu diff --git a/README.md b/pc/README.md similarity index 98% rename from README.md rename to pc/README.md index e1d44df..1b92990 100644 --- a/README.md +++ b/pc/README.md @@ -33,3 +33,4 @@ Note: build-depends references the paragraph in debian/control. > sudo make install Note: If you want to run ukui-menu, You just need to execute the ukui-menu command at the terminal. +# ukui-menu diff --git a/data/img/mainviewwidget/Development-Checked.svg b/pc/data/img/mainviewwidget/Development-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Development-Checked.svg rename to pc/data/img/mainviewwidget/Development-Checked.svg diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/pc/data/img/mainviewwidget/Development-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Development-Disabled.svg rename to pc/data/img/mainviewwidget/Development-Disabled.svg diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/pc/data/img/mainviewwidget/Development-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Development-Enabled.svg rename to pc/data/img/mainviewwidget/Development-Enabled.svg diff --git a/data/img/mainviewwidget/Development-Normal.svg b/pc/data/img/mainviewwidget/Development-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Development-Normal.svg rename to pc/data/img/mainviewwidget/Development-Normal.svg diff --git a/data/img/mainviewwidget/Education-Checked.svg b/pc/data/img/mainviewwidget/Education-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Education-Checked.svg rename to pc/data/img/mainviewwidget/Education-Checked.svg diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/pc/data/img/mainviewwidget/Education-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Education-Disabled.svg rename to pc/data/img/mainviewwidget/Education-Disabled.svg diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/pc/data/img/mainviewwidget/Education-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Education-Enabled.svg rename to pc/data/img/mainviewwidget/Education-Enabled.svg diff --git a/data/img/mainviewwidget/Education-Normal.svg b/pc/data/img/mainviewwidget/Education-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Education-Normal.svg rename to pc/data/img/mainviewwidget/Education-Normal.svg diff --git a/data/img/mainviewwidget/Game-Checked.svg b/pc/data/img/mainviewwidget/Game-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Game-Checked.svg rename to pc/data/img/mainviewwidget/Game-Checked.svg diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/pc/data/img/mainviewwidget/Game-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Game-Disabled.svg rename to pc/data/img/mainviewwidget/Game-Disabled.svg diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/pc/data/img/mainviewwidget/Game-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Game-Enabled.svg rename to pc/data/img/mainviewwidget/Game-Enabled.svg diff --git a/data/img/mainviewwidget/Game-Normal.svg b/pc/data/img/mainviewwidget/Game-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Game-Normal.svg rename to pc/data/img/mainviewwidget/Game-Normal.svg diff --git a/data/img/mainviewwidget/Image-Checked.svg b/pc/data/img/mainviewwidget/Image-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Image-Checked.svg rename to pc/data/img/mainviewwidget/Image-Checked.svg diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/pc/data/img/mainviewwidget/Image-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Image-Disabled.svg rename to pc/data/img/mainviewwidget/Image-Disabled.svg diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/pc/data/img/mainviewwidget/Image-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Image-Enabled.svg rename to pc/data/img/mainviewwidget/Image-Enabled.svg diff --git a/data/img/mainviewwidget/Image-Normal.svg b/pc/data/img/mainviewwidget/Image-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Image-Normal.svg rename to pc/data/img/mainviewwidget/Image-Normal.svg diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/pc/data/img/mainviewwidget/Internet-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Internet-Checked.svg rename to pc/data/img/mainviewwidget/Internet-Checked.svg diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/pc/data/img/mainviewwidget/Internet-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Internet-Disabled.svg rename to pc/data/img/mainviewwidget/Internet-Disabled.svg diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/pc/data/img/mainviewwidget/Internet-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Internet-Enabled.svg rename to pc/data/img/mainviewwidget/Internet-Enabled.svg diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/pc/data/img/mainviewwidget/Internet-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Internet-Normal.svg rename to pc/data/img/mainviewwidget/Internet-Normal.svg diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/pc/data/img/mainviewwidget/Mobile-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Mobile-Checked.svg rename to pc/data/img/mainviewwidget/Mobile-Checked.svg diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/pc/data/img/mainviewwidget/Mobile-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Mobile-Disabled.svg rename to pc/data/img/mainviewwidget/Mobile-Disabled.svg diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/pc/data/img/mainviewwidget/Mobile-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Mobile-Enabled.svg rename to pc/data/img/mainviewwidget/Mobile-Enabled.svg diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/pc/data/img/mainviewwidget/Mobile-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Mobile-Normal.svg rename to pc/data/img/mainviewwidget/Mobile-Normal.svg diff --git a/data/img/mainviewwidget/Office-Checked.svg b/pc/data/img/mainviewwidget/Office-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Office-Checked.svg rename to pc/data/img/mainviewwidget/Office-Checked.svg diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/pc/data/img/mainviewwidget/Office-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Office-Disabled.svg rename to pc/data/img/mainviewwidget/Office-Disabled.svg diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/pc/data/img/mainviewwidget/Office-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Office-Enabled.svg rename to pc/data/img/mainviewwidget/Office-Enabled.svg diff --git a/data/img/mainviewwidget/Office-Normal.svg b/pc/data/img/mainviewwidget/Office-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Office-Normal.svg rename to pc/data/img/mainviewwidget/Office-Normal.svg diff --git a/data/img/mainviewwidget/Others-Checked.svg b/pc/data/img/mainviewwidget/Others-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Others-Checked.svg rename to pc/data/img/mainviewwidget/Others-Checked.svg diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/pc/data/img/mainviewwidget/Others-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Others-Disabled.svg rename to pc/data/img/mainviewwidget/Others-Disabled.svg diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/pc/data/img/mainviewwidget/Others-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Others-Enabled.svg rename to pc/data/img/mainviewwidget/Others-Enabled.svg diff --git a/data/img/mainviewwidget/Others-Normal.svg b/pc/data/img/mainviewwidget/Others-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Others-Normal.svg rename to pc/data/img/mainviewwidget/Others-Normal.svg diff --git a/data/img/mainviewwidget/Social-Checked.svg b/pc/data/img/mainviewwidget/Social-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Social-Checked.svg rename to pc/data/img/mainviewwidget/Social-Checked.svg diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/pc/data/img/mainviewwidget/Social-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Social-Disabled.svg rename to pc/data/img/mainviewwidget/Social-Disabled.svg diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/pc/data/img/mainviewwidget/Social-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Social-Enabled.svg rename to pc/data/img/mainviewwidget/Social-Enabled.svg diff --git a/data/img/mainviewwidget/Social-Normal.svg b/pc/data/img/mainviewwidget/Social-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Social-Normal.svg rename to pc/data/img/mainviewwidget/Social-Normal.svg diff --git a/data/img/mainviewwidget/System-Checked.svg b/pc/data/img/mainviewwidget/System-Checked.svg similarity index 100% rename from data/img/mainviewwidget/System-Checked.svg rename to pc/data/img/mainviewwidget/System-Checked.svg diff --git a/data/img/mainviewwidget/System-Disabled.svg b/pc/data/img/mainviewwidget/System-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/System-Disabled.svg rename to pc/data/img/mainviewwidget/System-Disabled.svg diff --git a/data/img/mainviewwidget/System-Enabled.svg b/pc/data/img/mainviewwidget/System-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/System-Enabled.svg rename to pc/data/img/mainviewwidget/System-Enabled.svg diff --git a/data/img/mainviewwidget/System-Normal.svg b/pc/data/img/mainviewwidget/System-Normal.svg similarity index 100% rename from data/img/mainviewwidget/System-Normal.svg rename to pc/data/img/mainviewwidget/System-Normal.svg diff --git a/data/img/mainviewwidget/Video-Checked.svg b/pc/data/img/mainviewwidget/Video-Checked.svg similarity index 100% rename from data/img/mainviewwidget/Video-Checked.svg rename to pc/data/img/mainviewwidget/Video-Checked.svg diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/pc/data/img/mainviewwidget/Video-Disabled.svg similarity index 100% rename from data/img/mainviewwidget/Video-Disabled.svg rename to pc/data/img/mainviewwidget/Video-Disabled.svg diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/pc/data/img/mainviewwidget/Video-Enabled.svg similarity index 100% rename from data/img/mainviewwidget/Video-Enabled.svg rename to pc/data/img/mainviewwidget/Video-Enabled.svg diff --git a/data/img/mainviewwidget/Video-Normal.svg b/pc/data/img/mainviewwidget/Video-Normal.svg similarity index 100% rename from data/img/mainviewwidget/Video-Normal.svg rename to pc/data/img/mainviewwidget/Video-Normal.svg diff --git a/data/img/mainviewwidget/attributeaction.svg b/pc/data/img/mainviewwidget/attributeaction.svg similarity index 100% rename from data/img/mainviewwidget/attributeaction.svg rename to pc/data/img/mainviewwidget/attributeaction.svg diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/pc/data/img/mainviewwidget/downarrow-pressed.svg similarity index 100% rename from data/img/mainviewwidget/downarrow-pressed.svg rename to pc/data/img/mainviewwidget/downarrow-pressed.svg diff --git a/data/img/mainviewwidget/downarrow.svg b/pc/data/img/mainviewwidget/downarrow.svg similarity index 100% rename from data/img/mainviewwidget/downarrow.svg rename to pc/data/img/mainviewwidget/downarrow.svg diff --git a/data/img/mainviewwidget/fixed.svg b/pc/data/img/mainviewwidget/fixed.svg similarity index 100% rename from data/img/mainviewwidget/fixed.svg rename to pc/data/img/mainviewwidget/fixed.svg diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/pc/data/img/mainviewwidget/leftarrow-hover.svg similarity index 100% rename from data/img/mainviewwidget/leftarrow-hover.svg rename to pc/data/img/mainviewwidget/leftarrow-hover.svg diff --git a/data/img/mainviewwidget/leftarrow.svg b/pc/data/img/mainviewwidget/leftarrow.svg similarity index 100% rename from data/img/mainviewwidget/leftarrow.svg rename to pc/data/img/mainviewwidget/leftarrow.svg diff --git a/data/img/mainviewwidget/lock-fs.svg b/pc/data/img/mainviewwidget/lock-fs.svg similarity index 100% rename from data/img/mainviewwidget/lock-fs.svg rename to pc/data/img/mainviewwidget/lock-fs.svg diff --git a/data/img/mainviewwidget/lock.svg b/pc/data/img/mainviewwidget/lock.svg similarity index 100% rename from data/img/mainviewwidget/lock.svg rename to pc/data/img/mainviewwidget/lock.svg diff --git a/data/img/mainviewwidget/recent-disabled.svg b/pc/data/img/mainviewwidget/recent-disabled.svg similarity index 100% rename from data/img/mainviewwidget/recent-disabled.svg rename to pc/data/img/mainviewwidget/recent-disabled.svg diff --git a/data/img/mainviewwidget/recent-enabled.svg b/pc/data/img/mainviewwidget/recent-enabled.svg similarity index 100% rename from data/img/mainviewwidget/recent-enabled.svg rename to pc/data/img/mainviewwidget/recent-enabled.svg diff --git a/data/img/mainviewwidget/recent-gray.svg b/pc/data/img/mainviewwidget/recent-gray.svg similarity index 100% rename from data/img/mainviewwidget/recent-gray.svg rename to pc/data/img/mainviewwidget/recent-gray.svg diff --git a/data/img/mainviewwidget/recent.svg b/pc/data/img/mainviewwidget/recent.svg similarity index 100% rename from data/img/mainviewwidget/recent.svg rename to pc/data/img/mainviewwidget/recent.svg diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/pc/data/img/mainviewwidget/rightarrow-hover.svg similarity index 100% rename from data/img/mainviewwidget/rightarrow-hover.svg rename to pc/data/img/mainviewwidget/rightarrow-hover.svg diff --git a/data/img/mainviewwidget/rightarrow.svg b/pc/data/img/mainviewwidget/rightarrow.svg similarity index 100% rename from data/img/mainviewwidget/rightarrow.svg rename to pc/data/img/mainviewwidget/rightarrow.svg diff --git a/pc/data/img/mainviewwidget/search.svg b/pc/data/img/mainviewwidget/search.svg new file mode 100644 index 0000000..1516f6b --- /dev/null +++ b/pc/data/img/mainviewwidget/search.svg @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/data/img/mainviewwidget/unfixed.svg b/pc/data/img/mainviewwidget/unfixed.svg similarity index 100% rename from data/img/mainviewwidget/unfixed.svg rename to pc/data/img/mainviewwidget/unfixed.svg diff --git a/data/img/mainviewwidget/uninstall.svg b/pc/data/img/mainviewwidget/uninstall.svg similarity index 100% rename from data/img/mainviewwidget/uninstall.svg rename to pc/data/img/mainviewwidget/uninstall.svg diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/pc/data/img/mainviewwidget/uparrow-pressed.svg similarity index 100% rename from data/img/mainviewwidget/uparrow-pressed.svg rename to pc/data/img/mainviewwidget/uparrow-pressed.svg diff --git a/data/img/mainviewwidget/uparrow.svg b/pc/data/img/mainviewwidget/uparrow.svg similarity index 100% rename from data/img/mainviewwidget/uparrow.svg rename to pc/data/img/mainviewwidget/uparrow.svg diff --git a/data/img/sidebarwidget/commonuse.svg b/pc/data/img/sidebarwidget/commonuse.svg similarity index 100% rename from data/img/sidebarwidget/commonuse.svg rename to pc/data/img/sidebarwidget/commonuse.svg diff --git a/data/img/sidebarwidget/computer.svg b/pc/data/img/sidebarwidget/computer.svg similarity index 100% rename from data/img/sidebarwidget/computer.svg rename to pc/data/img/sidebarwidget/computer.svg diff --git a/data/img/sidebarwidget/control.svg b/pc/data/img/sidebarwidget/control.svg similarity index 100% rename from data/img/sidebarwidget/control.svg rename to pc/data/img/sidebarwidget/control.svg diff --git a/data/img/sidebarwidget/fixed.svg b/pc/data/img/sidebarwidget/fixed.svg similarity index 100% rename from data/img/sidebarwidget/fixed.svg rename to pc/data/img/sidebarwidget/fixed.svg diff --git a/data/img/sidebarwidget/fullusericon.png b/pc/data/img/sidebarwidget/fullusericon.png similarity index 100% rename from data/img/sidebarwidget/fullusericon.png rename to pc/data/img/sidebarwidget/fullusericon.png diff --git a/data/img/sidebarwidget/function.svg b/pc/data/img/sidebarwidget/function.svg similarity index 100% rename from data/img/sidebarwidget/function.svg rename to pc/data/img/sidebarwidget/function.svg diff --git a/data/img/sidebarwidget/letter.svg b/pc/data/img/sidebarwidget/letter.svg similarity index 100% rename from data/img/sidebarwidget/letter.svg rename to pc/data/img/sidebarwidget/letter.svg diff --git a/data/img/sidebarwidget/lock.svg b/pc/data/img/sidebarwidget/lock.svg similarity index 100% rename from data/img/sidebarwidget/lock.svg rename to pc/data/img/sidebarwidget/lock.svg diff --git a/data/img/sidebarwidget/max.svg b/pc/data/img/sidebarwidget/max.svg similarity index 100% rename from data/img/sidebarwidget/max.svg rename to pc/data/img/sidebarwidget/max.svg diff --git a/data/img/sidebarwidget/min.svg b/pc/data/img/sidebarwidget/min.svg similarity index 100% rename from data/img/sidebarwidget/min.svg rename to pc/data/img/sidebarwidget/min.svg diff --git a/data/img/sidebarwidget/personal.svg b/pc/data/img/sidebarwidget/personal.svg similarity index 100% rename from data/img/sidebarwidget/personal.svg rename to pc/data/img/sidebarwidget/personal.svg diff --git a/data/img/sidebarwidget/rightarrow.svg b/pc/data/img/sidebarwidget/rightarrow.svg similarity index 100% rename from data/img/sidebarwidget/rightarrow.svg rename to pc/data/img/sidebarwidget/rightarrow.svg diff --git a/data/img/sidebarwidget/setting.svg b/pc/data/img/sidebarwidget/setting.svg similarity index 100% rename from data/img/sidebarwidget/setting.svg rename to pc/data/img/sidebarwidget/setting.svg diff --git a/data/img/sidebarwidget/shutdown.svg b/pc/data/img/sidebarwidget/shutdown.svg similarity index 100% rename from data/img/sidebarwidget/shutdown.svg rename to pc/data/img/sidebarwidget/shutdown.svg diff --git a/data/img/sidebarwidget/trash.svg b/pc/data/img/sidebarwidget/trash.svg similarity index 100% rename from data/img/sidebarwidget/trash.svg rename to pc/data/img/sidebarwidget/trash.svg diff --git a/data/img/sidebarwidget/unfixed.svg b/pc/data/img/sidebarwidget/unfixed.svg similarity index 100% rename from data/img/sidebarwidget/unfixed.svg rename to pc/data/img/sidebarwidget/unfixed.svg diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/pc/data/img/sidebarwidget/usericon-darkcolor.svg similarity index 100% rename from data/img/sidebarwidget/usericon-darkcolor.svg rename to pc/data/img/sidebarwidget/usericon-darkcolor.svg diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/pc/data/img/sidebarwidget/usericon-lightcolor.svg similarity index 100% rename from data/img/sidebarwidget/usericon-lightcolor.svg rename to pc/data/img/sidebarwidget/usericon-lightcolor.svg diff --git a/main.cpp b/pc/main.cpp similarity index 62% rename from main.cpp rename to pc/main.cpp index 598276d..0d77a99 100644 --- a/main.cpp +++ b/pc/main.cpp @@ -27,6 +27,13 @@ #include #include +#include +#include +#include + +#include +// + int getScreenWidth() { Display *disp = XOpenDisplay(NULL); Screen *scrn = DefaultScreenOfDisplay(disp); @@ -43,6 +50,7 @@ int getScreenWidth() { int main(int argc, char *argv[]) { + qRegisterMetaType>("QVector"); if (getScreenWidth() > 2560) { @@ -54,6 +62,8 @@ int main(int argc, char *argv[]) app.setQuitOnLastWindowClosed(false); + + if(app.isRunning()) { app.sendMessage("raise_window_noop"); @@ -100,55 +110,31 @@ int main(int argc, char *argv[]) w.setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y,Style::minw,Style::minh)); app.setActivationWindow(&w); -// QRectF rect; -// rect.setX(w.rect().x()+1); -// rect.setY(w.rect().y()+1); -// rect.setWidth(w.rect().width()-2); -// rect.setHeight(w.rect().height()-2); - -// //QPainterPath画圆角矩形 -// const qreal radius = 6; -// QPainterPath path; -// path.moveTo(rect.topRight() - QPointF(radius, 0)); -// path.lineTo(rect.topLeft() + QPointF(radius, 0)); -// path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); -// path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); -// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); -// path.lineTo(rect.bottomRight() - QPointF(radius, 0)); -// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); -// path.lineTo(rect.topRight() + QPointF(0, radius)); -// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - - //右上角 -// path.moveTo(rect.topRight() - QPointF(radius, 0)); -// path.lineTo(rect.topLeft()); -// path.lineTo(rect.bottomLeft()); -// path.lineTo(rect.bottomRight()); -// path.lineTo(rect.topRight() + QPointF(0, radius)); -// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - //右下角 -// path.moveTo(rect.topRight()); -// path.lineTo(rect.topLeft()); -// path.lineTo(rect.bottomLeft()); -// path.lineTo(rect.bottomRight() - QPointF(radius, 0)); -// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); -// path.lineTo(rect.topRight()); - //左下角 -// path.moveTo(rect.topRight()); -// path.lineTo(rect.topLeft()); -// path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); -// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); -// path.lineTo(rect.bottomRight()); -// path.lineTo(rect.topRight()); -// w.setFrameStyle(); -// w.setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - //注释掉,以保证自启动时不显示界面 -// w.show(); -// w.raise(); -// w.activateWindow(); -// w.hide(); + KWindowEffects::enableBlurBehind(w.winId(),true); + + + + +//// +// QGSettings* tabletMode= new QGSettings(TABLED_SCHEMA); +// bool res = tabletMode->get("tablet-mode").toBool(); +// qDebug()<setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); + this->setStyleSheet("border:0px;background:transparent;");//transparent this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); + this->setFixedSize(Style::widthavailable, + Style::AppListWidHeight);//Style::MainViewWidWidth QHBoxLayout* mainLayout=new QHBoxLayout; // mainLayout->setContentsMargins(Style::LeftWidWidth,0,0,0); - mainLayout->setContentsMargins(0,0,0,0); + mainLayout->setContentsMargins(Style::listleftMargin,0,Style::listleftMargin+6,0);//Style::listleftMargin,100 this->setLayout(mainLayout); - m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); + m_spaceItem=new QSpacerItem(0,20,QSizePolicy::Expanding,QSizePolicy::Fixed);// 40-50 mainLayout->addItem(m_spaceItem); m_ukuiMenuInterface=new UkuiMenuInterface; @@ -57,12 +57,15 @@ void FullCommonUseWidget::initUi() void FullCommonUseWidget::initAppListWidget() { m_listView=new FullListView(this,0); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::listleftMargin*2+6,this->height());//Style::widthavailable-Style::LeftWidWidth + QHBoxLayout *mainLayout=qobject_cast(this->layout()); mainLayout->insertWidget(1,m_listView); + connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication); connect(m_listView,&FullListView::sendUpdateAppListSignal,this,&FullCommonUseWidget::updateListViewSlot); connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullCommonUseWidget::sendHideMainWindowSignal); + } void FullCommonUseWidget::fillAppList() @@ -78,11 +81,13 @@ void FullCommonUseWidget::fillAppList() */ void FullCommonUseWidget::execApplication(QString desktopfp) { - Q_EMIT sendHideMainWindowSignal(); - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo);} + Q_EMIT sendHideMainWindowSignal(); + GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); + g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); + g_object_unref(desktopAppInfo); + +} /** * 更新应用列表 */ @@ -101,8 +106,8 @@ void FullCommonUseWidget::updateListView() void FullCommonUseWidget::repaintWidget() { - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); + this->setFixedSize(Style::widthavailable, + Style::AppListWidHeight);//Style::MainViewWidWidth this->layout()->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/pc/src/CommonUseWidget/fullcommonusewidget.h similarity index 97% rename from src/CommonUseWidget/fullcommonusewidget.h rename to pc/src/CommonUseWidget/fullcommonusewidget.h index 667c3a3..d9e3e4d 100644 --- a/src/CommonUseWidget/fullcommonusewidget.h +++ b/pc/src/CommonUseWidget/fullcommonusewidget.h @@ -85,7 +85,15 @@ class FullCommonUseWidget : public QWidget void fillAppList(); public Q_SLOTS: - /** + + + /** + * 图标跟随鼠标移动 + * + */ + + + /** * @brief Open the application * @param arg: Desktop file path */ diff --git a/pc/src/Interface/ukuichineseletter.cpp b/pc/src/Interface/ukuichineseletter.cpp new file mode 100644 index 0000000..14aa0b7 --- /dev/null +++ b/pc/src/Interface/ukuichineseletter.cpp @@ -0,0 +1,5825 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + +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); + + return QString(appnamePy.at(0)); +} + +QString UkuiChineseLetter::getFirstLetters(const QString &src) +{ + QString firstLetters; + for (int i=0; ifromUnicode(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; ifromUnicode(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= 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/pc/src/Interface/ukuichineseletter.h b/pc/src/Interface/ukuichineseletter.h new file mode 100644 index 0000000..749025c --- /dev/null +++ b/pc/src/Interface/ukuichineseletter.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + + +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/Interface/ukuimenuinterface.cpp b/pc/src/Interface/ukuimenuinterface.cpp similarity index 93% rename from src/Interface/ukuimenuinterface.cpp rename to pc/src/Interface/ukuimenuinterface.cpp index 4988d9c..6d6f477 100644 --- a/src/Interface/ukuimenuinterface.cpp +++ b/pc/src/Interface/ukuimenuinterface.cpp @@ -36,7 +36,6 @@ QVector UkuiMenuInterface::desktopfpVector=QVector(); QVector UkuiMenuInterface::alphabeticVector=QVector(); QVector UkuiMenuInterface::functionalVector=QVector(); QVector UkuiMenuInterface::allAppVector=QVector(); -QStringList UkuiMenuInterface::androidDesktopfnList=QStringList(); UkuiMenuInterface::~UkuiMenuInterface() { @@ -156,7 +155,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath() filePathList.removeAll("/usr/share/applications/software-properties-livepatch.desktop"); filePathList.removeAll("/usr/share/applications/mate-color-select.desktop"); filePathList.removeAll("/usr/share/applications/blueman-adapters.desktop"); - filePathList.removeAll("/usr/share/applications/blueman-manager.desktop"); + // filePathList.removeAll("/usr/share/applications/blueman-manager.desktop"); filePathList.removeAll("/usr/share/applications/mate-user-guide.desktop"); filePathList.removeAll("/usr/share/applications/nm-connection-editor.desktop"); filePathList.removeAll("/usr/share/applications/debian-uxterm.desktop"); @@ -198,6 +197,12 @@ QStringList UkuiMenuInterface::getDesktopFilePath() filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop"); filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop"); + // QStringList inilist; + for(int i=0;i UkuiMenuInterface::createAppInfoVector() QStringList appInfoList; QString desktopfp=desktopfpList.at(i); QString name=getAppName(desktopfpList.at(i)); + QString englishName=getAppEnglishName(desktopfpList.at(i)); QString letter=getAppNameInitial(desktopfpList.at(i)); QString letters=getAppNameInitials(desktopfpList.at(i)); @@ -253,6 +259,7 @@ QVector UkuiMenuInterface::createAppInfoVector() //获取应用名称 QString UkuiMenuInterface::getAppName(QString desktopfp) { + GError** error=nullptr; GKeyFileFlags flags=G_KEY_FILE_NONE; GKeyFile* keyfile=g_key_file_new (); @@ -265,6 +272,7 @@ QString UkuiMenuInterface::getAppName(QString desktopfp) QString namestr=QString::fromLocal8Bit(name); g_key_file_free(keyfile); + return namestr; } @@ -280,6 +288,8 @@ QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) 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; } @@ -306,10 +316,11 @@ QString UkuiMenuInterface::getAppIcon(QString desktopfp) GKeyFile* keyfile=g_key_file_new (); QByteArray fpbyte=desktopfp.toLocal8Bit(); - char* filepath=fpbyte.data(); + 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); } @@ -641,7 +652,6 @@ QVector UkuiMenuInterface::getFunctionalClassification() switch (category) { case 0: appVector[0].append(appInfoVector.at(index)); - break; case 1: appVector[1].append(appInfoVector.at(index)); break; @@ -870,3 +880,44 @@ QString UkuiMenuInterface::getUserName() QString name=var.value().toString(); return name; } + +void UkuiMenuInterface::read_ini(QString str_desktop) +{ + + + QString str; +//打开文件.desktop + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=str_desktop.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","Exec", nullptr, nullptr); + //取出value值 + QString execnamestr=QString::fromLocal8Bit(name); + //处理value值 + str = execnamestr.section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size()-1]; + + //关闭文件 + g_key_file_free(keyfile); + //打开ini文件 + QString pathini=QDir::homePath()+"/.cache/ukui-menu/ukui-menu.ini"; + settt=new QSettings(pathini,QSettings::IniFormat); + // settt->beginGroup("application"); + + QString desktopfp1="application/"+str; + //判断 + bool bo=settt->contains(desktopfp1.toLocal8Bit().data());// iskey + bool bo1=settt->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool();//isvalue + if(bo && bo1==false)//都存在//存在并且为false,从filepathlist中去掉 + { + filePathList.removeAll(str_desktop); + return; + } + +} diff --git a/pc/src/Interface/ukuimenuinterface.h b/pc/src/Interface/ukuimenuinterface.h new file mode 100644 index 0000000..ff99d4c --- /dev/null +++ b/pc/src/Interface/ukuimenuinterface.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + +class UkuiMenuInterface +{ +private: + QStringList filePathList; + QStringList androidDesktopfnList; + QSettings* setting=nullptr; + QSettings* settt=nullptr; +protected: + void recursiveSearchFile(const QString& _filePath);//遍历/usr/share/applications/文件夹 + QStringList getSpecifiedCategoryAppList(QString categorystr);//获取指定类型应用列表 + +public: + UkuiMenuInterface(); + ~UkuiMenuInterface(); + QVector createAppInfoVector();//创建应用信息容器 + static QVector appInfoVector; + static QVector desktopfpVector; + static QVector alphabeticVector; + static QVector functionalVector; + static QVector allAppVector; + + /** + * 获取系统应用名称 + * @param desktopfp 为应用.desktop文件所在路径 + * @return 返回应用名称 + */ + QString getAppName(QString desktopfp);//获取应用名 + QString getAppEnglishName(QString desktopfp);//获取英语英文名 + QString getAppIcon(QString desktopfp);//获取应用图像 + QString getAppCategories(QString desktopfp);//获取应用分类 + QString getAppExec(QString desktopfp);//获取应用命令 + QString getAppType(QString desktopfp);//获取应用类型 + QString getAppComment(QString desktopfp);//获取应用注释 + QStringList getDesktopFilePath();//获取系统deskyop文件路径 + + void read_ini(QString desktopfp);//读取配置文件,处理deskyop文件路径列表 + + QVector getAlphabeticClassification();//获取字母分类 + QVector getFunctionalClassification();//获取功能分类 + QVector getCommonUseApp();//获取常用App + QVector getAllApp(); + void getAndroidApp();//获取安卓应用 + static bool cmpApp(QStringList &arg_1,QStringList &arg_2); + bool matchingAppCategories(QString desktopfp,QStringList categorylist);//匹配应用Categories + QString getAppNameInitials(QString desktopfp);//获取应用名所有首字母 + QString getAppNameInitial(QString desktopfp);//获取应用名所有首字母 + QString getAppNamePinyin(QString appname);//获取应用名拼音 + + //获取用户图像 + QString getUserIcon(); + //获取用户姓名 + QString getUserName(); + +}; + +#endif // UKUIMENUINTERFACE_H diff --git a/src/MainViewWidget/directorychangedthread.cpp b/pc/src/MainViewWidget/directorychangedthread.cpp similarity index 99% rename from src/MainViewWidget/directorychangedthread.cpp rename to pc/src/MainViewWidget/directorychangedthread.cpp index 7ce03d9..0d8ff10 100644 --- a/src/MainViewWidget/directorychangedthread.cpp +++ b/pc/src/MainViewWidget/directorychangedthread.cpp @@ -17,15 +17,19 @@ */ #include "directorychangedthread.h" + #include #include + + DirectoryChangedThread::DirectoryChangedThread() { m_ukuiMenuInterface=new UkuiMenuInterface; QString path=QDir::homePath()+"/.config/ukui/ukui-menu.ini"; setting=new QSettings(path,QSettings::IniFormat); + } DirectoryChangedThread::~DirectoryChangedThread() @@ -37,6 +41,8 @@ void DirectoryChangedThread::run() { // if(this->m_path=="/usr/share/applications") // { + + QStringList desktopfpList=m_ukuiMenuInterface->getDesktopFilePath(); if(desktopfpList.size() > UkuiMenuInterface::desktopfpVector.size())//有新的应用安装 { diff --git a/src/MainViewWidget/directorychangedthread.h b/pc/src/MainViewWidget/directorychangedthread.h similarity index 100% rename from src/MainViewWidget/directorychangedthread.h rename to pc/src/MainViewWidget/directorychangedthread.h diff --git a/src/MainViewWidget/mainviewwidget.cpp b/pc/src/MainViewWidget/mainviewwidget.cpp similarity index 66% rename from src/MainViewWidget/mainviewwidget.cpp rename to pc/src/MainViewWidget/mainviewwidget.cpp index d40c304..817b213 100644 --- a/src/MainViewWidget/mainviewwidget.cpp +++ b/pc/src/MainViewWidget/mainviewwidget.cpp @@ -23,23 +23,19 @@ #include #include #include +//#include +#include MainViewWidget::MainViewWidget(QWidget *parent) : QWidget(parent) { initUi(); + } MainViewWidget::~MainViewWidget() { -// delete m_commonUseWid; -// delete m_fullCommonUseWid; -// delete m_letterWid; -// delete m_fullLetterWid; -// delete m_functionWid; -// delete m_fullFunctionWid; -// delete m_searchResultWid; -// delete m_fullSearchResultWid; + delete m_ukuiMenuInterface; delete m_fileWatcher; @@ -53,13 +49,14 @@ void MainViewWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - + this->setStyleSheet("border:0px;background:transparent;");//transparent + this->setWindowOpacity(0.45);//设置总体透明度//0.95-0.45 + this->setProperty("doNotBlur",true); QVBoxLayout* mainLayout=new QVBoxLayout; mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); m_topWidget=new QWidget; - m_topWidget->setStyleSheet("border:0px;background:transparent;"); + m_topWidget->setStyleSheet("border:0px;background:transparent;");//transparent m_verticalSpacer=new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding); mainLayout->addWidget(m_topWidget); @@ -68,12 +65,11 @@ void MainViewWidget::initUi() this->setFocusPolicy(Qt::NoFocus); - m_commonUseWid=new CommonUseWidget; + // m_commonUseWid=new CommonUseWidget; m_fullCommonUseWid=new FullCommonUseWidget; - m_letterWid=new LetterWidget; - m_functionWid=new FunctionWidget; - m_fullLetterWid=new FullLetterWidget; - m_fullFunctionWid=new FullFunctionWidget; + + + //m_fullFunctionWid=new FullFunctionWidget; m_fullSearchResultWid=new FullSearchResultWidget; m_searchResultWid=new SearchResultWidget; @@ -86,36 +82,26 @@ void MainViewWidget::initUi() m_directoryChangedThread=new DirectoryChangedThread; connect(this,&MainViewWidget::sendDirectoryPath,m_directoryChangedThread,&DirectoryChangedThread::recvDirectoryPath); connect(m_directoryChangedThread,&DirectoryChangedThread::requestUpdateSignal,this,&MainViewWidget::requestUpdateSlot); - connect(this,&MainViewWidget::directoryChangedSignal,m_letterWid,&LetterWidget::updateAppListView); - connect(this,&MainViewWidget::directoryChangedSignal,m_fullLetterWid,&FullLetterWidget::updateAppListView); - connect(this,&MainViewWidget::directoryChangedSignal,m_functionWid,&FunctionWidget::updateAppListView); - connect(this,&MainViewWidget::directoryChangedSignal,m_fullFunctionWid,&FullFunctionWidget::updateAppListView); - connect(this,&MainViewWidget::directoryChangedSignal,m_commonUseWid,&CommonUseWidget::updateListViewSlot); + // connect(this,&MainViewWidget::directoryChangedSignal,m_commonUseWid,&CommonUseWidget::updateListViewSlot); connect(this,&MainViewWidget::directoryChangedSignal,m_fullCommonUseWid,&FullCommonUseWidget::updateListViewSlot); //发送隐藏主界面信号 - connect(m_commonUseWid,&CommonUseWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); - connect(m_fullCommonUseWid,&FullCommonUseWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); - connect(m_letterWid,&LetterWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); - connect(m_fullLetterWid,&FullLetterWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); - connect(m_functionWid,&FunctionWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); - connect(m_fullFunctionWid,&FullFunctionWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); + // connect(m_commonUseWid,&CommonUseWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); + connect(m_fullCommonUseWid,&FullCommonUseWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); connect(m_searchResultWid,&SearchResultWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); connect(m_fullSearchResultWid,&FullSearchResultWidget::sendHideMainWindowSignal,this,&MainViewWidget::sendHideMainWindowSignal); + + //client + + QDBusConnection::systemBus().connect(QString(), QString("/com/ukui/desktop/software"), "com.ukui.desktop.software", "send_to_client", this, SLOT(client_get(QString))); + connect(this, &MainViewWidget::UpdateSignal, [&](){ + directoryChangedSlot(); + }); + addTopControl(); - //加载默认视图 -// loadMinMainView(); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0,0,0,0); - m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); - m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_queryWid->show(); - mainLayout->insertWidget(1,m_commonUseWid); + //loadMinMainView(); + loadMaxMainView(); //监控应用进程开启 bamf_matcher_get_default(); @@ -130,8 +116,19 @@ void MainViewWidget::initUi() m_gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); connect(m_gsetting,&QGSettings::changed,this,&MainViewWidget::iconThemeChangeSlot); } + +} +void MainViewWidget::client_get(QString str) +{ + qDebug() << "Client get information from service!" << str; + Q_EMIT UpdateSignal(); } + + + + + /** * 添加顶部控件 */ @@ -141,7 +138,7 @@ void MainViewWidget::addTopControl() m_topLayout->setSpacing(0); m_queryLineEdit=new QLineEdit; char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;}",QueryLineEditBackground); + sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:25px;}",QueryLineEditBackground);// 6-1 m_queryLineEdit->setStyleSheet(style); m_topLayout->addWidget(m_queryLineEdit); m_topWidget->setLayout(m_topLayout); @@ -158,7 +155,7 @@ void MainViewWidget::initQueryLineEdit() m_queryWid=new QWidget; m_queryWid->setParent(m_queryLineEdit); m_queryWid->setFocusPolicy(Qt::NoFocus); - m_queryWid->setStyleSheet("border:0px;background:transparent"); + m_queryWid->setStyleSheet("border:0px;background:transparent;border-radius:25px;");//搜索框样式,圆角 QHBoxLayout* queryWidLayout=new QHBoxLayout; queryWidLayout->setContentsMargins(5,0,0,0); queryWidLayout->setSpacing(5); @@ -169,8 +166,8 @@ void MainViewWidget::initQueryLineEdit() m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setPixmap(pixmap); m_queryText=new QLabel; - m_queryText->setText(tr("Search")); - m_queryText->setStyleSheet("background:transparent;color:#626c6e;"); + m_queryText->setText(tr("Search Application"));//搜索栏中的文件,与translation中的对应,中英翻译 + m_queryText->setStyleSheet("background:transparent;color:#d9d9d9;border-radius:25px;");//border-radius:25px; m_queryText->adjustSize(); queryWidLayout->addWidget(m_queryIcon); queryWidLayout->addWidget(m_queryText); @@ -197,7 +194,7 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if(event->type()==QEvent::FocusIn) { char style[200]; - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:25px;color:#ffffff;}", QueryLineEditClickedBorder,QueryLineEditClickedBackground); m_queryLineEdit->setStyleSheet(style); if(!m_queryLineEdit->text().isEmpty()) @@ -214,8 +211,7 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) m_queryIcon->width()+5,Style::QueryLineEditHeight)); m_animation->setEasingCurve(QEasingCurve::OutQuad); m_animation->start(); -// m_queryLineEdit->setReadOnly(true); - m_queryLineEdit->setTextMargins(-5,1,0,1); + m_queryLineEdit->setReadOnly(true); } m_isSearching=true; } @@ -227,7 +223,7 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if(m_isSearching) { char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;}",QueryLineEditBackground); + sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:25px;}",QueryLineEditBackground);// m_animation->stop(); m_queryLineEdit->setStyleSheet(style); m_queryText->adjustSize(); @@ -241,7 +237,7 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) } else { char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;color:#ffffff;}", + sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:25px;color:#ffffff;}", QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); } @@ -275,7 +271,7 @@ void MainViewWidget::searchAppSlot(QString arg) if(m_widgetState!=0) { QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) + if((child=this->layout()->takeAt(2))!=nullptr) { QWidget* childWid=child->widget(); if(childWid!=nullptr) @@ -285,54 +281,56 @@ void MainViewWidget::searchAppSlot(QString arg) } } m_widgetState=0; - QVBoxLayout *layout=qobject_cast(this->layout()); - if(!m_isFullScreen) - layout->insertWidget(1,m_searchResultWid); - else - layout->insertWidget(1,m_fullSearchResultWid); + if(m_isFullScreen==false) + { + this->layout()->addWidget(m_searchResultWid); + } + else{ + this->layout()->addWidget(m_fullSearchResultWid); + } } } else{ -// QLayoutItem* child; -// if((child=this->layout()->takeAt(2))!=nullptr) -// { -// QWidget* childWid=child->widget(); -// if(childWid!=nullptr) -// { -// this->layout()->removeWidget(childWid); -// childWid->setParent(nullptr); -// } -// } - if(m_isFullScreen) + QLayoutItem* child; + if((child=this->layout()->takeAt(2))!=nullptr) { - switch (m_saveCurrentWidState) { - case 1: - loadFullCommonUseWidget(); - break; - case 2: - loadFullLetterWidget(); - break; - case 3: - loadFullFunctionWidget(); - default: - break; + QWidget* childWid=child->widget(); + if(childWid!=nullptr) + { + this->layout()->removeWidget(childWid); + childWid->setParent(nullptr); } } - else { + if(m_isFullScreen) + { switch (m_saveCurrentWidState) { case 1: - loadCommonUseWidget(); - break; - case 2: - loadLetterWidget(); - break; - case 3: - loadFunctionWidget(); + loadFullCommonUseWidget(); break; +// case 2: +// loadFullLetterWidget(); +// break; +// case 3: +// loadFullFunctionWidget(); default: break; } } +// else { +// switch (m_saveCurrentWidState) { +// case 1: +// loadCommonUseWidget(); +// break; +// case 2: +// loadLetterWidget(); +// break; +// case 3: +// loadFunctionWidget(); +// break; +// default: +// break; +// } +// } } Q_EMIT sendSearchKeyword(arg); @@ -355,7 +353,7 @@ void MainViewWidget::animationFinishedSlot() { m_queryWid->layout()->removeWidget(m_queryText); m_queryText->setParent(nullptr); -// m_queryLineEdit->setReadOnly(false); + m_queryLineEdit->setReadOnly(false); m_queryLineEdit->setTextMargins(20,1,0,1); if(!m_searchKeyWords.isEmpty()) { @@ -390,7 +388,7 @@ void MainViewWidget::loadMinMainView() if(m_widgetState==0) { QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) + if((child=this->layout()->takeAt(2))!=nullptr) { QWidget* childWid=child->widget(); if(childWid!=nullptr) @@ -399,17 +397,17 @@ void MainViewWidget::loadMinMainView() childWid->setParent(nullptr); } } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_searchResultWid); + this->layout()->addWidget(m_searchResultWid); } - else if(m_widgetState==1) - loadCommonUseWidget(); - else if(m_widgetState==2) - loadLetterWidget(); - else if(m_widgetState==3) - loadFunctionWidget(); +// else if(m_widgetState==1) +// loadCommonUseWidget(); +// else if(m_widgetState==2) +// loadLetterWidget(); +// else if(m_widgetState==3) +// loadFunctionWidget(); m_isFullScreen=false; m_isHiden=false; + } /** @@ -419,12 +417,16 @@ void MainViewWidget::loadMaxMainView() { this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); - m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); + m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight);//Style::widthavailable m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); - m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, +// m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, +// 0, +// (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, +// 0); + m_topLayout->setContentsMargins((m_topWidget->width()-m_queryLineEdit->width())/2, 0, - (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, + (m_topWidget->width()-m_queryLineEdit->width())/2, 0); if(m_queryLineEdit->text().isEmpty()) @@ -440,7 +442,7 @@ void MainViewWidget::loadMaxMainView() if(m_widgetState==0) { QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) + if((child=this->layout()->takeAt(2))!=nullptr) { QWidget* childWid=child->widget(); if(childWid!=nullptr) @@ -449,37 +451,49 @@ void MainViewWidget::loadMaxMainView() childWid->setParent(nullptr); } } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullSearchResultWid); + this->layout()->addWidget(m_fullSearchResultWid); } else if(m_widgetState==1) loadFullCommonUseWidget(); - else if(m_widgetState==2) - loadFullLetterWidget(); - else if(m_widgetState==3) - loadFullFunctionWidget(); +// else if(m_widgetState==2) +// loadFullLetterWidget(); +// else if(m_widgetState==3) +// loadFullFunctionWidget(); m_isFullScreen=true; m_isHiden=false; + } void MainViewWidget::resizeControl() { if(m_isFullScreen) { - if(m_widgetState==2) - m_fullLetterWid->setLetterBtnGeometry(); - if(m_widgetState==3) - m_fullFunctionWid->setFunctionBtnGeometry(); +// if(m_widgetState==2) +// m_fullLetterWid->setLetterBtnGeometry(); +// if(m_widgetState==3) +// m_fullFunctionWid->setFunctionBtnGeometry(); this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); - m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); + m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight);//Style::widthavailable m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); - m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, - 0, - (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, - 0); +// m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, +// 0, +// (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, +// 0); + m_topLayout->setContentsMargins((m_topWidget->width()-m_queryLineEdit->width())/2, + 0, + (m_topWidget->width()-m_queryLineEdit->width())/2, + 0); +// if(m_queryLineEdit->text().isEmpty() || m_isHiden) +// { +// if(m_queryWid->layout()->count()==1) +// m_queryWid->layout()->addWidget(m_queryText); +// m_queryText->adjustSize(); +// m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, +// m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); +// } } else { @@ -487,6 +501,15 @@ void MainViewWidget::resizeControl() m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); m_topLayout->setContentsMargins(0,0,0,0); m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); +// m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); +// if(m_queryLineEdit->text().isEmpty() || m_isHiden) +// { +// if(m_queryWid->layout()->count()==1) +// m_queryWid->layout()->addWidget(m_queryText); +// m_queryText->adjustSize(); +// m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, +// m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); +// } } } @@ -496,79 +519,76 @@ void MainViewWidget::resizeControl() */ void MainViewWidget::loadCommonUseWidget() { - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } +// m_fullCommonUseWid->widgetMakeZero(); +// // m_letterWid->widgetMakeZero(); +// // m_fullLetterWid->widgetMakeZero(); +// //m_functionWid->widgetMakeZero(); +// // m_fullFunctionWid->widgetMakeZero(); +// QLayoutItem *child; +// if((child = this->layout()->takeAt(2)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// this->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_commonUseWid); - m_commonUseWid->updateListView(); - m_widgetState=1; - m_saveCurrentWidState=1; +// } +// this->layout()->addWidget(m_commonUseWid); +// m_commonUseWid->updateListView(); +// m_widgetState=1; +// m_saveCurrentWidState=1; } /** * 加载字母分类界面 */ -void MainViewWidget::loadLetterWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } +//void MainViewWidget::loadLetterWidget() +//{ +// m_commonUseWid->widgetMakeZero(); +// m_fullCommonUseWid->widgetMakeZero(); +// m_fullLetterWid->widgetMakeZero(); +// m_functionWid->widgetMakeZero(); +// m_fullFunctionWid->widgetMakeZero(); +// QLayoutItem *child; +// if((child = this->layout()->takeAt(2)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// this->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_letterWid); - m_widgetState=2; - m_saveCurrentWidState=2; -} +// } +// this->layout()->addWidget(m_letterWid); +// m_widgetState=2; +// m_saveCurrentWidState=2; +//} /** * 加载功能分类界面 */ -void MainViewWidget::loadFunctionWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } +//void MainViewWidget::loadFunctionWidget() +//{ +// m_commonUseWid->widgetMakeZero(); +// m_fullCommonUseWid->widgetMakeZero(); +// m_letterWid->widgetMakeZero(); +// m_fullLetterWid->widgetMakeZero(); +// m_fullFunctionWid->widgetMakeZero(); +// QLayoutItem *child; +// if((child = this->layout()->takeAt(2)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// this->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_functionWid); - m_widgetState=3; - m_saveCurrentWidState=3; -} +// } +// this->layout()->addWidget(m_functionWid); +// m_widgetState=3; +// m_saveCurrentWidState=3; +//} /** @@ -576,13 +596,13 @@ void MainViewWidget::loadFunctionWidget() */ void MainViewWidget::loadFullCommonUseWidget() { - m_commonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); + //m_commonUseWid->widgetMakeZero(); + // m_letterWid->widgetMakeZero(); + //m_fullLetterWid->widgetMakeZero(); + //m_functionWid->widgetMakeZero(); + //m_fullFunctionWid->widgetMakeZero(); QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { + if((child = this->layout()->takeAt(2)) != nullptr) { QWidget* childwid=child->widget(); if(childwid!=nullptr) { @@ -591,8 +611,7 @@ void MainViewWidget::loadFullCommonUseWidget() } } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullCommonUseWid); + this->layout()->addWidget(m_fullCommonUseWid); m_fullCommonUseWid->updateListView(); m_widgetState=1; m_saveCurrentWidState=1; @@ -601,56 +620,54 @@ void MainViewWidget::loadFullCommonUseWidget() /** * 加载全屏字母分类界面 */ -void MainViewWidget::loadFullLetterWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullLetterWid); - if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) - m_fullLetterWid->enterAnimation(); - m_widgetState=2; - m_saveCurrentWidState=2; -} +//void MainViewWidget::loadFullLetterWidget() +//{ +// m_commonUseWid->widgetMakeZero(); +// m_fullCommonUseWid->widgetMakeZero(); +// m_letterWid->widgetMakeZero(); +// m_functionWid->widgetMakeZero(); +// m_fullFunctionWid->widgetMakeZero(); +// QLayoutItem *child; +// if((child = this->layout()->takeAt(2)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// this->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// } +// } +// this->layout()->addWidget(m_fullLetterWid); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) +// m_fullLetterWid->enterAnimation(); +// m_widgetState=2; +// m_saveCurrentWidState=2; +//} /** * 加载全屏功能分类界面 */ void MainViewWidget::loadFullFunctionWidget() { - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } +// m_commonUseWid->widgetMakeZero(); +// m_fullCommonUseWid->widgetMakeZero(); +// m_letterWid->widgetMakeZero(); +// m_fullLetterWid->widgetMakeZero(); +// m_functionWid->widgetMakeZero(); +// QLayoutItem *child; +// if((child = this->layout()->takeAt(2)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// this->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullFunctionWid); - if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) - m_fullFunctionWid->enterAnimation(); - m_widgetState=3; - m_saveCurrentWidState=3; +// } +// this->layout()->addWidget(m_fullFunctionWid); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) +// m_fullFunctionWid->enterAnimation(); +// m_widgetState=3; +// m_saveCurrentWidState=3; } /** @@ -797,12 +814,12 @@ void MainViewWidget::iconThemeChangeSlot(QString key) void MainViewWidget::repaintWidget() { this->setMinimumSize(Style::minw,Style::minh); - m_commonUseWid->repaintWidget(); + // m_commonUseWid->repaintWidget(); m_fullCommonUseWid->repaintWidget(); - m_letterWid->repaintWidget(); - m_fullLetterWid->repaintWidget(); - m_functionWid->repaintWidget(); - m_fullFunctionWid->repaintWidget(); + // m_letterWid->repaintWidget(); + // m_fullLetterWid->repaintWidget(); + //m_functionWid->repaintWidget(); + // m_fullFunctionWid->repaintWidget(); m_searchResultWid->repaintWidget(); m_fullSearchResultWid->repaintWidget(); } @@ -811,16 +828,16 @@ void MainViewWidget::widgetMakeZero() { m_isHiden=true; m_isSearching=false; - m_commonUseWid->widgetMakeZero(); + // m_commonUseWid->widgetMakeZero(); m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); + // m_letterWid->widgetMakeZero(); + //m_fullLetterWid->widgetMakeZero(); + // m_functionWid->widgetMakeZero(); + // m_fullFunctionWid->widgetMakeZero(); m_queryLineEdit->clear(); m_queryLineEdit->clearFocus(); char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:2px;}",QueryLineEditBackground); + sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:25px;}",QueryLineEditBackground);//2-25 m_queryLineEdit->setStyleSheet(style); m_queryLineEdit->setTextMargins(0,1,0,1); } @@ -830,7 +847,7 @@ void MainViewWidget::moveScrollBar(int type) if(m_widgetState==0) { if(m_isFullScreen) - m_fullSearchResultWid->moveScrollBar(type); + m_fullSearchResultWid->moveScrollBar(type);// dxg else m_searchResultWid->moveScrollBar(type); } @@ -838,23 +855,23 @@ void MainViewWidget::moveScrollBar(int type) { if(m_isFullScreen) m_fullCommonUseWid->moveScrollBar(type); - else - m_commonUseWid->moveScrollBar(type); - } - if(m_widgetState==2) - { - if(m_isFullScreen) - m_fullLetterWid->moveScrollBar(type); - else - m_letterWid->moveScrollBar(type); - } - if(m_widgetState==3) - { - if(m_isFullScreen) - m_fullFunctionWid->moveScrollBar(type); - else - m_functionWid->moveScrollBar(type); +// else +// m_commonUseWid->moveScrollBar(type); } +// if(m_widgetState==2) +// { +// if(m_isFullScreen) +// m_fullLetterWid->moveScrollBar(type); +// else +// m_letterWid->moveScrollBar(type); +// } +// if(m_widgetState==3) +// { +// if(m_isFullScreen) +// m_fullFunctionWid->moveScrollBar(type); +// else +// m_functionWid->moveScrollBar(type); +// } } //void MainViewWidget::mousePressEvent(QMouseEvent *event) diff --git a/src/MainViewWidget/mainviewwidget.h b/pc/src/MainViewWidget/mainviewwidget.h similarity index 88% rename from src/MainViewWidget/mainviewwidget.h rename to pc/src/MainViewWidget/mainviewwidget.h index 69845a8..ea32ccb 100644 --- a/src/MainViewWidget/mainviewwidget.h +++ b/pc/src/MainViewWidget/mainviewwidget.h @@ -31,29 +31,34 @@ #include #include #include "src/Interface/ukuimenuinterface.h" -#include "src/CommonUseWidget/commonusewidget.h" -#include "src/LetterWidget/letterwidget.h" -#include "src/FunctionWidget/functionwidget.h" +//#include "src/CommonUseWidget/commonusewidget.h" + +//#include "src/FunctionWidget/functionwidget.h" #include "src/CommonUseWidget/fullcommonusewidget.h" -#include "src/FunctionWidget/fullfunctionwidget.h" -#include "src/LetterWidget/fullletterwidget.h" +//#include "src/FunctionWidget/fullfunctionwidget.h" + #include "src/SearchResultWidget/fullsearchresultwidget.h" #include "src/SearchResultWidget/searchresultwidget.h" #include "src/SearchResultWidget/searchappthread.h" +//#include "src/SideBarWidget/sidebarwidget.h" #include "directorychangedthread.h" #include "src/Style/style.h" - +#include "src/UtilityFunction/pushbutton.h" class MainViewWidget : public QWidget { Q_OBJECT + + + + public: explicit MainViewWidget(QWidget *parent = nullptr); ~MainViewWidget(); /** * @brief Load the default main view */ - void loadMinMainView(); + void loadMinMainView(); /** * @brief Load the full screen main view */ @@ -87,7 +92,7 @@ class MainViewWidget : public QWidget UkuiMenuInterface *m_ukuiMenuInterface=nullptr; QWidget *m_topWidget=nullptr; QHBoxLayout *m_topLayout=nullptr; - + // SideBarWidget *sideBarWidget=nullptr; QSpacerItem *m_verticalSpacer=nullptr; QLineEdit *m_queryLineEdit=nullptr; @@ -101,19 +106,19 @@ class MainViewWidget : public QWidget FullSearchResultWidget *m_fullSearchResultWid=nullptr; SearchResultWidget *m_searchResultWid=nullptr; SearchAppThread *m_searchAppThread=nullptr; - CommonUseWidget *m_commonUseWid=nullptr; - LetterWidget *m_letterWid=nullptr; - FunctionWidget *m_functionWid=nullptr; + // CommonUseWidget *m_commonUseWid=nullptr; + + //FunctionWidget *m_functionWid=nullptr; FullCommonUseWidget *m_fullCommonUseWid=nullptr; - FullLetterWidget *m_fullLetterWid=nullptr; - FullFunctionWidget *m_fullFunctionWid=nullptr; + // FullLetterWidget *m_fullLetterWid=nullptr; + // FullFunctionWidget *m_fullFunctionWid=nullptr; DirectoryChangedThread *m_directoryChangedThread=nullptr; int m_widgetState=1;//Classification window number int m_saveCurrentWidState=-1;//Store the current category window number - bool m_isFullScreen=false; + bool m_isFullScreen=true; bool m_isHiden=false; QFileSystemWatcher *m_fileWatcher=nullptr;//Monitor desktop folder status @@ -136,6 +141,7 @@ class MainViewWidget : public QWidget void initQueryLineEdit(); public Q_SLOTS: + void client_get(QString); /** * @brief Search box focus event filtering */ @@ -147,11 +153,11 @@ public Q_SLOTS: /** * @brief Load the letter classification interface */ - void loadLetterWidget(); + // void loadLetterWidget(); /** * @brief Load function classification interface */ - void loadFunctionWidget(); + // void loadFunctionWidget(); /** * @brief Load full screen common classification interface */ @@ -159,7 +165,7 @@ public Q_SLOTS: /** * @brief Load the full screen letter classification interface */ - void loadFullLetterWidget(); + //void loadFullLetterWidget(); /** * @brief Load the full screen function classification interface */ @@ -198,6 +204,7 @@ public Q_SLOTS: void requestUpdateSlot(); Q_SIGNALS: + void UpdateSignal(); /** * @brief Desktop file directory change signal */ diff --git a/src/MainWindow/mainwindow.cpp b/pc/src/MainWindow/mainwindow.cpp similarity index 70% rename from src/MainWindow/mainwindow.cpp rename to pc/src/MainWindow/mainwindow.cpp index 0329518..d3da44b 100644 --- a/src/MainWindow/mainwindow.cpp +++ b/pc/src/MainWindow/mainwindow.cpp @@ -26,10 +26,12 @@ #include "src/XEventMonitor/xeventmonitor.h" #include "src/Style/style.h" + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { m_ukuiMenuInterface=new UkuiMenuInterface; + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); @@ -37,6 +39,20 @@ MainWindow::MainWindow(QWidget *parent) : Style::initWidStyle(); QString path=QDir::homePath()+"/.config/ukui/ukui-menu.ini"; m_setting=new QSettings(path,QSettings::IniFormat); + + + //平板 +// tabletMode=new QGSettings(TABLED_SCHEMA); +// connect(tabletMode,&QGSettings::changed,[this] (const QString &key) { +// bool res = tabletMode->get("tablet-mode").toBool(); +// qDebug()<hide(); +// else +// this->show(); + +// }); + initUi(); } @@ -44,10 +60,12 @@ MainWindow::~MainWindow() { XEventMonitor::instance()->quit(); delete m_ukuiMenuInterface; + } void MainWindow::initUi() { + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAutoFillBackground(false); @@ -56,10 +74,10 @@ void MainWindow::initUi() this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); this->setMinimumSize(Style::minw,Style::minh); this->setContentsMargins(0,0,0,0); - + this->setStyleSheet("border:0px;background:yellow;");//transparent m_frame=new QFrame; m_mainViewWid=new MainViewWidget; - m_sideBarWid=new SideBarWidget; + // m_sideBarWid=new SideBarWidget; this->setCentralWidget(m_frame); QHBoxLayout *mainlayout=new QHBoxLayout; @@ -68,34 +86,35 @@ void MainWindow::initUi() m_frame->setLayout(mainlayout); mainlayout->addWidget(m_mainViewWid); - m_line=new QFrame; + m_line=new QFrame(this); m_line->setFrameShape(QFrame::VLine); m_line->setFixedSize(1,this->height()); mainlayout->addWidget(m_line); char linestyle[100]; sprintf(linestyle, "background-color:%s;",LineBackground); m_line->setStyleSheet(linestyle); - mainlayout->addWidget(m_sideBarWid); + // // mainlayout->addWidget(m_sideBarWid); m_animation = new QPropertyAnimation(this, "geometry"); + connect(m_animation,&QPropertyAnimation::stateChanged, + this,&MainWindow::stateChangedSlot); connect(m_animation, &QPropertyAnimation::valueChanged, this, &MainWindow::animationValueChangedSlot); - connect(m_animation,&QPropertyAnimation::finished,this,&MainWindow::animationValueFinishedSlot); - connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); - connect(m_sideBarWid,&SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); - connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); +// connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); +// connect(m_sideBarWid,&SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); +// connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenCommonUseBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullCommonUseWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenLetterBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullLetterWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenFunctionBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullFunctionWidget); +// connect(m_sideBarWid,&SideBarWidget::sendFullScreenCommonUseBtnSignal, +// m_mainViewWid,&MainViewWidget::loadFullCommonUseWidget); +// connect(m_sideBarWid,&SideBarWidget::sendFullScreenLetterBtnSignal, +// m_mainViewWid,&MainViewWidget::loadFullLetterWidget); +// connect(m_sideBarWid,&SideBarWidget::sendFullScreenFunctionBtnSignal, +// m_mainViewWid,&MainViewWidget::loadFullFunctionWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenBtnSignal,this,&MainWindow::showFullScreenWidget); - connect(m_sideBarWid,&SideBarWidget::sendDefaultBtnSignal,this,&MainWindow::showDefaultWidget); - connect(m_mainViewWid,&MainViewWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); - connect(m_sideBarWid,&SideBarWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); +// connect(m_sideBarWid,&SideBarWidget::sendFullScreenBtnSignal,this,&MainWindow::showFullScreenWidget); +// // connect(m_sideBarWid,&SideBarWidget::sendDefaultBtnSignal,this,&MainWindow::showDefaultWidget); +// connect(m_mainViewWid,&MainViewWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); +// connect(m_sideBarWid,&SideBarWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); connect(QApplication::primaryScreen(),&QScreen::geometryChanged, this,&MainWindow::monitorResolutionChange); @@ -123,13 +142,17 @@ void MainWindow::initUi() // QDBusConnection::sessionBus().connect("com.ukui.menu","/com/ukui/menu","local.test.MainWindow", // QString("sendStartMenuSignal"),this,SLOT(recvStartMenuSlot())); + showFullScreenWidget(); + } + /** * 显示全屏窗口 */ void MainWindow::showFullScreenWidget() { + m_isFullScreen=true; this->setContentsMargins(0,0,0,0); int position=0; @@ -181,8 +204,8 @@ void MainWindow::showFullScreenWidget() m_mainViewWid->setParent(nullptr); this->centralWidget()->layout()->removeWidget(m_line); m_line->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_sideBarWid); - m_sideBarWid->setParent(nullptr); + //this->centralWidget()->layout()->removeWidget(m_sideBarWid); + // m_sideBarWid->setParent(nullptr); m_animation->setDuration(100);//动画总时间 m_animation->setStartValue(startRect); @@ -194,64 +217,85 @@ void MainWindow::showFullScreenWidget() /** * 显示默认窗口 */ -void MainWindow::showDefaultWidget() +//void MainWindow::showDefaultWidget() +//{ +// m_isFullScreen=false; +// this->setContentsMargins(0,0,0,0); +// int position=0; +// int panelSize=0; +// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) +// { +// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); +// if(gsetting->keys().contains(QString("panelposition"))) +// position=gsetting->get("panelposition").toInt(); +// else +// position=0; +// if(gsetting->keys().contains(QString("panelsize"))) +// panelSize=gsetting->get("panelsize").toInt(); +// else +// panelSize=46; +// } +// else +// { +// position=0; +// panelSize=46; +// } +// int x=QApplication::primaryScreen()->geometry().x(); +// int y=QApplication::primaryScreen()->geometry().y(); +// QRect startRect; +// QRect endRect; +// if(position==0) +// { +// endRect.setRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh,Style::minw,Style::minh); +// startRect.setRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); +// } +// else if(position==1) +// { +// endRect.setRect(x,y+panelSize,Style::minw,Style::minh); +// startRect.setRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); +// } +// else if(position==2) +// { +// endRect.setRect(x+panelSize,y,Style::minw,Style::minh); +// startRect.setRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); +// } +// else +// { +// endRect.setRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y,Style::minw,Style::minh); +// startRect.setRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); +// } + +// this->centralWidget()->layout()->removeWidget(m_mainViewWid); +// m_mainViewWid->setParent(nullptr); +// // this->centralWidget()->layout()->removeWidget(m_sideBarWid); +// // m_sideBarWid->setParent(nullptr); + +// m_animation->setDuration(100);//动画总时间 +// m_animation->setStartValue(startRect); +// m_animation->setEndValue(endRect); +// m_animation->setEasingCurve(QEasingCurve::Linear); +// m_animation->start(); +//} + +void MainWindow::stateChangedSlot(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) { - m_isFullScreen=false; - this->setContentsMargins(0,0,0,0); - int position=0; - int panelSize=0; - if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - if(gsetting->keys().contains(QString("panelposition"))) - position=gsetting->get("panelposition").toInt(); - else - position=0; - if(gsetting->keys().contains(QString("panelsize"))) - panelSize=gsetting->get("panelsize").toInt(); - else - panelSize=46; - } - else - { - position=0; - panelSize=46; - } - int x=QApplication::primaryScreen()->geometry().x(); - int y=QApplication::primaryScreen()->geometry().y(); - QRect startRect; - QRect endRect; - if(position==0) - { - endRect.setRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh,Style::minw,Style::minh); - startRect.setRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); - } - else if(position==1) - { - endRect.setRect(x,y+panelSize,Style::minw,Style::minh); - startRect.setRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); - } - else if(position==2) + Q_UNUSED(oldState); + if(m_isFullScreen && newState==QAbstractAnimation::Stopped) { - endRect.setRect(x+panelSize,y,Style::minw,Style::minh); - startRect.setRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); + this->centralWidget()->layout()->addWidget(m_mainViewWid); + // this->centralWidget()->layout()->addWidget(m_sideBarWid); + // // m_sideBarWid->loadMaxSidebar();//dxg + m_mainViewWid->loadMaxMainView(); + // //m_sideBarWid->enterAnimation();// + setFrameStyle(); } - else + if(!m_isFullScreen && newState==QAbstractAnimation::Stopped) { - endRect.setRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y,Style::minw,Style::minh); - startRect.setRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); - } - - this->centralWidget()->layout()->removeWidget(m_mainViewWid); - m_mainViewWid->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_sideBarWid); - m_sideBarWid->setParent(nullptr); + this->centralWidget()->layout()->addWidget(m_mainViewWid); + this->centralWidget()->layout()->addWidget(m_line); - m_animation->setDuration(100);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); + setFrameStyle(); + } } void MainWindow::animationValueChangedSlot(const QVariant &value) @@ -264,27 +308,6 @@ void MainWindow::animationValueChangedSlot(const QVariant &value) } } -void MainWindow::animationValueFinishedSlot() -{ - if(m_isFullScreen) - { - this->centralWidget()->layout()->addWidget(m_mainViewWid); - this->centralWidget()->layout()->addWidget(m_sideBarWid); - m_sideBarWid->loadMaxSidebar(); - m_mainViewWid->loadMaxMainView(); - m_sideBarWid->enterAnimation(); - } - else - { - this->centralWidget()->layout()->addWidget(m_mainViewWid); - this->centralWidget()->layout()->addWidget(m_line); - this->centralWidget()->layout()->addWidget(m_sideBarWid); - m_sideBarWid->loadMinSidebar(); - m_mainViewWid->loadMinMainView(); - } - setFrameStyle(); -} - /** * 鼠标点击窗口外部事件 */ @@ -296,7 +319,7 @@ bool MainWindow::event ( QEvent * event ) { this->hide(); m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); } } return QWidget::event(event); @@ -341,7 +364,7 @@ void MainWindow::XkbEventsRelease(const QString &keycode) { this->hide(); m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); } else{ this->loadMainWindow(); @@ -355,7 +378,7 @@ void MainWindow::XkbEventsRelease(const QString &keycode) { this->hide(); m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); } } @@ -387,11 +410,11 @@ void MainWindow::recvStartMenuSlot() { this->hide(); m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); } else{ m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); this->loadMainWindow(); this->show(); this->raise(); @@ -404,9 +427,10 @@ void MainWindow::recvStartMenuSlot() */ void MainWindow::recvHideMainWindowSlot() { - this->hide(); + + this->hide(); // m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); +// // m_sideBarWid->widgetMakeZero(); } void MainWindow::loadMainWindow() @@ -455,8 +479,7 @@ void MainWindow::loadMainWindow() this->setGeometry(QRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); else this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); - m_sideBarWid->loadMaxSidebar(); - m_sideBarWid->setSideBarBtnGeometry(); + m_mainViewWid->loadMaxMainView(); QPainterPath path; path.addRect(this->rect()); @@ -475,78 +498,13 @@ void MainWindow::loadMainWindow() this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, Style::minw,Style::minh)); - m_sideBarWid->loadMinSidebar(); - m_mainViewWid->loadMinMainView(); + + m_mainViewWid->loadMaxMainView();//加载全屏窗口 + m_isFullScreen=true; } setFrameStyle(); - //默认开启默认态 -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); -// bool ret=false; -// if(gsetting->keys().contains(QString("menufullScreen"))) -// ret=gsetting->get("menufull-screen").toBool(); -// if(ret) -// { -// if(position==0) -// this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); -// else -// this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); -// this->centralWidget()->layout()->removeWidget(m_line); -// m_line->setParent(nullptr); -// m_sideBarWid->loadMaxSidebar(); -// m_mainViewWid->loadMaxMainView(); -// m_sideBarWid->enterAnimation(); -// QPainterPath path; -// path.addRect(this->rect()); -// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); -// m_isFullScreen=true; -// } -// else -// { -// if(position==0) -// this->setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh, -// Style::minw,Style::minh)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); -// else -// this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, -// Style::minw,Style::minh)); -// QHBoxLayout* mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); -// m_sideBarWid->loadMinSidebar(); -// m_mainViewWid->loadMinMainView(); -// m_isFullScreen=false; -// } -// } -// else -// { -// if(position==0) -// this->setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh, -// Style::minw,Style::minh)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); -// else -// this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, -// Style::minw,Style::minh)); - -// QHBoxLayout *mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); -// m_sideBarWid->loadMinSidebar(); -// m_mainViewWid->loadMinMainView(); -// m_isFullScreen=false; -// } -// setFrameStyle(); } void MainWindow::monitorResolutionChange(QRect rect) @@ -608,8 +566,7 @@ void MainWindow::repaintWidget() this->setGeometry(QRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); else this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); - m_sideBarWid->loadMaxSidebar(); - m_sideBarWid->setSideBarBtnGeometry(); + m_mainViewWid->resizeControl(); QPainterPath path; path.addRect(this->rect()); @@ -628,9 +585,7 @@ void MainWindow::repaintWidget() this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, Style::minw,Style::minh)); -// QHBoxLayout *mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); - m_sideBarWid->loadMinSidebar(); + m_mainViewWid->resizeControl(); } setFrameStyle(); @@ -667,13 +622,13 @@ void MainWindow::setFrameStyle() if(gsetting->keys().contains(QString("transparency"))) { double transparency=gsetting->get("transparency").toDouble(); - m_defaultBackground=QString("rgba(19, 19, 20,"+QString::number(transparency)+")"); + m_defaultBackground=QString("rgba(100, 100, 100, 0.45"+QString::number(transparency)+")");//修改背景透明度0.7-0.45 19,19,20-255,255,255 } else - m_defaultBackground=QString("rgba(19, 19, 20, 0.7)"); + m_defaultBackground=QString("rgba(100, 100, 100, 0.45)"); } else - m_defaultBackground=QString("rgba(19, 19, 20, 0.7)"); + m_defaultBackground=QString("rgba(100, 100, 100, 0.45)"); if(!m_isFullScreen) { diff --git a/src/MainWindow/mainwindow.h b/pc/src/MainWindow/mainwindow.h similarity index 90% rename from src/MainWindow/mainwindow.h rename to pc/src/MainWindow/mainwindow.h index 67c1b0c..d4f0d93 100644 --- a/src/MainWindow/mainwindow.h +++ b/pc/src/MainWindow/mainwindow.h @@ -35,9 +35,10 @@ #include #include #include "src/Style/style.h" -#include "src/SideBarWidget/sidebarwidget.h" +//#include "src/SideBarWidget/sidebarwidget.h" #include "src/MainViewWidget/mainviewwidget.h" + class MainWindow : public QMainWindow { Q_OBJECT @@ -58,16 +59,20 @@ class MainWindow : public QMainWindow bool m_isFullScreen=false; UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + + QSettings *m_setting=nullptr; QFrame *m_line=nullptr;//Vertical dividing line QFrame *m_frame=nullptr; - SideBarWidget *m_sideBarWid=nullptr; + // SideBarWidget *m_sideBarWid=nullptr; MainViewWidget *m_mainViewWid=nullptr; QPropertyAnimation *m_animation=nullptr; bool m_winFlag = false; + // QGSettings* tabletMode=nullptr; + protected: void initUi(); /** @@ -97,7 +102,7 @@ public Q_SLOTS: /** * @brief Load the default window */ - void showDefaultWidget(); + // void showDefaultWidget(); void recvHideMainWindowSlot();//接收隐藏主窗口信号 /** * @brief Monitor screen resolution @@ -114,8 +119,11 @@ public Q_SLOTS: * @param key: Key */ void panelChangedSlot(QString key); + /** + * @brief Monitor the state change of the animation + */ + void stateChangedSlot(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); void animationValueChangedSlot(const QVariant &value);//动画当前值变化监控 - void animationValueFinishedSlot(); /** * @brief Open the start menu by signaling diff --git a/pc/src/QtSingleApplication/QtLockedFile b/pc/src/QtSingleApplication/QtLockedFile new file mode 100644 index 0000000..16b48ba --- /dev/null +++ b/pc/src/QtSingleApplication/QtLockedFile @@ -0,0 +1 @@ +#include "qtlockedfile.h" diff --git a/pc/src/QtSingleApplication/QtSingleApplication b/pc/src/QtSingleApplication/QtSingleApplication new file mode 100644 index 0000000..d111bf7 --- /dev/null +++ b/pc/src/QtSingleApplication/QtSingleApplication @@ -0,0 +1 @@ +#include "qtsingleapplication.h" diff --git a/pc/src/QtSingleApplication/qtlocalpeer.cpp b/pc/src/QtSingleApplication/qtlocalpeer.cpp new file mode 100644 index 0000000..cd1fb58 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlocalpeer.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtlocalpeer.h" +#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(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 (!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; + Q_EMIT messageReceived(message); //### (might take a long time to return) +} diff --git a/pc/src/QtSingleApplication/qtlocalpeer.h b/pc/src/QtSingleApplication/qtlocalpeer.h new file mode 100644 index 0000000..1b533b1 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlocalpeer.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtlockedfile.cpp b/pc/src/QtSingleApplication/qtlockedfile.cpp new file mode 100644 index 0000000..c142a86 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlockedfile.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtlockedfile.h b/pc/src/QtSingleApplication/qtlockedfile.h new file mode 100644 index 0000000..84c18e5 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlockedfile.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtlockedfile_unix.cpp b/pc/src/QtSingleApplication/qtlockedfile_unix.cpp new file mode 100644 index 0000000..976c1b9 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlockedfile_unix.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtlockedfile_win.cpp b/pc/src/QtSingleApplication/qtlockedfile_win.cpp new file mode 100644 index 0000000..6144ea7 --- /dev/null +++ b/pc/src/QtSingleApplication/qtlockedfile_win.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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 { + Q_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/src/QtSingleApplication/qtsingleapplication.cpp b/pc/src/QtSingleApplication/qtsingleapplication.cpp similarity index 100% rename from src/QtSingleApplication/qtsingleapplication.cpp rename to pc/src/QtSingleApplication/qtsingleapplication.cpp diff --git a/pc/src/QtSingleApplication/qtsingleapplication.h b/pc/src/QtSingleApplication/qtsingleapplication.h new file mode 100644 index 0000000..049406f --- /dev/null +++ b/pc/src/QtSingleApplication/qtsingleapplication.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtsingleapplication.pri b/pc/src/QtSingleApplication/qtsingleapplication.pri new file mode 100644 index 0000000..1d85285 --- /dev/null +++ b/pc/src/QtSingleApplication/qtsingleapplication.pri @@ -0,0 +1,16 @@ +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/pc/src/QtSingleApplication/qtsinglecoreapplication.cpp b/pc/src/QtSingleApplication/qtsinglecoreapplication.cpp new file mode 100644 index 0000000..5634537 --- /dev/null +++ b/pc/src/QtSingleApplication/qtsinglecoreapplication.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#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/pc/src/QtSingleApplication/qtsinglecoreapplication.h b/pc/src/QtSingleApplication/qtsinglecoreapplication.h new file mode 100644 index 0000000..b87fffe --- /dev/null +++ b/pc/src/QtSingleApplication/qtsinglecoreapplication.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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/pc/src/QtSingleApplication/qtsinglecoreapplication.pri b/pc/src/QtSingleApplication/qtsinglecoreapplication.pri new file mode 100644 index 0000000..d2d6cc3 --- /dev/null +++ b/pc/src/QtSingleApplication/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/src/RightClickMenu/rightclickmenu.cpp b/pc/src/RightClickMenu/rightclickmenu.cpp similarity index 87% rename from src/RightClickMenu/rightclickmenu.cpp rename to pc/src/RightClickMenu/rightclickmenu.cpp index 3cea666..699b88a 100644 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/pc/src/RightClickMenu/rightclickmenu.cpp @@ -28,6 +28,11 @@ RightClickMenu::RightClickMenu(QWidget *parent): m_cmdProc=new QProcess; connect(m_cmdProc , &QProcess::readyReadStandardOutput, this , &RightClickMenu::onReadOutput); + + sprintf(m_style, "QMenu{padding-left:2px;padding-top:6px;padding-right:2px;padding-bottom:6px;border:1px solid %s;border-radius:6px;background-color:%s;}\ + QMenu::item:selected{background-color:%s;border-radius:6px;}\ + QMenu::separator{height:1px;background-color:%s;margin-top:2px;margin-bottom:2px;}", + RightClickMenuBorder ,RightClickMenuBackground,RightClickMenuSelected,RightClickMenuSeparator); } RightClickMenu::~RightClickMenu() @@ -276,9 +281,8 @@ int RightClickMenu::showAppBtnMenu(QString desktopfp) menu.addAction(tr("Add to desktop shortcuts"), this,SLOT(addToDesktopActionTriggerSlot())); menu.addSeparator(); - if(!UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) - menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg",0)),tr("Uninstall"), - this,SLOT(uninstallActionTriggerSlot())); + menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg",0)),tr("Uninstall"), + this,SLOT(uninstallActionTriggerSlot())); menu.setAttribute(Qt::WA_TranslucentBackground); menu.exec(QCursor::pos()); @@ -289,24 +293,22 @@ int RightClickMenu::showShutdownMenu() { m_actionNumber=0; QMenu menu; -// menu.addAction(QIcon(getIconPixmap("stock-people-symbolic",1)),tr("Switch User"), -// this,SLOT(switchUserActionTriggerSlot())); -//#if (QT_VERSION < QT_VERSION_CHECK(5,12,0)) -// if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.session").toLocal8Bit()); -// if(gsetting->keys().contains(QString("canhibernate"))) -// { -// if(gsetting->get("canhibernate").toBool()) -// menu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Hibernate"), -// this,SLOT(hibernateActionTriggerSlot())); -// } -// } -//#endif + menu.addAction(QIcon(getIconPixmap("stock-people-symbolic",1)),tr("Switch User"), + this,SLOT(switchUserActionTriggerSlot())); + if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.session").toLocal8Bit()); + if(gsetting->keys().contains(QString("canhibernate"))) + { + if(gsetting->get("canhibernate").toBool()) + menu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Hibernate"), + this,SLOT(hibernateActionTriggerSlot())); + } + } menu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic",1)),tr("Sleep"), this,SLOT(sleepActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic",1)),tr("Lock Screen"), -// this,SLOT(lockScreenActionTriggerSlot())); + menu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic",1)),tr("Lock Screen"), + this,SLOT(lockScreenActionTriggerSlot())); menu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), this,SLOT(logoutActionTriggerSlot())); menu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), @@ -314,6 +316,7 @@ int RightClickMenu::showShutdownMenu() menu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"), this,SLOT(shutdownActionTriggerSlot())); menu.setAttribute(Qt::WA_TranslucentBackground); +// menu.setStyleSheet(m_style); menu.exec(QCursor::pos()); return m_actionNumber; } @@ -340,6 +343,7 @@ int RightClickMenu::showOtherMenu(QString desktopfp) menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"), this,SLOT(otherListActionTriggerSlot())); menu.setAttribute(Qt::WA_TranslucentBackground); +// menu.setStyleSheet(m_style); menu.exec(QCursor::pos()); return m_actionNumber; } diff --git a/src/RightClickMenu/rightclickmenu.h b/pc/src/RightClickMenu/rightclickmenu.h similarity index 98% rename from src/RightClickMenu/rightclickmenu.h rename to pc/src/RightClickMenu/rightclickmenu.h index 34d1526..43ec001 100644 --- a/src/RightClickMenu/rightclickmenu.h +++ b/pc/src/RightClickMenu/rightclickmenu.h @@ -34,6 +34,7 @@ #include #include #include +//#include #include "src/Interface/ukuimenuinterface.h" #include "src/Style/style.h" @@ -73,6 +74,8 @@ class RightClickMenu : public QWidget int m_actionNumber; QSettings *m_setting=nullptr; + char m_style[400]; + QProcess *m_cmdProc=nullptr; protected: diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/pc/src/SearchResultWidget/fullsearchresultwidget.cpp similarity index 76% rename from src/SearchResultWidget/fullsearchresultwidget.cpp rename to pc/src/SearchResultWidget/fullsearchresultwidget.cpp index 83e4aa5..586aed7 100644 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ b/pc/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -36,17 +36,17 @@ void FullSearchResultWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); + this->setStyleSheet("border:0px;background:transparent;");//transparent this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); + this->setFixedSize(Style::widthavailable, + Style::AppListWidHeight);//Style::MainViewWidWidth QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); + mainLayout->setContentsMargins(Style::listleftMargin,0,Style::listleftMargin+6,0);//127listleftMargin=94; + m_spaceItem=new QSpacerItem(0,20,QSizePolicy::Expanding,QSizePolicy::Fixed);//40-0 mainLayout->addItem(m_spaceItem); m_listView=new FullListView(this,3); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::listleftMargin*2+6,this->height());//this->width()-Style::LeftWidWidth-Style::LeftWidWidth mainLayout->addWidget(m_listView); this->setLayout(mainLayout); @@ -56,6 +56,9 @@ void FullSearchResultWidget::initUi() connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal); + + + } /** @@ -79,16 +82,17 @@ void FullSearchResultWidget::updateAppListView(QVector arg) void FullSearchResultWidget::repaintWidget() { - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - this->layout()->setContentsMargins(Style::LeftWidWidth,0,0,0); + this->setFixedSize(Style::widthavailable, + Style::AppListWidHeight);//MainViewWidWidth + this->layout()->setContentsMargins(0,0,0,0);//Style::LeftWidWidth this->layout()->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; m_listView=new FullListView(this,3); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::listleftMargin*2+6,this->height());//this->width()-Style::LeftWidWidth//Style::widthavailable QHBoxLayout *mainLayout=qobject_cast(this->layout()); - mainLayout->insertWidget(1,m_listView); + mainLayout->setContentsMargins(Style::listleftMargin,0,Style::listleftMargin+6,0);//127listleftMargin=94; + mainLayout->insertWidget(0,m_listView); m_data.clear(); m_listView->addData(m_data); connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); diff --git a/src/SearchResultWidget/fullsearchresultwidget.h b/pc/src/SearchResultWidget/fullsearchresultwidget.h similarity index 100% rename from src/SearchResultWidget/fullsearchresultwidget.h rename to pc/src/SearchResultWidget/fullsearchresultwidget.h diff --git a/src/SearchResultWidget/searchappthread.cpp b/pc/src/SearchResultWidget/searchappthread.cpp similarity index 58% rename from src/SearchResultWidget/searchappthread.cpp rename to pc/src/SearchResultWidget/searchappthread.cpp index 33d9eec..8670cfc 100644 --- a/src/SearchResultWidget/searchappthread.cpp +++ b/pc/src/SearchResultWidget/searchappthread.cpp @@ -61,28 +61,6 @@ void SearchAppThread::run() m_searchResultVector.append(QStringList()<getAppName(searchDesktopList.at(i))); } } -// else if(QString::compare("Mobile",keyword,Qt::CaseInsensitive)==0 || QString::compare("移动",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(0); -// else if(QString::compare("Internet",keyword,Qt::CaseInsensitive)==0 || QString::compare("网络",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(1); -// else if(QString::compare("Social",keyword,Qt::CaseInsensitive)==0 || QString::compare("社交",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(2); -// else if(QString::compare("Video",keyword,Qt::CaseInsensitive)==0 || QString::compare("影音",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(3); -// else if(QString::compare("Development",keyword,Qt::CaseInsensitive)==0 || QString::compare("开发",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(4); -// else if(QString::compare("Image",keyword,Qt::CaseInsensitive)==0 || QString::compare("图像",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(5); -// else if(QString::compare("Game",keyword,Qt::CaseInsensitive)==0 || QString::compare("游戏",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(6); -// else if(QString::compare("Office",keyword,Qt::CaseInsensitive)==0 || QString::compare("办公",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(7); -// else if(QString::compare("Education",keyword,Qt::CaseInsensitive)==0 || QString::compare("教育",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(8); -// else if(QString::compare("System",keyword,Qt::CaseInsensitive)==0 || QString::compare("系统",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(9); -// else if(QString::compare("Others",keyword,Qt::CaseInsensitive)==0 || QString::compare("其它",keyword,Qt::CaseInsensitive)==0) -// searchResultList=UkuiMenuInterface::functionalVector.at(10); else { while(index + +Style::Style() +{ + +} + +int Style::minw=0; +int Style::minh=0; +int Style::defaultMainViewWidWidth=0; +int Style::defaultTopWidHeight=0; +int Style::defaultQueryLineEditWidth=0; +int Style::defaultQueryLineEditHeight=0; +int Style::defaultQueryLineEditIconSize=0; +int Style::defaultContentWidHeight=0; +int Style::defaultSideBarWidWidth=0; +/** + * 全屏窗口 + */ +//主窗口 +int Style::widthavailable=0; +int Style::heightavailable=0; +//主视图 +int Style::MainViewWidWidth=0; +//搜索栏 +int Style::TopWidgetHeight=0; +int Style::QueryLineEditWidth=0; +int Style::QueryLineEditHeight=0; +int Style::QueryLineEditFontSize=0; +int Style::QueryLineEditIconSize=0; +//左侧栏 +int Style::LeftWidWidth=0; +int Style::LeftWidHeight=0; +int Style::LeftMargin=0; +int Style::RightMargin=0; +int Style::LeftBtnWidth=0; +int Style::LeftBtnHeight=0; +int Style::LeftLetterBtnHeight=0; +int Style::LeftFontSize=0; +int Style::LeftLetterFontSize=0; +int Style::LeftIconSize=0; +int Style::LeftSpaceIconLeft=0; +int Style::LeftSpaceIconText=0; +int Style::LeftSpaceBetweenItem=0; +//应用列表栏 +int Style::listleftMargin=0;// +int Style::AppListWidWidth=0; +int Style::AppListWidHeight=0; +int Style::AppListFontSize=0; +int Style::AppListIconSize=0; +int Style::AppListItemSizeWidth=0; +int Style::AppListGridSizeWidth=0; +int Style::AppLeftSpace=0; +int Style::AppTopSpace=0; +int Style::AppSpaceBetweenIconText=0; +int Style::AppBottomSpace=0; +int Style::SliderSize=0; + +//侧边栏 +int Style::SideBarWidWidth=0; +int Style::SideBarMargin=0; +int Style::MinMaxWidWidth=0; +int Style::MinMaxWidHeight=0; +int Style::MinMaxBtnWidth=0; +int Style::MinMaxIconSize=0; +int Style::SideBarBtnWidth=0; +int Style::SideBarBtnHeight=0; +int Style::SideBarFontSize=0; +int Style::SideBarIconSize=0; +int Style::SideBarSpaceIconLeft=0; +int Style::SideBarSpaceIconText=0; +int Style::SideBarSpaceBetweenItem=0; + + +void Style::initWidStyle() +{ + QGSettings* setting=new QGSettings(QString("org.mate.interface").toLocal8Bit()); + QString value=setting->get("font-name").toString(); + QStringList valstr=value.split(" "); + int fontSize=valstr.at(valstr.count()-1).toInt(); + + int position=0; + int panelSize=0; + if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + if(gsetting->keys().contains(QString("panelposition"))) + position=gsetting->get("panelposition").toInt(); + else + position=0; + if(gsetting->keys().contains(QString("panelsize"))) + panelSize=gsetting->get("panelsize").toInt(); + else + panelSize=46; + } + else + { + position=0; + panelSize=46; + } + + + if(position==0 || position==1) + { + widthavailable=QApplication::primaryScreen()->geometry().width(); + heightavailable=QApplication::primaryScreen()->geometry().height()-panelSize; + } + if(position==2 || position==3) + { + widthavailable=QApplication::primaryScreen()->geometry().width()-panelSize; + heightavailable=QApplication::primaryScreen()->geometry().height(); + } + + int len=0; + QString locale = QLocale::system().name(); + if (locale == "zh_CN") + len=0; + else + len=10; + + if(QApplication::primaryScreen()->geometry().width()==800 && + QApplication::primaryScreen()->geometry().height()==600) + { + minw=320; + minh=500; + defaultMainViewWidWidth=264; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=245; + defaultQueryLineEditHeight=50; + defaultContentWidHeight=446; + defaultSideBarWidWidth=55; + } + else + { + minw=376; + minh=590; + defaultMainViewWidWidth=320; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=288; + defaultQueryLineEditHeight=50; + defaultContentWidHeight=536; + defaultSideBarWidWidth=55; + } + if(widthavailable>=2000 && widthavailable<=4000) + { + MainViewWidWidth=widthavailable-round((widthavailable-1644)/8); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + listleftMargin=94; + + + AppListWidWidth=1644; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=96; + AppListItemSizeWidth=168; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=36; + AppTopSpace=15; + AppSpaceBetweenIconText=20; +// AppBottomSpace=27; + SliderSize=12; + + + } + else if (widthavailable>=1920 && widthavailable<2000) { + MainViewWidWidth=widthavailable-round((widthavailable-1314)/8); + + + + + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + LeftWidWidth=round((widthavailable-1314)/2); + listleftMargin=94; + + AppListWidWidth=1314; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;//186 + AppLeftSpace=32; + AppTopSpace=13; + AppSpaceBetweenIconText=18; +// AppBottomSpace=27; + SliderSize=12; + + + } + else if (widthavailable>=1600 && widthavailable<1920) { + MainViewWidWidth=widthavailable-round((widthavailable-1090)/8); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + listleftMargin=120; + + AppListWidWidth=1090; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=32; + AppTopSpace=10; + AppSpaceBetweenIconText=14; +// AppBottomSpace=static_cast(round(27*0.84)); + SliderSize=10; + + + } + else if (widthavailable>=1366 && widthavailable<1600) { + MainViewWidWidth=widthavailable-round((widthavailable-850)/8); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + listleftMargin=120; + + + AppListWidWidth=850; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=0; +// AppBottomSpace=static_cast(round(27*0.74)); + SliderSize=10; + + + } + else if (widthavailable>=1280 && widthavailable<1366) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/8); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + listleftMargin=120; + + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; +// AppBottomSpace=static_cast(round(27*0.65)); + SliderSize=8; + + + } + else if (widthavailable>=1152 && widthavailable<1280) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/8); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + listleftMargin=130; + + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; +// AppBottomSpace=static_cast(round(27*0.65)); + SliderSize=8; + + + } + else if (widthavailable>800 && widthavailable<1152){ + MainViewWidWidth=widthavailable-round((widthavailable-572)/8); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + + listleftMargin=150; + + AppListWidWidth=572; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; +// AppBottomSpace=static_cast(round(27*0.52)); + SliderSize=8; + + + } + else{ + MainViewWidWidth=widthavailable-round((widthavailable-560)/8); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=50; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + listleftMargin=150; + + AppListWidWidth=560; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=(MainViewWidWidth-2*listleftMargin+6)/6;; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; +// AppBottomSpace=static_cast(round(27*0.52)); + SliderSize=8; + + + } +} + diff --git a/pc/src/Style/style.h b/pc/src/Style/style.h new file mode 100644 index 0000000..c3d0849 --- /dev/null +++ b/pc/src/Style/style.h @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 + +//颜色 +#define BORDERCOLOR "rgba(37,41,43)" //边框 +#define SHADOWCOLOR "#80000000" //阴影 + +#define UserIconBackground "#ffffff" +#define UserIconOpacity 0.20 +#define RightClickMenuBackground "rgba(12, 12, 13, 0.7)"//右键菜单背景 +#define RightClickMenuSeparator "rgba(255, 255, 255, 0.08)"//右键菜单分割线 +#define RightClickMenuSelected "rgba(61, 107, 229, 1)"//右键菜单悬浮 +#define RightClickMenuBorder "rgba(255, 255, 255, 0.2)"//右键菜单边框 +#define RightClickMenuFont "rgba(255, 255, 255, 0.91)" +#define RightClickMenuOpacity 0.95 +#define ToolTipBackground "rgba(26, 26, 26, 0.7)" +#define DefaultBackground "rgba(19, 19, 20, 0.45)" //默认态背景色//0.70-0.45 +#define LineBackground "rgba(255,255,255,0.06)" //分割线背景色 +#define SBClassifyBtnSelectedBackground "#3D6BE5" //侧边栏上部分类按钮选择背景 +#define SBFunBtnHoverBackground "rgba(255, 255, 255, 0.14)" //侧边栏目下部功能按钮悬浮背景 +#define ClassifyBtnHoverBackground "rgba(255, 255, 255, 0.14)" //分类按钮悬浮背景 +#define MMBtnHoverBackground "rgba(255, 255, 255, 0.14)" //最大化最小化按钮悬浮背景 +#define QueryLineEditBackground "rgba(0, 0, 0,0.4)" //搜索框背景 +#define QueryLineEditClickedBackground "rgba(0, 0, 0,0.5)" //搜索框背景选中 +#define QueryLineEditClickedBorder "rgba(61, 107, 229, 1)" //搜索框背景选中边框 +#define AppBtnHover "#ffffff" //按钮悬浮 + +/** + * 大小(全屏) + */ +////左侧栏 +//#define LeftWidSize leftsize //大小 +//#define LeftMarginLeftSize Leftmarginleftsize //内左侧边距 +//#define LeftFontSize leftfontsize //字体大小 +//#define LeftIconSize lefticonsize //图标大小 +//#define LeftSpaceIconLeft leftspaceiconleft //按钮内左侧边距 +//#define LeftSpaceIconText leftspaceicontext //按钮图标与文字内边距 +//#define LeftSpaceBetweenItem leftspacebetweenitem //item间距 + +////应用列表栏 +//#define AppListWidSize applistwidsize //大小 +//#define AppListFontSize applistfontsize //字体大小 +//#define AppListIconSize applisticonsize //图标大小 +//#define AppListSpaceBetweenItem applistspacebetweenitem //item间距 +//#define SliderSize slidersize //滑块大小 + +////右侧栏 +//#define RightWidSize rightsize //大小 +//#define RightMarginLeftSize rightmarginleftsize //内右侧边距 +//#define RightFontSize rightfontsize //字体大小 +//#define RightIconSize righticonsize //图标大小 +//#define RightSpaceIconLeft rightspaceiconleft //按钮内左侧边距 +//#define RightSpaceIconText rightspaceicontext //按钮图标与文字内边距 +//#define RightSpaceBetweenItem rightspacebetweenitem //item间距 + +class Style +{ +public: + Style(); + static void initWidStyle(); + static int minw; + static int minh; + static int defaultMainViewWidWidth; + static int defaultTopWidHeight; + static int defaultQueryLineEditWidth; + static int defaultQueryLineEditHeight; + static int defaultQueryLineEditIconSize; + static int defaultContentWidHeight; + static int defaultSideBarWidWidth; + + /** + * 全屏 + */ + //主窗口 + static int widthavailable; + static int heightavailable; + //主视图 + static int MainViewWidWidth;//宽度 + //搜索栏 + static int TopWidgetHeight;//高度 + static int QueryLineEditWidth;//搜索框宽度 + static int QueryLineEditHeight;//搜索框高度 + static int QueryLineEditIconSize;//搜索框图标 + static int QueryLineEditFontSize;//搜索框字体大小 + //左侧栏 + static int LeftWidWidth; //宽度 + static int LeftWidHeight; //高度 + static int LeftMargin; //内左侧边距 + static int RightMargin;//内右侧边距 + static int LeftBtnWidth;//按钮宽度 + static int LeftBtnHeight;//按钮高度 + static int LeftLetterBtnHeight;//按钮高度 + static int LeftFontSize; //字体大小 + static int LeftLetterFontSize; //字体大小 + static int LeftIconSize; //图标大小 + static int LeftSpaceIconLeft; //按钮内左侧边距 + static int LeftSpaceIconText; //按钮图标与文字内边距 + static int LeftSpaceBetweenItem; //item间距 + //应用列表栏 + static int listleftMargin;// + + static int AppListWidWidth; //宽度 + static int AppListWidHeight; //高度 + static int AppListFontSize; //字体大小 + static int AppListIconSize; //图标大小 + static int AppListItemSizeWidth; //item大小 + static int AppListGridSizeWidth; //网格大小 + static int AppLeftSpace;//左侧边距 + static int AppTopSpace;//上侧边距 + static int AppSpaceBetweenIconText;//图标与文字边距 + static int AppBottomSpace;//下侧边距 + static int SliderSize; //滑块大小 + + /** + * 侧边栏 + */ + static int SideBarWidWidth; //宽度 + static int SideBarMargin; //内右侧边距 + static int MinMaxWidWidth; //放大缩小界面宽度 + static int MinMaxWidHeight; //放大缩小界面高度 + static int MinMaxBtnWidth; //放大缩小按钮宽度 + static int MinMaxIconSize; //放大缩小按钮大小 + static int SideBarBtnWidth;//按钮宽度 + static int SideBarBtnHeight;//按钮高度 + static int SideBarFontSize; //字体大小 + static int SideBarIconSize; //图标大小 + static int SideBarSpaceIconLeft; //按钮内左侧边距 + static int SideBarSpaceIconText; //按钮图标与文字内边距 + static int SideBarSpaceBetweenItem; //item间距 + +}; + +#endif // STYLE_H diff --git a/src/UtilityFunction/classifyscrollarea.cpp b/pc/src/UtilityFunction/classifyscrollarea.cpp similarity index 100% rename from src/UtilityFunction/classifyscrollarea.cpp rename to pc/src/UtilityFunction/classifyscrollarea.cpp diff --git a/src/UtilityFunction/classifyscrollarea.h b/pc/src/UtilityFunction/classifyscrollarea.h similarity index 100% rename from src/UtilityFunction/classifyscrollarea.h rename to pc/src/UtilityFunction/classifyscrollarea.h diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/pc/src/UtilityFunction/fullitemdelegate.cpp similarity index 84% rename from src/UtilityFunction/fullitemdelegate.cpp rename to pc/src/UtilityFunction/fullitemdelegate.cpp index e01cc6e..6801d51 100644 --- a/src/UtilityFunction/fullitemdelegate.cpp +++ b/pc/src/UtilityFunction/fullitemdelegate.cpp @@ -18,7 +18,8 @@ #include "fullitemdelegate.h" #include - +#include +#include FullItemDelegate::FullItemDelegate(QObject *parent, int module): QStyledItemDelegate(parent) { @@ -71,13 +72,23 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti // painter->drawPath(path); // } + + painter->setOpacity(1); + QString desktopfp=index.data(Qt::DisplayRole).value(); QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp); QIcon icon; QFileInfo iconFileInfo(iconstr); + + + + QString pathicon; if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) + { icon=QIcon(iconstr); + pathicon=iconstr; + } else { iconstr.remove(".png"); @@ -86,27 +97,61 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti if(icon.isNull()) { if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + pathicon=QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + pathicon=QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + pathicon=QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) + { + icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + pathicon=QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + pathicon=QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + pathicon=QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + pathicon=QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + pathicon=QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + pathicon=QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"); + } else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) + { icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + pathicon=QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"); + } else + { icon=QIcon::fromTheme(QString("application-x-desktop")); + pathicon=QString("application-x-desktop"); + } } } @@ -118,8 +163,15 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti rect.y()+Style::AppTopSpace, Style::AppListIconSize, Style::AppListIconSize); + + + icon.paint(painter,iconRect); + + + + textRect=QRect(rect.x()+5, iconRect.bottom()+Style::AppSpaceBetweenIconText, rect.width()-10, diff --git a/src/UtilityFunction/fullitemdelegate.h b/pc/src/UtilityFunction/fullitemdelegate.h similarity index 100% rename from src/UtilityFunction/fullitemdelegate.h rename to pc/src/UtilityFunction/fullitemdelegate.h diff --git a/src/UtilityFunction/fulllistview.cpp b/pc/src/UtilityFunction/fulllistview.cpp similarity index 90% rename from src/UtilityFunction/fulllistview.cpp rename to pc/src/UtilityFunction/fulllistview.cpp index dcfacd8..0ffb4b9 100644 --- a/src/UtilityFunction/fulllistview.cpp +++ b/pc/src/UtilityFunction/fulllistview.cpp @@ -48,12 +48,14 @@ void FullListView::initWidget() QListView:Item:pressed{background:transparent;}"); if(module!=1 && module!=2) - this->verticalScrollBar()->setStyleSheet("QScrollBar{width:3px;padding-top:0px;padding-bottom:0px;background:transparent;border-radius:6px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:1.5px;}" + this->verticalScrollBar()->setStyleSheet("QScrollBar{width:6px;padding-top:350px;padding-bottom:200px;background:transparent;border-radius:6px;min-height:10px;max-height:100px}" + "QScrollBar::handle{background-color:rgba(255,255,255,0.95); width:6px;border-radius:3px;height:20px;}" + "QScrollBar::handle:hover{background-color:#ffffff;border-radius:3px;width:10px;height:10px;}" + "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:3px;width:10px;height:10px;}" "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" + "QScrollBar::add-page{background-color:#000000;border-radius:3px;}" + "QScrollBar::sub-page{background-color:#000000;border-radius:3px;}" ); @@ -68,13 +70,13 @@ void FullListView::initWidget() this->setTextElideMode(Qt::ElideRight); this->setMouseTracking(true); this->setFocusPolicy(Qt::NoFocus); - this->setMovement(QListView::Static); + // this->setMovement(QListView::Static); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); this->setGridSize(QSize(Style::AppListGridSizeWidth,Style::AppListGridSizeWidth)); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot); connect(this,&FullListView::clicked,this,&FullListView::onClicked); + } void FullListView::addData(QStringList data) @@ -175,6 +177,8 @@ void FullListView::leaveEvent(QEvent *e) this->verticalScrollBar()->setVisible(false); } + + //void FullListView::mousePressEvent(QMouseEvent *event) //{ // if(!(this->indexAt(event->pos()).isValid()) && event->button()==Qt::LeftButton) diff --git a/src/UtilityFunction/fulllistview.h b/pc/src/UtilityFunction/fulllistview.h similarity index 95% rename from src/UtilityFunction/fulllistview.h rename to pc/src/UtilityFunction/fulllistview.h index 9b7f455..89e35ad 100644 --- a/src/UtilityFunction/fulllistview.h +++ b/pc/src/UtilityFunction/fulllistview.h @@ -28,7 +28,9 @@ #include #include "fullitemdelegate.h" #include "src/Style/style.h" - +#include +#include +#include class FullListView : public QListView { Q_OBJECT @@ -49,6 +51,7 @@ class FullListView : public QListView FullItemDelegate* m_delegate=nullptr; QStandardItemModel* listmodel=nullptr; int module=0; + bool mousemove=false; RightClickMenu* menu=nullptr;//右键菜单 QSettings *setting=nullptr; @@ -58,12 +61,15 @@ class FullListView : public QListView private Q_SLOTS: void onClicked(QModelIndex index);//点击item + void rightClickedSlot(const QPoint &pos);//右键菜单 Q_SIGNALS: void sendItemClickedSignal(QString arg);//发送item点击信号 + void sendHideMainWindowSignal(); void sendUpdateAppListSignal(); + }; #endif // FULLLISTVIEW_H diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/pc/src/UtilityFunction/functionclassifybutton.cpp similarity index 100% rename from src/UtilityFunction/functionclassifybutton.cpp rename to pc/src/UtilityFunction/functionclassifybutton.cpp diff --git a/src/UtilityFunction/functionclassifybutton.h b/pc/src/UtilityFunction/functionclassifybutton.h similarity index 100% rename from src/UtilityFunction/functionclassifybutton.h rename to pc/src/UtilityFunction/functionclassifybutton.h diff --git a/src/UtilityFunction/itemdelegate.cpp b/pc/src/UtilityFunction/itemdelegate.cpp similarity index 100% rename from src/UtilityFunction/itemdelegate.cpp rename to pc/src/UtilityFunction/itemdelegate.cpp diff --git a/src/UtilityFunction/itemdelegate.h b/pc/src/UtilityFunction/itemdelegate.h similarity index 100% rename from src/UtilityFunction/itemdelegate.h rename to pc/src/UtilityFunction/itemdelegate.h diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/pc/src/UtilityFunction/letterclassifybutton.cpp similarity index 100% rename from src/UtilityFunction/letterclassifybutton.cpp rename to pc/src/UtilityFunction/letterclassifybutton.cpp diff --git a/src/UtilityFunction/letterclassifybutton.h b/pc/src/UtilityFunction/letterclassifybutton.h similarity index 100% rename from src/UtilityFunction/letterclassifybutton.h rename to pc/src/UtilityFunction/letterclassifybutton.h diff --git a/src/UtilityFunction/listview.cpp b/pc/src/UtilityFunction/listview.cpp similarity index 95% rename from src/UtilityFunction/listview.cpp rename to pc/src/UtilityFunction/listview.cpp index b0a413c..2c85202 100644 --- a/src/UtilityFunction/listview.cpp +++ b/pc/src/UtilityFunction/listview.cpp @@ -44,10 +44,10 @@ void ListView::initWidget() { // this->setFixedSize(w,h); - this->verticalScrollBar()->setStyleSheet("QScrollBar{padding-top:0px;padding-bottom:0px;background:transparent;width:3px;border-radius:1.5px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;width:3px;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;width:3px;border-radius:1.5px;}" + this->verticalScrollBar()->setStyleSheet("QScrollBar{padding-top:500px;padding-bottom:500px;background:transparent;width:10px;border-radius:1.5px;;height:200px;}" + "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:6px;border-radius:1.5px;height:20px;}" + "QScrollBar::handle:hover{background-color:#697883;width:3px;border-radius:1.5px; width:6px;height:20px;}" + "QScrollBar::handle:pressed{background-color:#8897a3;width:3px;border-radius:1.5px; width:6px;height:20px;}" "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" ); @@ -67,7 +67,6 @@ void ListView::initWidget() this->setSpacing(0); this->setContentsMargins(0, 0, 0, 0); this->setMouseTracking(true); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); connect(this,&ListView::customContextMenuRequested,this,&ListView::rightClickedSlot); connect(this,&ListView::clicked,this,&ListView::onClicked); } diff --git a/src/UtilityFunction/listview.h b/pc/src/UtilityFunction/listview.h similarity index 100% rename from src/UtilityFunction/listview.h rename to pc/src/UtilityFunction/listview.h diff --git a/src/UtilityFunction/pushbutton.cpp b/pc/src/UtilityFunction/pushbutton.cpp similarity index 100% rename from src/UtilityFunction/pushbutton.cpp rename to pc/src/UtilityFunction/pushbutton.cpp diff --git a/src/UtilityFunction/pushbutton.h b/pc/src/UtilityFunction/pushbutton.h similarity index 100% rename from src/UtilityFunction/pushbutton.h rename to pc/src/UtilityFunction/pushbutton.h diff --git a/src/UtilityFunction/scrollarea.cpp b/pc/src/UtilityFunction/scrollarea.cpp similarity index 72% rename from src/UtilityFunction/scrollarea.cpp rename to pc/src/UtilityFunction/scrollarea.cpp index a86855b..60d272d 100644 --- a/src/UtilityFunction/scrollarea.cpp +++ b/pc/src/UtilityFunction/scrollarea.cpp @@ -22,17 +22,18 @@ ScrollArea::ScrollArea() { this->verticalScrollBar()->setVisible(false); - this->verticalScrollBar()->setStyleSheet("QScrollBar{width:3px;padding-top:0px;padding-bottom:0px;background:transparent;border-radius:6px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:1.5px;}" + this->verticalScrollBar()->setStyleSheet("QScrollBar{width:6px;padding-top:300px;padding-bottom:300px;background:transparent;border-radius:6px;max-height:50px;}" + "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:6px;height:10px;border-radius:1.5px;}" + "QScrollBar::handle:hover{background-color:#697883;border-radius:3px;width:6px;height:10px;}" + "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:3px;width:6px;height:10px;}" "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" + "QScrollBar::add-page{background-color:#000000;border-radius:3px;}" + "QScrollBar::sub-page{background-color:#000000;border-radius:3px;}" ); installEventFilter(this); this->setFocusPolicy(Qt::NoFocus); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); } void ScrollArea::enterEvent(QEvent *e) diff --git a/src/UtilityFunction/scrollarea.h b/pc/src/UtilityFunction/scrollarea.h similarity index 100% rename from src/UtilityFunction/scrollarea.h rename to pc/src/UtilityFunction/scrollarea.h diff --git a/src/UtilityFunction/toolbutton.cpp b/pc/src/UtilityFunction/toolbutton.cpp similarity index 100% rename from src/UtilityFunction/toolbutton.cpp rename to pc/src/UtilityFunction/toolbutton.cpp diff --git a/src/UtilityFunction/toolbutton.h b/pc/src/UtilityFunction/toolbutton.h similarity index 100% rename from src/UtilityFunction/toolbutton.h rename to pc/src/UtilityFunction/toolbutton.h diff --git a/src/UtilityFunction/utility.cpp b/pc/src/UtilityFunction/utility.cpp similarity index 100% rename from src/UtilityFunction/utility.cpp rename to pc/src/UtilityFunction/utility.cpp diff --git a/src/UtilityFunction/utility.h b/pc/src/UtilityFunction/utility.h similarity index 100% rename from src/UtilityFunction/utility.h rename to pc/src/UtilityFunction/utility.h diff --git a/src/XEventMonitor/xeventmonitor.cpp b/pc/src/XEventMonitor/xeventmonitor.cpp similarity index 100% rename from src/XEventMonitor/xeventmonitor.cpp rename to pc/src/XEventMonitor/xeventmonitor.cpp diff --git a/src/XEventMonitor/xeventmonitor.h b/pc/src/XEventMonitor/xeventmonitor.h similarity index 100% rename from src/XEventMonitor/xeventmonitor.h rename to pc/src/XEventMonitor/xeventmonitor.h diff --git a/translations/ukui-menu_bo.ts b/pc/translations/ukui-menu_bo.ts similarity index 99% rename from translations/ukui-menu_bo.ts rename to pc/translations/ukui-menu_bo.ts index 7e9676c..dd0a73b 100644 --- a/translations/ukui-menu_bo.ts +++ b/pc/translations/ukui-menu_bo.ts @@ -269,7 +269,7 @@ - Search + Search Application diff --git a/translations/ukui-menu_tr.ts b/pc/translations/ukui-menu_tr.ts similarity index 99% rename from translations/ukui-menu_tr.ts rename to pc/translations/ukui-menu_tr.ts index 5ae00ce..c26f5a4 100644 --- a/translations/ukui-menu_tr.ts +++ b/pc/translations/ukui-menu_tr.ts @@ -121,7 +121,7 @@ MainViewWidget - Search + Search Application Ara diff --git a/translations/ukui-menu_zh_CN.ts b/pc/translations/ukui-menu_zh_CN.ts similarity index 99% rename from translations/ukui-menu_zh_CN.ts rename to pc/translations/ukui-menu_zh_CN.ts index fc6a4d6..d3d574c 100644 --- a/translations/ukui-menu_zh_CN.ts +++ b/pc/translations/ukui-menu_zh_CN.ts @@ -121,8 +121,8 @@ MainViewWidget - Search - 搜索 + Search Application + 搜索应用 diff --git a/pc/ukui-menu.desktop b/pc/ukui-menu.desktop new file mode 100644 index 0000000..024ae20 --- /dev/null +++ b/pc/ukui-menu.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=ukui-menu +comment=ukui-menu +Comment[zh_CN]=开始菜单 +Comment[tr_TR]=Başlangıç menüsü +Exec=/usr/bin/ukui-menu +Terminal=false +Type=Application +Icon=ukui-menu +X-UKUI-AutoRestart=true +OnlyShowIn=UKUI +X-UKUI-Autostart-Phase=Application +NoDisplay=true diff --git a/pc/ukui-menu.pro b/pc/ukui-menu.pro new file mode 100644 index 0000000..8a15cd0 --- /dev/null +++ b/pc/ukui-menu.pro @@ -0,0 +1,112 @@ +#------------------------------------------------- +# +# ukui-menu +# +#------------------------------------------------- + +QT += core gui svg dbus x11extras KWindowSystem +QT += core gui network +QT += core gui dbus + +//CONFIG += c++11 +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +include(src/QtSingleApplication/qtsingleapplication.pri) +QMAKE_CXXFLAGS += -g + +TARGET = ukui-menu +TEMPLATE = app + +target.path = /usr/bin + +TRANSLATIONS+=\ + translations/ukui-menu_bo.ts \ + translations/ukui-menu_zh_CN.ts \ + translations/ukui-menu_tr.ts + +QM_FILES_INSTALL_PATH = /usr/share/ukui-menu/translations/ + +# CONFIG += lrelase not work for qt5.6, add those from lrelease.prf for compatibility +qtPrepareTool(QMAKE_LRELEASE, lrelease) +lrelease.name = lrelease +lrelease.input = TRANSLATIONS +lrelease.output = ${QMAKE_FILE_IN_BASE}.qm +lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} +lrelease.CONFIG = no_link +QMAKE_EXTRA_COMPILERS += lrelease +PRE_TARGETDEPS += compiler_lrelease_make_all + +for (translation, TRANSLATIONS) { + translation = $$basename(translation) + QM_FILES += $$OUT_PWD/$$replace(translation, \\..*$, .qm) +} +qm_files.files = $$QM_FILES +qm_files.path = $$QM_FILES_INSTALL_PATH +qm_files.CONFIG = no_check_exist +INSTALLS += qm_files + +# So we can access it from main.cpp +DEFINES += QM_FILES_INSTALL_PATH='\\"$${QM_FILES_INSTALL_PATH}\\"' + +SOURCES += \ + src/CommonUseWidget/fullcommonusewidget.cpp \ + src/MainViewWidget/directorychangedthread.cpp \ + src/MainViewWidget/mainviewwidget.cpp \ + src/MainWindow/mainwindow.cpp \ + src/RightClickMenu/rightclickmenu.cpp \ + src/SearchResultWidget/fullsearchresultwidget.cpp \ + src/SearchResultWidget/searchappthread.cpp \ + src/SearchResultWidget/searchresultwidget.cpp \ + src/Style/style.cpp \ + src/UtilityFunction/classifyscrollarea.cpp \ + src/UtilityFunction/fullitemdelegate.cpp \ + src/UtilityFunction/fulllistview.cpp \ + src/UtilityFunction/functionclassifybutton.cpp \ + src/UtilityFunction/itemdelegate.cpp \ + src/UtilityFunction/letterclassifybutton.cpp \ + src/UtilityFunction/listview.cpp \ + src/UtilityFunction/pushbutton.cpp \ + src/UtilityFunction/scrollarea.cpp \ + src/UtilityFunction/toolbutton.cpp \ + src/Interface/ukuichineseletter.cpp \ + src/Interface/ukuimenuinterface.cpp \ + main.cpp \ + src/UtilityFunction/utility.cpp \ + src/XEventMonitor/xeventmonitor.cpp + +HEADERS += \ + src/CommonUseWidget/fullcommonusewidget.h \ + src/MainViewWidget/directorychangedthread.h \ + src/MainViewWidget/mainviewwidget.h \ + src/MainWindow/mainwindow.h \ + src/RightClickMenu/rightclickmenu.h \ + src/SearchResultWidget/fullsearchresultwidget.h \ + src/SearchResultWidget/searchappthread.h \ + src/SearchResultWidget/searchresultwidget.h \ + src/Style/style.h \ + src/UtilityFunction/classifyscrollarea.h \ + src/UtilityFunction/fullitemdelegate.h \ + src/UtilityFunction/fulllistview.h \ + src/UtilityFunction/functionclassifybutton.h \ + src/UtilityFunction/itemdelegate.h \ + src/UtilityFunction/letterclassifybutton.h \ + src/UtilityFunction/listview.h \ + src/UtilityFunction/pushbutton.h \ + src/UtilityFunction/scrollarea.h \ + src/UtilityFunction/toolbutton.h \ + src/Interface/ukuichineseletter.h \ + src/Interface/ukuimenuinterface.h \ + src/UtilityFunction/utility.h \ + src/XEventMonitor/xeventmonitor.h + +RESOURCES += \ + res.qrc + +PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xrandr xtst +CONFIG += no_keywords link_pkgconfig + + +desktop_file.files = ukui-menu.desktop +desktop_file.path = /etc/xdg/autostart + +INSTALLS += \ + target desktop_file diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp deleted file mode 100644 index 1b9f98d..0000000 --- a/src/CommonUseWidget/commonusewidget.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 - -CommonUseWidget::CommonUseWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); - -} - -CommonUseWidget::~CommonUseWidget() -{ - delete m_ukuiMenuInterface; -} - -void CommonUseWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - fillAppList(); -} - -/** - * 初始化应用列表界面 - */ -void CommonUseWidget::initAppListWidget() -{ - m_listView=new ListView(this,this->width()-4,this->height(),0); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_listView->show(); - connect(m_listView,&ListView::sendItemClickedSignal,this,&CommonUseWidget::execApplication); - connect(m_listView,&ListView::sendUpdateAppListSignal,this,&CommonUseWidget::updateListViewSlot); - connect(m_listView,&ListView::sendHideMainWindowSignal,this,&CommonUseWidget::sendHideMainWindowSignal); -} - -/** - * 填充应用列表 - */ -void CommonUseWidget::fillAppList() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) - m_data.append(QStringList()<addData(m_data); -} - -/** - * 执行应用程序 - */ -void CommonUseWidget::execApplication(QStringList arg) -{ - Q_EMIT sendHideMainWindowSignal(); - QString desktopfp=arg.at(0); - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo); -} - - -/** - * 更新应用列表槽函数 - */ -void CommonUseWidget::updateListViewSlot() -{ - updateListView(); -} - -void CommonUseWidget::updateListView() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllApp()) - m_data.append(QStringList()<updateData(m_data); -} - -void CommonUseWidget::widgetMakeZero() -{ - m_listView->verticalScrollBar()->setSliderPosition(0); -} - -void CommonUseWidget::moveScrollBar(int type) -{ - if(type==0) - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100); - else - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100); -} - -void CommonUseWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_listView->show(); -} diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h deleted file mode 100644 index b007c29..0000000 --- a/src/CommonUseWidget/commonusewidget.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class CommonUseWidget : public QWidget -{ - Q_OBJECT - -public: - explicit CommonUseWidget(QWidget *parent = nullptr); - ~CommonUseWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Update application list - */ - void updateListView(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - ListView* m_listView=nullptr; - QVector m_data; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppList(); - -public Q_SLOTS: - /** - * @brief Open the application - * @param arg: The desktop file information that the application contains - */ - void execApplication(QStringList arg); - /** - * @brief Update the application list slot function - */ - void updateListViewSlot(); - -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); - -}; - -#endif // COMMONUSEWIDGET_H diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp deleted file mode 100644 index 92d9b17..0000000 --- a/src/FunctionWidget/fullfunctionwidget.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Style/style.h" -#include -#include -#include - -FullFunctionWidget::FullFunctionWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullFunctionWidget::~FullFunctionWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullFunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - m_applistWid=new QWidget(this); - m_iconListWid=new QWidget(this); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); - - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - mainLayout->setSpacing(0); - m_applistWid->setStyleSheet("border:0px;background:transparent;"); - m_iconListWid->setStyleSheet("border:0px;background:transparent"); - mainLayout->addWidget(m_iconListWid); - mainLayout->addWidget(m_applistWid); - this->setLayout(mainLayout); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - initIconListWidget(); -} - -/** - * 初始化应用列表界面 - */ -void FullFunctionWidget::initAppListWidget() -{ - QHBoxLayout* layout=new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0,0,0,0); - m_applistWid->setLayout(layout); - - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new QWidget; - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - fillAppList(); -} - -/** - * 填充应用列表 - */ -void FullFunctionWidget::fillAppList() -{ - m_classificationList.clear(); - QVector vector=UkuiMenuInterface::functionalVector; - QStringList androidlist=vector.at(0); - if(!androidlist.isEmpty()) - { - insertClassificationBtn("Mobile"); - insertAppList(androidlist); - } - - QStringList netlist=vector.at(1); - if(!netlist.isEmpty()) - { - insertClassificationBtn("Internet"); - insertAppList(netlist); - } - QStringList sociallist=vector.at(2); - if(!sociallist.isEmpty()) - { - insertClassificationBtn("Social"); - insertAppList(sociallist); - } - QStringList avlist=vector.at(3); - if(!avlist.isEmpty()) - { - insertClassificationBtn("Video"); - insertAppList(avlist); - } - QStringList developlist=vector.at(4); - if(!developlist.isEmpty()) - { - insertClassificationBtn("Development"); - insertAppList(developlist); - } - QStringList graphicslist=vector.at(5); - if(!graphicslist.isEmpty()) - { - insertClassificationBtn("Image"); - insertAppList(graphicslist); - } - QStringList gamelist=vector.at(6); - if(!gamelist.isEmpty()) - { - insertClassificationBtn("Game"); - insertAppList(gamelist); - } - QStringList officelist=vector.at(7); - if(!officelist.isEmpty()) - { - insertClassificationBtn("Office"); - insertAppList(officelist); - } - QStringList educationlist=vector.at(8); - if(!educationlist.isEmpty()) - { - insertClassificationBtn("Education"); - insertAppList(educationlist); - } - - QStringList systemadminlist=vector.at(9); - if(!systemadminlist.isEmpty()) - { - insertClassificationBtn("System"); - insertAppList(systemadminlist); - } - QStringList otherlist=vector.at(10); - if(!otherlist.isEmpty()) - { - insertClassificationBtn("Others"); - insertAppList(otherlist); - } - - resizeScrollAreaControls(); -} - -void FullFunctionWidget::insertClassificationBtn(QString category) -{ - PushButton* classificationbtn=new PushButton(this,category,m_scrollArea->width()-12,30,2); -// classificationbtn->setFixedSize(m_scrollArea->width()-12,25); - m_scrollAreaWidLayout->addWidget(classificationbtn); - m_classificationList.append(category); - -} - -void FullFunctionWidget::insertAppList(QStringList desktopfplist) -{ - FullListView* listview=new FullListView(this,2); - m_scrollAreaWidLayout->addWidget(listview); - m_data.clear(); - for(int i=0;iaddData(m_data); - connect(listview,&FullListView::sendItemClickedSignal,this,&FullFunctionWidget::execApplication); - connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullFunctionWidget::sendHideMainWindowSignal); -} - -//void FullFunctionWidget::updateRecentListView() -//{ -// data.clear(); -// QStringList recentlist; -// recentlist.clear(); -// recentlist=pUkuiMenuInterface->getRecentApp(); -// if(!recentlist.isEmpty())//最近添加非空 -// { -// if(m_classificationList.contains(tr("Recently")))//有最近添加分类 -// { -// QLayoutItem *child; -// if((child = m_scrollAreaWidLayout->itemAt(1)) != 0) -// { -// QWidget* wid=child->widget(); -// FullListView* listview=qobject_cast(wid); -// for(int i=0;igetDesktopPathByAppName(recentlist.at(i)); -// data.append(desktopfp); -// } -// listview->updateData(data); -// } -// } -// else//无最近添加分类 -// { -// PushButton* classificationbtn=new PushButton(this,tr("Recently"),scrollarea->width()-12,20); -// classificationbtn->setFixedSize(scrollarea->width()-12,20); -// m_scrollAreaWidLayout->insertWidget(0,classificationbtn); -// m_classificationList.insert(0,tr("Recently")); - -// FullListView* listview=new FullListView(this,2); -// m_scrollAreaWidLayout->insertWidget(1,listview); -// for(int i=0;igetDesktopPathByAppName(recentlist.at(i)); -// data.append(desktopfp); -// } -// listview->addData(data); -// connect(listview,SIGNAL(sendItemClickedSignal(QString)),this,SLOT(execApplication(QString))); - -// //刷新图标列表界面 -// Q_FOREACH (QAbstractButton* button, m_buttonList){ -// m_btnGroup->removeButton(button); -// } -// m_buttonList.clear(); -// QLayoutItem *child; -// while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_iconListScrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// } -// initIconListScrollArea(); -// } -// } -// else//最近添加为空 -// { -// if(m_classificationList.contains(tr("Recently"))) -// { -// int num=0; -// QLayoutItem *child; -// while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_scrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// num++; -// if(num==2) -// break; -// } -// m_classificationList.removeAt(0); - -// //刷新图标列表界面 -// Q_FOREACH (QAbstractButton* button, m_buttonList){ -// m_btnGroup->removeButton(button); -// } -// m_buttonList.clear(); -// while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_iconListScrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// } -// initIconListScrollArea(); -// } -// } -// resizeScrollAreaControls(); -// setting->endGroup(); -//} - -/** - * 执行应用程序 - */ -void FullFunctionWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo);} - -/** - * 更新应用列表 - */ -void FullFunctionWidget::updateAppListView() -{ - //刷新应用列表界面 - QLayoutItem *child; - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - fillAppList(); - - //刷新图标列表界面 - Q_FOREACH (QAbstractButton* button, m_buttonList){ - m_btnGroup->removeButton(button); - } - m_buttonList.clear(); - while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_iconListScrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - initIconListScrollArea(); -} - -/** - * 设置scrollarea所填充控件大小 - */ -void FullFunctionWidget::resizeScrollAreaControls() -{ - int row=0; - while(rowcount()/2) - { - //应用界面 - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - row++; - } - m_scrollArea->widget()->adjustSize(); -} - -/** - * 初始化图标列表界面 - */ -void FullFunctionWidget::initIconListWidget() -{ - m_iconListScrollArea=new ClassifyScrollArea(m_iconListWid); - m_iconListScrollAreaWid=new QWidget; - m_iconListScrollAreaWidLayout=new QVBoxLayout; - m_iconListScrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem); - m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout); - m_iconListScrollArea->setWidget(m_iconListScrollAreaWid); - - m_btnGroup=new QButtonGroup(m_iconListScrollAreaWid); - m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry"); - - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); - connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); - - initIconListScrollArea(); -} - -/** - * 初始化图标列表界面数据表格iconlisttableWid - */ -void FullFunctionWidget::initIconListScrollArea() -{ - for(int i=0;i vector=UkuiMenuInterface::functionalVector; -// QStringList androidlist=vector.at(0); -// for(int index=0;indexsetChecked(false); - m_buttonList.append(iconbtn); - m_iconListScrollAreaWidLayout->addWidget(iconbtn); -// } - - } - - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - m_btnGroup->addButton(btn,id++); - } - connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullFunctionWidget::btnGroupClickedSlot); - m_iconListScrollArea->widget()->adjustSize(); - m_btnGroup->button(0)->click(); -} - -void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - Q_FOREACH (QAbstractButton* button, m_buttonList) { - if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) - { - m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->stop(); - m_scrollAnimation->setStartValue(m_beginPos); - m_scrollAnimation->setEndValue(m_endPos); - m_scrollAnimation->start(); - button->setChecked(true); - } - else{ - button->setChecked(false); - } - } -} - -void FullFunctionWidget::animationFinishSlot() -{ - if(m_scrollArea->verticalScrollBar()->value()==m_endPos || - m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) - { - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - } -} - -void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - if (sender() != m_scrollAnimation) - return; - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) - ani->setEndValue(m_endPos); -} - -void FullFunctionWidget::valueChangedSlot(int value) -{ - int index=0; - while(index<=m_classificationList.count()-1) - { - int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); - int max=0; - if(index==m_classificationList.count()-1) - max=m_scrollAreaWid->height(); - else - max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); - if(value>=min && value(button); - if(index==m_buttonList.indexOf(button)) - { - fcbutton->setChecked(true); - } - else{ - fcbutton->setChecked(false); - } - } - break; - } - else - index++; - } -} - -void FullFunctionWidget::enterAnimation() -{ - int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0,(m_iconListWid->height()-height)/2, - 0,height)); - m_animation->setEndValue(QRect(Style::LeftMargin, - (m_iconListWid->height()-height)/2, - Style::LeftBtnWidth, - height)); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_iconListScrollArea->show(); -} - -void FullFunctionWidget::setFunctionBtnGeometry() -{ - int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; - m_iconListScrollArea->setGeometry(QRect(Style::LeftMargin, - (m_iconListWid->height()-height)/2, - Style::LeftBtnWidth, - height)); - m_iconListScrollArea->show(); - -} - -void FullFunctionWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - updateAppListView(); -} - -void FullFunctionWidget::widgetMakeZero() -{ -// Q_FOREACH (QAbstractButton* button, m_buttonList) { -// int num=m_classificationList.indexOf(functionnamelist.at(m_buttonList.indexOf(button))); -// if(num!=-1) -// { -// m_btnGroup->button(num)->setChecked(true); -// m_btnGroup->button(num)->click(); -// m_iconListScrollArea->verticalScrollBar()->setSliderPosition(0); -// break; -// } -// } - m_btnGroup->button(0)->click(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -} - -void FullFunctionWidget::moveScrollBar(int type) -{ - int height=QApplication::primaryScreen()->geometry().height(); - if(type==0) - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); -} diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/FunctionWidget/fullfunctionwidget.h deleted file mode 100644 index 8912cb8..0000000 --- a/src/FunctionWidget/fullfunctionwidget.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 -#include -#include "src/Interface/ukuimenuinterface.h" -#include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/pushbutton.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifyscrollarea.h" -#include "src/UtilityFunction/toolbutton.h" -#include "src/UtilityFunction/functionclassifybutton.h" -#include "src/Style/style.h" - -class FullFunctionWidget : public QWidget -{ - Q_OBJECT - -public: - explicit FullFunctionWidget(QWidget *parent=nullptr); - ~FullFunctionWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief The function category button uses animation to enter - */ - void enterAnimation(); - /** - * @brief Repaint window - */ - void repaintWidget(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Adjust function classification button position - */ - void setFunctionBtnGeometry(); - -private: - /*Application list interface*/ - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - QWidget* m_applistWid=nullptr; - ScrollArea* m_scrollArea=nullptr; - QWidget* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; - QStringList m_classificationList;//Store the list of category buttons - QStringList m_data; - - /*Function classification list interface*/ - QWidget* m_iconListWid=nullptr; - ClassifyScrollArea* m_iconListScrollArea=nullptr; - QWidget* m_iconListScrollAreaWid=nullptr; - QVBoxLayout* m_iconListScrollAreaWidLayout=nullptr; - QList m_buttonList; - QButtonGroup* m_btnGroup=nullptr; - - /*Animation*/ - QPropertyAnimation* m_animation=nullptr;//Function category button animation - QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation - int m_beginPos=0;//Application list scrollbar starting value - int m_endPos=0;//Application list scrollbar end value - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initializes the icon list interface - */ - void initIconListWidget(); - void initIconListScrollArea(); - - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppList(); - /** - * @brief Insert category button - * @param category: Functional classification name - */ - void insertClassificationBtn(QString category); - /** - * @brief Insert application list - * @param desktopfplist: Desktop file path list - */ - void insertAppList(QStringList desktopfplist); - /** - * @brief Set the control size in qscrollarea - */ - void resizeScrollAreaControls(); - -public Q_SLOTS: - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Respond to button click - * @param btn: QButtonGroup button - */ - void btnGroupClickedSlot(QAbstractButton *btn); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to application list scrolling - * @param value: Scrollbar current value - */ - void valueChangedSlot(int value); - /** - * @brief Respond to application list animation finish - */ - void animationFinishSlot(); - /** - * @brief Respond to application list animation current value change - * @param value: animation current value - */ - void animationValueChangedSlot(const QVariant &value); - -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // FULLFUNCTIONWIDGET_H diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp deleted file mode 100644 index 02f3738..0000000 --- a/src/FunctionWidget/functionbuttonwidget.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 - -FunctionButtonWidget::FunctionButtonWidget(QWidget *parent) : - QWidget(parent) -{ - m_categoryList.append("Mobile"); - m_categoryList.append("Internet"); - m_categoryList.append("Social"); - m_categoryList.append("Video"); - m_categoryList.append("Development"); - m_categoryList.append("Image"); - m_categoryList.append("Game"); - m_categoryList.append("Office"); - m_categoryList.append("Education"); - m_categoryList.append("System"); - m_categoryList.append("Others"); - - initUi(); -} - -FunctionButtonWidget::~FunctionButtonWidget() -{ -} - -void FunctionButtonWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->resize(Style::LeftBtnWidth*2+5,Style::LeftBtnHeight*6+25); - - QGridLayout* gridLayout=new QGridLayout; - gridLayout->setContentsMargins(0,0,0,0); - gridLayout->setSpacing(5); - this->setLayout(gridLayout); - - for(int row=0;row<6;row++) - for(int col=0;col<2;col++) - { - FunctionClassifyButton* iconbtn=new FunctionClassifyButton(Style::LeftBtnWidth, - Style::LeftBtnHeight, - Style::LeftIconSize, - m_categoryList.at(row*2+col), - false, - false); - - gridLayout->addWidget(iconbtn,row,col); - connect(iconbtn,&FunctionClassifyButton::buttonClicked,this, &FunctionButtonWidget::functionBtnClickedSlot); - if(row*2+col==10)break; - } -} - -/** - * 功能分类按钮槽函数 - */ -void FunctionButtonWidget::functionBtnClickedSlot() -{ - FunctionClassifyButton* btn=dynamic_cast(sender()); - QWidget* wid=btn->layout()->itemAt(1)->widget(); - QLabel* label=qobject_cast(wid); - Q_EMIT sendFunctionBtnSignal(label->text()); -} - -/** - * 接收FunctionWidget界面分类按钮列表 - */ -void FunctionButtonWidget::recvClassificationBtnList() -{ - QGridLayout* gridLayout=qobject_cast(this->layout()); - for(int row=0;row<6;row++) - for(int col=0;col<2;col++) - { - QLayoutItem* item=gridLayout->itemAtPosition(row,col); - FunctionClassifyButton* btn=qobject_cast(item->widget()); - if(UkuiMenuInterface::functionalVector.at(row*2+col).isEmpty()) - btn->m_enabled=false; - else - btn->m_enabled=true; - btn->setEnabled(btn->m_enabled); - btn->updateBtnState(); - - if(row*2+col==10)break; - } -} diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/FunctionWidget/functionbuttonwidget.h deleted file mode 100644 index 2b4bb9b..0000000 --- a/src/FunctionWidget/functionbuttonwidget.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/UtilityFunction/functionclassifybutton.h" -#include "src/Interface/ukuimenuinterface.h" - -class FunctionButtonWidget : public QWidget -{ - Q_OBJECT - -public: - explicit FunctionButtonWidget(QWidget *parent = nullptr); - ~FunctionButtonWidget(); - -private: - QStringList m_categoryList; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - -Q_SIGNALS: - /** - * @brief Send button click signal to functionwidget interface - * @param btnname: Category button name - */ - void sendFunctionBtnSignal(QString btnname); - -public Q_SLOTS: - /** - * @brief Respond to button click - */ - void functionBtnClickedSlot(); - /** - * @brief Receive function classification list - */ - void recvClassificationBtnList(); -}; - -#endif // FUNCTIONBUTTONWIDGET_H diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp deleted file mode 100644 index 0ea09a1..0000000 --- a/src/FunctionWidget/functionwidget.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 - -FunctionWidget::FunctionWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FunctionWidget::~FunctionWidget() -{ - delete m_ukuiMenuInterface; -} - -/** - * 主界面初始化 - */ -void FunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - initAppListWidget(); - - m_functionBtnWid=new FunctionButtonWidget(this); - m_functionBtnWid->hide(); - connect(this,&FunctionWidget::sendClassificationbtnList,m_functionBtnWid,&FunctionButtonWidget::recvClassificationBtnList); - connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal); - - m_enterAnimation=new QPropertyAnimation; - m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation=new QPropertyAnimation; - m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); - connect(m_enterAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); - -} - -/** - * 初始化应用列表界面 - */ -void FunctionWidget::initAppListWidget() -{ - m_appListView=new ListView(this,this->width()-4,this->height(),2); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); - fillAppListView(0); - connect(m_appListView,&ListView::sendItemClickedSignal,this,&FunctionWidget::recvItemClickedSlot); - connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&FunctionWidget::sendHideMainWindowSignal); -} - - -/** - * 填充应用列表 - */ -void FunctionWidget::fillAppListView(int type) -{ - row=0; - m_data.clear(); - m_classificationList.clear(); - m_classificationBtnRowList.clear(); - QVector vector=UkuiMenuInterface::functionalVector; - QStringList androidlist=vector.at(0); - if(!androidlist.isEmpty()) - { - insertClassificationBtn(tr("Mobile")); - insertAppList(androidlist); - } - QStringList netlist=vector.at(1); - if(!netlist.isEmpty()) - { - insertClassificationBtn(tr("Internet")); - insertAppList(netlist); - } - QStringList sociallist=vector.at(2); - if(!sociallist.isEmpty()) - { - insertClassificationBtn(tr("Social")); - insertAppList(sociallist); - } - QStringList avlist=vector.at(3); - if(!avlist.isEmpty()) - { - insertClassificationBtn(tr("Video")); - insertAppList(avlist); - } - QStringList developlist=vector.at(4); - if(!developlist.isEmpty()) - { - insertClassificationBtn(tr("Development")); - insertAppList(developlist); - } - QStringList graphicslist=vector.at(5); - if(!graphicslist.isEmpty()) - { - insertClassificationBtn(tr("Image")); - insertAppList(graphicslist); - } - QStringList gamelist=vector.at(6); - if(!gamelist.isEmpty()) - { - insertClassificationBtn(tr("Game")); - insertAppList(gamelist); - } - QStringList officelist=vector.at(7); - if(!officelist.isEmpty()) - { - insertClassificationBtn(tr("Office")); - insertAppList(officelist); - } - QStringList educationlist=vector.at(8); - if(!educationlist.isEmpty()) - { - insertClassificationBtn(tr("Education")); - insertAppList(educationlist); - } - - QStringList systemadminlist=vector.at(9); - if(!systemadminlist.isEmpty()) - { - insertClassificationBtn(tr("System")); - insertAppList(systemadminlist); - } - QStringList otherlist=vector.at(10); - if(!otherlist.isEmpty()) - { - insertClassificationBtn(tr("Others")); - insertAppList(otherlist); - } - - if(type==0) - m_appListView->addData(m_data); - else - m_appListView->updateData(m_data); -} - -void FunctionWidget::insertClassificationBtn(QString btnname) -{ - m_classificationList.append(btnname); - m_data.append(QStringList()<setStartValue(QRect(0,0,this->width()-4,this->height())); - m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setEndValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, - (this->height()-Style::LeftBtnHeight*6-25)/2, - Style::LeftBtnWidth*2+5, - Style::LeftBtnHeight*6+25)); - m_leaveAnimation->setDuration(10); - m_enterAnimation->setDuration(80); - - //加载FunctionButtonWidget界面 - Q_EMIT sendClassificationbtnList(); - m_leaveAnimation->setTargetObject(m_appListView); - m_enterAnimation->setTargetObject(m_functionBtnWid); - m_leaveAnimation->start(); - m_widgetState=1; -} - -/** - * 接收FunctionButtonWidget界面按钮信号 - */ -void FunctionWidget::recvFunctionBtnSignal(QString btnname) -{ - //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 - int index=m_classificationList.indexOf(btnname); - if(index!=-1) - { - int row=m_classificationBtnRowList.at(index).toInt(); - m_appListView->verticalScrollBar()->setValue(row); - } - - m_leaveAnimation->setStartValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, - (this->height()-Style::LeftBtnHeight*6-25)/2, - Style::LeftBtnWidth*2+5, - Style::LeftBtnHeight*6+25)); - m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setEndValue(QRect(0,0,this->width()-4,this->height())); - m_leaveAnimation->setDuration(80); - m_enterAnimation->setDuration(10); - - m_leaveAnimation->setTargetObject(m_functionBtnWid); - m_enterAnimation->setTargetObject(m_appListView); - m_leaveAnimation->start(); - m_widgetState=0; -} - -void FunctionWidget::animationFinishedSLot() -{ - if(m_widgetState==1) - { - m_appListView->hide(); - m_enterAnimation->start(); - m_widgetState=-1; - m_functionBtnWid->show(); - } - if(m_widgetState==0) - { - m_functionBtnWid->hide(); - m_enterAnimation->start(); - m_widgetState=-1; - m_appListView->show(); - } -} - -void FunctionWidget::widgetMakeZero() -{ - m_functionBtnWid->hide(); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); - m_appListView->verticalScrollBar()->setValue(0); -} - -void FunctionWidget::moveScrollBar(int type) -{ - if(type==0) - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); - else - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); -} - -void FunctionWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); -} diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h deleted file mode 100644 index 10f284e..0000000 --- a/src/FunctionWidget/functionwidget.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" -#include "functionbuttonwidget.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class FunctionWidget : public QWidget -{ - Q_OBJECT - -public: - explicit FunctionWidget(QWidget *parent=nullptr); - ~FunctionWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - FunctionButtonWidget* m_functionBtnWid=nullptr;//Classification list interface - ListView* m_appListView=nullptr; - QVector m_data; - QStringList m_classificationList;//Store the list of category buttons - QStringList m_classificationBtnRowList;//Store the row in which the category button is located - int row=0; - /*Interface switching animation*/ - QPropertyAnimation* m_enterAnimation=nullptr; - QPropertyAnimation* m_leaveAnimation=nullptr; - int m_widgetState=-1; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppListView(int type); - /** - * @brief Insert category button - * @param category: Functional classification name - */ - void insertClassificationBtn(QString btnname); - /** - * @brief Insert application list - * @param desktopfplist: Desktop file path list - */ - void insertAppList(QStringList appnamelist); - -public Q_SLOTS: - /** - * @brief Switch to the function classification button interface - */ - void appClassificationBtnClickedSlot(); - /** - * @brief Receive function classification button interface signal - * @param Category button name - */ - void recvFunctionBtnSignal(QString btnname); - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to the list item click - * @param arg: The desktop file information that the application contains - */ - void recvItemClickedSlot(QStringList arg); - /** - * @brief Respond to animation finish - */ - void animationFinishedSLot(); - -Q_SIGNALS: - /** - * @brief Send the classification button click signal to functionbuttonwidget - */ - void sendClassificationbtnList(); - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // FUNCTIONWIDGET_H diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp deleted file mode 100644 index 06641b8..0000000 --- a/src/LetterWidget/fullletterwidget.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 - -FullLetterWidget::FullLetterWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullLetterWidget::~FullLetterWidget() -{ - delete m_ukuiMenuInterface; -} - -/** - * 主界面初始化 - */ -void FullLetterWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - - m_applistWid=new QWidget(this); - m_letterListWid=new QWidget(this); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); - - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - mainLayout->setSpacing(0); - m_applistWid->setStyleSheet("border:0px;background: transparent;"); - m_letterListWid->setStyleSheet("border:0px;background: transparent;"); - mainLayout->addWidget(m_letterListWid); - mainLayout->addWidget(m_applistWid); - this->setLayout(mainLayout); - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - initLetterListWidget(); -} - -/** - * 初始化应用列表界面 - */ -void FullLetterWidget::initAppListWidget() -{ - QHBoxLayout* layout=new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0,0,0,0); - m_applistWid->setLayout(layout); - - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new QWidget; - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - - fillAppList(); - -} - -/** - * 填充应用列表 - */ -void FullLetterWidget::fillAppList() -{ - m_letterList.clear(); - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - //插入字母分类按钮 - PushButton* letterbtn=new PushButton(this,letterstr,m_scrollArea->width()-12,30,1); -// letterbtn->setFixedSize(m_scrollArea->width(),20); - m_scrollAreaWidLayout->addWidget(letterbtn); - - //插入应用列表 - FullListView* listview=new FullListView(this,1); - m_scrollAreaWidLayout->addWidget(listview); - m_data.clear(); - for(int i=0;iaddData(m_data); - - connect(listview,&FullListView::sendItemClickedSignal,this,&FullLetterWidget::execApplication); - connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullLetterWidget::sendHideMainWindowSignal); - } - } - - resizeScrollAreaControls(); -} - -/** - * 执行应用程序 - */ -void FullLetterWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo); -} - -/** - * 更新应用列表 - */ -void FullLetterWidget::updateAppListView() -{ - //刷新应用列表界面 - QLayoutItem *child; - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - fillAppList(); - - //刷新字母列表界面 - Q_FOREACH (QAbstractButton* button, m_buttonList) { - m_btnGroup->removeButton(button); - } - m_buttonList.clear(); - m_letterListScrollAreaWidLayout->removeItem(m_letterListBottomSpacer); - while ((child = m_letterListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_letterListScrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - //防止按钮位置偏移 - initLetterListScrollArea(); -} - -/** - * 设置scrollarea所填充控件大小 - */ -void FullLetterWidget::resizeScrollAreaControls() -{ - int row=0; - while(rowcount()/2) - { - //应用界面 - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - row++; - } - m_scrollArea->widget()->adjustSize(); -} - -/** - * 初始化字母列表界面 - */ -void FullLetterWidget::initLetterListWidget() -{ - m_letterListScrollArea=new ClassifyScrollArea(m_letterListWid); - m_letterListScrollAreaWid=new QWidget(m_letterListScrollArea); - m_letterListScrollAreaWidLayout=new QVBoxLayout; - m_letterListScrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_letterListScrollAreaWidLayout->setSpacing(0); - m_letterListScrollAreaWid->setLayout(m_letterListScrollAreaWidLayout); - m_letterListScrollArea->setWidget(m_letterListScrollAreaWid); - m_letterListScrollArea->setWidgetResizable(true); - - m_letterListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - m_btnGroup=new QButtonGroup(m_letterListScrollAreaWid); - m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry"); - - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); - connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); - - initLetterListScrollArea(); -} - -/** - * 初始化字母列表 - */ -void FullLetterWidget::initLetterListScrollArea() -{ -// m_letterListScrollArea->setStyleSheet("border:1px solid #ff0000;"); -// m_letterListScrollArea->setFixedSize(Style::LeftLetterBtnHeight*2, -// (m_letterList.size()+1)*Style::LeftLetterBtnHeight); - -// m_letterListScrollArea->setStyleSheet("border:1px solid #ff0000;"); - if(m_letterList.contains("&")) - m_letterList.replace(m_letterList.indexOf("&"),"&&"); - for(int i=0;iaddWidget(letterbtn); - m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter); - connect(letterbtn,&LetterClassifyButton::buttonClicked,m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); - } - m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer); - - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - m_btnGroup->addButton(btn,id++); - } - - connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullLetterWidget::btnGroupClickedSlot); - m_letterListScrollArea->widget()->adjustSize(); - m_btnGroup->button(0)->click(); -} - -void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - Q_FOREACH (QAbstractButton* button, m_buttonList) { - LetterClassifyButton* letterbtn=qobject_cast(button); - if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) - { - letterbtn->setChecked(true); - //此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端 - QString letterstr=letterbtn->text(); - int num=m_letterList.indexOf(letterstr); - if(num!=-1) - { - m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->stop(); - m_scrollAnimation->setStartValue(m_beginPos); - m_scrollAnimation->setEndValue(m_endPos); - m_scrollAnimation->start(); - - } - } - else{ - letterbtn->setChecked(false); - } - } -} - -void FullLetterWidget::animationFinishSlot() -{ - if(m_scrollArea->verticalScrollBar()->value()==m_endPos || - m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) - { - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - } -} - -void FullLetterWidget::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - if (sender() != m_scrollAnimation) - return; - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) - ani->setEndValue(m_endPos); -} - -void FullLetterWidget::valueChangedSlot(int value) -{ - int index=0; - while(index<=m_letterList.count()-1) - { - int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); - int max=0; - if(index==m_letterList.count()-1) - max=m_scrollAreaWid->height(); - else - max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); - - if(value>=min && value (button); - if(index==m_buttonList.indexOf(button)) - { - letterbtn->setChecked(true); - } - else - { - letterbtn->setChecked(false); - } - } - break; - } - else - index++; - } - - //向下滚动 - if((m_buttonList.at(index)->pos().y()+m_buttonList.at(index)->height()+m_letterListScrollArea->widget()->pos().y()) >= m_letterListScrollArea->height()) - { - int val=m_letterListScrollArea->verticalScrollBar()->sliderPosition()+m_buttonList.at(index)->height(); - m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); - } - - //向上滚动 - if((m_buttonList.at(index)->pos().y()+m_letterListScrollArea->widget()->pos().y()) <= 0) - { - - int val=m_letterListScrollArea->verticalScrollBar()->value()-m_buttonList.at(index)->height(); - m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); - } - -} - -void FullLetterWidget::enterAnimation() -{ - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0,(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - 0,(m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_animation->setEndValue(QRect(Style::LeftMargin, - (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - Style::LeftLetterBtnHeight*2, - (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_letterListScrollArea->show(); -} - -void FullLetterWidget::setLetterBtnGeometry() -{ - m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, - (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - Style::LeftLetterBtnHeight*2, - (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_letterListScrollArea->show(); -} - -void FullLetterWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - updateAppListView(); -} - -void FullLetterWidget::widgetMakeZero() -{ - Q_FOREACH (QAbstractButton* button, m_buttonList) { - QString letterstr=button->text().at(0); - int num=m_letterList.indexOf(letterstr); - if(num!=-1) - { - m_btnGroup->button(num)->click(); - m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); - break; - } - } - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -} - -void FullLetterWidget::moveScrollBar(int type) -{ - int height=QApplication::primaryScreen()->geometry().height(); - if(type==0) - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); -} diff --git a/src/LetterWidget/fullletterwidget.h b/src/LetterWidget/fullletterwidget.h deleted file mode 100644 index 8e7d9c0..0000000 --- a/src/LetterWidget/fullletterwidget.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include "src/UtilityFunction/letterclassifybutton.h" -#include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/pushbutton.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifyscrollarea.h" -#include "src/UtilityFunction/toolbutton.h" -#include "src/Style/style.h" - -class FullLetterWidget : public QWidget -{ - Q_OBJECT - -public: - explicit FullLetterWidget(QWidget *parent=nullptr); - ~FullLetterWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief The letter category button uses animation to enter - */ - void enterAnimation(); - /** - * @brief Repaint window - */ - void repaintWidget(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Adjust the position of the alphabetical classification button - */ - void setLetterBtnGeometry(); - -private: - /*Application list interface*/ - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - QWidget* m_applistWid=nullptr; - ScrollArea* m_scrollArea=nullptr; - QWidget* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; - QStringList m_letterList;//Store the list of letter buttons - QStringList m_data; - - /*Alphabetic classification list interface*/ - QWidget* m_letterListWid=nullptr; - ClassifyScrollArea* m_letterListScrollArea=nullptr; - QWidget* m_letterListScrollAreaWid=nullptr; - QVBoxLayout* m_letterListScrollAreaWidLayout=nullptr; - QList m_buttonList; - QButtonGroup* m_btnGroup=nullptr; - QSpacerItem* m_letterListBottomSpacer=nullptr; - - /*Animation*/ - QPropertyAnimation* m_animation=nullptr;//Letter category button animation - int m_beginPos=0;//Application list scrollbar starting value - int m_endPos=0;//Application list scrollbar end value - QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief fill application list - */ - void fillAppList(); - /** - * @brief Initializes the letter list interface - */ - void initLetterListWidget(); - void initLetterListScrollArea(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief Set the control size in qscrollarea - */ - void resizeScrollAreaControls(); - -public Q_SLOTS: - /** - * @brief Respond to button click - * @param btn: QButtonGroup button - */ - void btnGroupClickedSlot(QAbstractButton *btn); - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to application list scrolling - * @param value: Scrollbar current value - */ - void valueChangedSlot(int value); - /** - * @brief Respond to animation finish - */ - void animationFinishSlot(); - /** - * @brief Respond to animation current value change - * @param value: animation current value - */ - void animationValueChangedSlot(const QVariant &value); - -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // FULLLETTERWIDGET_H diff --git a/src/LetterWidget/letterbuttonwidget.cpp b/src/LetterWidget/letterbuttonwidget.cpp deleted file mode 100644 index 31aa016..0000000 --- a/src/LetterWidget/letterbuttonwidget.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 - -LetterButtonWidget::LetterButtonWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -LetterButtonWidget::~LetterButtonWidget() -{ -} - -void LetterButtonWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->resize(235,366); - - QGridLayout* gridLayout=new QGridLayout; - gridLayout->setContentsMargins(0,0,0,0); - gridLayout->setSpacing(5); - this->setLayout(gridLayout); - - char btncolor[400]; - sprintf(btncolor,"QToolButton{background:transparent;color:#ffffff;padding-left:0px;}\ - QToolButton:hover{background-color:%s;color:#ffffff;border-radius:4px;}\ - QToolButton:pressed{background-color:%s;color:#ffffff;border-radius:4px;}\ - QToolButton:disabled{color:rgba(255, 255, 255, 0.25);}", - ClassifyBtnHoverBackground, - ClassifyBtnHoverBackground); - - QStringList letterlist; - letterlist.clear(); - for(int i=0;i<26;i++) - { - char letter=static_cast(65+i); - letterlist.append(QString(QChar(letter))); - } - letterlist.append("&&"); - letterlist.append("#"); - - for(int row=0;row<7;row++) - { - for(int col=0;col<4;col++) - { - if(row*4+colsetFixedSize(55,48); - btn->setStyleSheet(QString::fromLocal8Bit(btncolor)); - btn->setText(letterlist.at(row*4+col)); - gridLayout->addWidget(btn,row,col); - connect(btn, &QToolButton::clicked, this, &LetterButtonWidget::letterBtnClickedSlot); - } - else { - break; - } - } - } -} - -/** - * 字母分类按钮槽函数 - */ -void LetterButtonWidget::letterBtnClickedSlot() -{ - QToolButton* btn=dynamic_cast(QObject::sender()); - QString btnname=btn->text(); - Q_EMIT sendLetterBtnSignal(btnname); -} - -/** - * 接收LetterWidget字母按钮列表 - */ -void LetterButtonWidget::recvLetterBtnList(QStringList list) -{ - QGridLayout* gridLayout=qobject_cast(this->layout()); - for(int row=0;row<7;row++) - { - for(int col=0;col<4;col++) - { - QLayoutItem* item=gridLayout->itemAt(row*4+col); - QToolButton* btn=static_cast(item->widget()); - QString letterstr=btn->text(); - if(list.indexOf(letterstr.at(0))==-1) - btn->setEnabled(false); - else - btn->setEnabled(true); - - if(row*4+col==27) break; - } - } -} diff --git a/src/LetterWidget/letterbuttonwidget.h b/src/LetterWidget/letterbuttonwidget.h deleted file mode 100644 index 904166c..0000000 --- a/src/LetterWidget/letterbuttonwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/UtilityFunction/functionclassifybutton.h" - -class LetterButtonWidget : public QWidget -{ - Q_OBJECT - -public: - explicit LetterButtonWidget(QWidget *parent = nullptr); - ~LetterButtonWidget(); - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - -Q_SIGNALS: - /** - * @brief Send button click signal to letterwidget interface - * @param btnname: Category button name - */ - void sendLetterBtnSignal(QString btnname); - -public Q_SLOTS: - /** - * @brief Respond to button click - */ - void letterBtnClickedSlot(); - /** - * @brief Receive letters classification list - * @param list: Letters classification list - */ - void recvLetterBtnList(QStringList list); -}; - -#endif // LETTERBUTTONWIDGET_H diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp deleted file mode 100644 index 3c13fca..0000000 --- a/src/LetterWidget/letterwidget.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/UtilityFunction/itemdelegate.h" - -LetterWidget::LetterWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -LetterWidget::~LetterWidget() -{ - delete m_ukuiMenuInterface; -} - -/** - * 主界面初始化 - */ -void LetterWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - initAppListWidget(); - - m_letterBtnWid=new LetterButtonWidget(this); - m_letterBtnWid->hide(); - connect(this,&LetterWidget::sendLetterBtnList,m_letterBtnWid,&LetterButtonWidget::recvLetterBtnList); - connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal,this,&LetterWidget::recvLetterBtnSlot); - - m_enterAnimation=new QPropertyAnimation; - m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation=new QPropertyAnimation; - m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); - connect(m_enterAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); -} - -/** - * 初始化应用列表界面 - */ -void LetterWidget::initAppListWidget() -{ - m_appListView=new ListView(this,this->width()-4,this->height(),1); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); - fillAppListView(); - connect(m_appListView,&ListView::sendItemClickedSignal,this,&LetterWidget::recvItemClickedSlot); - connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&LetterWidget::sendHideMainWindowSignal); -} - - -/** - * 填充应用列表 - */ -void LetterWidget::fillAppListView() -{ - int row=0; - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList()<addData(m_data); -} - -void LetterWidget::recvItemClickedSlot(QStringList arg) -{ - if(arg.at(1).toInt()==0) - appClassificationBtnClickedSlot(); - else - execApplication(arg.at(0)); -} - -/** - * 执行应用程序 - */ -void LetterWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - bool ret=g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo); - syslog(LOG_LOCAL0 | LOG_DEBUG ,"执行应用程序 %s:%d:%s:%s", - desktopfp.toLocal8Bit().data(), - ret, - m_ukuiMenuInterface->getAppExec(desktopfp).toLocal8Bit().data(), - m_ukuiMenuInterface->getAppIcon(desktopfp).toLocal8Bit().data()); -} - -/** - * 更新应用列表 - */ -void LetterWidget::updateAppListView() -{ - int row=0; - m_data.clear(); - m_letterList.clear(); - m_letterBtnRowList.clear(); - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList()<updateData(m_data); -} - -/** - * 应用列表字母分类按钮槽函数 - */ -void LetterWidget::appClassificationBtnClickedSlot() -{ - m_leaveAnimation->setStartValue(QRect(0,0,this->width()-4,this->height())); - m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setEndValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); - m_leaveAnimation->setDuration(10); - m_enterAnimation->setDuration(80); - - //加载LetterBUttonWidget界面 - Q_EMIT sendLetterBtnList(m_letterList); - m_leaveAnimation->setTargetObject(m_appListView); - m_enterAnimation->setTargetObject(m_letterBtnWid); - m_letterBtnWid->setWindowOpacity(0.1); - m_leaveAnimation->start(); - m_widgetState=1; -} - -/** - * 接收LetterButtonWidget界面按钮信号 - */ -void LetterWidget::recvLetterBtnSlot(QString btnname) -{ - //此处需实现将字母为btnname的应用列表移动到applistWid界面最顶端 - int num=m_letterList.indexOf(QString(QChar(btnname.at(0)))); - if(num!=-1) - { - int row=m_letterBtnRowList.at(num).toInt(); - m_appListView->verticalScrollBar()->setValue(row); - } - - m_leaveAnimation->setStartValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); - m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setEndValue(QRect(0,0,this->width()-4,this->height())); - m_leaveAnimation->setDuration(80); - m_enterAnimation->setDuration(10); - - m_leaveAnimation->setTargetObject(m_letterBtnWid); - m_enterAnimation->setTargetObject(m_appListView); - m_leaveAnimation->start(); - m_widgetState=0; -} - -void LetterWidget::animationFinishedSLot() -{ - if(m_widgetState==1) - { - m_enterAnimation->start(); - m_widgetState=-1; - m_appListView->hide(); - m_letterBtnWid->show(); - } - if(m_widgetState==0) - { - m_enterAnimation->start(); - m_widgetState=-1; - m_letterBtnWid->hide(); - m_appListView->show(); - } -} - -void LetterWidget::widgetMakeZero() -{ - m_letterBtnWid->hide(); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); - m_appListView->verticalScrollBar()->setValue(0); -} - -void LetterWidget::moveScrollBar(int type) -{ - if(type==0) - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); - else - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); -} - -void LetterWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); - m_appListView->show(); -} diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h deleted file mode 100644 index 7340de3..0000000 --- a/src/LetterWidget/letterwidget.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" -#include "letterbuttonwidget.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class LetterWidget : public QWidget -{ - Q_OBJECT - -public: - explicit LetterWidget(QWidget *parent=nullptr); - ~LetterWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - LetterButtonWidget* m_letterBtnWid=nullptr; - ListView* m_appListView=nullptr; - QVector m_data; - QStringList m_letterList; - QStringList m_letterBtnRowList; - - /*Interface switching animation*/ - QPropertyAnimation* m_enterAnimation=nullptr; - QPropertyAnimation* m_leaveAnimation=nullptr; - int m_widgetState=-1; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppListView(); - -public Q_SLOTS: - /** - * @brief Switch to the alphabetic classification button interface - */ - void appClassificationBtnClickedSlot(); - /** - * @brief Receive alphabetic classification button interface signal - * @param Category button name - */ - void recvLetterBtnSlot(QString btnname); - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to the list item click - * @param arg: The desktop file information that the application contains - */ - void recvItemClickedSlot(QStringList arg); - /** - * @brief Respond to animation finish - */ - void animationFinishedSLot(); - -Q_SIGNALS: - /** - * @brief Send alphabetic classification list to the letterbuttonwidget - * @param list: Alphabetic classification list - */ - void sendLetterBtnList(QStringList list); - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // LETTERWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp deleted file mode 100644 index 02828a0..0000000 --- a/src/SideBarWidget/sidebarwidget.cpp +++ /dev/null @@ -1,654 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Style/style.h" -#include "src/UtilityFunction/utility.h" - -SideBarWidget::SideBarWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); - m_allBtn->click(); -} - -SideBarWidget::~SideBarWidget() -{ - delete m_ukuiMenuInterface; - delete m_shutDownMenu; - delete m_otherMenu; -} - -/** - * 侧边栏初始化 - */ -void SideBarWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); - this->setFocusPolicy(Qt::NoFocus); - - addSidebarBtn(); - loadMinSidebar(); - - m_ukuiMenuInterface=new UkuiMenuInterface; - m_shutDownMenu=new RightClickMenu; - m_otherMenu=new RightClickMenu; -} - -/** - * 侧边栏添加控件 - */ -void SideBarWidget::addSidebarBtn() -{ - m_mainWidget=new QWidget; - m_mainWidget->setParent(this); - m_mainWidgetLayout=new QVBoxLayout; - m_mainWidgetLayout->setContentsMargins(0,0,0,0); - m_mainWidgetLayout->setSpacing(10); - m_mainWidget->setLayout(m_mainWidgetLayout); - m_mainWidget->setStyleSheet("background:transparent;"); - - //放大缩小按钮界面 - m_minMaxWidget=new QWidget; - m_minMaxWidget->setStyleSheet("QWidget{background:transparent;border:0px;}"); - m_minMaxLayout=new QHBoxLayout; - m_minMaxBtn=new QToolButton; -// m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator); -// m_minMaxBtn->setShortcut(Qt::Key_Enter); - m_minMaxBtn->setShortcut(Qt::Key_Return); - m_minMaxLayout->addWidget(m_minMaxBtn); - m_minMaxWidget->setLayout(m_minMaxLayout); - char btncolor[300]; - sprintf(btncolor,"QToolButton{background:transparent;border:0px;padding-left:0px;border-radius:4px;}\ - QToolButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QToolButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - MMBtnHoverBackground,MMBtnHoverBackground); - m_minMaxBtn->setStyleSheet(QString::fromLocal8Bit(btncolor)); - - //分类按钮 - m_buttonList.clear(); -// m_buttonTextList.clear(); - m_btnGroup=new QButtonGroup(m_mainWidget); - m_allBtn=new QPushButton; - initBtn(m_allBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"),tr("All"),0); - m_letterBtn=new QPushButton; - initBtn(m_letterBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"),tr("Letter"),1); - m_functionBtn=new QPushButton; - initBtn(m_functionBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"),tr("Function"),2); - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - m_btnGroup->addButton(btn,id++); - } - - QString usericon=m_ukuiMenuInterface->getUserIcon(); - QString username=m_ukuiMenuInterface->getUserName(); - m_userIconBtn=new QPushButton; - initBtn(m_userIconBtn,usericon,username,3); - m_personalBtn=new QPushButton; - initBtn(m_personalBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"),tr("Personal"),4); - m_trashBtn=new QPushButton; - initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Recycle Bin"),5); - m_computerBtn=new QPushButton; - initBtn(m_computerBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"),tr("Computer"),6); - m_controlBtn=new QPushButton; - initBtn(m_controlBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"),tr("Settings"),7); - m_shutDownBtn=new QPushButton; - initBtn(m_shutDownBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"),tr("Power"),8); - connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&SideBarWidget::btnGroupClickedSlot); - connect(m_computerBtn,&QPushButton::clicked,this,&SideBarWidget::computerBtnClickedSlot); - connect(m_personalBtn,&QPushButton::clicked,this,&SideBarWidget::personalBtnClickedSlot); - connect(m_controlBtn,&QPushButton::clicked,this,&SideBarWidget::controlBtnClickedSlot); - connect(m_trashBtn,&QPushButton::clicked,this,&SideBarWidget::trashBtnClickedSlot); - connect(m_shutDownBtn,&QPushButton::clicked,this,&SideBarWidget::shutdownBtnClickedSlot); - connect(m_userIconBtn,&QPushButton::clicked,this,&SideBarWidget::userIconBtnClickedSlot); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - if(m_buttonList.indexOf(button)>3 && m_buttonList.indexOf(button)setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_shutDownBtn,&QPushButton::customContextMenuRequested,this, - &SideBarWidget::shutdownBtnRightClickSlot); - - //监控用户账户信息更改 - qint64 uid=static_cast(getuid()); - QDBusInterface iface("org.freedesktop.Accounts", - "/org/freedesktop/Accounts", - "org.freedesktop.Accounts", - QDBusConnection::systemBus()); - QDBusReplyobjPath=iface.call("FindUserById",uid); - QDBusConnection::systemBus().connect("org.freedesktop.Accounts", - objPath.value().path(), - "org.freedesktop.Accounts.User", - QString("Changed"),this,SLOT(userAccountsChanged())); - - m_mainWidgetLayout->addWidget(m_minMaxWidget); - m_mainWidgetLayout->addWidget(m_buttonList.at(0)); - m_mainWidgetLayout->addWidget(m_buttonList.at(1)); - m_mainWidgetLayout->addWidget(m_buttonList.at(2)); - m_verticalSpacer = new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainWidgetLayout->addItem(m_verticalSpacer); - m_mainWidgetLayout->addWidget(m_buttonList.at(3)); - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) - { - m_gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); - if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - connect(m_gsetting,&QGSettings::changed, - this,&SideBarWidget::resetSidebarBtnSlot); - } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); - - m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); -} - -void SideBarWidget::resetSidebarBtnSlot() -{ - QLayoutItem *child; - while ((child = m_mainWidgetLayout->takeAt(6)) != 0) { - QWidget* wid=child->widget(); - m_mainWidgetLayout->removeWidget(wid); - wid->setParent(nullptr); - delete child; - } - - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) - { - if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); -} - -/** - * 设置按钮样式 - */ -void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num) -{ - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - btn->setStyleSheet(QString::fromLocal8Bit(btncolor)); - QHBoxLayout* btnLayout=new QHBoxLayout; - QLabel* labelicon=new QLabel; - labelicon->setAlignment(Qt::AlignCenter); - labelicon->setStyleSheet("background:transparent;border:0px;"); - const auto ratio=devicePixelRatioF(); - if(num!=3) - { - QPixmap pixmap=loadSvg(btnicon,Style::SideBarIconSize*ratio); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setFixedSize(Style::SideBarIconSize,Style::SideBarIconSize); - labelicon->setPixmap(pixmap); - } - else { - if(!QFile::exists(btnicon)) - btnicon=QString("/usr/share/ukui/faces/default.png"); - labelicon->setObjectName(QStringLiteral("faceLabel")); - labelicon->setFocusPolicy(Qt::NoFocus); - labelicon->setAlignment(Qt::AlignCenter); - labelicon->setFixedSize(Style::SideBarIconSize+4,Style::SideBarIconSize+4); - - QPixmap facePixmap(btnicon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); - facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setPixmap(facePixmap); - } - - btnLayout->setSpacing(0); - btnLayout->addWidget(labelicon); - btnLayout->addStretch(); - btn->setLayout(btnLayout); - btn->setFocusPolicy(Qt::NoFocus); - - m_buttonList.append(btn); - m_textList.append(text); -} - -QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius) -{ - if (src.isNull()) { - return QPixmap(); - } - - QPixmap pixmapa(src); - QPixmap pixmap(radius*2,radius*2); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPainterPath path; - path.addEllipse(0, 0, radius*2, radius*2); - painter.setClipPath(path); - painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa); - return pixmap; -} - - -/** - * 加载关机按钮右键菜单 - */ -void SideBarWidget::shutdownBtnRightClickSlot() -{ - int ret=m_shutDownMenu->showShutdownMenu(); - if(ret>=10 && ret<=14) - { - Q_EMIT sendHideMainWindowSignal(); - switch (ret) { - case 10: - QProcess::startDetached(QString("ukui-screensaver-command -l")); - break; - case 11: - QProcess::startDetached(QString("ukui-session-tools --switchuser")); - break; - case 12: - QProcess::startDetached(QString("ukui-session-tools --logout")); - break; - case 13: - QProcess::startDetached(QString("ukui-session-tools --reboot")); - break; - case 14: - QProcess::startDetached(QString("ukui-session-tools --shutdown")); - break; - case 16: - QProcess::startDetached(QString("ukui-session-tools --hibernate")); - break; - case 17: - QProcess::startDetached(QString("ukui-session-tools --sleep")); - break; - default: - break; - } - - } -} - -void SideBarWidget::addRightClickMenu(QPushButton *btn) -{ - btn->setContextMenuPolicy(Qt::CustomContextMenu); -// disconnect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); - connect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); -} - -void SideBarWidget::otherBtnRightClickSlot() -{ - QPushButton* btn=dynamic_cast(QObject::sender()); - int index=m_buttonList.indexOf(btn); - QString desktopfp; - switch (index) { - case 4: - desktopfp=QString("/usr/share/applications/peony-home.desktop"); - break; - case 5: - desktopfp=QString("/usr/share/applications/peony-trash.desktop"); - break; - case 6: - desktopfp=QString("/usr/share/applications/peony-computer.desktop"); - break; - case 7: - desktopfp=QString("/usr/share/applications/ukui-control-center.desktop"); - break; - default: - break; - } - int ret=m_otherMenu->showOtherMenu(desktopfp); - if(ret==15) - { - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -d")); - } -} - -void SideBarWidget::computerBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony computer:///")); -} - -void SideBarWidget::personalBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony")); -} - -void SideBarWidget::controlBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QString execpath=m_ukuiMenuInterface->getAppExec(QString("/usr/share/applications/ukui-control-center.desktop")); - //移除启动参数%u或者%U - if(execpath.contains("%")) - { - int index=execpath.indexOf(QString("%").at(0)); - execpath.remove(index-1,3); - } - QProcess::startDetached(execpath); - -} - -void SideBarWidget::trashBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony trash:///")); -} - -void SideBarWidget::shutdownBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-session-tools")); -} - -void SideBarWidget::userIconBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -u")); -} - -void SideBarWidget::userAccountsChanged() -{ - const auto ratio=devicePixelRatioF(); - QString usericon=m_ukuiMenuInterface->getUserIcon(); - if(!QFile::exists(usericon)) - usericon=QString("/usr/share/ukui/faces/default.png"); - QPixmap facePixmap(usericon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); - -// QLayoutItem* item=m_userIconBtn->layout()->itemAt(0); -// QLabel* labelicon=qobject_cast(item->widget()); -// labelicon->setScaledContents(true); - QLabel* labelicon=m_userIconBtn->findChild("faceLabel"); - facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setPixmap(facePixmap); -} - -/** - * 加载默认侧边栏 - */ -void SideBarWidget::loadMinSidebar() -{ - m_isFullScreen=false; - setMaxBtn(); - - this->setFixedSize(Style::defaultSideBarWidWidth,Style::minh); - m_mainWidget->setGeometry(QRect(0,0,this->width(),this->height())); - m_mainWidget->show(); - m_minMaxWidget->setFixedSize(37,70); - m_minMaxLayout->setContentsMargins(0,0,0,0); - - m_mainWidgetLayout->setContentsMargins(8,0,10,0); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - setMinSidebarBtn(btn); - } - - disconnect(m_minMaxBtn,&QToolButton::clicked,this, &SideBarWidget::sendDefaultBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); -} - -/** - * 设置全屏按钮 - */ -void SideBarWidget::setMaxBtn() -{ - m_minMaxBtn->setFixedSize(37,37); - QSvgRenderer* svgRender = new QSvgRenderer(m_minMaxBtn); - svgRender->load(QString(":/data/img/sidebarwidget/max.svg")); - QPixmap* pixmap = new QPixmap(14,14); - pixmap->fill(Qt::transparent);//设置背景透明 - QPainter p(pixmap); - svgRender->render(&p); - m_minMaxBtn->setIcon(QIcon(*pixmap)); -} - -/** - * 设置默认侧边栏按钮 - */ -void SideBarWidget::setMinSidebarBtn(QPushButton* btn) -{ - const auto ratio=devicePixelRatioF(); - btn->setFixedSize(37,37); - if(m_buttonList.indexOf(btn)==3) - btn->layout()->setContentsMargins(7,0,17,0); - else - btn->layout()->setContentsMargins(9,0,17,0); - btn->layout()->setSpacing(0); - - //移除按钮文本 - QLayoutItem *child; - if((child = btn->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - btn->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - delete childwid; - delete child; - } - } -} - -/** - * 加载全屏侧边栏 - */ -void SideBarWidget::loadMaxSidebar() -{ - m_isFullScreen=true; - setMinBtn(); - - this->setFixedSize(Style::SideBarWidWidth,Style::heightavailable); - - m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth,Style::MinMaxWidHeight); - m_minMaxLayout->setContentsMargins(m_minMaxWidget->width()-m_minMaxBtn->width(),0,0,0); - - m_mainWidgetLayout->setContentsMargins(0,0,0,0); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - setMaxSidebarBtn(btn); - } - - disconnect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendDefaultBtnSignal); -} - -/** - * 设置还原按钮 - */ -void SideBarWidget::setMinBtn() -{ - m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth,Style::MinMaxBtnWidth); - QSvgRenderer* svgRender = new QSvgRenderer(m_minMaxBtn); - svgRender->load(QString(":/data/img/sidebarwidget/min.svg")); - QPixmap* pixmap = new QPixmap(Style::MinMaxIconSize,Style::MinMaxIconSize); - pixmap->fill(Qt::transparent);//设置背景透明 - QPainter p(pixmap); - svgRender->render(&p); - m_minMaxBtn->setIcon(QIcon(*pixmap)); -} - -/** - * 设置全屏侧边栏按钮 - */ -void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) -{ - QHBoxLayout* layout=qobject_cast(btn->layout()); - if(m_buttonList.indexOf(btn)==3) - { - layout->setContentsMargins(13,0,0,0); - layout->setSpacing(8); - } - else - { - layout->setContentsMargins(15,0,0,0); - layout->setSpacing(10); - } - - //修复修改字体大小时获取文本Label大小无效 - //移除按钮文本 - QLayoutItem *child; - if((child = btn->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - btn->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - delete childwid; - delete child; - } - } - //添加文本 - QLabel* labeltext=new QLabel; - labeltext->setStyleSheet(QString("QLabel{background:transparent;color:#ffffff;border:0px;}")); - if(m_buttonList.indexOf(btn)<=2) - { - labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - labeltext->setText(m_textList.at(m_buttonList.indexOf(btn))); - labeltext->adjustSize(); - m_btnWidth=44+labeltext->width()+10; - } - else - { - QFont ft; - QFontMetrics fm(ft); - QString text_1 = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth-44); - labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - labeltext->setText(text_1); - labeltext->setFixedSize(m_btnWidth-44,Style::SideBarBtnHeight); - labeltext->adjustSize(); - } - - btn->layout()->addWidget(labeltext); - btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); -// btn->setToolTip(""); -} - -void SideBarWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - - char pressstyle[200]; - sprintf(pressstyle,"QPushButton{background-color:%s;border:0px;padding-left:0;border-radius:4px;}",SBClassifyBtnSelectedBackground); - - Q_FOREACH (QAbstractButton* button, m_buttonList) { - if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) - { - button->setStyleSheet(pressstyle); - if(m_btnGroup->id(btn)==0) - { - if(m_isFullScreen) - Q_EMIT sendFullScreenCommonUseBtnSignal(); - else - Q_EMIT sendCommonUseBtnSignal(); - } - else if(m_btnGroup->id(btn)==1) - { - if(m_isFullScreen) - Q_EMIT sendFullScreenLetterBtnSignal(); - else Q_EMIT sendLetterBtnSignal(); - } - else{ - if(m_isFullScreen) - Q_EMIT sendFullScreenFunctionBtnSignal(); - else Q_EMIT sendFunctionBtnSignal(); - } - } - else{ - button->setStyleSheet(btncolor); - } - } -} - -void SideBarWidget::enterAnimation() -{ - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(this->width(),0, - 0,this->height())); - m_animation->setEndValue(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, - m_btnWidth,this->height())); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_mainWidget->show(); -} - -void SideBarWidget::setSideBarBtnGeometry() -{ - m_mainWidget->setGeometry(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, - m_btnWidth,this->height())); - m_mainWidget->show(); -} - -void SideBarWidget::widgetMakeZero() -{ - char pressstyle[200]; - sprintf(pressstyle,"QPushButton{background-color:%s;border:0px;padding-left:0;border-radius:4px;}",SBClassifyBtnSelectedBackground); - m_allBtn->setStyleSheet(pressstyle); - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - m_letterBtn->setStyleSheet(btncolor); - m_functionBtn->setStyleSheet(btncolor); -} - -//void SideBarWidget::mousePressEvent(QMouseEvent *event) -//{ -// if(m_isFullScreen && event->button()==Qt::LeftButton) -// { -// int x=event->x(); -// int y=event->y(); -// QRect rect_1(0,0,this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,this->height()); -// QRect rect_2(this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,0,Style::MinMaxWidWidth,Style::MinMaxWidHeight); -// QRect rect_3(rect_1.width()+m_functionBtn->x(),m_functionBtn->y()+m_functionBtn->height(),Style::SideBarBtnWidth,m_otherButtonList.at(0)->y()-m_functionBtn->y()-m_functionBtn->height()); -// syslog(LOG_LOCAL0 | LOG_DEBUG ,"坐标:%d:%d:%d",x,rect_1.x(),rect_3.x()); -// if((x>=rect_1.x() && x<=rect_1.x()+rect_1.width() && y>=rect_1.y() && y<=rect_1.y()+rect_1.height()) || -// (x>=rect_2.x() && x<=rect_2.x()+rect_2.width() && y>=rect_2.y() && y<=rect_2.y()+rect_2.height()) || -// (x>=rect_3.x() && x<=rect_3.x()+rect_3.width() && y>=rect_3.y() && y<=rect_3.y()+rect_3.height())) -// this->parentWidget()->parentWidget()->hide(); -// } -//} diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h deleted file mode 100644 index 74cc62f..0000000 --- a/src/SideBarWidget/sidebarwidget.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include "src/Style/style.h" -#include "src/RightClickMenu/rightclickmenu.h" - -class SideBarWidget : public QWidget -{ - Q_OBJECT - -public: - explicit SideBarWidget(QWidget *parent = nullptr); - ~SideBarWidget(); - /** - * @brief Load the default sidebar - */ - void loadMinSidebar(); - /** - * @brief Load the full-screen sidebar - */ - void loadMaxSidebar(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Sidebar animation - */ - void enterAnimation(); - /** - * @brief Adjust the position of the sidebar buttons - */ - void setSideBarBtnGeometry(); - -private: - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; - - QWidget *m_mainWidget=nullptr; - QVBoxLayout *m_mainWidgetLayout=nullptr; - - QWidget *m_minMaxWidget=nullptr; - QHBoxLayout *m_minMaxLayout=nullptr; - QToolButton *m_minMaxBtn=nullptr; - - QButtonGroup *m_btnGroup=nullptr; - QList m_buttonList; - QStringList m_textList; - QPushButton *m_allBtn=nullptr; - QPushButton *m_letterBtn=nullptr; - QPushButton *m_functionBtn=nullptr; - - QPushButton *m_userIconBtn=nullptr; - QPushButton *m_computerBtn=nullptr; - QPushButton *m_personalBtn=nullptr; - QPushButton *m_controlBtn=nullptr; - QPushButton *m_trashBtn=nullptr; - QPushButton *m_shutDownBtn=nullptr; - QSpacerItem *m_verticalSpacer=nullptr; - bool m_isFullScreen=false; - QGSettings *m_gsetting=nullptr; - RightClickMenu *m_shutDownMenu=nullptr; - RightClickMenu *m_otherMenu=nullptr; - QPropertyAnimation* m_animation=nullptr; - - int m_btnWidth, m_btnheight; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Add a sidebar button - */ - void addSidebarBtn(); - /** - * @brief Set button style - * @param btn: QPushButton - * @param btnicon: Button icon - * @param label: QLabel - * @param text: Button text - * @param num: Button Number - */ - void initBtn(QPushButton *btn, QString btnicon,QString text,int num); - /** - * @brief Set the default sidebar button - * @param btn: QPushButton - */ - void setMinSidebarBtn(QPushButton *btn); - /** - * @brief Set the full-screen sidebar button - * @param btn: QPushButton - */ - void setMaxSidebarBtn(QPushButton *btn); - /** - * @brief Add right-click menu - * @param btn: QPushButton - */ - void addRightClickMenu(QPushButton* btn); - /** - * @brief Set the minimize button - */ - void setMinBtn(); - /** - * @brief Set the maximize button - */ - void setMaxBtn(); - QPixmap PixmapToRound(const QPixmap &src, int radius); -// void mousePressEvent(QMouseEvent* event); - -private Q_SLOTS: - /** - * @brief Respond to button click - * @param btn: QButtonGroup button - */ - void btnGroupClickedSlot(QAbstractButton *btn); - /** - * @brief Load power button right-click menu - */ - void shutdownBtnRightClickSlot(); - /** - * @brief Load other application right-click menu - */ - void otherBtnRightClickSlot(); - /** - * @brief Respond to computer btn - */ - void computerBtnClickedSlot(); - /** - * @brief Respond to personal btn - */ - void personalBtnClickedSlot(); - /** - * @brief Respond to control btn - */ - void controlBtnClickedSlot(); - /** - * @brief Respond to trash btn - */ - void trashBtnClickedSlot(); - /** - * @brief Respond to power btn - */ - void shutdownBtnClickedSlot(); - /** - * @brief Respond to user icon btn - */ - void userIconBtnClickedSlot(); - /** - * @brief Monitor user account changes - */ - void userAccountsChanged(); - /** - * @brief Reset the sidebar button - */ - void resetSidebarBtnSlot(); - -Q_SIGNALS: - /** - * @brief Send all category button signal - */ - void sendCommonUseBtnSignal(); - /** - * @brief Send the letter classification button signal - */ - void sendLetterBtnSignal(); - /** - * @brief Send function classification button signal - */ - void sendFunctionBtnSignal(); - /** - * @brief Send all category button signal of full screen - */ - void sendFullScreenCommonUseBtnSignal(); - /** - * @brief Send the letter classification button of full screen - */ - void sendFullScreenLetterBtnSignal(); - /** - * @brief Send function classification button signal of full screen - */ - void sendFullScreenFunctionBtnSignal(); - /** - * @brief Send a full-screen button click signal - */ - void sendFullScreenBtnSignal(); - /** - * @brief Send the default button click signal - */ - void sendDefaultBtnSignal();//发送默认(还原)按钮点击信号 - /** - * @brief Send a hidden main window signal to the MainWindow - */ - void sendHideMainWindowSignal(); -}; - -#endif // SIDEBARWIDGET_H diff --git a/ukui-menu.pro b/ukui-menu.pro index 1cda237..b679b20 100644 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -1,125 +1,5 @@ -#------------------------------------------------- -# -# ukui-menu -# -#------------------------------------------------- +TEMPLATE = subdirs -QT += core gui svg dbus x11extras KWindowSystem - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -include(src/QtSingleApplication/qtsingleapplication.pri) -QMAKE_CXXFLAGS += -g - -TARGET = ukui-menu -TEMPLATE = app - -target.path = /usr/bin - -TRANSLATIONS+=\ - translations/ukui-menu_bo.ts \ - translations/ukui-menu_zh_CN.ts \ - translations/ukui-menu_tr.ts - -QM_FILES_INSTALL_PATH = /usr/share/ukui-menu/translations/ - -# CONFIG += lrelase not work for qt5.6, add those from lrelease.prf for compatibility -qtPrepareTool(QMAKE_LRELEASE, lrelease) -lrelease.name = lrelease -lrelease.input = TRANSLATIONS -lrelease.output = ${QMAKE_FILE_IN_BASE}.qm -lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} -lrelease.CONFIG = no_link -QMAKE_EXTRA_COMPILERS += lrelease -PRE_TARGETDEPS += compiler_lrelease_make_all - -for (translation, TRANSLATIONS) { - translation = $$basename(translation) - QM_FILES += $$OUT_PWD/$$replace(translation, \\..*$, .qm) -} -qm_files.files = $$QM_FILES -qm_files.path = $$QM_FILES_INSTALL_PATH -qm_files.CONFIG = no_check_exist -INSTALLS += qm_files - -# So we can access it from main.cpp -DEFINES += QM_FILES_INSTALL_PATH='\\"$${QM_FILES_INSTALL_PATH}\\"' - -SOURCES += \ - src/CommonUseWidget/commonusewidget.cpp \ - src/CommonUseWidget/fullcommonusewidget.cpp \ - src/FunctionWidget/fullfunctionwidget.cpp \ - src/FunctionWidget/functionbuttonwidget.cpp \ - src/FunctionWidget/functionwidget.cpp \ - src/LetterWidget/fullletterwidget.cpp \ - src/LetterWidget/letterbuttonwidget.cpp \ - src/LetterWidget/letterwidget.cpp \ - src/MainViewWidget/directorychangedthread.cpp \ - src/MainViewWidget/mainviewwidget.cpp \ - src/MainWindow/mainwindow.cpp \ - src/RightClickMenu/rightclickmenu.cpp \ - src/SearchResultWidget/fullsearchresultwidget.cpp \ - src/SearchResultWidget/searchappthread.cpp \ - src/SearchResultWidget/searchresultwidget.cpp \ - src/SideBarWidget/sidebarwidget.cpp \ - src/Style/style.cpp \ - src/UtilityFunction/classifyscrollarea.cpp \ - src/UtilityFunction/fullitemdelegate.cpp \ - src/UtilityFunction/fulllistview.cpp \ - src/UtilityFunction/functionclassifybutton.cpp \ - src/UtilityFunction/itemdelegate.cpp \ - src/UtilityFunction/letterclassifybutton.cpp \ - src/UtilityFunction/listview.cpp \ - src/UtilityFunction/pushbutton.cpp \ - src/UtilityFunction/scrollarea.cpp \ - src/UtilityFunction/toolbutton.cpp \ - src/Interface/ukuichineseletter.cpp \ - src/Interface/ukuimenuinterface.cpp \ - main.cpp \ - src/UtilityFunction/utility.cpp \ - src/XEventMonitor/xeventmonitor.cpp - -HEADERS += \ - src/CommonUseWidget/commonusewidget.h \ - src/CommonUseWidget/fullcommonusewidget.h \ - src/FunctionWidget/fullfunctionwidget.h \ - src/FunctionWidget/functionbuttonwidget.h \ - src/FunctionWidget/functionwidget.h \ - src/LetterWidget/fullletterwidget.h \ - src/LetterWidget/letterbuttonwidget.h \ - src/LetterWidget/letterwidget.h \ - src/MainViewWidget/directorychangedthread.h \ - src/MainViewWidget/mainviewwidget.h \ - src/MainWindow/mainwindow.h \ - src/RightClickMenu/rightclickmenu.h \ - src/SearchResultWidget/fullsearchresultwidget.h \ - src/SearchResultWidget/searchappthread.h \ - src/SearchResultWidget/searchresultwidget.h \ - src/SideBarWidget/sidebarwidget.h \ - src/Style/style.h \ - src/UtilityFunction/classifyscrollarea.h \ - src/UtilityFunction/fullitemdelegate.h \ - src/UtilityFunction/fulllistview.h \ - src/UtilityFunction/functionclassifybutton.h \ - src/UtilityFunction/itemdelegate.h \ - src/UtilityFunction/letterclassifybutton.h \ - src/UtilityFunction/listview.h \ - src/UtilityFunction/pushbutton.h \ - src/UtilityFunction/scrollarea.h \ - src/UtilityFunction/toolbutton.h \ - src/Interface/ukuichineseletter.h \ - src/Interface/ukuimenuinterface.h \ - src/UtilityFunction/utility.h \ - src/XEventMonitor/xeventmonitor.h - -RESOURCES += \ - res.qrc - -PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xrandr xtst -CONFIG += no_keywords link_pkgconfig - - -desktop_file.files = ukui-menu.desktop -desktop_file.path = /etc/xdg/autostart - -INSTALLS += \ - target desktop_file +SUBDIRS += \ + pad/menu.pro \ + pc/ukui-menu.pro