diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml old mode 100644 new mode 100755 diff --git a/COPYING b/COPYING old mode 100644 new mode 100755 diff --git a/NEWS b/NEWS old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg new file mode 100755 index 0000000..7b506cb --- /dev/null +++ b/data/img/sidebarwidget/default.svg @@ -0,0 +1 @@ +avatar \ No newline at end of file diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg old mode 100644 new mode 100755 diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index 2a97a60..05ffbaa --- a/main.cpp +++ b/main.cpp @@ -29,16 +29,12 @@ #include #include "src/UtilityFunction/utility.h" #include "src/SearchResultWidget/file-utils.h" -#include -#include -#include "src/UtilityFunction/utility.h" #include int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-menu"); - projectCodeName = KDKGetPrjCodeName().c_str(); qRegisterMetaType>("QVector"); #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -55,17 +51,31 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } +// auto Style=new ProxyStyle; +// app.setStyle(Style); QTranslator translator; if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) { app.installTranslator(&translator); } else { - myDebug() << "Load translations file" << QLocale() << "failed!"; + qDebug() << "Load translations file" << QLocale() << "failed!"; } Zeeker::FileUtils::loadHanziTable(":/src/SearchResultWidget/pinyinWithoutTone.txt"); MainWindow w; app.setActivationWindow(&w); +// w.setProperty("useSystemStyleBlur", true); + //测试 +// if(Style::panelPosition==0) +// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::primaryScreenHeight-Style::panelSize-Style::minh-3, +// Style::minw,Style::minh)); +// else if(Style::panelPosition==1) +// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::panelSize+4,Style::minw,Style::minh)); +// else if(Style::panelPosition==2) +// w.setGeometry(QRect(Style::primaryScreenX+Style::panelSize+4,Style::primaryScreenY+4,Style::minw,Style::minh)); +// else +// w.setGeometry(QRect(Style::primaryScreenX+Style::primaryScreenWidth-Style::panelSize-Style::minw-4,Style::primaryScreenY+4, +// Style::minw,Style::minh)); w.show(); w.raise(); w.update(); diff --git a/man/ukui-menu.1 b/man/ukui-menu.1 old mode 100644 new mode 100755 diff --git a/res.qrc b/res.qrc old mode 100644 new mode 100755 index fc6c8ee..c09c00d --- a/res.qrc +++ b/res.qrc @@ -83,5 +83,6 @@ data/img/mainviewwidget/Mobile-Normal.svg src/SearchResultWidget/pinyinWithTone.txt src/SearchResultWidget/pinyinWithoutTone.txt + data/img/sidebarwidget/default.svg diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp old mode 100644 new mode 100755 index c19abb7..3c49d1c --- a/src/CommonUseWidget/commonusewidget.cpp +++ b/src/CommonUseWidget/commonusewidget.cpp @@ -54,7 +54,8 @@ void CommonUseWidget::initUi() void CommonUseWidget::initAppListWidget() { m_listView = new ListView(this, this->width(), this->height() - 6, 0); - m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->setFixedSize(this->width(), this->height() - 6); +//m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); connect(m_listView, &ListView::sendItemClickedSignal, this, &CommonUseWidget::execApplication); connect(m_listView, &ListView::sendUpdateAppListSignal, this, &CommonUseWidget::updateListViewSlot); @@ -69,7 +70,7 @@ void CommonUseWidget::fillAppList() { m_data.clear(); - Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { m_data.append(QStringList() << desktopfp << "1"); } diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h old mode 100644 new mode 100755 diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp old mode 100644 new mode 100755 index 34bb7a1..a3afed2 --- a/src/CommonUseWidget/fullcommonusewidget.cpp +++ b/src/CommonUseWidget/fullcommonusewidget.cpp @@ -43,18 +43,16 @@ void FullCommonUseWidget::initUi() this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - myDebug() << "width" << this->width() << "height" << this->height(); this->setFocusPolicy(Qt::NoFocus); - mainLayout = new QHBoxLayout; + QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); this->setLayout(mainLayout); m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); mainLayout->addItem(m_spaceItem); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; @@ -70,7 +68,16 @@ void FullCommonUseWidget::initUi() void FullCommonUseWidget::initAppListWidget() { m_listView = new FullListView(this, 0); +// m_listView->setFixedSize(this->width()-Style::LeftWidWidth+3,this->height()); +// QHBoxLayout *mainLayout=qobject_cast(this->layout()); +// mainLayout->insertWidget(1,m_listView); m_scrollAreaWidLayout->addWidget(m_listView); + connect(m_scrollArea, &ScrollArea::requestUpdate, m_listView->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + m_listView->repaint(); + }); connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); @@ -100,7 +107,7 @@ void FullCommonUseWidget::fillAppList() { m_data.clear(); - Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { m_data.append(desktopfp); } @@ -119,6 +126,8 @@ void FullCommonUseWidget::execApplication(QString desktopfp) void FullCommonUseWidget::selectFirstItem() { + // this->focusNextChild(); + qDebug() << "void FullCommonUseWidget::selectFirstItem()"; m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); } @@ -164,7 +173,6 @@ void FullCommonUseWidget::repaintWidget() this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/CommonUseWidget/fullcommonusewidget.h old mode 100644 new mode 100755 index 966cb86..1afe6f4 --- a/src/CommonUseWidget/fullcommonusewidget.h +++ b/src/CommonUseWidget/fullcommonusewidget.h @@ -65,16 +65,16 @@ public: */ void moveScrollBar(int type); -private: + FullListView* m_listView=nullptr; +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QStringList m_data; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QSpacerItem *m_spaceItem = nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QHBoxLayout *mainLayout = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; - FullListView *m_listView = nullptr; + QSpacerItem *m_spaceItem=nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; + protected: /** * @brief Initializes UI diff --git a/src/DBus/dbus-adaptor.cpp b/src/DBus/dbus-adaptor.cpp old mode 100644 new mode 100755 index 4fdf0cf..46418e7 --- a/src/DBus/dbus-adaptor.cpp +++ b/src/DBus/dbus-adaptor.cpp @@ -37,26 +37,19 @@ QString MenuAdaptor::GetSecurityConfigPath() { // handle method call org.ukui.menu.GetSecurityConfigPath QString out0; - QMetaObject::invokeMethod(parent(), "getSecurityConfigPath", Q_RETURN_ARG(QString, out0)); + QMetaObject::invokeMethod(parent(), "GetSecurityConfigPath", Q_RETURN_ARG(QString, out0)); return out0; } void MenuAdaptor::ReloadSecurityConfig() { // handle method call org.ukui.menu.ReloadSecurityConfig - QMetaObject::invokeMethod(parent(), "reloadSecurityConfig"); + QMetaObject::invokeMethod(parent(), "ReloadSecurityConfig"); } void MenuAdaptor::WinKeyResponse() { // handle method call org.ukui.menu.WinKeyResponse - QMetaObject::invokeMethod(parent(), "winKeyResponse"); -} - -QStringList MenuAdaptor::GetPkgNameWhiteList() -{ - QStringList pkgList; - QMetaObject::invokeMethod(parent(), "getPkgNameWhiteList", Q_RETURN_ARG(QStringList, pkgList)); - return pkgList; + QMetaObject::invokeMethod(parent(), "WinKeyResponse"); } diff --git a/src/DBus/dbus-adaptor.h b/src/DBus/dbus-adaptor.h old mode 100644 new mode 100755 index f1800fc..0d51f6d --- a/src/DBus/dbus-adaptor.h +++ b/src/DBus/dbus-adaptor.h @@ -32,17 +32,14 @@ class MenuAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") Q_CLASSINFO("D-Bus Introspection", "" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "") +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") public: MenuAdaptor(QObject *parent); virtual ~MenuAdaptor(); @@ -52,7 +49,6 @@ public Q_SLOTS: // METHODS QString GetSecurityConfigPath(); void ReloadSecurityConfig(); void WinKeyResponse(); - QStringList GetPkgNameWhiteList(); Q_SIGNALS: // SIGNALS }; diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp old mode 100644 new mode 100755 index 6dc9888..7196fc0 --- a/src/DBus/dbus.cpp +++ b/src/DBus/dbus.cpp @@ -18,29 +18,24 @@ #include "dbus.h" #include #include -#include "src/RightClickMenu/uninstallwhitelist.h" DBus::DBus(QObject *parent) : QObject(parent) { + } -void DBus::reloadSecurityConfig() +void DBus::ReloadSecurityConfig() { Q_EMIT sendReloadSignal(); } -QString DBus::getSecurityConfigPath() +QString DBus::GetSecurityConfigPath() { - QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + QString path=QDir::homePath()+"/.config/ukui-menu-security-config.json"; return path; } -void DBus::winKeyResponse() +void DBus::WinKeyResponse() { Q_EMIT winKeyResponseSignal(); } - -QStringList DBus::getPkgNameWhiteList() -{ - return UninstallWhitelist::getInstance()->getPkgNameWhiteList(); -} diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h old mode 100644 new mode 100755 index 3db1556..4a70f04 --- a/src/DBus/dbus.h +++ b/src/DBus/dbus.h @@ -23,7 +23,7 @@ class DBus : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") + Q_CLASSINFO("D-Bus Interface","org.ukui.menu") public: explicit DBus(QObject *parent = 0); @@ -32,10 +32,9 @@ Q_SIGNALS: void winKeyResponseSignal(); public Q_SLOTS: - QString getSecurityConfigPath(); - void reloadSecurityConfig(); - void winKeyResponse(); - QStringList getPkgNameWhiteList(); + QString GetSecurityConfigPath(); + void ReloadSecurityConfig(); + void WinKeyResponse(); }; #endif // DBUS_H diff --git a/src/DBus/org.ukui.menu.xml b/src/DBus/org.ukui.menu.xml old mode 100644 new mode 100755 diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp old mode 100644 new mode 100755 index 3b84dd4..9d564a5 --- a/src/FunctionWidget/fullfunctionwidget.cpp +++ b/src/FunctionWidget/fullfunctionwidget.cpp @@ -58,13 +58,13 @@ void FullFunctionWidget::initUi() m_ukuiMenuInterface = new UkuiMenuInterface; initAppListWidget(); initIconListWidget(); - m_flag = true; + flag = true; //翻页灵敏度时间调节 - m_time = new QTimer(this); - connect(m_time, &QTimer::timeout, [ = ]() { - if (m_flag == false) { - m_flag = true; - m_time->stop(); + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); } }); } @@ -74,14 +74,13 @@ void FullFunctionWidget::initUi() */ void FullFunctionWidget::initAppListWidget() { - layout = new QHBoxLayout(m_applistWid); + QHBoxLayout *layout = new QHBoxLayout(m_applistWid); layout->setContentsMargins(0, 0, 0, 0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; @@ -92,25 +91,94 @@ void FullFunctionWidget::initAppListWidget() connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullFunctionWidget::valueChangedSlot); m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - fillSoftwareAppList(); + fillAppList(); } /** * 填充应用列表 */ -void FullFunctionWidget::fillSoftwareAppList() +void FullFunctionWidget::fillAppList() { m_classificationList.clear(); - QVector vector = UkuiMenuInterface::m_functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList androidlist = vector.at(0); - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - insertClassificationBtn(functionList.at(i)); - insertAppList(vector.at(i)); - } + 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); + } + + m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); resizeScrollAreaControls(); } @@ -124,6 +192,13 @@ void FullFunctionWidget::insertClassificationBtn(QString category) void FullFunctionWidget::insertAppList(QStringList desktopfplist) { FullListView *listview = new FullListView(this, 2); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + listview->repaint(listview->rect()); + }); connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); @@ -165,7 +240,7 @@ void FullFunctionWidget::updateAppListView() delete child; } - fillSoftwareAppList(); + fillAppList(); //刷新图标列表界面 Q_FOREACH (QAbstractButton *button, m_buttonList) { @@ -209,7 +284,7 @@ void FullFunctionWidget::resizeScrollAreaControls() rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height() * rowcount); + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); row++; } @@ -222,7 +297,9 @@ void FullFunctionWidget::resizeScrollAreaControls() void FullFunctionWidget::initIconListWidget() { m_iconListScrollArea = new ClassifyBtnScrollArea(m_iconListWid); - m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_iconListScrollArea); +// m_iconListScrollArea->resize(Style::LeftBtnWidth, +// m_iconListWid->height()); + m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid; m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); m_iconListScrollAreaWidLayout = new QVBoxLayout; @@ -255,7 +332,7 @@ void FullFunctionWidget::initIconListScrollArea() Style::LeftIconSize, m_classificationList.at(i), true, - true, this); + true); iconbtn->setChecked(false); m_buttonList.append(iconbtn); m_iconListScrollAreaWidLayout->addWidget(iconbtn); @@ -390,7 +467,6 @@ void FullFunctionWidget::repaintWidget() Style::AppListWidHeight); m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); @@ -419,8 +495,14 @@ void FullFunctionWidget::moveScrollBar(int type) void FullFunctionWidget::onSetSlider(int value) { +// if(flag) +// { +// flag = false; +// time->start(100); int curvalue = m_scrollArea->verticalScrollBar()->value(); m_scrollArea->verticalScrollBar()->setValue(curvalue + value); +// qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; +// } } bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) @@ -438,6 +520,34 @@ bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) Q_EMIT setFocusToSideWin(); } +// if(ke->key() == Qt::Key_Up) +// { +// QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); +// QWidget* widTop = widItemTop->widget(); +// FullListView* m_listviewTop = qobject_cast(widTop); +// if(!m_listviewTop->hasFocus()) +// { +// QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); +// btnGroupClickedSlot(buttonTop); +// this->m_scrollArea->setFocusToPreChild(); +// return true; +// } +// } +// if(ke->key() == Qt::Key_Down) +// { +// QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); +// QWidget* wid = widItem->widget(); +// FullListView* m_listview = qobject_cast(wid); + +// if(!m_listview->hasFocus()) +// { +// QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); +// btnGroupClickedSlot(button); +// this->m_scrollArea->setFocusToNextChild(); +// return true; +// } +// } + if (ke->key() == Qt::Key_Up) { if (!m_listviewTop->hasFocus()) { QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/FunctionWidget/fullfunctionwidget.h old mode 100644 new mode 100755 index 9b44f87..81551b7 --- a/src/FunctionWidget/fullfunctionwidget.h +++ b/src/FunctionWidget/fullfunctionwidget.h @@ -48,7 +48,7 @@ class FullFunctionWidget : public QWidget Q_OBJECT public: - explicit FullFunctionWidget(QWidget *parent = nullptr); + explicit FullFunctionWidget(QWidget *parent=nullptr); ~FullFunctionWidget(); /** * @brief Initializes the interface state @@ -76,36 +76,35 @@ public: void functionButtonClick(); - QAbstractButton *getCurLetterButton(int value); + QAbstractButton* getCurLetterButton(int value); private: /*Application list interface*/ - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *m_applistWid = nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + QWidget* m_applistWid=nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; QStringList m_classificationList;//Store the list of category buttons QStringList m_data; - QTimer *m_time = nullptr; - bool m_flag; + QTimer *time = nullptr; + bool flag; /*Function classification list interface*/ - QWidget *m_iconListWid = nullptr; - ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; - ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; - QVBoxLayout *m_iconListScrollAreaWidLayout = nullptr; - QHBoxLayout *layout = nullptr; - QList m_buttonList; - QButtonGroup *m_btnGroup = nullptr; - QSpacerItem *m_topSpacerItem = nullptr; - QSpacerItem *m_bottomSpacerItem = nullptr; - QSpacerItem *m_appListBottomSpacer = nullptr; + QWidget* m_iconListWid=nullptr; + ClassifyBtnScrollArea* m_iconListScrollArea=nullptr; + ClassifyBtnScrollAreaWid* m_iconListScrollAreaWid=nullptr; + QVBoxLayout* m_iconListScrollAreaWidLayout=nullptr; + QList m_buttonList; + QButtonGroup* m_btnGroup=nullptr; + QSpacerItem* m_topSpacerItem=nullptr; + QSpacerItem* m_bottomSpacerItem=nullptr; + QSpacerItem* m_appListBottomSpacer=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 + 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 int m_index = 0; protected: @@ -125,7 +124,7 @@ protected: /** * @brief fill application list */ - void fillSoftwareAppList(); + void fillAppList(); /** * @brief Insert category button * @param category: Functional classification name diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp old mode 100644 new mode 100755 index 6b36844..0cde546 --- a/src/FunctionWidget/functionbuttonwidget.cpp +++ b/src/FunctionWidget/functionbuttonwidget.cpp @@ -25,18 +25,18 @@ FunctionButtonWidget::FunctionButtonWidget(QWidget *parent) : QWidget(parent) { - m_categoryList.clear(); - m_categoryList.append(QObject::tr("Office")); - m_categoryList.append(QObject::tr("Development")); - m_categoryList.append(QObject::tr("Image")); - m_categoryList.append(QObject::tr("Video")); - m_categoryList.append(QObject::tr("Internet")); - m_categoryList.append(QObject::tr("Game")); - m_categoryList.append(QObject::tr("Education")); - m_categoryList.append(QObject::tr("Social")); - m_categoryList.append(QObject::tr("System")); - m_categoryList.append(QObject::tr("Safe")); - m_categoryList.append(QObject::tr("Others")); + 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(); } @@ -47,37 +47,36 @@ FunctionButtonWidget::~FunctionButtonWidget() void FunctionButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->resize(Style::LeftBtnWidth * 2 + 5, Style::LeftBtnHeight * 6 + 25); - QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(0, 0, 0, 0); + this->setAttribute(Qt::WA_StyledBackground,true); + 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, this); - gridLayout->addWidget(iconbtn, row, col); + 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); m_buttonList.append(iconbtn); - connect(iconbtn, &FunctionClassifyButton::buttonClicked, this, &FunctionButtonWidget::functionBtnClickedSlot); - - if (row * 2 + col == 10) { - break; - } + connect(iconbtn,&FunctionClassifyButton::buttonClicked,this, &FunctionButtonWidget::functionBtnClickedSlot); + if(row*2+col==10)break; } - } - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - connect(&gsetting, &QGSettings::changed, this, [ = ] { - Q_FOREACH (QAbstractButton *btn, m_buttonList) - { - FunctionClassifyButton *fbtn = qobject_cast(btn); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + FunctionClassifyButton *fbtn=qobject_cast(btn); fbtn->updateIconState(); } }); @@ -89,9 +88,9 @@ void FunctionButtonWidget::initUi() */ void FunctionButtonWidget::functionBtnClickedSlot() { - FunctionClassifyButton *btn = dynamic_cast(sender()); - QWidget *wid = btn->layout()->itemAt(0)->widget(); - QLabel *label = qobject_cast(wid); + FunctionClassifyButton* btn=dynamic_cast(sender()); + QWidget* wid=btn->layout()->itemAt(1)->widget(); + QLabel* label=qobject_cast(wid); Q_EMIT sendFunctionBtnSignal(label->text()); } @@ -100,25 +99,19 @@ void FunctionButtonWidget::functionBtnClickedSlot() */ 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::m_functionalVector.at(row * 2 + col).isEmpty()) { - btn->m_enabled = false; - } else { - btn->m_enabled = true; - } - + 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; - } + if(row*2+col==10)break; } - } } diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/FunctionWidget/functionbuttonwidget.h old mode 100644 new mode 100755 index 581fa62..e2cc5d1 --- a/src/FunctionWidget/functionbuttonwidget.h +++ b/src/FunctionWidget/functionbuttonwidget.h @@ -28,7 +28,6 @@ #include #include "src/UtilityFunction/functionclassifybutton.h" #include "src/Interface/ukuimenuinterface.h" -#include class FunctionButtonWidget : public QWidget { diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp old mode 100644 new mode 100755 index d30fee1..a70ec66 --- a/src/FunctionWidget/functionwidget.cpp +++ b/src/FunctionWidget/functionwidget.cpp @@ -49,9 +49,9 @@ void FunctionWidget::initUi() m_functionBtnWid->hide(); connect(this, &FunctionWidget::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &FunctionWidget::recvFunctionBtnSignal); - m_enterAnimation = new QPropertyAnimation(this); + m_enterAnimation = new QPropertyAnimation; m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation = new QPropertyAnimation(this); + 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); @@ -65,30 +65,98 @@ void FunctionWidget::initAppListWidget() m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 2); m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); m_appListView->show(); - fillSoftwareAppListView(m_addDate); + fillAppListView(0); connect(m_appListView, &ListView::sendItemClickedSignal, this, &FunctionWidget::recvItemClickedSlot); connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &FunctionWidget::sendHideMainWindowSignal); connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &FunctionWidget::sendMainWinActiveSignal); } + /** * 填充应用列表 */ -void FunctionWidget::fillSoftwareAppListView(int type) +void FunctionWidget::fillAppListView(int type) { - m_row = 0; + row = 0; m_data.clear(); m_classificationList.clear(); m_classificationBtnRowList.clear(); - QVector vector = UkuiMenuInterface::m_functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList androidlist = vector.at(0); - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - QString functionName = functionList.at(i); - insertClassificationBtn(functionName); - insertAppList(vector.at(i)); - } + 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) { @@ -102,12 +170,12 @@ void FunctionWidget::insertClassificationBtn(QString btnname) { m_classificationList.append(btnname); m_data.append(QStringList() << btnname << "0"); - m_classificationBtnRowList.append(QString::number(m_row)); + m_classificationBtnRowList.append(QString::number(row)); } void FunctionWidget::insertAppList(QStringList appnamelist) { - m_row += (appnamelist.count() + 1); + row += (appnamelist.count() + 1); for (int i = 0; i < appnamelist.count(); i++) { m_data.append(QStringList() << appnamelist.at(i) << "1"); @@ -137,7 +205,7 @@ void FunctionWidget::execApplication(QString desktopfp) */ void FunctionWidget::updateAppListView() { - fillSoftwareAppListView(m_updateDate); + fillAppListView(1); } /** diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h old mode 100644 new mode 100755 index 5eec927..beffaa3 --- a/src/FunctionWidget/functionwidget.h +++ b/src/FunctionWidget/functionwidget.h @@ -62,9 +62,7 @@ private: 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 m_row=0; - int m_addDate = 0; - int m_updateDate = 1; + int row=0; /*Interface switching animation*/ QPropertyAnimation* m_enterAnimation=nullptr; QPropertyAnimation* m_leaveAnimation=nullptr; @@ -82,9 +80,9 @@ protected: /** * @brief fill application list */ - void fillSoftwareAppListView(int type); + void fillAppListView(int type); /** - * @brief Insert the software center category button + * @brief Insert category button * @param category: Functional classification name */ void insertClassificationBtn(QString btnname); diff --git a/src/Interface/ukuichineseletter.cpp b/src/Interface/ukuichineseletter.cpp old mode 100644 new mode 100755 diff --git a/src/Interface/ukuichineseletter.h b/src/Interface/ukuichineseletter.h old mode 100644 new mode 100755 diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp old mode 100644 new mode 100755 index 3350aaa..884ddd0 --- a/src/Interface/ukuimenuinterface.cpp +++ b/src/Interface/ukuimenuinterface.cpp @@ -32,33 +32,17 @@ UkuiMenuInterface::UkuiMenuInterface() { } -QVector UkuiMenuInterface::m_appInfoVector = QVector(); -QVector UkuiMenuInterface::m_desktopfpVector = QVector(); -QVector UkuiMenuInterface::m_alphabeticVector = QVector(); -QVector UkuiMenuInterface::m_functionalVector = QVector(); -QVector UkuiMenuInterface::m_allAppVector = QVector(); -QStringList UkuiMenuInterface::m_androidDesktopfnList = QStringList(); +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() { } -QStringList UkuiMenuInterface::getFunctionClassName() -{ - QStringList functionList; - functionList.append(QObject::tr("Office")); - functionList.append(QObject::tr("Development")); - functionList.append(QObject::tr("Image")); - functionList.append(QObject::tr("Video")); - functionList.append(QObject::tr("Internet")); - functionList.append(QObject::tr("Game")); - functionList.append(QObject::tr("Education")); - functionList.append(QObject::tr("Social")); - functionList.append(QObject::tr("System")); - functionList.append(QObject::tr("Safe")); - functionList.append(QObject::tr("Others")); - return functionList; -} //文件递归查询 void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) { @@ -104,63 +88,63 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) continue; } - m_keyfile = g_key_file_new(); + keyfile = g_key_file_new(); - if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { + if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) { return; } - char *ret_0 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + char *ret_0 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); if (ret_0 != nullptr) { QString str = QString::fromLocal8Bit(ret_0); if (str.contains("Android")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); if (ret_1 != nullptr) { QString str = QString::fromLocal8Bit(ret_1); if (str.contains("true")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); if (ret_2 != nullptr) { QString str = QString::fromLocal8Bit(ret_2); if (str.contains("UKUI")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); if (ret != nullptr) { QString str = QString::fromLocal8Bit(ret); if (str.contains("LXQt") || str.contains("KDE")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - g_key_file_free(m_keyfile); - m_filePathList.append(filePathStr); + g_key_file_free(keyfile); + filePathList.append(filePathStr); } i++; @@ -170,7 +154,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) //获取系统desktop文件路径 QStringList UkuiMenuInterface::getDesktopFilePath() { - m_filePathList.clear(); + filePathList.clear(); QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; QFile file(jsonPath); @@ -189,11 +173,11 @@ QStringList UkuiMenuInterface::getDesktopFilePath() for (int index = 0; index < enArray.size(); index++) { QJsonObject obj = enArray.at(index).toObject(); - m_filePathList.append(obj.value("path").toString()); + filePathList.append(obj.value("path").toString()); // qDebug()< UkuiMenuInterface::createSoftwareAppInfoVector() +//创建应用信息容器 +QVector UkuiMenuInterface::createAppInfoVector() { - m_desktopfpVector.clear(); + desktopfpVector.clear(); QVector appInfoVector; QVector vector; - vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公 - vector.append(QStringList() << "develop" << "Development"); //1开发 - vector.append(QStringList() << "graphic" << "Graphics"); //2图像 - vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音 - vector.append(QStringList() << "network" << "Network"); //4网络 - vector.append(QStringList() << "game" << "Game"); //5游戏 - vector.append(QStringList() << "education" << "Education"); //6教育 - vector.append(QStringList() << "social" << "Messaging"); //7社交 - vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统 - vector.append(QStringList() << "safe"); //9安全 - vector.append(QStringList() << "others"); //10其他 + 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(); - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); for (int i = 0; i < desktopfpList.count(); i++) { QStringList appInfoList; @@ -310,37 +291,19 @@ QVector UkuiMenuInterface::createSoftwareAppInfoVector() QString englishName = getAppEnglishName(desktopfpList.at(i)); QString letter = getAppNameInitial(desktopfpList.at(i)); QString letters = getAppNameInitials(desktopfpList.at(i)); - m_desktopfpVector.append(desktopfp); + desktopfpVector.append(desktopfp); appInfoList << desktopfp << name << englishName << letter << letters; - QString desktopfpExecName = getAppExec(desktopfpList.at(i)); - desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1); - desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" ")); - sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); + bool is_owned = false; - if (sql.next()) { - myDebug() << "数据库执行成功"; - - for (int j = 0; j < vector.size(); j++) { - if (vector.at(j).contains(sql.value(0).toString())) { - appInfoList.append(QString::number(j)); - } + for (int j = 0; j < vector.size(); j++) { + if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类 + is_owned = true; + appInfoList.append(QString::number(j)); } - } else { - myDebug() << "数据库执行失败"; - bool is_owned = false; + } - for (int j = 0; j < vector.size(); j++) { - //有对应分类 - if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { - is_owned = true; - appInfoList.append(QString::number(j)); - break; - } - } - - if (!is_owned) { //该应用无对应分类 - appInfoList.append(QString::number(10)); - } + if (!is_owned) { //该应用无对应分类 + appInfoList.append(QString::number(10)); } appInfoVector.append(appInfoList); @@ -375,7 +338,6 @@ QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) char *filepath = fpbyte.data(); g_key_file_load_from_file(keyfile, filepath, flags, error); char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - g_key_file_free(keyfile); QString namestr = QString::fromLocal8Bit(name); return namestr; } @@ -470,27 +432,6 @@ bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) } } -bool UkuiMenuInterface::cmpfixedApp(QStringList &arg_1, QStringList &arg_2) -{ - QLocale local; - QString language = local.languageToString(local.language()); - - if (QString::compare(language, "Chinese") == 0) { - local = QLocale(QLocale::Chinese); - } else { - local = QLocale(QLocale::English); - } - - QCollator collator(local); - - //数组中分别存放desktop、中文名称、英文名称、首字母、全拼 首字母,按首字母排列,对下标3进行比较 - if (collator.compare(arg_1.at(3), arg_2.at(3)) < 0) { - return true; - } else { - return false; - } -} - QVector UkuiMenuInterface::getAllClassification() { QVector allAppVector; @@ -502,9 +443,9 @@ QVector UkuiMenuInterface::getAllClassification() commonVector = getCommonUseApp(); int index = 0; - Q_FOREACH (QString desktopfp, m_desktopfpVector) { + Q_FOREACH (QString desktopfp, desktopfpVector) { if (!commonVector.contains(desktopfp)) { - appVector.append(m_appInfoVector.at(index)); + appVector.append(appInfoVector.at(index)); } index++; @@ -525,46 +466,93 @@ QVector UkuiMenuInterface::getAllClassification() QVector UkuiMenuInterface::getCommonUseApp() { +// QDateTime dt=QDateTime::currentDateTime(); +// int currentDateTime=dt.toTime_t(); +// int nDaySec=24*60*60; +// setting->beginGroup("datetime"); +// QStringList dateTimeKeys=setting->allKeys(); +// QStringList timeOutKeys; +// timeOutKeys.clear(); +// for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4) +// { +// timeOutKeys.append(dateTimeKeys.at(i)); +// } +// } +// setting->endGroup(); +// for(int i=0;ibeginGroup("application"); +// setting->remove(timeOutKeys.at(i)); +// setting->sync(); +// setting->endGroup(); +// setting->beginGroup("datetime"); +// setting->remove(timeOutKeys.at(i)); +// setting->sync(); +// setting->endGroup(); +// } +// setting->beginGroup("lockapplication"); +// QStringList lockdesktopfnList=setting->allKeys(); +// for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt(); +// int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt(); +// if(value_1 > value_2) +// { +// QString tmp=lockdesktopfnList.at(j); +// lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); +// lockdesktopfnList.replace(j+1,tmp); +// } +// } +// setting->endGroup(); +// setting->beginGroup("application"); +// QStringList desktopfnList=setting->allKeys(); +// for(int i=0;ivalue(desktopfnList.at(j)).toInt(); +// int value_2=setting->value(desktopfnList.at(j+1)).toInt(); +// if(value_1 < value_2) +// { +// QString tmp=desktopfnList.at(j); +// desktopfnList.replace(j,desktopfnList.at(j+1)); +// desktopfnList.replace(j+1,tmp); +// } +// } +// setting->endGroup(); +// QVector data; +// Q_FOREACH(QString desktopfn,lockdesktopfnList) +// { +// QString desktopfp; +// if(androidDesktopfnList.contains(desktopfn)) +// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); +// else +// desktopfp=QString("/usr/share/applications/"+desktopfn); +// QFileInfo fileInfo(desktopfp); +// if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp)) +// continue; +// data.append(desktopfp); +// } +// Q_FOREACH(QString desktopfn,desktopfnList) +// { +// QString desktopfp; +// if(androidDesktopfnList.contains(desktopfn)) +// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); +// else +// desktopfp=QString("/usr/share/applications/"+desktopfn); +// QFileInfo fileInfo(desktopfp); +// if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) +// continue; +// data.append(desktopfp); +// } QVector data; - QStringList lockAppListSort; - QStringList lockAppListFp; - QVector lockAppVector; - int index = 0; Q_FOREACH (QString desktopfn, getLockAppList()) { QString desktopfp; - if (m_androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - lockAppListFp.append(desktopfp); - } - - Q_FOREACH (QString desktopfp, m_desktopfpVector) { - if (lockAppListFp.contains(desktopfp)) { - lockAppVector.append(m_appInfoVector.at(index)); - } - - index++; - } - - qSort(lockAppVector.begin(), lockAppVector.end(), cmpfixedApp); - - for (int index = 0; index < lockAppVector.size(); index++) { - lockAppListSort.append(lockAppVector.at(index).at(0)); - } - - Q_FOREACH (QString desktopfp, lockAppListSort) { - data.append(desktopfp); - } - - Q_FOREACH (QString desktopfn, getUnlockAllList()) { - QString desktopfp; - - if (m_androidDesktopfnList.contains(desktopfn)) { + if (androidDesktopfnList.contains(desktopfn)) { desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); } else { desktopfp = QString("/usr/share/applications/" + desktopfn); @@ -572,7 +560,25 @@ QVector UkuiMenuInterface::getCommonUseApp() QFileInfo fileInfo(desktopfp); - if (!fileInfo.isFile() || !m_desktopfpVector.contains(desktopfp)) { + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + Q_FOREACH (QString desktopfn, getUnlockAllList()) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { continue; } @@ -590,8 +596,8 @@ QVector UkuiMenuInterface::getAlphabeticClassification() QVector appVector[27]; int index = 0; - while (index < m_appInfoVector.size()) { - QString appname = m_appInfoVector.at(index).at(1); + while (index < appInfoVector.size()) { + QString appname = appInfoVector.at(index).at(1); QString appnamepy = UkuiChineseLetter::getPinyins(appname); if (!appnamepy.isEmpty()) { @@ -599,111 +605,111 @@ QVector UkuiMenuInterface::getAlphabeticClassification() switch (c) { case 'A': - appVector[0].append(m_appInfoVector.at(index)); + appVector[0].append(appInfoVector.at(index)); break; case 'B': - appVector[1].append(m_appInfoVector.at(index)); + appVector[1].append(appInfoVector.at(index)); break; case 'C': - appVector[2].append(m_appInfoVector.at(index)); + appVector[2].append(appInfoVector.at(index)); break; case 'D': - appVector[3].append(m_appInfoVector.at(index)); + appVector[3].append(appInfoVector.at(index)); break; case 'E': - appVector[4].append(m_appInfoVector.at(index)); + appVector[4].append(appInfoVector.at(index)); break; case 'F': - appVector[5].append(m_appInfoVector.at(index)); + appVector[5].append(appInfoVector.at(index)); break; case 'G': - appVector[6].append(m_appInfoVector.at(index)); + appVector[6].append(appInfoVector.at(index)); break; case 'H': - appVector[7].append(m_appInfoVector.at(index)); + appVector[7].append(appInfoVector.at(index)); break; case 'I': - appVector[8].append(m_appInfoVector.at(index)); + appVector[8].append(appInfoVector.at(index)); break; case 'J': - appVector[9].append(m_appInfoVector.at(index)); + appVector[9].append(appInfoVector.at(index)); break; case 'K': - appVector[10].append(m_appInfoVector.at(index)); + appVector[10].append(appInfoVector.at(index)); break; case 'L': - appVector[11].append(m_appInfoVector.at(index)); + appVector[11].append(appInfoVector.at(index)); break; case 'M': - appVector[12].append(m_appInfoVector.at(index)); + appVector[12].append(appInfoVector.at(index)); break; case 'N': - appVector[13].append(m_appInfoVector.at(index)); + appVector[13].append(appInfoVector.at(index)); break; case 'O': - appVector[14].append(m_appInfoVector.at(index)); + appVector[14].append(appInfoVector.at(index)); break; case 'P': - appVector[15].append(m_appInfoVector.at(index)); + appVector[15].append(appInfoVector.at(index)); break; case 'Q': - appVector[16].append(m_appInfoVector.at(index)); + appVector[16].append(appInfoVector.at(index)); break; case 'R': - appVector[17].append(m_appInfoVector.at(index)); + appVector[17].append(appInfoVector.at(index)); break; case 'S': - appVector[18].append(m_appInfoVector.at(index)); + appVector[18].append(appInfoVector.at(index)); break; case 'T': - appVector[19].append(m_appInfoVector.at(index)); + appVector[19].append(appInfoVector.at(index)); break; case 'U': - appVector[20].append(m_appInfoVector.at(index)); + appVector[20].append(appInfoVector.at(index)); break; case 'V': - appVector[21].append(m_appInfoVector.at(index)); + appVector[21].append(appInfoVector.at(index)); break; case 'W': - appVector[22].append(m_appInfoVector.at(index)); + appVector[22].append(appInfoVector.at(index)); break; case 'X': - appVector[23].append(m_appInfoVector.at(index)); + appVector[23].append(appInfoVector.at(index)); break; case 'Y': - appVector[24].append(m_appInfoVector.at(index)); + appVector[24].append(appInfoVector.at(index)); break; case 'Z': - appVector[25].append(m_appInfoVector.at(index)); + appVector[25].append(appInfoVector.at(index)); break; default: - appVector[26].append(m_appInfoVector.at(index)); + appVector[26].append(appInfoVector.at(index)); break; } } @@ -763,55 +769,55 @@ QVector UkuiMenuInterface::getFunctionalClassification() QVector appVector[11]; int index = 0; - while (index < m_appInfoVector.size()) { - int count = m_appInfoVector.at(index).size() - 5; + while (index < appInfoVector.size()) { + int count = appInfoVector.at(index).size() - 5; for (int i = 0; i < count; i++) { - int category = m_appInfoVector.at(index).at(5 + i).toInt(); + int category = appInfoVector.at(index).at(5 + i).toInt(); switch (category) { case 0: - appVector[0].append(m_appInfoVector.at(index)); + appVector[0].append(appInfoVector.at(index)); break; case 1: - appVector[1].append(m_appInfoVector.at(index)); + appVector[1].append(appInfoVector.at(index)); break; case 2: - appVector[2].append(m_appInfoVector.at(index)); + appVector[2].append(appInfoVector.at(index)); break; case 3: - appVector[3].append(m_appInfoVector.at(index)); + appVector[3].append(appInfoVector.at(index)); break; case 4: - appVector[4].append(m_appInfoVector.at(index)); + appVector[4].append(appInfoVector.at(index)); break; case 5: - appVector[5].append(m_appInfoVector.at(index)); + appVector[5].append(appInfoVector.at(index)); break; case 6: - appVector[6].append(m_appInfoVector.at(index)); + appVector[6].append(appInfoVector.at(index)); break; case 7: - appVector[7].append(m_appInfoVector.at(index)); + appVector[7].append(appInfoVector.at(index)); break; case 8: - appVector[8].append(m_appInfoVector.at(index)); + appVector[8].append(appInfoVector.at(index)); break; case 9: - appVector[9].append(m_appInfoVector.at(index)); + appVector[9].append(appInfoVector.at(index)); break; case 10: - appVector[10].append(m_appInfoVector.at(index)); + appVector[10].append(appInfoVector.at(index)); break; default: @@ -860,7 +866,7 @@ bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList cat void UkuiMenuInterface::getAndroidApp() { - m_androidDesktopfnList.clear(); + androidDesktopfnList.clear(); QVector androidVector; androidVector.clear(); QString path = QDir::homePath() + "/.local/share/applications/"; @@ -901,57 +907,22 @@ void UkuiMenuInterface::getAndroidApp() QByteArray fpbyte = filePathStr.toLocal8Bit(); char *filepath = fpbyte.data(); - - if (0 != access(filepath, R_OK)) { //判断文件是否可读 - i++; - continue; - } - - m_keyfile = g_key_file_new(); - - if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { - return; - } - - char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); - - if (ret_1 != nullptr) { - QString str = QString::fromLocal8Bit(ret_1); - - if (str.contains("true")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); - - if (ret_2 != nullptr) { - QString str = QString::fromLocal8Bit(ret_2); - - if (str.contains("UKUI")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); - - if (ret != nullptr) { - QString str = QString::fromLocal8Bit(ret); - - if (str.contains("LXQt") || str.contains("KDE")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - m_filePathList.append(filePathStr); - m_androidDesktopfnList.append(fileInfo.fileName()); + 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()); diff --git a/src/Interface/ukuimenuinterface.h b/src/Interface/ukuimenuinterface.h old mode 100644 new mode 100755 index 521786a..c241c27 --- a/src/Interface/ukuimenuinterface.h +++ b/src/Interface/ukuimenuinterface.h @@ -31,26 +31,26 @@ class UkuiMenuInterface { private: - QStringList m_filePathList; + QStringList filePathList; - GError **m_error = nullptr; - GKeyFileFlags m_flags = G_KEY_FILE_NONE; - GKeyFile *m_keyfile = nullptr; + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=nullptr; protected: - void recursiveSearchFile(const QString &_filePath);//遍历/usr/share/applications/文件夹 + void recursiveSearchFile(const QString& _filePath);//遍历/usr/share/applications/文件夹 QStringList getSpecifiedCategoryAppList(QString categorystr);//获取指定类型应用列表 public: UkuiMenuInterface(); ~UkuiMenuInterface(); - QVector createSoftwareAppInfoVector();//创建软件商店应用信息容器 - static QVector m_appInfoVector; - static QVector m_desktopfpVector; - static QVector m_alphabeticVector; - static QVector m_functionalVector; - static QVector m_allAppVector; - static QStringList m_androidDesktopfnList; + QVector createAppInfoVector();//创建应用信息容器 + static QVector appInfoVector; + static QVector desktopfpVector; + static QVector alphabeticVector; + static QVector functionalVector; + static QVector allAppVector; + static QStringList androidDesktopfnList; /** * 获取系统应用名称 @@ -65,16 +65,14 @@ public: QString getAppType(QString desktopfp);//获取应用类型 QString getAppComment(QString desktopfp);//获取应用注释 QStringList getDesktopFilePath();//获取系统deskyop文件路径 - QStringList getFunctionClassName();//获取功能类别名称 QVector getAlphabeticClassification();//字母分类模块 QVector getFunctionalClassification();//功能分类模块 QVector getCommonUseApp();//获取常用App QVector getAllClassification();//所有软件模块 void getAndroidApp();//获取安卓应用 - static bool cmpApp(QStringList &arg_1, QStringList &arg_2); - static bool cmpfixedApp(QStringList &arg_1, QStringList &arg_2); - bool matchingAppCategories(QString desktopfp, QStringList categorylist); //匹配应用Categories + 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);//获取应用名拼音 diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp old mode 100644 new mode 100755 index 4f4d021..d0aa93a --- a/src/LetterWidget/fullletterwidget.cpp +++ b/src/LetterWidget/fullletterwidget.cpp @@ -76,11 +76,10 @@ void FullLetterWidget::initAppListWidget() QHBoxLayout *layout = new QHBoxLayout(m_applistWid); layout->setContentsMargins(0, 0, 0, 0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); @@ -106,7 +105,7 @@ void FullLetterWidget::setFocusToThis() void FullLetterWidget::fillAppList() { m_letterList.clear(); - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); @@ -131,6 +130,13 @@ void FullLetterWidget::fillAppList() connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider); connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + listview->repaint(listview->rect()); + }); m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); @@ -231,7 +237,7 @@ void FullLetterWidget::resizeScrollAreaControls() void FullLetterWidget::initLetterListWidget() { m_letterListScrollArea = new ClassifyBtnScrollArea(m_letterListWid); - m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_letterListScrollArea); + m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid; m_letterListScrollAreaWidLayout = new QVBoxLayout; m_letterListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); m_letterListScrollAreaWidLayout->setSpacing(0); @@ -241,7 +247,7 @@ void FullLetterWidget::initLetterListWidget() 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", this); + 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); @@ -411,7 +417,6 @@ void FullLetterWidget::repaintWidget() Style::AppListWidHeight); m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); updateAppListView(); } diff --git a/src/LetterWidget/fullletterwidget.h b/src/LetterWidget/fullletterwidget.h old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterbuttonwidget.cpp b/src/LetterWidget/letterbuttonwidget.cpp old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterbuttonwidget.h b/src/LetterWidget/letterbuttonwidget.h old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp old mode 100644 new mode 100755 index e5b1767..f029f1f --- a/src/LetterWidget/letterwidget.cpp +++ b/src/LetterWidget/letterwidget.cpp @@ -89,7 +89,7 @@ void LetterWidget::fillAppListView() { m_data.clear(); int row = 0; - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); @@ -147,7 +147,7 @@ void LetterWidget::updateAppListView() m_data.clear(); m_letterList.clear(); m_letterBtnRowList.clear(); - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h old mode 100644 new mode 100755 diff --git a/src/MainViewWidget/directorychangedthread.cpp b/src/MainViewWidget/directorychangedthread.cpp old mode 100644 new mode 100755 index d261771..6ff4c21 --- a/src/MainViewWidget/directorychangedthread.cpp +++ b/src/MainViewWidget/directorychangedthread.cpp @@ -21,8 +21,7 @@ #include #include "src/UtilityFunction/utility.h" -DirectoryChangedThread::DirectoryChangedThread(QObject *parent): - QThread(parent) +DirectoryChangedThread::DirectoryChangedThread() { m_ukuiMenuInterface = new UkuiMenuInterface; } @@ -41,9 +40,9 @@ void DirectoryChangedThread::run() openDataBase("DirectoryChangedThread"); QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); - if (desktopfpList.size() >= UkuiMenuInterface::m_desktopfpVector.size()) { //有新的应用安装 + if (desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装 for (int i = 0; i < desktopfpList.count(); i++) { - if (!UkuiMenuInterface::m_desktopfpVector.contains(desktopfpList.at(i))) { + if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) { QFileInfo fileInfo(desktopfpList.at(i)); QString desktopfn = fileInfo.fileName(); updateDataBaseTableRecent(desktopfn); @@ -51,9 +50,9 @@ void DirectoryChangedThread::run() } } } else { //软件卸载 - for (int i = 0; i < UkuiMenuInterface::m_desktopfpVector.size(); i++) { - if (!desktopfpList.contains(UkuiMenuInterface::m_desktopfpVector.at(i))) { - QString desktopfp = UkuiMenuInterface::m_appInfoVector.at(i).at(0); + for (int i = 0; i < UkuiMenuInterface::desktopfpVector.size(); i++) { + if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) { + QString desktopfp = UkuiMenuInterface::appInfoVector.at(i).at(0); QFileInfo fileInfo(desktopfp); QString desktopfn = fileInfo.fileName(); deleteAppRecord(desktopfn); @@ -62,5 +61,11 @@ void DirectoryChangedThread::run() } } + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::alphabeticVector.clear(); + UkuiMenuInterface::functionalVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT requestUpdateSignal(); } diff --git a/src/MainViewWidget/directorychangedthread.h b/src/MainViewWidget/directorychangedthread.h old mode 100644 new mode 100755 index ef4ac44..63f9ef4 --- a/src/MainViewWidget/directorychangedthread.h +++ b/src/MainViewWidget/directorychangedthread.h @@ -27,12 +27,12 @@ class DirectoryChangedThread: public QThread { Q_OBJECT public: - DirectoryChangedThread(QObject *parent = nullptr); + DirectoryChangedThread(); ~DirectoryChangedThread(); void run(); private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; Q_SIGNALS: /** diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp old mode 100644 new mode 100755 index 3e0e9ca..e3ef9a0 --- a/src/MainViewWidget/mainviewwidget.cpp +++ b/src/MainViewWidget/mainviewwidget.cpp @@ -48,8 +48,8 @@ void MainViewWidget::initUi() QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); - m_topWidget = new QWidget(this); - m_contentWid = new QWidget(this); + m_topWidget = new QWidget; + m_contentWid = new QWidget; mainLayout->addWidget(m_topWidget); mainLayout->addWidget(m_contentWid); this->setLayout(mainLayout); @@ -71,7 +71,8 @@ void MainViewWidget::initUi() << QString("/var/lib/snapd/desktop/applications/") << QString("/var/lib/flatpak/exports/share/applications/")); connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainViewWidget::directoryChangedSlot); - m_directoryChangedThread = new DirectoryChangedThread(this); + m_directoryChangedThread = new DirectoryChangedThread; + m_directoryChangedThread->setParent(this); connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &MainViewWidget::requestUpdateSlot); connect(this, &MainViewWidget::directoryChangedSignal, m_letterWid, &LetterWidget::updateAppListView); connect(this, &MainViewWidget::directoryChangedSignal, m_fullLetterWid, &FullLetterWidget::updateAppListView); @@ -102,6 +103,7 @@ void MainViewWidget::initUi() connect(m_commonUseWid, &CommonUseWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); connect(m_functionWid, &FunctionWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); connect(m_letterWid, &LetterWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); + connect(m_searchResultWid, &SearchResultWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); addTopControl(); //加载默认视图 //搜索区 @@ -130,19 +132,10 @@ void MainViewWidget::initUi() } }); - //监控图标主题与字体变化 + //监控图标主题 if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit(), QByteArray(), this); - connect(m_gsetting, &QGSettings::changed, [ = ](QString key) { - if (key == "iconThemeName" || key == "icon-theme-name") { - Q_EMIT directoryChangedSignal(); - } - - if (key == "systemFont" || key == "systemFontSize") { - repaintWidget(); - repaintTextline(); - } - }); + m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(m_gsetting, &QGSettings::changed, this, &MainViewWidget::iconThemeChangeSlot); } } @@ -153,28 +146,20 @@ void MainViewWidget::addTopControl() { m_topLayout = new QHBoxLayout; m_topLayout->setSpacing(0); - m_queryLineEdit = new MyLineEdit(this); - m_queryLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); - m_queryLineEdit->setAttribute(Qt::WA_KeyCompression); + m_queryLineEdit = new MyLineEdit; m_topLayout->addWidget(m_queryLineEdit); m_topWidget->setLayout(m_topLayout); - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); initQueryLineEdit(); } @@ -193,7 +178,8 @@ void MainViewWidget::addTopControl() */ void MainViewWidget::initQueryLineEdit() { - m_queryWid = new QWidget(m_queryLineEdit); + m_queryWid = new QWidget; + m_queryWid->setParent(m_queryLineEdit); m_queryWid->setFocusPolicy(Qt::NoFocus); QHBoxLayout *queryWidLayout = new QHBoxLayout; queryWidLayout->setContentsMargins(0, 0, 0, 0); @@ -209,11 +195,12 @@ void MainViewWidget::initQueryLineEdit() } pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon = new QLabel(this); + m_queryIcon = new QLabel; m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setPixmap(pixmap); - m_queryText = new QLabel(this); + m_queryText = new QLabel; m_queryText->setText(tr("Search")); + m_queryText->adjustSize(); queryWidLayout->addWidget(m_queryIcon); queryWidLayout->addWidget(m_queryText); queryWidLayout->setAlignment(m_queryIcon, Qt::AlignVCenter); @@ -221,10 +208,11 @@ void MainViewWidget::initQueryLineEdit() m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); m_queryLineEdit->installEventFilter(this); m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); - m_animation = new QPropertyAnimation(m_queryWid, "geometry", this); + m_animation = new QPropertyAnimation(m_queryWid, "geometry", m_queryWid); m_animation->setDuration(100); connect(m_animation, &QPropertyAnimation::finished, this, &MainViewWidget::animationFinishedSlot); - m_searchAppThread = new SearchAppThread(this); + m_searchAppThread = new SearchAppThread; + m_searchAppThread->setParent(this); connect(this, &MainViewWidget::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); connect(m_searchAppThread, &SearchAppThread::sendSearchResult, @@ -235,40 +223,30 @@ void MainViewWidget::initQueryLineEdit() bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) { if (watched == m_queryLineEdit) { - if ((m_queryIcon->x() == 0) && - (event->type() == QEvent::MouseButtonPress || - event->type() == QEvent::InputMethod)) { + if ((m_queryIcon->x() == 0) && (event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::InputMethod)) { if (m_queryLineEdit->text().isEmpty() || (m_queryWid->layout()->count() != 2)) { QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); return false; } } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; if (event->type() == QEvent::FocusIn && m_queryLineEdit->hasFocus()) { if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditClickedDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditClickedBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditClickedDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditClickedBackground); + } else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditClickedBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); if (!m_queryLineEdit->text().isEmpty() && (m_queryLineEdit->text().size() >= 1)) { if (m_searchKeyWords.isEmpty()) { @@ -296,22 +274,17 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + } else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); m_animation->stop(); m_queryText->adjustSize(); m_animation->setStartValue(QRect(0, 0, @@ -325,22 +298,17 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedDefaultBackground).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedDefaultBackground, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + } else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); } m_isSearching = false; @@ -362,25 +330,12 @@ void MainViewWidget::setLineEditFocus(QString arg) } } -void MainViewWidget::repaintTextline() -{ - m_queryWid->layout()->removeWidget(m_queryIcon); - m_queryIcon->setParent(nullptr); - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - m_queryWid->layout()->addWidget(m_queryIcon); - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); -} - /** * 搜索程序和文件槽函数 */ void MainViewWidget::searchAppSlot(QString arg) { - //切换至搜索模块 - if (!arg.isEmpty()) { + if (!arg.isEmpty()) { //切换至搜索模块 if (m_widgetState != 0) { m_widgetState = 0; @@ -406,7 +361,7 @@ void MainViewWidget::searchAppSlot(QString arg) m_queryLineEdit->setTextMargins(-5, 0, 0, 0); } - myDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; + qDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; Q_EMIT sendSearchKeyword(arg); m_searchAppThread->start(); } else { //搜索模块显示所有的软件 @@ -457,19 +412,16 @@ void MainViewWidget::recvSearchResult(QVector arg) void MainViewWidget::animationFinishedSlot() { - //进入搜索状态 - if (m_isSearching) { - // m_queryWid->layout()->removeWidget(m_queryText); - // m_queryText->setParent(nullptr); + if (m_isSearching) { //进入搜索状态 +// m_queryWid->layout()->removeWidget(m_queryText); +// m_queryText->setParent(nullptr); m_queryLineEdit->setTextMargins(20, 0, 0, 0); if (!m_searchKeyWords.isEmpty()) { m_queryLineEdit->setText(m_searchKeyWords); m_searchKeyWords.clear(); } - } - //退出搜索状态 - else { + } else { //退出搜索状态 m_queryWid->layout()->addWidget(m_queryText); m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); @@ -478,8 +430,7 @@ void MainViewWidget::animationFinishedSlot() if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - //反黑 - if (gsetting.get("style-name").toString() == "ukui-light") { + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); } else { pe.setColor(QPalette::Text, QColor(Qt::white)); @@ -517,30 +468,25 @@ void MainViewWidget::loadMinMainView() m_queryWid->show(); } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; QPalette pe = m_queryText->palette(); const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); } else { - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); } - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); @@ -567,7 +513,6 @@ void MainViewWidget::loadMaxMainView() { this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); - myDebug() << "width" << this->width() << "height" << this->height(); //搜索区 m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); @@ -589,15 +534,13 @@ void MainViewWidget::loadMaxMainView() m_queryWid->show(); } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - m_queryLineEdit->setStyleSheet(queryLineStyle); + char style[200]; + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + m_queryLineEdit->setStyleSheet(style); const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 QPalette pe = m_queryText->palette(); pe.setColor(QPalette::Text, QColor(Qt::white)); m_queryText->setPalette(pe); @@ -605,7 +548,6 @@ void MainViewWidget::loadMaxMainView() m_queryIcon->setPixmap(pixmap); //内容区 m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - myDebug() << "m_contentWid size" << m_contentWid->size() << "m_widgetState" << m_widgetState; if (m_widgetState == 0) { loadFullSearchResultWidget(); @@ -640,7 +582,6 @@ void MainViewWidget::resizeControl() (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, 0); m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - myDebug() << "void MainViewWidget::resizeControl()" << m_contentWid->size(); } else { this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); m_topWidget->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultTopWidHeight); @@ -665,10 +606,7 @@ void MainViewWidget::resetQueryLine() 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)); - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; const auto ratio = devicePixelRatioF(); QPalette pe = m_queryText->palette(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); @@ -677,31 +615,33 @@ void MainViewWidget::resetQueryLine() QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); } else { - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); } } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); } - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); } + + m_queryLineEdit->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_queryLineEdit->simulateFocusOutEvent(nullptr); + }); } /** @@ -772,7 +712,6 @@ void MainViewWidget::loadFullCommonUseWidget() m_fullFunctionWid->widgetMakeZero(); hideWidget(); m_fullCommonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); - myDebug() << "m_fullCommonUseWid size" << m_fullCommonUseWid->size() << "mainViewWidget size" << this->size() << "m_topWidget size" << m_topWidget->size(); m_fullCommonUseWid->show(); m_fullCommonUseWid->updateListView(); m_widgetState = 1; @@ -861,7 +800,7 @@ void MainViewWidget::changeFocuDown() */ void MainViewWidget::ViewOpenedSlot(QString desktopfp) { - QVector desktopfpVec = UkuiMenuInterface::m_desktopfpVector; + QVector desktopfpVec = UkuiMenuInterface::desktopfpVector; if (desktopfpVec.contains(desktopfp)) { QFileInfo fileInfo(desktopfp); @@ -889,15 +828,16 @@ void MainViewWidget::directoryChangedSlot(const QString &path) void MainViewWidget::requestUpdateSlot() { m_directoryChangedThread->quit(); - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_alphabeticVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT directoryChangedSignal(); } +void MainViewWidget::iconThemeChangeSlot(QString key) +{ + if (key == "iconThemeName" || key == "icon-theme-name") { + Q_EMIT directoryChangedSignal(); + } +} + void MainViewWidget::reloadUkuiMenu() { Q_EMIT directoryChangedSignal(); @@ -916,14 +856,6 @@ void MainViewWidget::repaintWidget() m_fullSearchResultWid->repaintWidget(); } -void MainViewWidget::repaintFullWidget() -{ - m_fullCommonUseWid->repaintWidget(); - m_fullLetterWid->repaintWidget(); - m_fullFunctionWid->repaintWidget(); - m_fullSearchResultWid->repaintWidget(); -} - void MainViewWidget::widgetMakeZero() { m_isSearching = false; @@ -984,9 +916,9 @@ void MainViewWidget::keyPressEvent(QKeyEvent *e) } switch (e->key()) { - case Qt::Key_Enter : - case Qt::Key_Return : - case Qt::Key_Down : { + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Down: { if (m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) { if (m_isFullScreen) { m_fullSearchResultWid->setViewFocus(); diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h old mode 100644 new mode 100755 index fe96abd..67332c8 --- a/src/MainViewWidget/mainviewwidget.h +++ b/src/MainViewWidget/mainviewwidget.h @@ -44,38 +44,17 @@ #include "directorychangedthread.h" #include "src/Style/style.h" -class MyLineEdit : public QLineEdit -{ +class MyLineEdit : public QLineEdit{ Q_OBJECT public: - explicit MyLineEdit(QWidget *parent = nullptr) - { - unsetCursor(); - } - ~MyLineEdit() - { - if (m_focusEvent != nullptr) { - delete m_focusEvent; - m_focusEvent = nullptr; - } + explicit MyLineEdit(QLineEdit *parent = nullptr){unsetCursor();} + ~MyLineEdit(){} - if (m_focusOut != nullptr) { - delete m_focusOut; - m_focusOut = nullptr; - } + void simulateFocusOutEvent(QKeyEvent *e){ + QApplication::postEvent(this, new QEvent(QEvent::FocusOut)); + this->focusOutEvent(new QFocusEvent(QEvent::FocusOut)); } - - void simulateFocusOutEvent(QKeyEvent *e) - { - m_focusOut = new QEvent(QEvent::FocusOut); - QApplication::postEvent(this, m_focusOut); - m_focusEvent = new QFocusEvent(QEvent::FocusOut); - this->focusOutEvent(m_focusEvent); - } -private: - QFocusEvent *m_focusEvent = nullptr; - QEvent *m_focusOut = nullptr; }; class MainViewWidget : public QWidget @@ -106,10 +85,6 @@ public: * @brief Repaint window */ void repaintWidget(); - /** - * @brief Only repaint full window - */ - void repaintFullWidget(); /** * @brief changeFocuUp */ @@ -130,49 +105,44 @@ public: void resetQueryLine(); - MyLineEdit *getQueryLineEditer() - { - return m_queryLineEdit; - } + MyLineEdit* getQueryLineEditer() {return m_queryLineEdit;} private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *m_topWidget = nullptr; - QHBoxLayout *m_topLayout = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + QWidget *m_topWidget=nullptr; + QHBoxLayout *m_topLayout=nullptr; - QWidget *m_contentWid = nullptr; + QWidget *m_contentWid=nullptr; - MyLineEdit *m_queryLineEdit = nullptr; - QWidget *m_queryWid = nullptr; - QLabel *m_queryIcon = nullptr; - QLabel *m_queryText = nullptr; - bool m_isSearching = false; + MyLineEdit *m_queryLineEdit=nullptr; + QWidget *m_queryWid=nullptr; + QLabel *m_queryIcon=nullptr; + QLabel *m_queryText=nullptr; + bool m_isSearching; QString m_searchKeyWords; - QPropertyAnimation *m_animation = nullptr; + QPropertyAnimation *m_animation=nullptr; - FullSearchResultWidget *m_fullSearchResultWid = nullptr; - SearchResultWidget *m_searchResultWid = nullptr; - SearchAppThread *m_searchAppThread = nullptr; - CommonUseWidget *m_commonUseWid = nullptr; - LetterWidget *m_letterWid = nullptr; - FunctionWidget *m_functionWid = nullptr; - FullCommonUseWidget *m_fullCommonUseWid = nullptr; - FullLetterWidget *m_fullLetterWid = nullptr; - FullFunctionWidget *m_fullFunctionWid = nullptr; + FullSearchResultWidget *m_fullSearchResultWid=nullptr; + SearchResultWidget *m_searchResultWid=nullptr; + SearchAppThread *m_searchAppThread=nullptr; + CommonUseWidget *m_commonUseWid=nullptr; + LetterWidget *m_letterWid=nullptr; + FunctionWidget *m_functionWid=nullptr; + FullCommonUseWidget *m_fullCommonUseWid=nullptr; + FullLetterWidget *m_fullLetterWid=nullptr; + FullFunctionWidget *m_fullFunctionWid=nullptr; - DirectoryChangedThread *m_directoryChangedThread = nullptr; + DirectoryChangedThread *m_directoryChangedThread=nullptr; - int m_widgetState = 1; //Classification window number - int m_saveCurrentWidState = -1; //Store the current category window number + int m_widgetState=1;//Classification window number + int m_saveCurrentWidState=-1;//Store the current category window number - bool m_isFullScreen = false; + bool m_isFullScreen=false; // bool m_isHiden=false; - QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status + QFileSystemWatcher *m_fileWatcher=nullptr;//Monitor desktop folder status - QGSettings *m_gsetting = nullptr; - - void repaintTextline(); + QGSettings *m_gsetting=nullptr; protected: /** @@ -191,7 +161,7 @@ protected: void loadSearchResultWidget(); void loadFullSearchResultWidget(); void hideWidget(); - void keyPressEvent(QKeyEvent *e); + void keyPressEvent(QKeyEvent* e); // void focusInEvent(QFocusEvent *event); public Q_SLOTS: @@ -249,6 +219,10 @@ public Q_SLOTS: * @brief Monitor icon theme changes * @param key: Key */ + void iconThemeChangeSlot(QString key); + /** + * @brief Request for updating the application list + */ void requestUpdateSlot(); void setFocusToThis(); diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp old mode 100644 new mode 100755 index ff5ef81..214d35d --- a/src/MainWindow/mainwindow.cpp +++ b/src/MainWindow/mainwindow.cpp @@ -37,25 +37,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { getCurrentCPU(); - openDataBase("MainThreadDataBase"); - initDatabase(); - m_softwareDbThread = new SoftwareDatabaseUpdateThread(this); - //获取软件商店类别信号 - QDBusConnection::sessionBus().connect("com.kylin.softwarecenter.getsearchresults", - "/com/kylin/softwarecenter/getsearchresults", - "com.kylin.getsearchresults", - "get_app_category_list_signal", - this, - SLOT(updateAppCategorySlot(QString)) - ); + openDataBase("MainThread"); m_ukuiMenuInterface = new UkuiMenuInterface; - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::m_allAppVector = m_ukuiMenuInterface->getAllClassification(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + initDatabase(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification(); Style::initWidStyle(); initUi(); - m_dbus = new DBus(this); + m_dbus = new DBus; new MenuAdaptor(m_dbus); QDBusConnection con = QDBusConnection::sessionBus(); @@ -65,13 +56,12 @@ MainWindow::MainWindow(QWidget *parent) : } connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] { - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_alphabeticVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::alphabeticVector.clear(); + UkuiMenuInterface::functionalVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT m_mainViewWid->reloadUkuiMenu(); }); connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { @@ -79,12 +69,14 @@ MainWindow::MainWindow(QWidget *parent) : { QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); +// if(gsetting.keys().contains("win-key-release")) +// if(gsetting.get("win-key-release").toBool()) +// return; if (gsetting.keys().contains("winKeyRelease")) if (gsetting.get("winKeyRelease").toBool()) { return; } } - if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); @@ -98,7 +90,6 @@ MainWindow::MainWindow(QWidget *parent) : if (this->isVisible()) { this->hide(); - m_mainViewWid->widgetMakeZero(); } else { this->loadMainWindow(); @@ -106,12 +97,13 @@ MainWindow::MainWindow(QWidget *parent) : this->raise(); this->activateWindow(); } + m_mainViewWid->widgetMakeZero(); }); } MainWindow::~MainWindow() { - closeDataBase("MainThreadDataBase"); + closeDataBase("MainThread"); if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; @@ -123,28 +115,31 @@ void MainWindow::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAttribute(Qt::WA_InputMethodEnabled); - this->setAttribute(Qt::WA_KeyCompression); this->setAutoFillBackground(false); this->setFocusPolicy(Qt::NoFocus); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); this->setMinimumSize(Style::minw, Style::minh); this->setContentsMargins(0, 0, 0, 0); - m_frame = new QFrame(this); - m_mainViewWid = new MainViewWidget(this); - m_sideBarWid = new SideBarWidget(this); +// this->setFocus(); + m_frame = new QFrame; + m_mainViewWid = new MainViewWidget; + m_sideBarWid = new SideBarWidget; +// m_frame->installEventFilter(this); +// m_mainViewWid->installEventFilter(this); +// m_sideBarWid->installEventFilter(this); +// setTabOrder(m_mainViewWid , m_sideBarWid); +// setTabOrder(m_sideBarWid , m_mainViewWid); this->setCentralWidget(m_frame); - QHBoxLayout *mainlayout = new QHBoxLayout(this); + QHBoxLayout *mainlayout = new QHBoxLayout; mainlayout->setContentsMargins(0, 0, 0, 0); mainlayout->setSpacing(0); m_frame->setLayout(mainlayout); mainlayout->addWidget(m_mainViewWid); - m_line = new QFrame(this); + m_line = new QFrame; m_line->installEventFilter(this); m_line->setFrameShape(QFrame::VLine); - m_line->setFixedSize(1, this->height() - 5); + m_line->setFixedSize(1, this->height() - 1); m_line->setEnabled(false); - m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); mainlayout->addWidget(m_line); mainlayout->addWidget(m_sideBarWid); m_sideBarWid->loadMinSidebar(); @@ -152,7 +147,6 @@ void MainWindow::initUi() m_animation = new QPropertyAnimation(this, "geometry"); connect(m_animation, &QPropertyAnimation::finished, this, &MainWindow::animationValueFinishedSlot); connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab); - connect(m_sideBarWid, &SideBarWidget::setLineEditFocus, m_mainViewWid, &MainViewWidget::setLineEditFocus); 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); @@ -185,8 +179,8 @@ void MainWindow::initUi() //监听屏幕缩放 if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { - QGSettings xsetting(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); - connect(&xsetting, &QGSettings::changed, this, [ = ](const QString & key) { + QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); + connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) { if (key == "scalingFactor") { repaintWidget(); } @@ -194,8 +188,8 @@ void MainWindow::initUi() } if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings psetting(QString("org.ukui.panel.settings").toLocal8Bit()); - connect(&psetting, &QGSettings::changed, + QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + connect(gsetting, &QGSettings::changed, this, &MainWindow::panelChangedSlot); } } @@ -210,33 +204,27 @@ void MainWindow::getCurrentCPU() processCpuInfo->waitForFinished(); QString ctrCpuInfo = processCpuInfo->readAll(); - if (ctrCpuInfo.indexOf("HUAWEI Kirin") != -1) { + if (ctrCpuInfo.contains("HUAWEI") || ctrCpuInfo.contains("Kirin")) { isHuaWeiPC = true; } - if (ctrCpuInfo.indexOf("HUAWEI kirin 9006C") != -1) { - isHuaWei9006C = true; + if (ctrCpuInfo.contains("PANGU")) { + isPANGU = true; } } + void MainWindow::paintEvent(QPaintEvent *event) { double transparency = getTransparency(); - QRect rect = this->rect().adjusted(4, 3, -3, -3); + QRect rect = this->rect(); QPainterPath path; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setPen(Qt::transparent); if (!m_isFullScreen) { - qreal radius; - - if (projectCodeName == "V10SP2") { - radius = 12; - } else { - radius = 6; - } - + qreal radius = 6; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); @@ -250,16 +238,8 @@ void MainWindow::paintEvent(QPaintEvent *event) painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawPath(path); +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - QColor color(Qt::black); - - for (int i = 0; i < 5; i++) { - rect = this->rect().adjusted(i, i, - i, - i); - color.setAlpha(transparency * (20 + (i * 10))); - painter.setBrush(Qt::NoBrush); - painter.setPen(QPen(color, 1)); - painter.drawRoundRect(rect, 6, 6); - } } else { //全屏固定背景色(黑底白字) // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { @@ -309,24 +289,31 @@ void MainWindow::paintEvent(QPaintEvent *event) */ void MainWindow::showFullScreenWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = true; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; +// int width = Style::primaryScreenWidth; +// int height = Style::primaryScreenHeight; QRect startRect; QRect endRect; - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + } else if (position == 1) { + startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); + } else if (position == 2) { + startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); } - endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -335,7 +322,7 @@ void MainWindow::showFullScreenWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { is_repaint = false; this->hide(); QEventLoop loop; @@ -365,36 +352,35 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) } } -void MainWindow::inputMethodEvent(QInputMethodEvent *event) -{ - QInputMethodEvent *iEvent = dynamic_cast(event); - m_mainViewWid->setLineEditFocus(iEvent->commitString()); - myDebug() << iEvent->commitString(); -} - - /** * 显示默认窗口 */ void MainWindow::showDefaultWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = false; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; QRect startRect; QRect endRect; - startRect.setRect(x, y, width, height); - if (position == BOTTOM) { - endRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - endRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + endRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + startRect.setRect(x, y, width, height - panelSize); + } else if (position == 1) { + endRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + startRect.setRect(x, y + panelSize, width, height - panelSize); + } else if (position == 2) { + endRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + panelSize, y, width - panelSize, height); } else { - endRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x, y, width - panelSize, height); } this->centralWidget()->layout()->removeWidget(m_mainViewWid); @@ -402,7 +388,7 @@ void MainWindow::showDefaultWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { this->setGeometry(endRect); animationValueFinishedSlot(); } else { @@ -439,22 +425,25 @@ void MainWindow::animationValueFinishedSlot() m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); } + + m_mainViewWid->getQueryLineEditer()->setFocus(); + + if (m_mainViewWid->getQueryLineEditer()->text().isEmpty()) { + qDebug() << "there is no letter in search lineEditer"; + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); + } } + void MainWindow::activeWindowSolt(bool flag) { // qDebug() << "void MainWindow::activeWindowSolt(bool flag)"; - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { QTimer::singleShot(50, this, SLOT(mainWinShowSlot())); } } -void MainWindow::keyPressEvent(QKeyEvent *e) -{ - if (e->type() == QEvent::KeyPress) { - if ((e->key() >= 0x30 && e->key() <= 0x39) || (e->key() >= 0x41 && e->key() <= 0x5a)) { - m_mainViewWid->setLineEditFocus(e->text()); - } - } -} + void MainWindow::mainWinShowSlot() { this->activateWindow(); @@ -465,6 +454,7 @@ void MainWindow::mainWinShowSlot() qDebug() << "void MainWindow::activeWindowSolt()"; } + /** * 鼠标点击窗口外部事件 */ @@ -484,20 +474,31 @@ bool MainWindow::event(QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = (QKeyEvent *) event; - if (keyEvent->key() == Qt::Key_Escape) { - this->hide(); - } - +// if (keyEvent->key() == Qt::Key_Tab) +// { +// m_mainViewWid->setFocus(); +// Q_EMIT setFocusSignal(); +// return true; +// } if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Tab) { m_mainViewWid->setFocus(); Q_EMIT setFocusSignal(); + // return true; } } + if (event->type() == QEvent::FocusIn) { + m_mainViewWid->getQueryLineEditer()->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); + } + return QWidget::event(event); } + /** * 隐藏窗口 */ @@ -507,14 +508,17 @@ void MainWindow::recvHideMainWindowSlot() // m_mainViewWid->widgetMakeZero(); // m_sideBarWid->widgetMakeZero(); } + void MainWindow::loadMainWindow() { cleanTimeoutApp(); + QRect availableGeometry = getScreenAvailableGeometry(); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; this->setFocus(); if (m_isFullScreen) { @@ -522,14 +526,19 @@ void MainWindow::loadMainWindow() QRect startRect; QRect endRect; - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + } else if (position == 1) { + startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); + } else if (position == 2) { + startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); } - endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -537,86 +546,157 @@ void MainWindow::loadMainWindow() m_line->setParent(nullptr); this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); +// m_sideBarWid->clearFocus(); +// m_mainViewWid->clearFocus(); m_animation->setDuration(1);//动画总时间 m_animation->setStartValue(startRect); m_animation->setEndValue(endRect); m_animation->setEasingCurve(QEasingCurve::Linear); m_animation->start(); } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } +// QGSettings* setting1 = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); +// QString value1 = setting1->get("scaling-factor").toString(); +// double scaling = value1.toDouble(); + qDebug() << "availableGeometry.height();" << availableGeometry.height(); + + if (position == 0) + this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, + Style::minw, Style::minh)); + else if (position == 1) { + this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); + } else + this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, + Style::minw, Style::minh)); + m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); + m_mainViewWid->getQueryLineEditer()->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); } } + void MainWindow::panelChangedSlot(QString key) { Q_UNUSED(key); repaintWidget(); } + void MainWindow::primaryScreenChangeSlot() { Style::initWidStyle(); - m_mainViewWid->repaintFullWidget(); resizeWidget(); } + void MainWindow::repaintWidget() { Style::initWidStyle(); + QRect availableGeometry = getScreenAvailableGeometry();/*qApp->primaryScreen()->availableGeometry();*/ this->setMinimumSize(Style::minw, Style::minh); m_line->setFixedSize(1, this->height() - 1); - m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); m_mainViewWid->repaintWidget(); resizeWidget(); } + void MainWindow::resizeWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); + if (QApplication::activeWindow() == this) { int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; if (m_isFullScreen) { - this->setGeometry(x, y, width, height); + if (position == 0) { + this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); + } else if (position == 1) { + this->setGeometry(QRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height())); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height())); + } else { + this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); + } + m_sideBarWid->loadMaxSidebar(); m_sideBarWid->setSideBarBtnGeometry(); + m_mainViewWid->resizeControl(); } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } + if (position == 0) + this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, + Style::minw, Style::minh)); + else if (position == 1) { + this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); + } else + this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, + Style::minw, Style::minh)); + m_sideBarWid->loadMinSidebar(); + m_mainViewWid->resizeControl(); } - m_mainViewWid->resizeControl(); } } +//void MainWindow::setFrameStyle() +//{ +// 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; +// } + +// QRectF rect; +// rect.setX(this->rect().x()+1); +// rect.setY(this->rect().y()+1); +// rect.setWidth(this->rect().width()-2); +// rect.setHeight(this->rect().height()-2); +// qreal radius = 0; +// QPainterPath path; +// if(!m_isFullScreen) +// { +// radius=12; +// } +// else +// { +// radius=0; +// } + +// 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)); + +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); +//} + void MainWindow::mainWinHideSlot() { this->hide(); m_mainViewWid->widgetMakeZero(); } -void MainWindow::updateAppCategorySlot(QString category) -{ - m_softwareDbThread->getDatabaseList(category); - m_softwareDbThread->start(); - connect(m_softwareDbThread, &SoftwareDatabaseUpdateThread::updateDatabaseSignal, this, &MainWindow::databaseThreadCloseSlot); -} -void MainWindow::databaseThreadCloseSlot() -{ - m_softwareDbThread->quit(); - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - m_mainViewWid->reloadUkuiMenu(); -} diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h old mode 100644 new mode 100755 index 401c6aa..c848ce0 --- a/src/MainWindow/mainwindow.h +++ b/src/MainWindow/mainwindow.h @@ -39,7 +39,6 @@ #include "src/MainViewWidget/mainviewwidget.h" #include "src/DBus/dbus.h" #include "src/DBus/dbus-adaptor.h" -#include "src/UtilityFunction/softwaredatabaseupdatethread.h" #include class MainWindow : public QMainWindow @@ -49,7 +48,10 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); - + /** + * @brief Set the QFrame style + */ +// void setFrameStyle(); /** * @brief Load the main window */ @@ -58,18 +60,18 @@ public: private: - bool m_isFullScreen = false; + bool m_isFullScreen=false; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + + QFrame *m_line=nullptr;//Vertical dividing line + QFrame *m_frame=nullptr; + SideBarWidget *m_sideBarWid=nullptr; + MainViewWidget *m_mainViewWid=nullptr; + + QPropertyAnimation *m_animation=nullptr; bool m_winFlag = false; bool is_repaint = true; - - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QFrame *m_line = nullptr; //Vertical dividing line - QFrame *m_frame = nullptr; - SideBarWidget *m_sideBarWid = nullptr; - MainViewWidget *m_mainViewWid = nullptr; - QPropertyAnimation *m_animation = nullptr; - DBus *m_dbus = nullptr; - SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; + DBus *m_dbus=nullptr; protected: void initUi(); @@ -77,7 +79,7 @@ protected: * @brief Handle events clicking on the outside of the window */ bool event(QEvent *event); - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent* event); /** * @brief The query box responds to keyboard events */ @@ -87,10 +89,6 @@ protected: void mouseReleaseEvent(QMouseEvent *event); - void inputMethodEvent(QInputMethodEvent *event); - - void keyPressEvent(QKeyEvent *e); - public Q_SLOTS: /** * @brief Load the full screen window @@ -112,8 +110,6 @@ public Q_SLOTS: void activeWindowSolt(bool flag); void mainWinShowSlot(); void mainWinHideSlot(); - void updateAppCategorySlot(QString category); - void databaseThreadCloseSlot(); public: Q_SIGNALS: diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/QtSingleApplication b/src/QtSingleApplication/QtSingleApplication old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/src/QtSingleApplication/qtlocalpeer.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp old mode 100644 new mode 100755 index 3c3788e..51a3587 --- a/src/QtSingleApplication/qtsingleapplication.cpp +++ b/src/QtSingleApplication/qtsingleapplication.cpp @@ -47,7 +47,6 @@ #include #include #include "src/MainWindow/mainwindow.h" -#include "src/UtilityFunction/utility.h" /*! diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/menubox.cpp b/src/RightClickMenu/menubox.cpp old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/menubox.h b/src/RightClickMenu/menubox.h old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp old mode 100644 new mode 100755 index b9e4bb3..290eae6 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -18,19 +18,45 @@ #include "rightclickmenu.h" #include "src/UtilityFunction/utility.h" -#include "uninstallwhitelist.h" #include RightClickMenu::RightClickMenu(QWidget *parent): QWidget(parent) { - m_cmdProc = new QProcess(this); - m_whiteList = UninstallWhitelist::getInstance()->getWhiteList(); + m_cmdProc = new QProcess; + m_whiteList.append("kylin-screenshot.desktop"); + m_whiteList.append("ukui-notebook.desktop"); + m_whiteList.append("ukui-clock.desktop"); + m_whiteList.append("kylin-calculator.desktop"); + m_whiteList.append("kylin-recorder.desktop"); + m_whiteList.append("kylin-software-center.desktop"); + m_whiteList.append("kylin-camera.desktop"); + m_whiteList.append("biometric-manager.desktop"); + m_whiteList.append("yhkylin-backup-tools.desktop"); + m_whiteList.append("box-manager.desktop"); + m_whiteList.append("ukui-system-monitor.desktop"); + m_whiteList.append("ksc-defender.desktop"); + m_whiteList.append("logview.desktop"); + m_whiteList.append("kylin-service-support.desktop"); + m_whiteList.append("kylin-user-guide.desktop"); + m_whiteList.append("ukui-control-center.desktop"); + m_whiteList.append("peony.desktop"); + m_whiteList.append("engrampa.desktop"); + + if (isPANGU || isHuaWeiPC) { + m_whiteList.append("org.gnome.FileRoller.desktop"); + m_whiteList.append("mate-terminal.desktop"); + m_whiteList.append("hwaudioui.desktop"); + m_whiteList.append("kylin-sogouIme-configtool.desktop"); + } + m_ukuiMenuInterface = new UkuiMenuInterface; } RightClickMenu::~RightClickMenu() { + delete m_cmdProc; + if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -72,41 +98,24 @@ void RightClickMenu::unfixedFromAllActionTriggerSlot() void RightClickMenu::fixToTaskbarActionTriggerSlot() { - QProcess *process = new QProcess(); - process->start(QString("dpkg -s ukui-panel")); - process->waitForFinished(); - QString str = process->readAll(); - delete process; - - QList strList = str.split('\n'); - QString version; - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - break; - } - } - - if (version.startsWith("3.0")) { - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); - } else { - QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); - message << m_desktopfp; - QDBusConnection::sessionBus().send(message); - } +// QDBusInterface iface("com.ukui.panel.desktop", +// "/", +// "com.ukui.panel.desktop", +// QDBusConnection::sessionBus()); +// QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); + QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); + message << m_desktopfp; + QDBusConnection::sessionBus().send(message); m_actionNumber = 3; } void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() { - QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "RemoveFromTaskbar"); - message << m_desktopfp; - QDBusConnection::sessionBus().send(message); + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("RemoveFromTaskbar", m_desktopfp); m_actionNumber = 4; } @@ -135,8 +144,8 @@ void RightClickMenu::uninstallActionTriggerSlot() QString cmd = QString("kylin-uninstaller %1") .arg(m_desktopfp.toLocal8Bit().data()); bool ret = QProcess::startDetached(cmd); - myDebug() << "卸载:" << cmd << ret; - myDebug() << "kylin-uninstaller"; + qDebug() << "卸载:" << cmd << ret; + qDebug() << "kylin-uninstaller"; // } // else // { @@ -222,7 +231,13 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"), this, SLOT(unfixedFromAllActionTriggerSlot())); - if (!checkIfFixedToTaskbar(desktopfn)) + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("CheckIfExist", desktopfp); + + if (!ret) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to taskbar"), this, SLOT(fixToTaskbarActionTriggerSlot())); else @@ -248,6 +263,7 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); m_showAppMenu.exec(pos); + qDebug() << "RightClickMenu::showAppBtnMenu(QString desktopfp)"; return m_actionNumber; } @@ -269,6 +285,7 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos) m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); m_showShutMenu.raise(); m_showShutMenu.exec(pos); + qDebug() << "RightClickMenu::showShutdownMenu()"; return m_actionNumber; } @@ -296,42 +313,6 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); m_showOtherMenu.exec(pos); + qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; return m_actionNumber; } - -QList > RightClickMenu::getTaskbarFixedList() -{ - QSettings settings(QDir::homePath() + "/.config/ukui/panel.conf", QSettings::IniFormat); - QList > array; - int size = settings.beginReadArray("/taskbar/apps"); - - for (int i = 0; i < size; ++i) { - settings.setArrayIndex(i); - QMap hash; - const auto keys = settings.childKeys(); - - for (const QString &key : keys) { - hash[key] = settings.value(key); - } - - array << hash; - } - - return array; -} - -bool RightClickMenu::checkIfFixedToTaskbar(const QString &desktopfp) -{ - QString fixdDesktop; - const auto apps = getTaskbarFixedList(); - - for (const QMap &app : apps) { - fixdDesktop = app.value("desktop", "").toString(); - - if (fixdDesktop.contains(desktopfp)) { - return true; - } - } - - return false; -} diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h old mode 100644 new mode 100755 index 2177159..5760972 --- a/src/RightClickMenu/rightclickmenu.h +++ b/src/RightClickMenu/rightclickmenu.h @@ -73,8 +73,8 @@ public: private: QString m_desktopfp; int m_actionNumber; - QProcess *m_cmdProc = nullptr; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QProcess *m_cmdProc=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; QStringList m_whiteList; @@ -145,10 +145,6 @@ private Q_SLOTS: */ void otherListActionTriggerSlot(); - QList > getTaskbarFixedList(); - - bool checkIfFixedToTaskbar(const QString &desktopfp); - public: Q_SIGNALS: void sendMainWinActiveSignal(bool flag); diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp deleted file mode 100644 index 51e5cbe..0000000 --- a/src/RightClickMenu/uninstallwhitelist.cpp +++ /dev/null @@ -1,84 +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 - -UninstallWhitelist *UninstallWhitelist::instance = nullptr; - -UninstallWhitelist::UninstallWhitelist() -{ - m_whiteList.append("kylin-screenshot.desktop"); - m_whiteList.append("ukui-notebook.desktop"); - m_whiteList.append("ukui-clock.desktop"); - m_whiteList.append("kylin-calculator.desktop"); - m_whiteList.append("kylin-recorder.desktop"); - m_whiteList.append("kylin-software-center.desktop"); - m_whiteList.append("kylin-camera.desktop"); - m_whiteList.append("biometric-manager.desktop"); - m_whiteList.append("yhkylin-backup-tools.desktop"); - m_whiteList.append("box-manager.desktop"); - m_whiteList.append("ukui-system-monitor.desktop"); - m_whiteList.append("ksc-defender.desktop"); - m_whiteList.append("logview.desktop"); - m_whiteList.append("kylin-service-support.desktop"); - m_whiteList.append("kylin-user-guide.desktop"); - m_whiteList.append("ukui-control-center.desktop"); - m_whiteList.append("peony.desktop"); - m_whiteList.append("engrampa.desktop"); - - if (isHuaWei9006C || isHuaWeiPC) { - m_whiteList.append("org.gnome.FileRoller.desktop"); - m_whiteList.append("mate-terminal.desktop"); - m_whiteList.append("hwaudioui.desktop"); - } -} - -UninstallWhitelist *UninstallWhitelist::getInstance() -{ - if (instance == nullptr) { - instance = new UninstallWhitelist(); - } - - return instance; -} - -QStringList UninstallWhitelist::getPkgNameWhiteList() -{ - QStringList pkgNameList; - - Q_FOREACH (QString desktop, m_whiteList) { - QProcess *processPkgName = new QProcess(); - processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop)); - connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() { - processPkgName->deleteLater(); - }); - processPkgName->waitForFinished(); - QString pkgName = processPkgName->readAll(); - pkgName = pkgName.left(pkgName.indexOf(":")); - pkgNameList.append(pkgName); - } - - return pkgNameList; -} - -QStringList UninstallWhitelist::getWhiteList() -{ - return m_whiteList; -} diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/RightClickMenu/uninstallwhitelist.h deleted file mode 100644 index a478292..0000000 --- a/src/RightClickMenu/uninstallwhitelist.h +++ /dev/null @@ -1,47 +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 - -class UninstallWhitelist : public QObject -{ - Q_OBJECT - -public: - static UninstallWhitelist *getInstance(); - /** - * @brief 获取不可卸载包名列表 - * @return - */ - QStringList getPkgNameWhiteList(); - /** - * @brief 获取不可卸载desktop列表 - * @return - */ - QStringList getWhiteList(); -private: - UninstallWhitelist(); -private: - static UninstallWhitelist *instance; - - QStringList m_whiteList; -}; - -#endif // UNINSTALLWHITELIST_H diff --git a/src/SearchResultWidget/file-utils.cpp b/src/SearchResultWidget/file-utils.cpp old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/file-utils.h b/src/SearchResultWidget/file-utils.h old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp old mode 100644 new mode 100755 index ffb7b6f..49ee973 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ b/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -49,8 +49,8 @@ void FullSearchResultWidget::initUi() mainLayout->addItem(m_spaceItem); m_listView = new FullListView(this, 3); this->setLayout(mainLayout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setWidget(m_scrollAreaWid); @@ -114,11 +114,13 @@ void FullSearchResultWidget::repaintWidget() this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); +// this->layout()->setContentsMargins(Style::LeftWidWidth,0,0,0); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; m_listView = new FullListView(this, 3); m_scrollAreaWidLayout->insertWidget(0, m_listView); + m_data.clear(); m_listView->addData(m_data); resizeScrollAreaControls(); connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); diff --git a/src/SearchResultWidget/fullsearchresultwidget.h b/src/SearchResultWidget/fullsearchresultwidget.h old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp old mode 100644 new mode 100755 index 36d69a0..a332168 --- a/src/SearchResultWidget/searchappthread.cpp +++ b/src/SearchResultWidget/searchappthread.cpp @@ -20,8 +20,7 @@ #include #include "src/SearchResultWidget/file-utils.h" -SearchAppThread::SearchAppThread(QObject *parent): - QThread(parent) +SearchAppThread::SearchAppThread() { m_ukuiMenuInterface = new UkuiMenuInterface; } @@ -37,7 +36,7 @@ SearchAppThread::~SearchAppThread() void SearchAppThread::run() { m_appInfoVector.clear(); - m_appInfoVector = UkuiMenuInterface::m_appInfoVector; + m_appInfoVector = UkuiMenuInterface::appInfoVector; m_searchResultVector.clear(); m_searchFirstVector.clear(); m_searchRestVector.clear(); @@ -45,7 +44,45 @@ void SearchAppThread::run() if (!this->m_keyWord.isEmpty()) { QString str = m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); int index = 0; +// if(str.size()==1) +// { +// int num=static_cast(str.toLocal8Bit().at(0)); +// QStringList searchDesktopList; +// searchDesktopList.clear(); +// if(num>=65 && num<=90) +// { +// for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1)); +//// QString appEnglishName=m_appInfoVector.at(index).at(2); +// QString appNameFl=m_appInfoVector.at(index).at(3); +// if(appNameFl==str)//匹配首字母 +// { +// m_searchResultVector.append(m_appInfoVector.at(index)); +// } +// index++; +// } +// } +//// else if(num<48 || (num>57 && num<65) || num>90) +//// for(int i=0;igetAppName(searchDesktopList.at(i))); +// } +// } +// else + //{ while (index < m_appInfoVector.size()) { // QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1)); QStringList appNameLs; @@ -62,8 +99,7 @@ void SearchAppThread::run() QString appEnglishName = m_appInfoVector.at(index).at(2); //QString appNameFls=m_appInfoVector.at(index).at(4); - if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { - //中文正则表达式 + if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式 if (appName.toUpper().contains(m_keyWord.toUpper())) { m_searchResultVector.append(m_appInfoVector.at(index)); } @@ -83,6 +119,7 @@ void SearchAppThread::run() } index++; + //} } } diff --git a/src/SearchResultWidget/searchappthread.h b/src/SearchResultWidget/searchappthread.h old mode 100644 new mode 100755 index 852d311..9447d73 --- a/src/SearchResultWidget/searchappthread.h +++ b/src/SearchResultWidget/searchappthread.h @@ -26,7 +26,7 @@ class SearchAppThread : public QThread { Q_OBJECT public: - SearchAppThread(QObject *parent = nullptr); + SearchAppThread(); ~SearchAppThread(); void run(); @@ -36,7 +36,7 @@ private: QVector m_searchFirstVector; QVector m_searchRestVector; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QVector m_appInfoVector; public Q_SLOTS: diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp old mode 100644 new mode 100755 index 116ffcb..691eff5 --- a/src/SearchResultWidget/searchresultwidget.cpp +++ b/src/SearchResultWidget/searchresultwidget.cpp @@ -51,6 +51,7 @@ void SearchResultWidget::initUi() m_ukuiMenuInterface = new UkuiMenuInterface; connect(m_listView, &ListView::sendItemClickedSignal, this, &SearchResultWidget::execApplication); connect(m_listView, &ListView::sendHideMainWindowSignal, this, &SearchResultWidget::sendHideMainWindowSignal); + connect(m_listView, &ListView::sendMainWinActiveSignal, this, &SearchResultWidget::sendMainWinActiveSignal); } /** diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h old mode 100644 new mode 100755 index 2897b23..ce3b5ec --- a/src/SearchResultWidget/searchresultwidget.h +++ b/src/SearchResultWidget/searchresultwidget.h @@ -59,8 +59,8 @@ public: void setViewFocus(); private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - ListView* m_listView=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + ListView *m_listView = nullptr; QVector m_data; protected: @@ -81,6 +81,8 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); + + void sendMainWinActiveSignal(bool flag); }; #endif // SEARCHRESULTWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp old mode 100644 new mode 100755 index 57e70ac..7cb2b3e --- a/src/SideBarWidget/sidebarwidget.cpp +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/Style/style.h" #include "src/UtilityFunction/utility.h" @@ -49,31 +48,19 @@ void SideBarWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground, true); - this->setAttribute(Qt::WA_InputMethodEnabled); - this->setAttribute(Qt::WA_KeyCompression); this->setFocusPolicy(Qt::NoFocus); addSidebarBtn(); loadMinSidebar(); m_minMaxBtn->installEventFilter(this); - m_minMaxBtn->setAttribute(Qt::WA_KeyCompression); - m_minMaxBtn->setAttribute(Qt::WA_InputMethodEnabled); m_allBtn->installEventFilter(this); m_letterBtn->installEventFilter(this); m_functionBtn->installEventFilter(this); m_userIconBtn->installEventFilter(this); - m_userIconBtn->setAttribute(Qt::WA_KeyCompression); - m_userIconBtn->setAttribute(Qt::WA_InputMethodEnabled); m_computerBtn->installEventFilter(this); - m_computerBtn->setAttribute(Qt::WA_KeyCompression); - m_computerBtn->setAttribute(Qt::WA_InputMethodEnabled); m_personalBtn->installEventFilter(this); m_controlBtn->installEventFilter(this); - m_controlBtn->setAttribute(Qt::WA_KeyCompression); - m_controlBtn->setAttribute(Qt::WA_InputMethodEnabled); m_trashBtn->installEventFilter(this); m_shutDownBtn->installEventFilter(this); - m_shutDownBtn->setAttribute(Qt::WA_KeyCompression); - m_shutDownBtn->setAttribute(Qt::WA_InputMethodEnabled); m_ukuiMenuInterface = new UkuiMenuInterface; // m_shutDownMenu=new RightClickMenu; // m_otherMenu=new RightClickMenu; @@ -103,11 +90,6 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event) } } - if (event->type() == QEvent::InputMethod) { - QInputMethodEvent *iEvent = dynamic_cast(event); - Q_EMIT setLineEditFocus(iEvent->commitString()); - } - return QWidget::eventFilter(target, event); } @@ -118,7 +100,8 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event) */ void SideBarWidget::addSidebarBtn() { - m_mainWidget = new QWidget(this); + m_mainWidget = new QWidget; + m_mainWidget->setParent(this); m_mainWidgetLayout = new QVBoxLayout; m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); m_mainWidgetLayout->setSpacing(10); @@ -129,9 +112,9 @@ void SideBarWidget::addSidebarBtn() // palette.setBrush(QPalette::Background,Qt::red); // m_mainWidget->setPalette(palette); //放大缩小按钮界面 - m_minMaxWidget = new QWidget(this); + m_minMaxWidget = new QWidget; m_minMaxLayout = new QHBoxLayout; - m_minMaxBtn = new QPushButton(this); + m_minMaxBtn = new QPushButton; m_minMaxBtn->setFlat(true); m_minMaxBtn->setProperty("useButtonPalette", true); // m_minMaxBtn->setProperty("doNotAnimate",true); @@ -151,19 +134,17 @@ void SideBarWidget::addSidebarBtn() // m_minMaxWidget->hasFocus(); //分类按钮 m_buttonList.clear(); - m_allBtn = new QPushButton(this); + m_allBtn = new QPushButton; initBtn(m_allBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"), tr("All"), 0); - m_letterBtn = new QPushButton(this); + m_letterBtn = new QPushButton; initBtn(m_letterBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"), tr("Letter"), 1); - m_functionBtn = new QPushButton(this); + 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++); btn->setCheckable(true); - btn->setAttribute(Qt::WA_KeyCompression); - btn->setAttribute(Qt::WA_InputMethodEnabled); } QString usericon = getUserIcon(); @@ -189,33 +170,13 @@ void SideBarWidget::addSidebarBtn() connect(m_trashBtn, &QPushButton::clicked, this, &SideBarWidget::trashBtnClickedSlot); connect(m_shutDownBtn, &QPushButton::clicked, this, &SideBarWidget::shutdownBtnClickedSlot); connect(m_userIconBtn, &QPushButton::clicked, this, &SideBarWidget::userIconBtnClickedSlot); - - // 判断控制面版版本号,选择是否屏蔽右键菜单 - QProcess *prosess = new QProcess(this); - prosess->start(QString("dpkg -s ukui-control-center")); - prosess->waitForFinished(); - QString str = prosess->readAll(); - delete prosess; - QList strList = str.split('\n'); - QString version; - - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - } - } - - if (version.startsWith("3.0")) { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); - if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { - button->setCheckable(false); - addRightClickMenu(btn); - } - } - } - +// Q_FOREACH (QAbstractButton *button, m_buttonList) { +// QPushButton *btn = qobject_cast(button); +// if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { +// button->setCheckable(false); +// addRightClickMenu(btn); +// } +// } m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_shutDownBtn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::shutdownBtnRightClickSlot); @@ -239,7 +200,7 @@ void SideBarWidget::addSidebarBtn() 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(), QByteArray(), this); + 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)); @@ -268,7 +229,7 @@ void SideBarWidget::addSidebarBtn() connect(gsetting, &QGSettings::changed, this, &SideBarWidget::themeModeChangeSlot); } - m_animation = new QPropertyAnimation(m_mainWidget, "geometry", this); + m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); } void SideBarWidget::resetSidebarBtnSlot() @@ -311,7 +272,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int btn->setFlat(true); btn->setProperty("useButtonPalette", true); QHBoxLayout *btnLayout = new QHBoxLayout; - QLabel *labelicon = new QLabel(this); + QLabel *labelicon = new QLabel; labelicon->setAlignment(Qt::AlignCenter); const auto ratio = devicePixelRatioF(); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); @@ -330,7 +291,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int labelicon->setPixmap(pixmap); } else { if (!QFile::exists(btnicon)) { - btnicon = QString("/usr/share/ukui/faces/default.png"); + btnicon = QString(":/data/img/sidebarwidget/default.svg"); } labelicon->setObjectName("faceLabel"); @@ -347,7 +308,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int btnLayout->setSpacing(0); btnLayout->addWidget(labelicon); // btnLayout->addStretch(); - QLabel *textLabel = new QLabel(this); + QLabel *textLabel = new QLabel; if (num == 3) { textLabel->setObjectName("nameLabel"); @@ -390,6 +351,7 @@ void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) RightClickMenu m_otherMenu(this); int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); Q_EMIT sendShowMainWindowSignal(false); + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; if (ret >= 10 && ret <= 17) { Q_EMIT sendHideMainWindowSignal(); @@ -427,50 +389,55 @@ void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) break; } } + + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 结束"; } -void SideBarWidget::addRightClickMenu(QPushButton *btn) -{ - btn->setContextMenuPolicy(Qt::CustomContextMenu); - connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); -} +//void SideBarWidget::addRightClickMenu(QPushButton *btn) +//{ +// btn->setContextMenuPolicy(Qt::CustomContextMenu); +// connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); +//} -void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) -{ - QPushButton *btn = dynamic_cast(QObject::sender()); - int index = m_buttonList.indexOf(btn); - QString desktopfp; +//void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) +//{ +// qDebug() << "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; +// 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 5: +// desktopfp = QString("/usr/share/applications/peony-trash.desktop"); +// break; - case 6: - desktopfp = QString("/usr/share/applications/peony-computer.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; +// case 7: +// desktopfp = QString("/usr/share/applications/ukui-control-center.desktop"); +// break; - default: - break; - } +// default: +// break; +// } - RightClickMenu m_otherMenu; - int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); - Q_EMIT sendShowMainWindowSignal(false); +// RightClickMenu m_otherMenu; +// int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); +// Q_EMIT sendShowMainWindowSignal(false); - if (ret == 15) { - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -d")); - } -} +// if (ret == 15) { +// Q_EMIT sendHideMainWindowSignal(); +// QProcess::startDetached(QString("ukui-control-center -d")); +// } + +// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束"; +//} void SideBarWidget::computerBtnClickedSlot() { @@ -505,25 +472,7 @@ void SideBarWidget::shutdownBtnClickedSlot() void SideBarWidget::userIconBtnClickedSlot() { Q_EMIT sendHideMainWindowSignal(); - QProcess *prosess = new QProcess(this); - prosess->start(QString("dpkg -s ukui-control-center")); - prosess->waitForFinished(); - QString str = prosess->readAll(); - delete prosess; - QList strList = str.split('\n'); - QString version; - - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - } - } - if (version.startsWith("3.0")) { - QProcess::startDetached(QString("ukui-control-center -u")); - } else { - QProcess::startDetached(QString("ukui-control-center -m Userinfo")); - } + QProcess::startDetached(QString("ukui-control-center -m Userinfo")); } void SideBarWidget::userAccountsChanged() @@ -532,7 +481,7 @@ void SideBarWidget::userAccountsChanged() QString usericon = getUserIcon(); if (!QFile::exists(usericon)) { - usericon = QString("/usr/share/ukui/faces/default.png"); + usericon = QString(":/data/img/sidebarwidget/default.svg"); } QPixmap facePixmap(usericon); @@ -770,29 +719,25 @@ void SideBarWidget::btnFuncClickedSlot() void SideBarWidget::themeModeChangeSlot(QString styleName) { if (styleName == "styleName") { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); Q_FOREACH (QAbstractButton *button, m_buttonList) { QPushButton *btn = qobject_cast(button); QLayoutItem *item = btn->layout()->itemAt(0); QLabel *label = qobject_cast(item->widget()); QString iconStr; - QIcon buttIcon; switch (m_buttonList.indexOf(button)) { case 0: iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - buttIcon = QIcon::fromTheme("commonuse.svg"); break; case 1: iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - buttIcon = QIcon::fromTheme("letter.svg"); break; case 2: iconStr = QString(":/data/img/sidebarwidget/function.svg"); - buttIcon = QIcon::fromTheme("function.svg"); break; case 3: @@ -801,27 +746,22 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) case 4: iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - buttIcon = QIcon::fromTheme("personal.svg"); break; case 5: iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - buttIcon = QIcon::fromTheme("trash.svg"); break; case 6: iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - buttIcon = QIcon::fromTheme("computer.svg"); break; case 7: iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - buttIcon = QIcon::fromTheme("setting.svg"); break; case 8: iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - buttIcon = QIcon::fromTheme("shutdown.svg"); break; default: @@ -832,13 +772,7 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(iconStr, 19 * ratio); - if (buttIcon.isNull()) { - pixmap = loadSvg(iconStr, 19 * ratio); - } else { - pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); - } - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + if (gsetting->get("style-name").toString() == "ukui-light") { //反黑 pixmap = drawSymbolicBlackColoredPixmap(pixmap); } else { pixmap = drawSymbolicColoredPixmap(pixmap); //反白 @@ -853,29 +787,25 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) void SideBarWidget::changeIconColor(bool isFullScreen) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); Q_FOREACH (QAbstractButton *button, m_buttonList) { QPushButton *btn = qobject_cast(button); QLayoutItem *item = btn->layout()->itemAt(0); QLabel *label = qobject_cast(item->widget()); QString iconStr; - QIcon buttIcon; switch (m_buttonList.indexOf(button)) { case 0: iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - buttIcon = QIcon::fromTheme("commonuse.svg"); break; case 1: iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - buttIcon = QIcon::fromTheme("letter.svg"); break; case 2: iconStr = QString(":/data/img/sidebarwidget/function.svg"); - buttIcon = QIcon::fromTheme("function.svg"); break; case 3: @@ -884,27 +814,22 @@ void SideBarWidget::changeIconColor(bool isFullScreen) case 4: iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - buttIcon = QIcon::fromTheme("personal.svg"); break; case 5: iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - buttIcon = QIcon::fromTheme("trash.svg"); break; case 6: iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - buttIcon = QIcon::fromTheme("computer.svg"); break; case 7: iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - buttIcon = QIcon::fromTheme("setting.svg"); break; case 8: iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - buttIcon = QIcon::fromTheme("shutdown.svg"); break; default: @@ -913,15 +838,9 @@ void SideBarWidget::changeIconColor(bool isFullScreen) if (m_buttonList.indexOf(button) != 3) { const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(iconStr, 19 * ratio); + QPixmap pixmap = loadSvg(iconStr, 18 * ratio); - if (buttIcon.isNull()) { - pixmap = loadSvg(iconStr, 19 * ratio); - } else { - pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); - } - - if (gsetting.get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 + if (gsetting->get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 pixmap = drawSymbolicBlackColoredPixmap(pixmap); } else { pixmap = drawSymbolicColoredPixmap(pixmap); //反白 @@ -992,7 +911,7 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Down: - myDebug() << "key_Down"; + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down"; // focusNextChild(); // if(m_buttonList.at(2)->hasFocus()) // { @@ -1005,7 +924,7 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Up: - myDebug() << "key_Up"; + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up"; // /* focusPreviousChild(); // if(m_buttonList.at(0)->hasFocus()) // { diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h old mode 100644 new mode 100755 index 35fb1c2..6e800d1 --- a/src/SideBarWidget/sidebarwidget.h +++ b/src/SideBarWidget/sidebarwidget.h @@ -124,7 +124,7 @@ protected: * @brief Add right-click menu * @param btn: QPushButton */ - void addRightClickMenu(QPushButton *btn); +// void addRightClickMenu(QPushButton* btn); /** * @brief Set the minimize button */ @@ -160,7 +160,7 @@ private Q_SLOTS: /** * @brief Load other application right-click menu */ - void otherBtnRightClickSlot(const QPoint &pos); +// void otherBtnRightClickSlot(const QPoint &pos); /** * @brief Respond to computer btn */ @@ -242,8 +242,6 @@ Q_SIGNALS: void setFocusToMainWin(); void setSlideBar(int value); - - void setLineEditFocus(QString arg); }; #endif // SIDEBARWIDGET_H diff --git a/src/Style/style.cpp b/src/Style/style.cpp old mode 100644 new mode 100755 index 3397119..71719e8 --- a/src/Style/style.cpp +++ b/src/Style/style.cpp @@ -22,484 +22,509 @@ Style::Style() { + } -int Style::primaryScreenX = 0; -int Style::primaryScreenY = 0; -int Style::primaryScreenWidth = 0; -int Style::primaryScreenHeight = 0; -int Style::panelPosition = 0; -int Style::panelSize = 0; +int Style::primaryScreenX=0; +int Style::primaryScreenY=0; +int Style::primaryScreenWidth=0; +int Style::primaryScreenHeight=0; +int Style::panelPosition=0; +int Style::panelSize=0; //默认窗口 -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::defaultIconSize = 32; +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::defaultIconSize=32; /** * 全屏窗口 */ //主窗口 -int Style::widthavailable = 0; -int Style::heightavailable = 0; +int Style::widthavailable=0; +int Style::heightavailable=0; //主视图 -int Style::MainViewWidWidth = 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::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::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::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::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; //侧边栏primaryScreen -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; +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() { - getScreenAvailableGeometry(); - int fontSize = 10; - if (QGSettings::isSchemaInstalled(QString("org.mate.interface").toLocal8Bit())) { - QGSettings *setting = new QGSettings(QString("org.mate.interface").toLocal8Bit()); - if (setting->keys().contains(QString("font-name"))) { - QString value = setting->get("font-name").toString(); - QStringList valstr = value.split(" "); - fontSize = valstr.at(valstr.count() - 1).toInt(); - } + QVariantList list=getScreenGeometry(); + if(list.count()>=6) + { + primaryScreenX=list.at(0).toInt(); + primaryScreenY=list.at(1).toInt(); + primaryScreenWidth=list.at(2).toInt(); + primaryScreenHeight=list.at(3).toInt(); + panelSize=list.at(4).toInt(); + panelPosition=list.at(5).toInt(); } - int len = 0; + 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(); + + if(panelPosition==0 || panelPosition==1) + { + widthavailable=primaryScreenWidth; + heightavailable=primaryScreenHeight-panelSize; + } + if(panelPosition==2 || panelPosition==3) + { + widthavailable=primaryScreenWidth-panelSize; + heightavailable=primaryScreenHeight; + } + int len=0; QString locale = QLocale::system().name(); + if (locale == "zh_CN") + len=0; + else + len=10; - if (locale == "zh_CN") { - len = 0; - } else { - len = 10; + if(primaryScreenWidth==800 && primaryScreenHeight==600) + { + minw=320; + minh=500; + defaultMainViewWidWidth=264; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=245; + defaultQueryLineEditHeight=30; + defaultContentWidHeight=446; + defaultSideBarWidWidth=55; + } + else + { + minw=376; + minh=590; + defaultMainViewWidWidth=320; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=288; + defaultQueryLineEditHeight=30; + defaultContentWidHeight=536; + defaultSideBarWidWidth=55; } - primaryScreenWidth = qApp->primaryScreen()->geometry().width(); - primaryScreenHeight = qApp->primaryScreen()->geometry().height(); + if(widthavailable>=2000 && widthavailable<=4000) + { + MainViewWidWidth=widthavailable-round((widthavailable-1644)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + LeftWidWidth=round((widthavailable-1644)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=20; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=14; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=15; + AppListWidWidth=1644; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=96; + AppListItemSizeWidth=168; + AppListGridSizeWidth=204; + AppLeftSpace=36; + AppTopSpace=15; + AppSpaceBetweenIconText=20; +// AppBottomSpace=27; + SliderSize=12; - if (primaryScreenWidth == 800 && primaryScreenHeight == 600) { - minw = 320; - minh = 500; - defaultMainViewWidWidth = 264; - defaultTopWidHeight = 54; - defaultQueryLineEditWidth = 245; - defaultQueryLineEditHeight = 32; - defaultContentWidHeight = 446; - defaultSideBarWidWidth = 55; - } else { - minw = 382; - minh = 594; - defaultMainViewWidWidth = 320; - defaultTopWidHeight = 54; - defaultQueryLineEditWidth = 288; - defaultQueryLineEditHeight = 32; - defaultContentWidHeight = 536; - defaultSideBarWidWidth = 55; + SideBarWidWidth=round((widthavailable-1644)/2); + SideBarMargin=20; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; } + else if (widthavailable>=1920 && widthavailable<2000) { + MainViewWidWidth=widthavailable-round((widthavailable-1314)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + LeftWidWidth=round((widthavailable-1314)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=20; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=14; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=15; + AppListWidWidth=1314; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=186; + AppLeftSpace=32; + AppTopSpace=13; + AppSpaceBetweenIconText=18; +// AppBottomSpace=27; + SliderSize=12; - if (widthavailable >= 2000 && widthavailable <= 4000) { - AppListWidWidth = 1652; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 16; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 20; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 14; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 15; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 96; - AppListItemSizeWidth = 168; - AppListGridSizeWidth = 202; - AppLeftSpace = 36; - AppTopSpace = 15; - AppSpaceBetweenIconText = 20; -// AppBottomSpace=27; - SliderSize = 20; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 20; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1920 && widthavailable < 2000) { - myDebug() << "[1920,2000)"; - AppListWidWidth = 1322; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 16; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 20; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 14; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 15; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - AppListGridSizeWidth = 186; - AppLeftSpace = 32; - AppTopSpace = 13; - AppSpaceBetweenIconText = 18; -// AppBottomSpace=27; - SliderSize = 20; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 20; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1600 && widthavailable < 1920) { - myDebug() << "[1600,1920)"; - AppListWidWidth = 1070; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - AppListGridSizeWidth = 178; - AppLeftSpace = 32; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SideBarWidWidth=round((widthavailable-1314)/2); + SideBarMargin=20; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1600 && widthavailable<1920) { + MainViewWidWidth=widthavailable-round((widthavailable-1090)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-1090)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=1090; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=180; + AppLeftSpace=32; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.84)); - SliderSize = 18; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1366 && widthavailable < 1600) { - AppListWidWidth = 858; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 138; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 0; + SliderSize=10; + + SideBarWidWidth=round((widthavailable-1090)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1366 && widthavailable<1600) { + MainViewWidWidth=widthavailable-round((widthavailable-850)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-850)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=850; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=140; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=0; // AppBottomSpace=static_cast(round(27*0.74)); - SliderSize = 18; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1280 && widthavailable < 1366) { - AppListWidWidth = 726; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 140; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=10; + + SideBarWidWidth=round((widthavailable-850)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1280 && widthavailable<1366) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-718)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=142; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.65)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1152 && widthavailable < 1280) { - AppListWidWidth = 726; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 140; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-718)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1152 && widthavailable<1280) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-718)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=142; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.65)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable > 800 && widthavailable < 1152) { - AppListWidWidth = 580; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 139; - AppLeftSpace = 25; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-718)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>800 && widthavailable<1152){ + MainViewWidWidth=widthavailable-round((widthavailable-572)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-572)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=572; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=141; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.52)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else { - AppListWidWidth = 568; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 136; - AppLeftSpace = 25; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-572)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else{ + MainViewWidWidth=widthavailable-round((widthavailable-560)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-560)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=560; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=138; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.52)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } + SliderSize=8; - QueryLineEditWidth = 350; - QueryLineEditHeight = 32; - LeftFontSize = fontSize; - QueryLineEditFontSize = fontSize; - AppListFontSize = fontSize; -} - -//不通过任务栏获取屏幕可用区域数据 -void Style::getScreenAvailableGeometry() -{ - QRect rect; - rect = qApp->primaryScreen()->geometry(); - - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - if (reply.isValid()) { - panelSize = reply.value().at(4).toInt(); - panelPosition = reply.value().at(5).toInt(); - } - - QList posIndex; - switch (panelPosition) { - case BOTTOM: - posIndex = {0, 0, 0, -1}; - break; - case TOP: - posIndex = {0, 1, 0, -1}; - break; - case LEFT: - posIndex = {1, 0, -1, 0}; - break; - case RIGHT: - posIndex = {0, 0, -1, 0}; - } - - primaryScreenX = rect.x() + posIndex[0] * panelSize; - primaryScreenY = rect.y() + posIndex[1] * panelSize; - widthavailable = rect.width() + posIndex[2] * panelSize; - heightavailable = rect.height() + posIndex[3] * panelSize; + SideBarWidWidth=round((widthavailable-560)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } } diff --git a/src/Style/style.h b/src/Style/style.h old mode 100644 new mode 100755 index c5ef25c..548a846 --- a/src/Style/style.h +++ b/src/Style/style.h @@ -27,7 +27,6 @@ #include #include #include -#include //颜色 #define BORDERCOLOR "rgba(37,41,43)" //边框 @@ -166,9 +165,6 @@ public: static int SideBarSpaceIconText; //按钮图标与文字内边距 static int SideBarSpaceBetweenItem; //item间距 -private: - static void getScreenAvailableGeometry(); //获取屏幕可用区域 - }; #endif // STYLE_H diff --git a/src/UtilityFunction/classifybtnscrollarea.cpp b/src/UtilityFunction/classifybtnscrollarea.cpp old mode 100644 new mode 100755 index 26a37da..ea0e400 --- a/src/UtilityFunction/classifybtnscrollarea.cpp +++ b/src/UtilityFunction/classifybtnscrollarea.cpp @@ -22,8 +22,7 @@ #include #include -ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): - QWidget(parent) +ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); @@ -31,8 +30,9 @@ ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); + double transparency=getTransparency(); QPainter painter(this); + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); @@ -62,10 +62,10 @@ void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) // } // } // else{ - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } QWidget::paintEvent(event); } diff --git a/src/UtilityFunction/classifybtnscrollarea.h b/src/UtilityFunction/classifybtnscrollarea.h old mode 100644 new mode 100755 index 797c7e8..41b9bb2 --- a/src/UtilityFunction/classifybtnscrollarea.h +++ b/src/UtilityFunction/classifybtnscrollarea.h @@ -25,17 +25,17 @@ class ClassifyBtnScrollAreaWid: public QWidget { public: - ClassifyBtnScrollAreaWid(QWidget *parent = nullptr); + ClassifyBtnScrollAreaWid(); protected: - void paintEvent(QPaintEvent *event); - // void keyPressEvent(QKeyEvent* e); + void paintEvent(QPaintEvent* event); + // void keyPressEvent(QKeyEvent* e); }; class ClassifyBtnScrollArea : public QScrollArea { public: - explicit ClassifyBtnScrollArea(QWidget *parent = nullptr); + explicit ClassifyBtnScrollArea(QWidget* parent=nullptr); protected: void initWid(); diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp old mode 100644 new mode 100755 index cbea3f1..672f8d1 --- a/src/UtilityFunction/convertdesktoptowinid.cpp +++ b/src/UtilityFunction/convertdesktoptowinid.cpp @@ -32,7 +32,7 @@ QString ConvertDesktopToWinId::tranIdToDesktop(WId id) { KWindowInfo info(id, 0, NET::WM2AllProperties); QString desktopName = confirmDesktopFile(info); - myDebug() << "desktopName is :" << desktopName; + qDebug() << "desktopName is :" << desktopName; return desktopName; } diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/UtilityFunction/convertdesktoptowinid.h old mode 100644 new mode 100755 index 671672e..09d99f4 --- a/src/UtilityFunction/convertdesktoptowinid.h +++ b/src/UtilityFunction/convertdesktoptowinid.h @@ -36,11 +36,10 @@ #define ANDROID_APP_CURRENT "/.local/share/applications/." #define ANDROID_APP_UPER "/.local/share/applications/.." - /** * @brief The ConvertDesktopToWinId class * 需要实现的功能,desktop文件与windowId的转换 - * 传入desktop文件的路径,转化为(int)WindowId + * 传入WindowId 转化为desktop文件路径 */ class ConvertDesktopToWinId: public QObject diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UtilityFunction/fullitemdelegate.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp old mode 100644 new mode 100755 index 7755089..9bc0aa3 --- a/src/UtilityFunction/fulllistview.cpp +++ b/src/UtilityFunction/fulllistview.cpp @@ -28,11 +28,14 @@ FullListView::FullListView(QWidget *parent, int module): { this->module = module; initWidget(); +// inCurView = false; m_ukuiMenuInterface = new UkuiMenuInterface; +// menu=new RightClickMenu; } FullListView::~FullListView() { +// delete menu; if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -42,6 +45,8 @@ FullListView::~FullListView() void FullListView::initWidget() { viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setStyleSheet("background:transparent");//在paint中绘制,滚动页面会导致透明效果绘制不及时出现黑影,将paintEvent替换为样式表 + this->setAutoFillBackground(false); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // if(module==1 || module==2)s @@ -55,17 +60,24 @@ void FullListView::initWidget() this->setMovement(QListView::Static); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); - myDebug() << "GridSize" << this->gridSize(); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame);//移除边框 this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); connect(this, &FullListView::clicked, this, &FullListView::onClicked); + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); + } + }); } void FullListView::addData(QStringList data) { - myDebug() << "FullListView::addData"; listmodel = new QStandardItemModel(this); this->setModel(listmodel); @@ -81,17 +93,18 @@ void FullListView::addData(QStringList data) void FullListView::focusInEvent(QFocusEvent *event) { + //inCurView = true; return QListView::focusInEvent(event); } void FullListView::focusOutEvent(QFocusEvent *event) { + //inCurView = false; return QListView::focusOutEvent(event); } void FullListView::updateData(QStringList data) { - myDebug() << "FullListView::updateData"; listmodel->clear(); Q_FOREACH (QString desktopfp, data) { @@ -99,8 +112,6 @@ void FullListView::updateData(QStringList data) item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); listmodel->appendRow(item); } - - this->setItemDelegate(m_delegate); } void FullListView::onClicked(QModelIndex index) @@ -183,77 +194,135 @@ void FullListView::leaveEvent(QEvent *e) void FullListView::selectFirstItem() { + qDebug() << "void FullListView::selectFirstItem()"; + if (this->currentIndex().row() == -1) { this->setCurrentIndex(this->model()->index(0, 0)); } } +//void FullListView::paintEvent(QPaintEvent *e) +//{ +// double transparency=getTransparency(); +// QPainter painter(this->viewport()); + +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting.keys().contains(QString("effect"))) +// { +// if(gsetting.get("effect").toBool()) +// { +// painter.setBrush(Qt::black); +// painter.setPen(Qt::transparent); +// painter.setOpacity(0.25); +// painter.drawRect(this->rect()); +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// QListView::paintEvent(e); +//} void FullListView::keyPressEvent(QKeyEvent *e) { - QRect center = visualRect(currentIndex()); + if (flag) { //避免长按按键界面滚动过快 + flag = false; + time->start(100); + QRect center = visualRect(currentIndex()); - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - case Qt::Key_Left: { - if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Left: { + this->clearFocus(); - case Qt::Key_Right: { - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Up: { - if (module == 0) { - if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { + if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Right: { + this->clearFocus(); - case Qt::Key_Down: { - if (module == 0) { if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Up: { + if (module == 0) { + if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { + this->clearFocus(); + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + this->setFocus(); + } + } - default: - return QListView::keyPressEvent(e); - break; + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Down: { + if (module == 0) { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { + this->clearFocus(); + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + this->setFocus(); + } + } + + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } } } } -void FullListView::mouseReleaseEvent(QMouseEvent *event) +void FullListView::mousePressEvent(QMouseEvent *event) { if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { Q_EMIT sendHideMainWindowSignal(); } else { - return QListView::mouseReleaseEvent(event); + return QListView::mousePressEvent(event); } } diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h old mode 100644 new mode 100755 index 4e4be10..c5c87d5 --- a/src/UtilityFunction/fulllistview.h +++ b/src/UtilityFunction/fulllistview.h @@ -41,14 +41,13 @@ public: protected: void initWidget(); - void keyPressEvent(QKeyEvent *e); void enterEvent(QEvent *e) Q_DECL_OVERRIDE; void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; - +// void paintEvent(QPaintEvent *e) override; void focusInEvent(QFocusEvent *event); void focusOutEvent(QFocusEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); private: FullItemDelegate *m_delegate = nullptr; @@ -57,9 +56,11 @@ private: double transparency; RightClickMenu *menu = nullptr; //右键菜单 QStringList data; - QGSettings *gsetting; UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + bool flag; + QTimer *time = nullptr; + // bool inCurView; public Q_SLOTS: diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/src/UtilityFunction/functionclassifybutton.cpp old mode 100644 new mode 100755 index 8d7527d..21ee26a --- a/src/UtilityFunction/functionclassifybutton.cpp +++ b/src/UtilityFunction/functionclassifybutton.cpp @@ -24,84 +24,83 @@ #include FunctionClassifyButton::FunctionClassifyButton(int width, - int height, - int iconSize, - QString category, - bool fullscreen, - bool enabled, - QWidget *parent): - QPushButton(parent), + int height, + int iconSize, + QString category, + bool fullscreen, + bool enabled, + QWidget *parent): + QPushButton (parent), m_width(width), m_height(height), m_iconSize(iconSize), m_category(category), m_fullscreen(fullscreen), m_enabled(enabled), - m_iconLabel(new QLabel(this)), - m_textLabel(new QLabel(this)) + m_iconLabel(new QLabel), + m_textLabel(new QLabel) { this->setFlat(true); - this->setFixedSize(m_width, m_height); + this->setFixedSize(m_width,m_height); this->setFocusPolicy(Qt::NoFocus); - m_iconLabel->setFixedSize(m_iconSize, m_iconSize); + m_iconLabel->setFixedSize(m_iconSize,m_iconSize); m_textLabel->adjustSize(); - - if (m_fullscreen) { + if(m_fullscreen) + { QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::ButtonText, QColor(Qt::white)); + pe.setColor(QPalette::ButtonText,QColor(Qt::white)); m_textLabel->setPalette(pe); } - - m_textLabel->setText(m_category); - - if (m_fullscreen) { + setLabelText(); + if(m_fullscreen) + { updateIconState(Normal); this->setCheckable(true); - } else { - if (m_enabled) { + } + else + { + if(m_enabled) updateIconState(Enabled); - } else { + else updateIconState(Disabled); - } - this->setCheckable(false); } - QHBoxLayout *mainlayout = new QHBoxLayout; - mainlayout->setContentsMargins(Style::LeftSpaceIconLeft, 0, 0, 0); + QHBoxLayout* mainlayout=new QHBoxLayout; + mainlayout->setContentsMargins(Style::LeftSpaceIconLeft,0,0,0); mainlayout->setSpacing(Style::LeftSpaceIconText); this->setLayout(mainlayout); - //mainlayout->addWidget(m_iconLabel); + mainlayout->addWidget(m_iconLabel); mainlayout->addWidget(m_textLabel); - connect(this, &FunctionClassifyButton::toggled, this, &FunctionClassifyButton::reactToToggle); - connect(this, &FunctionClassifyButton::clicked, this, &FunctionClassifyButton::buttonClickedSlot); + connect(this,&FunctionClassifyButton::toggled,this,&FunctionClassifyButton::reactToToggle); + connect(this,&FunctionClassifyButton::clicked,this,&FunctionClassifyButton::buttonClickedSlot); } -void FunctionClassifyButton::paintEvent(QPaintEvent *e) +void FunctionClassifyButton::paintEvent(QPaintEvent* e) { Q_UNUSED(e); QStylePainter painter(this); QStyleOptionButton option; initStyleOption(&option); - if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { painter.save(); painter.setPen(Qt::NoPen); - - if (!m_fullscreen) { + if(!m_fullscreen) + { QColor color = option.palette.color(QPalette::Text); color.setAlphaF(0.15); painter.setBrush(color); - } else { + } + else + { painter.setOpacity(0.15); painter.setBrush(Qt::white); } - painter.drawRoundedRect(option.rect, 4, 4); painter.restore(); } - - if (m_fullscreen && (option.state & QStyle::State_On)) { + if(m_fullscreen && (option.state & QStyle::State_On)) + { painter.save(); painter.setPen(Qt::NoPen); // QColor color = option.palette.color(QPalette::Text); @@ -122,18 +121,17 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e) void FunctionClassifyButton::updateBtnState() { - if (m_enabled) { + if(m_enabled) updateIconState(Enabled); - } else { + else updateIconState(Disabled); - } } void FunctionClassifyButton::enterEvent(QEvent *e) { Q_UNUSED(e); - - if (m_enabled) { + if(m_enabled) + { updateIconState(Checked); } } @@ -141,26 +139,26 @@ void FunctionClassifyButton::enterEvent(QEvent *e) void FunctionClassifyButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - - if (m_fullscreen) { - if (!isChecked()) { + if(m_fullscreen) + { + if(!isChecked()) updateIconState(Normal); - } - } else { - if (m_enabled) { + } + else + { + if(m_enabled) updateIconState(Enabled); - } } } void FunctionClassifyButton::reactToToggle(bool checked) { - if (m_fullscreen) { - if (checked) { + if(m_fullscreen) + { + if(checked) updateIconState(Checked); - } else { + else updateIconState(Normal); - } } } @@ -173,90 +171,131 @@ void FunctionClassifyButton::updateIconState() { this->setFlat(true); QString picState; - - switch (m_state) { - case Enabled: - picState = "Enabled"; - break; - - case Disabled: - picState = "Disabled"; - break; - - case Normal: - picState = "Normal"; - break; - - case Checked: - picState = "Checked"; - break; - - default: - break; + switch (m_state) + { + case Enabled: picState="Enabled"; break; + case Disabled: picState="Disabled"; break; + case Normal: picState="Normal"; break; + case Checked: picState="Checked"; break; + default: break; } + + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_iconLabel->setPixmap(pixmap); } void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) { - if (state == m_state) { + if (state == m_state) return; - } - m_state = state; + QString picState; - - switch (state) { - case Enabled: - picState = "Enabled"; - break; - - case Disabled: - picState = "Disabled"; - break; - - case Normal: - picState = "Normal"; - break; - - case Checked: - picState = "Checked"; - break; - - default: - break; + switch (state) + { + case Enabled: picState="Enabled"; break; + case Disabled: picState="Disabled"; break; + case Normal: picState="Normal"; break; + case Checked: picState="Checked"; break; + default: break; } + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + if(!m_fullscreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + } + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_iconLabel->setPixmap(pixmap); updateTextState(state); } void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State state) { // QPalette p= m_textLabel->palette(); - switch (state) { - case Enabled: + switch (state) + { + case Enabled: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); - break; - - case Disabled: + break; + case Disabled: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);"); - break; - - case Normal: + break; + case Normal: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);"); - break; - - case Checked: + break; + case Checked: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); // m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); - break; - - default: - break; + break; + default: + break; } - // p.setColor(QPalette::Window,Qt::transparent); // m_textLabel->setPalette(p); } + +void FunctionClassifyButton::setLabelText() +{ + QMetaEnum metaEnum=QMetaEnum::fromType(); + switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) { + case Mobile: + m_textLabel->setText(tr("Mobile")); + break; + case Internet: + m_textLabel->setText(tr("Internet")); + break; + case Social: + m_textLabel->setText(tr("Social")); + break; + case Video: + m_textLabel->setText(tr("Video")); + break; + case Development: + m_textLabel->setText(tr("Development")); + break; + case Image: + m_textLabel->setText(tr("Image")); + break; + case Game: + m_textLabel->setText(tr("Game")); + break; + case Office: + m_textLabel->setText(tr("Office")); + break; + case Education: + m_textLabel->setText(tr("Education")); + break; + case System: + m_textLabel->setText(tr("System")); + break; + default: + m_textLabel->setText(tr("Others")); + break; + } +} diff --git a/src/UtilityFunction/functionclassifybutton.h b/src/UtilityFunction/functionclassifybutton.h old mode 100644 new mode 100755 index 0e311a8..1b80037 --- a/src/UtilityFunction/functionclassifybutton.h +++ b/src/UtilityFunction/functionclassifybutton.h @@ -63,7 +63,6 @@ public: Office, Education, System, - Safe, Others, }; Q_ENUM(Category) @@ -87,6 +86,7 @@ protected: void paintEvent(QPaintEvent* e); void updateIconState(const State state); void updateTextState(const State state); + void setLabelText(); Q_SIGNALS: void buttonClicked(); diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/itemdelegate.h b/src/UtilityFunction/itemdelegate.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/letterclassifybutton.h b/src/UtilityFunction/letterclassifybutton.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp old mode 100644 new mode 100755 index fccbc4a..f554276 --- a/src/UtilityFunction/listview.cpp +++ b/src/UtilityFunction/listview.cpp @@ -29,10 +29,12 @@ ListView::ListView(QWidget *parent, int width, int height, int module): this->module = module; initWidget(); m_ukuiMenuInterface = new UkuiMenuInterface; - menu = new RightClickMenu(this); + menu = new RightClickMenu; } ListView::~ListView() { + delete menu; + if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -191,7 +193,8 @@ void ListView::paintEvent(QPaintEvent *e) painter.fillRect(this->rect(), this->palette().base()); //滚动条 QPalette p = this->verticalScrollBar()->palette(); - QColor color = p.color(QPalette::Light); + QColor color(255, 255, 255); +// QColor color=p.color(QPalette::Active,QPalette::Button); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp old mode 100644 new mode 100755 index 8fbc0dc..0ffa9ef --- a/src/UtilityFunction/proxystyle.cpp +++ b/src/UtilityFunction/proxystyle.cpp @@ -21,10 +21,11 @@ ProxyStyle::ProxyStyle() { - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - connect(&gsetting, &QGSettings::changed, this, [ = ] { - for (auto widget : QApplication::allWidgets()) + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + for(auto widget: QApplication::allWidgets()) { widget->update(); } @@ -34,31 +35,32 @@ ProxyStyle::ProxyStyle() QPalette ProxyStyle::standardPalette() const { - auto m_palette = QProxyStyle::standardPalette(); + auto m_palette=QProxyStyle::standardPalette(); QColor m_highlightbg; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting->keys().contains(QString("styleName"))) { - if (gsetting->get("style-name").toString() == "ukui-light") { - m_highlightbg = QColor(0, 0, 0); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + if(gsetting->keys().contains(QString("styleName"))) + { + if(gsetting->get("style-name").toString()=="ukui-light") + { + m_highlightbg=QColor(0, 0, 0); m_highlightbg.setAlphaF(0.15); - } else { - m_highlightbg = QColor(255, 255, 255); + } + else + { + m_highlightbg=QColor(255,255,255); m_highlightbg.setAlphaF(0.14); } } - - m_palette.setBrush(QPalette::Highlight, m_highlightbg); + m_palette.setBrush(QPalette::Highlight,m_highlightbg); return m_palette; } - return m_palette; } void ProxyStyle::polish(QPalette &pal) { - pal = standardPalette(); + pal=standardPalette(); // QProxyStyle::polish(pal); } diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/scrollarea.cpp b/src/UtilityFunction/scrollarea.cpp old mode 100644 new mode 100755 index 9c2c543..3d9bee5 --- a/src/UtilityFunction/scrollarea.cpp +++ b/src/UtilityFunction/scrollarea.cpp @@ -22,8 +22,7 @@ #include #include "utility.h" -ScrollAreaWid::ScrollAreaWid(QWidget *parent): - QWidget(parent) +ScrollAreaWid::ScrollAreaWid() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); @@ -31,8 +30,9 @@ ScrollAreaWid::ScrollAreaWid(QWidget *parent): void ScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); + double transparency=getTransparency(); QPainter painter(this); + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); @@ -64,33 +64,30 @@ void ScrollAreaWid::paintEvent(QPaintEvent *event) // } // else // { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } QWidget::paintEvent(event); } -ScrollArea::ScrollArea(QWidget *parent): - QScrollArea(parent) +ScrollArea::ScrollArea() { this->verticalScrollBar()->setVisible(false); this->setFocusPolicy(Qt::NoFocus); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame); - this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //滚动条设置 - QPalette p = this->verticalScrollBar()->palette(); - QColor color = p.color(QPalette::Light); + QPalette p=this->verticalScrollBar()->palette(); + QColor color(255, 255, 255); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); - this->setStyleSheet("QWidget{background:transparent;}QScrollBar:vertical{" - "background:none}"); } void ScrollArea::setFocusToNextChild() @@ -138,8 +135,10 @@ void ScrollArea::leaveEvent(QEvent *e) void ScrollArea::scrollContentsBy(int dx, int dy) { - QScrollArea::scrollContentsBy(dx, dy); + QScrollArea::scrollContentsBy(dx,dy); + Q_EMIT requestUpdate(); + // update(); // viewport()->update(); } diff --git a/src/UtilityFunction/scrollarea.h b/src/UtilityFunction/scrollarea.h old mode 100644 new mode 100755 index e4f6d8c..730ccc0 --- a/src/UtilityFunction/scrollarea.h +++ b/src/UtilityFunction/scrollarea.h @@ -28,17 +28,17 @@ class ScrollAreaWid: public QWidget { public: - ScrollAreaWid(QWidget *parent = nullptr); + ScrollAreaWid(); protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent* event); }; class ScrollArea : public QScrollArea { Q_OBJECT public: - ScrollArea(QWidget *parent = nullptr); + ScrollArea(); void setFocusToNextChild(); void setFocusToPreChild(); @@ -46,8 +46,8 @@ Q_SIGNALS: void requestUpdate(); protected: - void enterEvent(QEvent *e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; + void enterEvent(QEvent* e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; // void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; void scrollContentsBy(int dx, int dy) override; diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.cpp b/src/UtilityFunction/softwaredatabaseupdatethread.cpp deleted file mode 100644 index 68429d2..0000000 --- a/src/UtilityFunction/softwaredatabaseupdatethread.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "softwaredatabaseupdatethread.h" -#include -#include -#include -#include -#include -#include -#include "src/UtilityFunction/utility.h" - -#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" - -SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent): - QThread(parent) -{ -} - -SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread() -{ -} - -void SoftwareDatabaseUpdateThread::run() -{ - QSqlDatabase db; - db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase"); - db.setDatabaseName(DATABASENAME); - - if (false == db.open()) { - qDebug() << db.lastError().text(); - } - - QSqlQuery sql(db); - QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data()); - QJsonObject jsonObject = jsonDocument.object(); - QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray(); - - int number = 0; - db.transaction(); - - Q_FOREACH(QJsonValue jsonValue, jsonArray){ - QJsonObject arrObject = jsonValue.toObject(); - QString execline = QString("replace into appCategory values(\"%0\", \"%1\", \"%2\")") - .arg(arrObject[arrObject.keys()[0]].toString()) - .arg(arrObject[arrObject.keys()[1]].toString()) - .arg(arrObject[arrObject.keys()[2]].toString()); - sql.exec(execline); - - ++number; - if (number % 5000 == 0) { - db.commit(); - db.transaction(); - } - } - db.commit(); - - myDebug() << "数据库已经更新"; - Q_EMIT updateDatabaseSignal(); -} - -void SoftwareDatabaseUpdateThread::getDatabaseList(QString category) -{ - this->m_category = category; -} diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h deleted file mode 100644 index 44b460d..0000000 --- a/src/UtilityFunction/softwaredatabaseupdatethread.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SOFTWAREDATABASEUPDATETHREAD_H -#define SOFTWAREDATABASEUPDATETHREAD_H - -#include -#include -#include -#include -#include -#include -#include - -class SoftwareDatabaseUpdateThread: public QThread -{ - Q_OBJECT -public: - SoftwareDatabaseUpdateThread(QObject *parent = nullptr); - ~SoftwareDatabaseUpdateThread(); - void run(); - void getDatabaseList(QString category); -Q_SIGNALS: - void updateDatabaseSignal(); - -private: - QString m_category; -}; - -#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/UtilityFunction/splitbarframe.cpp b/src/UtilityFunction/splitbarframe.cpp old mode 100644 new mode 100755 index 68f5999..6a9b517 --- a/src/UtilityFunction/splitbarframe.cpp +++ b/src/UtilityFunction/splitbarframe.cpp @@ -24,8 +24,8 @@ SplitBarFrame::SplitBarFrame(QWidget *parent, QString category, int width, int h m_width(width), m_height(height), m_module(module), - m_textLabel(new QLabel(this)), - m_line(new QFrame(this)) + m_textLabel(new QLabel), + m_line(new QFrame) { initAppBtn(); } @@ -35,32 +35,78 @@ SplitBarFrame::~SplitBarFrame() } void SplitBarFrame::initAppBtn() -{ - this->setFixedSize(m_width, m_height); +{ + this->setFixedSize(m_width,m_height); // this->setStyleSheet("background:transparent"); //按钮透明 this->setFocusPolicy(Qt::NoFocus); this->setAttribute(Qt::WA_TranslucentBackground); - QHBoxLayout *layout = new QHBoxLayout; - layout->setContentsMargins(15, 0, 0, 0); + QHBoxLayout* layout=new QHBoxLayout; + layout->setContentsMargins(15,0,0,0); layout->setSpacing(6); + m_textLabel->setAutoFillBackground(false); m_textLabel->setAlignment(Qt::AlignCenter); - m_textLabel->setText(m_category); + if(m_module==1) + m_textLabel->setText(m_category); + else + setLabelText(); m_textLabel->adjustSize(); - QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::WindowText, Qt::white); + QPalette pe=m_textLabel->palette(); + pe.setColor(QPalette::WindowText,Qt::white); m_textLabel->setPalette(pe); m_line->setFrameShape(QFrame::HLine); m_line->setFixedHeight(1); - m_line->setFixedSize(m_width - m_textLabel->width() - 5, 1); + m_line->setFixedSize(m_width-m_textLabel->width()-15,1); m_line->setEnabled(false); - QPalette linePe = m_line->palette(); - QColor color = linePe.color(QPalette::Dark); + QPalette linePe=m_line->palette(); + QColor color(255,255,255); color.setAlphaF(0.10); - linePe.setColor(QPalette::WindowText, color); + linePe.setColor(QPalette::WindowText,color); m_line->setPalette(linePe); + this->setLayout(layout); layout->addWidget(m_textLabel); layout->addWidget(m_line); } + +void SplitBarFrame::setLabelText() +{ + QMetaEnum metaEnum=QMetaEnum::fromType(); + switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) + { + case Mobile: + m_textLabel->setText(tr("Mobile")); + break; + case Internet: + m_textLabel->setText(tr("Internet")); + break; + case Social: + m_textLabel->setText(tr("Social")); + break; + case Video: + m_textLabel->setText(tr("Video")); + break; + case Development: + m_textLabel->setText(tr("Development")); + break; + case Image: + m_textLabel->setText(tr("Image")); + break; + case Game: + m_textLabel->setText(tr("Game")); + break; + case Office: + m_textLabel->setText(tr("Office")); + break; + case Education: + m_textLabel->setText(tr("Education")); + break; + case System: + m_textLabel->setText(tr("System")); + break; + default: + m_textLabel->setText(tr("Others")); + break; + } +} diff --git a/src/UtilityFunction/splitbarframe.h b/src/UtilityFunction/splitbarframe.h old mode 100644 new mode 100755 index de45c3d..ee33748 --- a/src/UtilityFunction/splitbarframe.h +++ b/src/UtilityFunction/splitbarframe.h @@ -51,7 +51,6 @@ public: Office, Education, System, - Safe, Others, }; Q_ENUM(Category) @@ -66,6 +65,7 @@ private: protected: void initAppBtn(); + void setLabelText(); }; #endif // PUSHBUTTON_H diff --git a/src/UtilityFunction/toolbutton.cpp b/src/UtilityFunction/toolbutton.cpp old mode 100644 new mode 100755 index 51b1f92..a0824ab --- a/src/UtilityFunction/toolbutton.cpp +++ b/src/UtilityFunction/toolbutton.cpp @@ -28,73 +28,58 @@ ToolButton::ToolButton(int width, int module, QString text) { - this->setFixedSize(width, height); - this->iconstr = iconstr; - this->piconstr = piconstr; - this->hoverbg = hoverbg; - this->pressedbg = pressedbg; - this->module = module; - this->text = text; + this->setFixedSize(width,height); + this->iconstr=iconstr; + this->piconstr=piconstr; + this->hoverbg=hoverbg; + this->pressedbg=pressedbg; + this->module=module; + this->text=text; + this->setFocusPolicy(Qt::StrongFocus); - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(iconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - if (module == 2) { + if(module==2) + { this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText(tr(text.toLocal8Bit().data())); // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); } - // else // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); } -ToolButton::~ToolButton() -{ - if (pixmap != nullptr) { - delete pixmap; - pixmap = nullptr; - } -} void ToolButton::enterEvent(QEvent *e) { Q_UNUSED(e); - QByteArray byte = hoverbg.toLocal8Bit(); - char *hover = byte.data(); + QByteArray byte=hoverbg.toLocal8Bit(); + char* hover=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); - } - + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); @@ -114,22 +99,17 @@ void ToolButton::leaveEvent(QEvent *e) // else // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); delete svgRender; - svgRender = new QSvgRenderer(this); - - if (module == 2 && is_pressed) { + svgRender=new QSvgRenderer(this); + if(module==2 && is_pressed) svgRender->load(piconstr); - } else { + else svgRender->load(iconstr); - } - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); @@ -138,74 +118,63 @@ void ToolButton::leaveEvent(QEvent *e) void ToolButton::mousePressEvent(QMouseEvent *event) { - QByteArray byte = pressedbg.toLocal8Bit(); - char *pressed = byte.data(); + QByteArray byte=pressedbg.toLocal8Bit(); + char* pressed=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", pressed); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", pressed); - } - - if (event->button() == Qt::LeftButton) { + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",pressed); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",pressed); + if(event->button()==Qt::LeftButton) + { // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - is_pressed = true; + + is_pressed=true; } } void ToolButton::mouseReleaseEvent(QMouseEvent *event) { - QByteArray byte = hoverbg.toLocal8Bit(); - char *hover = byte.data(); + QByteArray byte=hoverbg.toLocal8Bit(); + char* hover=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); - } - - if (event->button() == Qt::LeftButton) { + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); + if(event->button()==Qt::LeftButton) + { // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - - if (module == 2) { + if(module==2) Q_EMIT buttonClicked(this); - } else { + else Q_EMIT clicked(); - } } } diff --git a/src/UtilityFunction/toolbutton.h b/src/UtilityFunction/toolbutton.h old mode 100644 new mode 100755 index 24caaf7..8b1f07b --- a/src/UtilityFunction/toolbutton.h +++ b/src/UtilityFunction/toolbutton.h @@ -46,9 +46,8 @@ public: QString pressedbg, int module, QString text); - ~ToolButton(); - bool is_pressed = false; //记录功能分类模块点击状态 + bool is_pressed=false;//记录功能分类模块点击状态 private: QString iconstr; @@ -56,21 +55,21 @@ private: QString hoverbg; QString pressedbg; int module; - QLabel *label = nullptr; - QHBoxLayout *layout = nullptr; - QPixmap *pixmap = nullptr; - QSvgRenderer *svgRender = nullptr; + QLabel* label; + QHBoxLayout* layout; + QPixmap* pixmap; + QSvgRenderer* svgRender; QString text; protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); + void enterEvent(QEvent* e); + void leaveEvent(QEvent* e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); Q_SIGNALS: - void buttonClicked(QAbstractButton *btn); + void buttonClicked(QAbstractButton* btn); }; #endif // TOOLBUTTON_H diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp old mode 100644 new mode 100755 index 48a16f3..5bb639a --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -31,8 +31,7 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" bool isHuaWeiPC = false; -bool isHuaWei9006C = false; -QString projectCodeName = ""; +bool isPANGU = false; const QPixmap loadSvg(const QString &fileName, const int size) { @@ -99,6 +98,76 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) return QPixmap::fromImage(img); } +QRect getScreenAvailableGeometry() +{ + QRect rect; + QVariantList list; + list.clear(); + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenAvailableGeometry"); + + if (iface.isValid() && reply.isValid()) { + list = reply.value(); + rect = QRect(list.at(0).toInt(), list.at(1).toInt(), list.at(2).toInt(), list.at(3).toInt()); + } else { + rect = qApp->primaryScreen()->availableGeometry(); + } + + return rect; +} + +QVariantList getScreenGeometry() +{ + QVariantList list; + list.clear(); + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); + + if (iface.isValid() && reply.isValid()) { + list = reply.value(); + } else { + QRect rect = QApplication::desktop()->screenGeometry(0); + list.append(QString::number(rect.x())); + list.append(QString::number(rect.y())); + list.append(QString::number(rect.width())); + list.append(QString::number(rect.height())); + 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; + } + + delete gsetting; + } else { + position = 0; + panelSize = 46; + } + + list.append(QString::number(panelSize)); + list.append(QString::number(position)); + } + + return list; +} + double getTransparency() { double transparency = 0.0; @@ -130,6 +199,29 @@ void debugLog(QString strMsg) } } +QString getEnvOverriddenDesktopFile(int pid) +{ + QString ret; + QString path = QString("/proc/%1/environ") + .arg(pid); + QFile file(path); + + if (file.open(QIODevice::ReadOnly)) { + QList list = file.readLine().split('\x00'); + + Q_FOREACH (QByteArray array, list) { + if (array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) { + ret = QString(array.split('=').at(1)); + break; + } + } + + file.close(); + } + + return ret; +} + void openDataBase(QString connectionName) { QSqlDatabase db; @@ -143,7 +235,7 @@ void openDataBase(QString connectionName) void closeDataBase(QString connectionName) { - QSqlDatabase db = QSqlDatabase::database(connectionName); + QSqlDatabase db = QSqlDatabase::database("connectionName"); db.close(); QSqlDatabase::removeDatabase(connectionName); } @@ -152,21 +244,21 @@ void initDatabase() { QStringList desktopfnList; desktopfnList.clear(); - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); sql.exec("select count(*) from sqlite_master where type='table' and name='appInfo'"); if (sql.next()) { if (sql.value(0).toInt() == 0) { - QSettings setting("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); - setting.beginGroup("application"); + QSettings *setting = new QSettings("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); + setting->beginGroup("application"); QString desktopfp; - Q_FOREACH (QString desktopfn, setting.allKeys()) { - if (setting.value(desktopfn).toInt() == 1) { + Q_FOREACH (QString desktopfn, setting->allKeys()) { + if (setting->value(desktopfn).toInt() == 1) { desktopfp.clear(); - if (UkuiMenuInterface::m_androidDesktopfnList.contains(desktopfn)) { + if (UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) { desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); } else { desktopfp = QString("/usr/share/applications/" + desktopfn); @@ -174,7 +266,7 @@ void initDatabase() QFileInfo info(desktopfp); - if (!info.isFile() || !UkuiMenuInterface::m_desktopfpVector.contains(desktopfp)) { + if (!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) { continue; } @@ -182,7 +274,8 @@ void initDatabase() } } - setting.endGroup(); + setting->endGroup(); + delete setting; } } @@ -199,28 +292,12 @@ void initDatabase() .arg(0); sql.exec(cmd); } - - sql.exec("create table appCategory(app_name char primary key, name_en char, name_zh char)"); - sql.exec("insert into appCategory values('indicator-china-weather', '其他', 'others')"); - sql.exec("insert into appCategory values('peony', '其他', 'others')"); - sql.exec("insert into appCategory values('kylin-usb-creator', '其他', 'others')"); - sql.exec("insert into appCategory values('kylin-burner', '其他', 'others')"); - sql.exec("insert into appCategory values('sc-reader', '办公', 'office')"); - sql.exec("insert into appCategory values('kylin-scanner', '办公', 'office')"); - sql.exec("insert into appCategory values('onboard', '系统', 'system')"); - sql.exec("insert into appCategory values('evolution', '系统', 'system')"); - sql.exec("insert into appCategory values('kylin-screenshot', '系统', 'system')"); - sql.exec("insert into appCategory values('kylin-ipmsg', '网络', 'network')"); - sql.exec("insert into appCategory values('ksc-defender', '安全', 'safe')"); - sql.exec("insert into appCategory values('yhkylin-backup-tools', '安全', 'safe')"); - sql.exec("insert into appCategory values('box-manager', '安全', 'safe')"); - sql.exec("insert into appCategory values('ukui-system-monitor', '安全', 'safe')"); } bool updateDataBaseTableTimes(QString desktopfn) { bool ret = false; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; cmd = QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); @@ -248,13 +325,14 @@ bool updateDataBaseTableTimes(QString desktopfn) ret = sql.exec(cmd); } + qDebug() << "数据库更新应用使用频率成功"; return ret; } bool updateDataBaseTableType(QString desktopfn, int type) { bool ret = false; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; @@ -318,7 +396,7 @@ bool updateDataBaseTableRecent(QString desktopfn) bool checkIfLocked(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select type from appInfo where desktop=\"%1\"") .arg(desktopfn); @@ -340,7 +418,7 @@ bool checkIfLocked(QString desktopfn) bool checkIfRecent(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select recent from appInfo where desktop=\"%1\"") .arg(desktopfn); @@ -363,7 +441,7 @@ bool checkIfRecent(QString desktopfn) QStringList getLockAppList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select desktop from appInfo where type=1"); @@ -379,7 +457,7 @@ QStringList getLockAppList() QStringList getUnlockAllList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); @@ -394,7 +472,7 @@ QStringList getUnlockAllList() void cleanTimeoutApp() { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QDateTime dt = QDateTime::currentDateTime(); int datetime = dt.toTime_t() - 24 * 60 * 60 * 3; QString cmd = QString("select desktop from appInfo where time < %1") @@ -438,22 +516,18 @@ void execApp(QString desktopfp) QString appName = interface.getAppExec(desktopfp); QStringList strList = (appName.replace("\"", "")).split(" "); +// for(int i = 1; i < strList.size(); i++) +// { if (QString(strList.at(0)) == "kmplayer") { QProcess::startDetached(strList.at(0)); return; } +// } 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); } - - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - - if (desktopfn.startsWith("app.web.")) { - updateDataBaseTableTimes(desktopfn); - } } bool checkOsRelease() diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h old mode 100644 new mode 100755 index 1a5bc82..33fcc5a --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "src/Interface/ukuimenuinterface.h" @@ -32,13 +31,8 @@ #define DBUS_PATH "/panel/position" #define DBUS_INTERFACE "org.ukui.panel" -#define myDebug() qDebug() << QString("%1 %2 行 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__) -#define KFILENAME QString(__FILE__).mid(QString(__FILE__).lastIndexOf("/") + 1) -#define KFUNCNAME QString(__FUNCTION__) - extern bool isHuaWeiPC; -extern bool isHuaWei9006C; -extern QString projectCodeName; +extern bool isPANGU; const QPixmap loadSvg(const QString &fileName, const int size); @@ -51,7 +45,10 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); //调试日志 void debugLog(QString strMsg); +QVariantList getScreenGeometry(); +QRect getScreenAvailableGeometry(); double getTransparency(); +QString getEnvOverriddenDesktopFile(int pid); //数据库操作 void openDataBase(QString connectionName); void closeDataBase(QString connectionName); @@ -75,11 +72,5 @@ QString getUserIcon(); //获取用户姓名 QString getUserName(); -enum PanelPositon{ - BOTTOM = 0, - TOP = 1, - LEFT = 2, - RIGHT = 3 -}; #endif // UTILITY_H diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo.ts old mode 100644 new mode 100755 similarity index 54% rename from translations/ukui-menu_bo_CN.ts rename to translations/ukui-menu_bo.ts index f3b9875..52e731e --- a/translations/ukui-menu_bo_CN.ts +++ b/translations/ukui-menu_bo.ts @@ -1,302 +1,292 @@ - + FunctionClassifyButton - - - Mobile - གནས་སྤོར། - - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + Mobile + - Social - འབྲེལ་འདྲིས། + Internet + - Video - བརྙན་ཟློས། + Social + - Development - གསར་སྤེལ། + Video + - Image - པར་རིས།། + Development + - Game - རོལ་རྩེད། + Image + - Office - གཞུང་ལས།དྲ་རྒྱ། + Game + - Education - སློབ་གསོ། + Office + - System - རྒྱུད་ཁོངས། + Education + - Safe - + System + Others - གཞན་དག + + + + + FunctionWidget + + + Mobile + + + + + Internet + + + + + Social + + + + + Video + + + + + Development + + + + + Image + + + + + Game + + + + + Office + + + + + Education + + + + + System + + + + + Others + MainViewWidget - + Search - འཚོལ་བ། - - - - QObject - - - Office - གཞུང་ལས།དྲ་རྒྱ། - - - - Development - གསར་སྤེལ། - - - - Image - པར་རིས།། - - - - Video - བརྙན་ཟློས། - - - - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། - - - - Game - རོལ་རྩེད། - - - - Education - སློབ་གསོ། - - - - Social - འབྲེལ་འདྲིས། - - - - System - རྒྱུད་ཁོངས། - - - - Safe - - - - - Others - གཞན་དག + RightClickMenu - + Pin to all - “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ། + - + Unpin from all - “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ། + - + Pin to taskbar - འགན་བྱང་དུ་འཇོག་པ། + - + Unpin from taskbar - འགན་བྱང་ནས་ལེན་པ། + - + Add to desktop shortcuts - ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ། + - + Uninstall - ལྷུ་གཏོར + - + Sleep - མལ་གསོ། + - + Log Out - རྩིས་ཐེམ་ནས་བསུབ་པ། + - + Restart - བསྐྱར་སློང་། + - + Power Off - འཁོར་ཁ་རྒྱག་པ། + - + Personalize this list - མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ། + SideBarWidget - + All - མཉེན་ཆས་ཚང་མ། + - + Letter - འཕྲིན་ཡིག + - + Function - བྱེད་ནུས། + - + Trash - སྙིགས་སྒམ། + - + Computer - རྩིས་ཆས། + - + Max - ཆེས་ཆེ་བ། + - + Personal - མི་སྒེར། + - + Settings - སྒྲིག་འགོད། + - + Power - ཁ་རྒྱག་པ། + SplitBarFrame - + Mobile - གནས་སྤོར། + - + Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + - + Social - འབྲེལ་འདྲིས། + - + Video - བརྙན་ཟློས། + - + Development - གསར་སྤེལ། + - + Image - པར་རིས།། + - + Game - རོལ་རྩེད། + - + Office - གཞུང་ལས།དྲ་རྒྱ། + - + Education - སློབ་གསོ། + - + System - རྒྱུད་ཁོངས། + - - Safe - सुरक्षा - - - + Others - གཞན་དག + diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts old mode 100644 new mode 100755 index a89dde3..691fbea --- a/translations/ukui-menu_tr.ts +++ b/translations/ukui-menu_tr.ts @@ -4,60 +4,55 @@ FunctionClassifyButton - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - - - Safe - - Others @@ -67,54 +62,65 @@ FunctionWidget + Mobile - Mobil + Mobil + Internet - İnternet + İnternet + Social - Sosyal + Sosyal + Video - Video + Video + Development - Programlama + Programlama + Image - Grafik + Grafik + Game - Oyunlar + Oyunlar + Office - Ofis Uygulamaları + Ofis Uygulamaları + Education - Eğitim + Eğitim + System - Sistem + Sistem + Others - Diğer + Diğer MainViewWidget - + Search Ara @@ -166,93 +172,35 @@ Diğer - - QObject - - - Office - Ofis Uygulamaları - - - - Development - Programlama - - - - Image - Grafik - - - - Video - Video - - - - Internet - İnternet - - - - Game - Oyunlar - - - - Education - Eğitim - - - - Social - Sosyal - - - - System - Sistem - - - - Safe - - - - - Others - Diğer - - RightClickMenu - + Pin to all Tümünü sabitle - + Unpin from all Tüm sabitlemeleri kaldır - + Pin to taskbar Görev çubuğuna sabitle - + Unpin from taskbar Görev çubuğundan sabitlemeyi kaldır - + Add to desktop shortcuts Masaüstü kısayollarına ekle - + Uninstall Kaldır @@ -261,7 +209,7 @@ Beklemeye Al - + Sleep Uyku Modu @@ -274,22 +222,22 @@ Kullanıcı Değiştir - + Log Out Çıkış - + Restart Yeniden Başlat - + Power Off Kapat - + Personalize this list Bu listeyi özelleştirin @@ -297,42 +245,42 @@ SideBarWidget - + All Tümü - + Letter Alfabetik - + Function Kategori - + Trash Çöp - + Computer Bilgisayar - + Max - + Personal Kişisel - + Settings Ayarlar @@ -341,7 +289,7 @@ Çöp - + Power Kapat @@ -349,107 +297,59 @@ SplitBarFrame - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - - Safe - - - - + Others Diğer - - UkuiMenuInterface - - Office - Ofis Uygulamaları - - - Development - Programlama - - - Image - Grafik - - - Video - Video - - - Internet - İnternet - - - Game - Oyunlar - - - Education - Eğitim - - - Social - Sosyal - - - System - Sistem - - - Others - Diğer - - diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts old mode 100644 new mode 100755 index 675c51d..f4c522a --- a/translations/ukui-menu_zh_CN.ts +++ b/translations/ukui-menu_zh_CN.ts @@ -4,60 +4,55 @@ FunctionClassifyButton - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - - - Safe - 安全 - Others @@ -67,58 +62,65 @@ FunctionWidget + Mobile - 移动 + 移动 + Internet - 网络 + 网络 + Social - 社交 + 社交 + Video - 影音 + 影音 + Development - 开发 + 开发 + Image - 图像 + 图像 + Game - 游戏 + 游戏 + Office - 办公 + 办公 + Education - 教育 + 教育 + System - 系统 + 系统 + Others - 其它 - - - Safe - 安全 + 其它 MainViewWidget - + Search 搜索 @@ -170,93 +172,35 @@ 其它 - - QObject - - - Office - 办公 - - - - Development - 开发 - - - - Image - 图像 - - - - Video - 影音 - - - - Internet - 网络 - - - - Game - 游戏 - - - - Education - 教育 - - - - Social - 社交 - - - - System - 系统 - - - - Safe - 安全 - - - - Others - 其它 - - RightClickMenu - + Pin to all 固定到“所有软件” - + Unpin from all 从“所有软件”取消固定 - + Pin to taskbar 固定到任务栏 - + Unpin from taskbar 从任务栏取消固定 - + Add to desktop shortcuts 添加到桌面快捷方式 - + Uninstall 卸载 @@ -265,7 +209,7 @@ 休眠 - + Sleep 睡眠 @@ -278,22 +222,22 @@ 切换用户 - + Log Out 注销 - + Restart 重启 - + Power Off 关机 - + Personalize this list 设置开始菜单显示列表 @@ -301,42 +245,42 @@ SideBarWidget - + All 所有软件 - + Letter 字母排序 - + Function 功能分类 - + Trash 回收站 - + Computer 计算机 - + Max 放大 - + Personal 个人 - + Settings 设置 @@ -345,7 +289,7 @@ 回收站 - + Power 电源 @@ -353,111 +297,59 @@ SplitBarFrame - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - - Safe - 安全 - - - + Others 其它 - - UkuiMenuInterface - - Office - 办公 - - - Development - 开发 - - - Image - 图像 - - - Video - 影音 - - - Internet - 网络 - - - Game - 游戏 - - - Education - 教育 - - - Social - 社交 - - - System - 系统 - - - Safe - 安全 - - - Others - 其它 - - diff --git a/ukui-menu.desktop b/ukui-menu.desktop old mode 100644 new mode 100755 diff --git a/ukui-menu.ini b/ukui-menu.ini old mode 100644 new mode 100755 diff --git a/ukui-menu.pro b/ukui-menu.pro old mode 100644 new mode 100755 index cfb10e7..a5b48e5 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui svg dbus x11extras KWindowSystem sql +QT += core gui svg dbus x11extras KWindowSystem sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets include(src/QtSingleApplication/qtsingleapplication.pri) @@ -16,7 +16,7 @@ TEMPLATE = app target.path = /usr/bin TRANSLATIONS+=\ - translations/ukui-menu_bo_CN.ts \ + translations/ukui-menu_bo.ts \ translations/ukui-menu_zh_CN.ts \ translations/ukui-menu_tr.ts @@ -58,7 +58,6 @@ SOURCES += \ src/MainWindow/mainwindow.cpp \ src/RightClickMenu/menubox.cpp \ src/RightClickMenu/rightclickmenu.cpp \ - src/RightClickMenu/uninstallwhitelist.cpp \ src/SearchResultWidget/file-utils.cpp \ src/SearchResultWidget/fullsearchresultwidget.cpp \ src/SearchResultWidget/searchappthread.cpp \ @@ -75,7 +74,6 @@ SOURCES += \ src/UtilityFunction/listview.cpp \ src/UtilityFunction/proxystyle.cpp \ src/UtilityFunction/scrollarea.cpp \ - src/UtilityFunction/softwaredatabaseupdatethread.cpp \ src/UtilityFunction/splitbarframe.cpp \ src/UtilityFunction/toolbutton.cpp \ src/Interface/ukuichineseletter.cpp \ @@ -99,7 +97,6 @@ HEADERS += \ src/MainWindow/mainwindow.h \ src/RightClickMenu/menubox.h \ src/RightClickMenu/rightclickmenu.h \ - src/RightClickMenu/uninstallwhitelist.h \ src/SearchResultWidget/file-utils.h \ src/SearchResultWidget/fullsearchresultwidget.h \ src/SearchResultWidget/searchappthread.h \ @@ -116,7 +113,6 @@ HEADERS += \ src/UtilityFunction/listview.h \ src/UtilityFunction/proxystyle.h \ src/UtilityFunction/scrollarea.h \ - src/UtilityFunction/softwaredatabaseupdatethread.h \ src/UtilityFunction/splitbarframe.h \ src/UtilityFunction/toolbutton.h \ src/Interface/ukuichineseletter.h \ @@ -132,7 +128,7 @@ PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt CONFIG += no_keywords link_pkgconfig -LIBS+=-pthread -luchardet -lukui-log4qt -lukui-com4c -lukui-com4cxx +LIBS+=-pthread -luchardet -lukui-log4qt desktop_file.files = ukui-menu.desktop desktop_file.path = /etc/xdg/autostart