Import Upstream version 3.0.1.0720.1update1

This commit is contained in:
谢炜 2022-05-20 16:38:37 +08:00
parent d56635f2e8
commit 3c242b8f5a
67 changed files with 3913 additions and 3410 deletions

View File

@ -0,0 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 256"><defs><style>.cls-1{fill:none;}.cls-2{clip-path:url(#clip-path);}.cls-3{opacity:0.15;}.cls-4{fill:#fff;}</style><clipPath id="clip-path"><rect class="cls-1" width="256" height="256"/></clipPath></defs><title>avatar</title><g class="cls-2"><g class="cls-2"><g class="cls-3"><g class="cls-2"><path d="M256,128A128,128,0,1,1,128,0,128,128,0,0,1,256,128"/></g></g><path class="cls-4" d="M164,143H92a30,30,0,0,0-30,30v12a18,18,0,0,0,18,18h96a18,18,0,0,0,18-18V173a30,30,0,0,0-30-30"/><path class="cls-4" d="M128,123A35,35,0,1,0,93,88a35,35,0,0,0,35,35"/></g></g></svg>

After

Width:  |  Height:  |  Size: 703 B

View File

@ -36,6 +36,7 @@ int main(int argc, char *argv[])
{
initUkuiLog4qt("ukui-menu");
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
@ -43,29 +44,34 @@ int main(int argc, char *argv[])
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
QtSingleApplication app("ukui-menu", argc, argv);
app.setQuitOnLastWindowClosed(false);
if (app.isRunning()) {
if(app.isRunning())
{
app.sendMessage("raise_window_noop");
return EXIT_SUCCESS;
}
// auto Style=new ProxyStyle;
// app.setStyle(Style);
QTranslator translator;
if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) {
QTranslator translator;
if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH))
app.installTranslator(&translator);
} else {
else
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));
@ -76,11 +82,13 @@ int main(int argc, char *argv[])
// 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();
w.activateWindow();
w.hide();
//测试
return app.exec();
}

View File

@ -27,23 +27,23 @@ CommonUseWidget::CommonUseWidget(QWidget *parent) :
QWidget(parent)
{
initUi();
}
CommonUseWidget::~CommonUseWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void CommonUseWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_ukuiMenuInterface = new UkuiMenuInterface;
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
fillAppList();
}
@ -53,14 +53,12 @@ void CommonUseWidget::initUi()
*/
void CommonUseWidget::initAppListWidget()
{
m_listView = new ListView(this, this->width(), this->height() - 6, 0);
m_listView->setFixedSize(this->width(), this->height() - 6);
//m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_listView=new ListView(this,this->width()-6,this->height()-6,0);
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);
connect(m_listView, &ListView::sendHideMainWindowSignal, this, &CommonUseWidget::sendHideMainWindowSignal);
connect(m_listView, &ListView::sendMainWinActiveSignal, this, &CommonUseWidget::sendMainWinActiveSignal);
connect(m_listView,&ListView::sendItemClickedSignal,this,&CommonUseWidget::execApplication);
connect(m_listView,&ListView::sendUpdateAppListSignal,this,&CommonUseWidget::updateListViewSlot);
connect(m_listView,&ListView::sendHideMainWindowSignal,this,&CommonUseWidget::sendHideMainWindowSignal);
}
/**
@ -69,26 +67,23 @@ void CommonUseWidget::initAppListWidget()
void CommonUseWidget::fillAppList()
{
m_data.clear();
Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) {
m_data.append(QStringList() << desktopfp << "1");
}
Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector)
m_data.append(QStringList()<<desktopfp<<"1");
m_listView->addData(m_data);
}
void CommonUseWidget::selectFirstItem()
{
this->focusNextChild();
m_listView->setCurrentIndex(m_listView->model()->index(0, 0));
m_listView->setCurrentIndex(m_listView->model()->index(0,0));
}
void CommonUseWidget::selectFirstItemTab()
{
this->setFocus();
if (m_listView->currentIndex().row() == -1) {
m_listView->setCurrentIndex(m_listView->model()->index(0, 0));
if(m_listView->currentIndex().row() == -1)
{
m_listView->setCurrentIndex(m_listView->model()->index(0,0));
}
}
/**
@ -97,7 +92,7 @@ void CommonUseWidget::selectFirstItemTab()
void CommonUseWidget::execApplication(QStringList arg)
{
Q_EMIT sendHideMainWindowSignal();
QString desktopfp = arg.at(0);
QString desktopfp=arg.at(0);
execApp(desktopfp);
}
@ -113,13 +108,10 @@ void CommonUseWidget::updateListViewSlot()
void CommonUseWidget::updateListView()
{
m_data.clear();
Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) {
m_data.append(QStringList() << desktopfp << "1");
}
Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification())
m_data.append(QStringList()<<desktopfp<<"1");
m_listView->updateData(m_data);
// m_listView->setFocus();
// m_listView->setFocus();
}
void CommonUseWidget::widgetMakeZero()
@ -129,17 +121,16 @@ void CommonUseWidget::widgetMakeZero()
void CommonUseWidget::moveScrollBar(int type)
{
if (type == 0) {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100);
} else {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100);
}
if(type==0)
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100);
else
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100);
}
void CommonUseWidget::repaintWidget()
{
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_listView->show();
}

View File

@ -103,7 +103,6 @@ Q_SIGNALS:
* @brief Send a hidden main window signal to the MainViewWidget
*/
void sendHideMainWindowSignal();
void sendMainWinActiveSignal(bool flag);
};
#endif // COMMONUSEWIDGET_H

View File

@ -30,87 +30,91 @@ FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) :
FullCommonUseWidget::~FullCommonUseWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void FullCommonUseWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_StyledBackground, true);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setAttribute(Qt::WA_StyledBackground,true);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
this->setFocusPolicy(Qt::NoFocus);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* mainLayout=new QHBoxLayout;
mainLayout->setContentsMargins(0,0,0,0);
this->setLayout(mainLayout);
m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed);
m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed);
mainLayout->addItem(m_spaceItem);
m_scrollArea = new ScrollArea;
m_scrollAreaWid = new ScrollAreaWid;
m_scrollArea=new ScrollArea;
m_scrollAreaWid=new ScrollAreaWid;
m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground);
m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height());
m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height());
m_scrollArea->setWidget(m_scrollAreaWid);
m_scrollArea->setWidgetResizable(true);
m_scrollAreaWidLayout = new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout=new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWid->setLayout(m_scrollAreaWidLayout);
mainLayout->addWidget(m_scrollArea);
m_ukuiMenuInterface = new UkuiMenuInterface;
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
fillAppList();
flag = true;
//翻页灵敏度时间调节
time = new QTimer(this);
connect(time,&QTimer::timeout,[=](){
if(flag == false)
{
flag = true;
time->stop();
}
});
}
void FullCommonUseWidget::initAppListWidget()
{
m_listView = new FullListView(this, 0);
m_listView=new FullListView(this,0);
// m_listView->setFixedSize(this->width()-Style::LeftWidWidth+3,this->height());
// QHBoxLayout *mainLayout=qobject_cast<QHBoxLayout*>(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);
connect(m_listView, &FullListView::sendSetslidebar, this, &FullCommonUseWidget::onSetSlider);
connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication);
connect(m_listView,&FullListView::sendUpdateAppListSignal,this,&FullCommonUseWidget::updateListViewSlot);
connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullCommonUseWidget::sendHideMainWindowSignal);
connect(m_listView,&FullListView::sendSetslidebar,this,&FullCommonUseWidget::onSetSlider);
}
void FullCommonUseWidget::resizeScrollAreaControls()
{
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0);
QWidget *wid = widItem->widget();
FullListView *listview = qobject_cast<FullListView *>(wid);
QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0);
QWidget* wid=widItem->widget();
FullListView* listview=qobject_cast<FullListView*>(wid);
listview->adjustSize();
int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
int rowcount = 0;
int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth;
int rowcount=0;
if(listview->model()->rowCount()%dividend>0)
{
rowcount=listview->model()->rowCount()/dividend+1;
}
else
{
rowcount=listview->model()->rowCount()/dividend;
if (listview->model()->rowCount() % dividend > 0) {
rowcount = listview->model()->rowCount() / dividend + 1;
} else {
rowcount = listview->model()->rowCount() / dividend;
}
listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount);
listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount);
m_scrollArea->widget()->adjustSize();
}
void FullCommonUseWidget::fillAppList()
{
m_data.clear();
Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) {
Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector)
m_data.append(desktopfp);
}
m_listView->addData(m_data);
resizeScrollAreaControls();
}
@ -128,26 +132,34 @@ void FullCommonUseWidget::selectFirstItem()
{
// this->focusNextChild();
qDebug() << "void FullCommonUseWidget::selectFirstItem()";
m_listView->setCurrentIndex(m_listView->model()->index(0, 0));
m_listView->setCurrentIndex(m_listView->model()->index(0,0));
}
void FullCommonUseWidget::selectFirstItemTab()
{
this->setFocus();
if (m_listView->currentIndex().row() == -1) {
m_listView->setCurrentIndex(m_listView->model()->index(0, 0));
if(m_listView->currentIndex().row() == -1)
{
m_listView->setCurrentIndex(m_listView->model()->index(0,0));
}
}
void FullCommonUseWidget::onSetSlider(int value)
{
if (value == 0) {
// if(flag)
// {
// flag = false;
// time->start(100);
if(value == 0)
{
m_scrollArea->verticalScrollBar()->setValue(0);
} else {
}
else
{
int curvalue = m_scrollArea->verticalScrollBar()->value();
m_scrollArea->verticalScrollBar()->setValue(curvalue + value);
}
// }
}
/**
*
@ -160,11 +172,8 @@ void FullCommonUseWidget::updateListViewSlot()
void FullCommonUseWidget::updateListView()
{
m_data.clear();
Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) {
Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification())
m_data.append(desktopfp);
}
m_listView->updateData(m_data);
}
@ -172,7 +181,8 @@ void FullCommonUseWidget::repaintWidget()
{
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height());
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;
@ -187,11 +197,9 @@ void FullCommonUseWidget::widgetMakeZero()
void FullCommonUseWidget::moveScrollBar(int type)
{
int height = Style::primaryScreenHeight;
if (type == 0) {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080);
} else {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080);
}
int height=Style::primaryScreenHeight;
if(type==0)
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080);
else
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080);
}

View File

@ -74,6 +74,8 @@ private:
ScrollArea* m_scrollArea=nullptr;
ScrollAreaWid* m_scrollAreaWid=nullptr;
QVBoxLayout* m_scrollAreaWidLayout=nullptr;
bool flag;
QTimer *time = nullptr;
protected:
/**

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dbus.h"
#include <QFileInfo>
#include <QDir>

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DBUS_H
#define DBUS_H

View File

@ -32,37 +32,39 @@ FullFunctionWidget::FullFunctionWidget(QWidget *parent) :
FullFunctionWidget::~FullFunctionWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void FullFunctionWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setAttribute(Qt::WA_TranslucentBackground);
m_applistWid = new QWidget(this);
m_iconListWid = new QWidget(this);
m_applistWid=new QWidget(this);
m_iconListWid=new QWidget(this);
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
m_applistWid->setFixedSize(Style::AppListWidWidth, this->height());
m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height());
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
m_applistWid->setFixedSize(Style::AppListWidWidth,this->height());
m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height());
QHBoxLayout* mainLayout=new QHBoxLayout;
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->setSpacing(0);
mainLayout->addWidget(m_iconListWid);
mainLayout->addWidget(m_applistWid);
this->setLayout(mainLayout);
m_ukuiMenuInterface = new UkuiMenuInterface;
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
initIconListWidget();
flag = true;
//翻页灵敏度时间调节
time = new QTimer(this);
connect(time, &QTimer::timeout, [ = ]() {
if (flag == false) {
connect(time,&QTimer::timeout,[=](){
if(flag == false)
{
flag = true;
time->stop();
}
@ -74,23 +76,24 @@ void FullFunctionWidget::initUi()
*/
void FullFunctionWidget::initAppListWidget()
{
QHBoxLayout *layout = new QHBoxLayout(m_applistWid);
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* layout=new QHBoxLayout(m_applistWid);
layout->setContentsMargins(0,0,0,0);
m_applistWid->setLayout(layout);
m_scrollArea = new ScrollArea;
m_scrollAreaWid = new ScrollAreaWid;
m_scrollArea=new ScrollArea;
m_scrollAreaWid=new ScrollAreaWid;
m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground);
m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height());
m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height());
m_scrollArea->setWidget(m_scrollAreaWid);
m_scrollArea->setWidgetResizable(true);
m_scrollAreaWidLayout = new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout=new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWid->setLayout(m_scrollAreaWidLayout);
layout->addWidget(m_scrollArea);
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullFunctionWidget::valueChangedSlot);
m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullFunctionWidget::valueChangedSlot);
m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
fillAppList();
}
@ -100,103 +103,92 @@ void FullFunctionWidget::initAppListWidget()
void FullFunctionWidget::fillAppList()
{
m_classificationList.clear();
QVector<QStringList> vector = UkuiMenuInterface::functionalVector;
QStringList androidlist = vector.at(0);
if (!androidlist.isEmpty()) {
QVector<QStringList> vector=UkuiMenuInterface::functionalVector;
QStringList androidlist=vector.at(0);
if(!androidlist.isEmpty())
{
insertClassificationBtn("Mobile");
insertAppList(androidlist);
}
QStringList netlist = vector.at(1);
if (!netlist.isEmpty()) {
QStringList netlist=vector.at(1);
if(!netlist.isEmpty())
{
insertClassificationBtn("Internet");
insertAppList(netlist);
}
QStringList sociallist = vector.at(2);
if (!sociallist.isEmpty()) {
QStringList sociallist=vector.at(2);
if(!sociallist.isEmpty())
{
insertClassificationBtn("Social");
insertAppList(sociallist);
}
QStringList avlist = vector.at(3);
if (!avlist.isEmpty()) {
QStringList avlist=vector.at(3);
if(!avlist.isEmpty())
{
insertClassificationBtn("Video");
insertAppList(avlist);
}
QStringList developlist = vector.at(4);
if (!developlist.isEmpty()) {
QStringList developlist=vector.at(4);
if(!developlist.isEmpty())
{
insertClassificationBtn("Development");
insertAppList(developlist);
}
QStringList graphicslist = vector.at(5);
if (!graphicslist.isEmpty()) {
QStringList graphicslist=vector.at(5);
if(!graphicslist.isEmpty())
{
insertClassificationBtn("Image");
insertAppList(graphicslist);
}
QStringList gamelist = vector.at(6);
if (!gamelist.isEmpty()) {
QStringList gamelist=vector.at(6);
if(!gamelist.isEmpty())
{
insertClassificationBtn("Game");
insertAppList(gamelist);
}
QStringList officelist = vector.at(7);
if (!officelist.isEmpty()) {
QStringList officelist=vector.at(7);
if(!officelist.isEmpty())
{
insertClassificationBtn("Office");
insertAppList(officelist);
}
QStringList educationlist = vector.at(8);
if (!educationlist.isEmpty()) {
QStringList educationlist=vector.at(8);
if(!educationlist.isEmpty())
{
insertClassificationBtn("Education");
insertAppList(educationlist);
}
QStringList systemadminlist = vector.at(9);
if (!systemadminlist.isEmpty()) {
QStringList systemadminlist=vector.at(9);
if(!systemadminlist.isEmpty())
{
insertClassificationBtn("System");
insertAppList(systemadminlist);
}
QStringList otherlist = vector.at(10);
if (!otherlist.isEmpty()) {
QStringList otherlist=vector.at(10);
if(!otherlist.isEmpty())
{
insertClassificationBtn("Others");
insertAppList(otherlist);
}
m_scrollAreaWidLayout->addItem(m_appListBottomSpacer);
resizeScrollAreaControls();
}
void FullFunctionWidget::insertClassificationBtn(QString category)
{
SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 16, 30, 2);
SplitBarFrame* classificationbtn=new SplitBarFrame(this,category,m_scrollArea->width()-12,30,2);
m_scrollAreaWidLayout->addWidget(classificationbtn);
m_classificationList.append(category);
}
void FullFunctionWidget::insertAppList(QStringList desktopfplist)
{
FullListView *listview = new FullListView(this, 2);
FullListView* listview=new FullListView(this,2);
//修复异常黑框问题
connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() {
QEventLoop loop;
QTimer::singleShot(1, &loop, SLOT(quit()));
loop.exec();
connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){
listview->repaint(listview->rect());
});
connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider);
@ -204,14 +196,11 @@ void FullFunctionWidget::insertAppList(QStringList desktopfplist)
listview->installEventFilter(this);
m_scrollAreaWidLayout->addWidget(listview);
m_data.clear();
for (int i = 0; i < desktopfplist.count(); i++) {
for(int i=0;i<desktopfplist.count();i++)
m_data.append(desktopfplist.at(i));
}
listview->addData(m_data);
connect(listview, &FullListView::sendItemClickedSignal, this, &FullFunctionWidget::execApplication);
connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullFunctionWidget::sendHideMainWindowSignal);
connect(listview,&FullListView::sendItemClickedSignal,this,&FullFunctionWidget::execApplication);
connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullFunctionWidget::sendHideMainWindowSignal);
}
/**
@ -231,34 +220,29 @@ void FullFunctionWidget::updateAppListView()
//刷新应用列表界面
QLayoutItem *child;
m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer);
while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) {
QWidget *wid = child->widget();
QWidget* wid=child->widget();
m_scrollAreaWidLayout->removeWidget(wid);
wid->setParent(nullptr);
delete wid;
delete child;
}
fillAppList();
//刷新图标列表界面
Q_FOREACH (QAbstractButton *button, m_buttonList) {
Q_FOREACH (QAbstractButton* button, m_buttonList){
m_btnGroup->removeButton(button);
}
m_buttonList.clear();
m_iconListScrollAreaWidLayout->removeItem(m_topSpacerItem);
m_iconListScrollAreaWidLayout->removeItem(m_bottomSpacerItem);
while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) {
QWidget *wid = child->widget();
QWidget* wid=child->widget();
m_iconListScrollAreaWidLayout->removeWidget(wid);
wid->setParent(nullptr);
delete wid;
delete child;
}
initIconListScrollArea();
}
@ -267,27 +251,29 @@ void FullFunctionWidget::updateAppListView()
*/
void FullFunctionWidget::resizeScrollAreaControls()
{
int row = 0;
while (row < m_scrollAreaWidLayout->count() / 2) {
int row=0;
while(row<m_scrollAreaWidLayout->count()/2)
{
//应用界面
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1);
QWidget *wid = widItem->widget();
FullListView *listview = qobject_cast<FullListView *>(wid);
QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1);
QWidget* wid=widItem->widget();
FullListView* listview=qobject_cast<FullListView*>(wid);
listview->adjustSize();
int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
int rowcount = 0;
int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth;
int rowcount=0;
if(listview->model()->rowCount()%dividend>0)
{
rowcount=listview->model()->rowCount()/dividend+1;
}
else
{
rowcount=listview->model()->rowCount()/dividend;
if (listview->model()->rowCount() % dividend > 0) {
rowcount = listview->model()->rowCount() / dividend + 1;
} else {
rowcount = listview->model()->rowCount() / dividend;
}
listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount);
listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount);
row++;
}
m_scrollArea->widget()->adjustSize();
}
@ -296,25 +282,29 @@ void FullFunctionWidget::resizeScrollAreaControls()
*/
void FullFunctionWidget::initIconListWidget()
{
m_iconListScrollArea = new ClassifyBtnScrollArea(m_iconListWid);
m_iconListScrollArea=new ClassifyBtnScrollArea(m_iconListWid);
// m_iconListScrollArea->resize(Style::LeftBtnWidth,
// m_iconListWid->height());
m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid;
m_iconListScrollAreaWid=new ClassifyBtnScrollAreaWid;
m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth,
m_iconListWid->height());
m_iconListScrollAreaWidLayout = new QVBoxLayout;
m_iconListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_iconListScrollAreaWidLayout=new QVBoxLayout;
m_iconListScrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem);
m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout);
m_iconListScrollArea->setWidget(m_iconListScrollAreaWid);
m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_bottomSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_btnGroup = new QButtonGroup(m_iconListScrollAreaWid);
m_topSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
m_bottomSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
m_btnGroup=new QButtonGroup(m_iconListScrollAreaWid);
m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry");
m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value");
m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad);
connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot);
connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot);
initIconListScrollArea();
}
@ -324,9 +314,9 @@ void FullFunctionWidget::initIconListWidget()
void FullFunctionWidget::initIconListScrollArea()
{
m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem);
for (int i = 0; i < m_classificationList.size(); i++) {
FunctionClassifyButton *iconbtn = new FunctionClassifyButton(
for(int i=0;i<m_classificationList.size();i++)
{
FunctionClassifyButton* iconbtn=new FunctionClassifyButton(
Style::LeftBtnWidth,
Style::LeftBtnHeight,
Style::LeftIconSize,
@ -337,38 +327,35 @@ void FullFunctionWidget::initIconListScrollArea()
m_buttonList.append(iconbtn);
m_iconListScrollAreaWidLayout->addWidget(iconbtn);
}
m_iconListScrollAreaWidLayout->addItem(m_bottomSpacerItem);
int id = 0;
Q_FOREACH (QAbstractButton *btn, m_buttonList) {
m_btnGroup->addButton(btn, id++);
int id=0;
Q_FOREACH (QAbstractButton* btn, m_buttonList) {
m_btnGroup->addButton(btn,id++);
}
connect(m_btnGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot);
connect(m_btnGroup,static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),this,&FullFunctionWidget::btnGroupClickedSlot);
// m_iconListScrollArea->widget()->adjustSize();
if (m_btnGroup->button(0) != nullptr) {
if(m_btnGroup->button(0)!=nullptr)
m_btnGroup->button(0)->click();
}
}
void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn)
{
disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullFunctionWidget::valueChangedSlot);
Q_FOREACH (QAbstractButton *button, m_buttonList) {
if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) {
m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition();
m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y();
disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullFunctionWidget::valueChangedSlot);
Q_FOREACH (QAbstractButton* button, m_buttonList) {
if(m_btnGroup->id(btn)==m_buttonList.indexOf(button))
{
m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition();
m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y();
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollAnimation->stop();
m_scrollAnimation->setStartValue(m_beginPos);
m_scrollAnimation->setEndValue(m_endPos);
m_scrollAnimation->start();
button->setChecked(true);
} else {
}
else{
button->setChecked(false);
}
}
@ -376,62 +363,58 @@ void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn)
void FullFunctionWidget::animationFinishSlot()
{
if (m_scrollArea->verticalScrollBar()->value() == m_endPos ||
m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) {
if(m_scrollArea->verticalScrollBar()->value()==m_endPos ||
m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum())
{
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullFunctionWidget::valueChangedSlot);
connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullFunctionWidget::valueChangedSlot);
}
}
void FullFunctionWidget::animationValueChangedSlot(const QVariant &value)
{
Q_UNUSED(value);
if (sender() != m_scrollAnimation) {
if (sender() != m_scrollAnimation)
return;
}
QPropertyAnimation *ani = qobject_cast<QPropertyAnimation *>(sender());
if (m_endPos != ani->endValue()) {
if (m_endPos != ani->endValue())
ani->setEndValue(m_endPos);
}
}
void FullFunctionWidget::valueChangedSlot(int value)
{
int index = 0;
while (index <= m_classificationList.count() - 1) {
int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y();
int max = 0;
if (index == m_classificationList.count() - 1) {
max = m_scrollAreaWid->height();
} else {
max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y();
}
if (value >= min && value < max) {
Q_FOREACH (QAbstractButton *button, m_buttonList) {
FunctionClassifyButton *fcbutton = qobject_cast<FunctionClassifyButton *>(button);
if (index == m_buttonList.indexOf(button)) {
int index=0;
while(index<=m_classificationList.count()-1)
{
int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y();
int max=0;
if(index==m_classificationList.count()-1)
max=m_scrollAreaWid->height();
else
max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y();
if(value>=min && value<max)
{
Q_FOREACH (QAbstractButton* button, m_buttonList) {
FunctionClassifyButton* fcbutton=qobject_cast<FunctionClassifyButton*>(button);
if(index==m_buttonList.indexOf(button))
{
fcbutton->setChecked(true);
} else {
}
else{
fcbutton->setChecked(false);
}
}
break;
} else {
index++;
}
else
index++;
}
}
QAbstractButton *FullFunctionWidget::getCurLetterButton(int value)
QAbstractButton* FullFunctionWidget::getCurLetterButton(int value)
{
return m_buttonList.at(value);
}
@ -440,8 +423,8 @@ QAbstractButton *FullFunctionWidget::getCurLetterButton(int value)
void FullFunctionWidget::enterAnimation()
{
m_animation->setDuration(200);//动画总时间
m_animation->setStartValue(QRect(0, 0,
0, m_iconListWid->height()));
m_animation->setStartValue(QRect(0,0,
0,m_iconListWid->height()));
m_animation->setEndValue(QRect(Style::LeftMargin,
0,
Style::LeftBtnWidth,
@ -459,15 +442,17 @@ void FullFunctionWidget::setFunctionBtnGeometry()
Style::LeftBtnWidth,
m_iconListWid->height()));
m_iconListScrollArea->show();
}
void FullFunctionWidget::repaintWidget()
{
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
m_applistWid->setFixedSize(Style::AppListWidWidth, this->height());
m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height());
m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height());
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());
updateAppListView();
@ -475,22 +460,18 @@ void FullFunctionWidget::repaintWidget()
void FullFunctionWidget::widgetMakeZero()
{
if (m_btnGroup->button(0) != nullptr) {
if(m_btnGroup->button(0)!=nullptr)
m_btnGroup->button(0)->click();
}
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}
void FullFunctionWidget::moveScrollBar(int type)
{
int height = Style::primaryScreenHeight;
if (type == 0) {
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080);
} else {
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080);
}
int height=Style::primaryScreenHeight;
if(type==0)
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080);
else
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080);
}
void FullFunctionWidget::onSetSlider(int value)
@ -507,19 +488,21 @@ void FullFunctionWidget::onSetSlider(int value)
bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
QWidget *wid = widItem->widget();
FullListView *m_listview = qobject_cast<FullListView *>(wid);
QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1);
QWidget *widTop = widItemTop->widget();
FullListView *m_listviewTop = qobject_cast<FullListView *>(widTop);
QKeyEvent *ke = (QKeyEvent *)event;
if( event->type() == QEvent::KeyPress )
{
QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
QWidget* wid = widItem->widget();
FullListView* m_listview = qobject_cast<FullListView*>(wid);
if (ke->key() == Qt::Key_Tab) {
QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1);
QWidget* widTop = widItemTop->widget();
FullListView* m_listviewTop = qobject_cast<FullListView*>(widTop);
QKeyEvent *ke = (QKeyEvent *)event;
if( ke->key() == Qt::Key_Tab )
{
Q_EMIT setFocusToSideWin();
}
// if(ke->key() == Qt::Key_Up)
// {
// QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1);
@ -548,49 +531,51 @@ bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event)
// }
// }
if (ke->key() == Qt::Key_Up) {
if (!m_listviewTop->hasFocus()) {
QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size());
if(ke->key() == Qt::Key_Up)
{
if(!m_listviewTop->hasFocus())
{
QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size());
btnGroupClickedSlot(buttonTop);
this->m_scrollArea->setFocusToPreChild();
} else {
}
else
{
m_listview->setFocus();
QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1);
QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1);
btnGroupClickedSlot(button);
m_index = m_buttonList.size() - 1;
}
Q_EMIT selectFirstItem();
return true;
}
if (ke->key() == Qt::Key_Down) {
if (!m_listview->hasFocus()) {
QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size());
if(ke->key() == Qt::Key_Down)
{
if(!m_listview->hasFocus())
{
QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size());
btnGroupClickedSlot(button);
this->m_scrollArea->setFocusToNextChild();
} else {
}
else
{
m_listviewTop->setFocus();
QAbstractButton *buttonTop = getCurLetterButton(0);
QAbstractButton* buttonTop = getCurLetterButton(0);
btnGroupClickedSlot(buttonTop);
m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0, 0));
m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0,0));
m_index = 0;
}
Q_EMIT selectFirstItem();
return true;
}
}
return QWidget::eventFilter(watched, event);
return QWidget::eventFilter(watched,event);
}
void FullFunctionWidget::functionButtonClick()
{
if (m_btnGroup->button(0) != nullptr) {
if(m_btnGroup->button(0)!=nullptr)
m_btnGroup->button(0)->click();
}
m_index = 0;
}

View File

@ -28,10 +28,7 @@ FunctionWidget::FunctionWidget(QWidget *parent) :
FunctionWidget::~FunctionWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
/**
@ -40,21 +37,24 @@ FunctionWidget::~FunctionWidget()
void FunctionWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_StyledBackground, true);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_ukuiMenuInterface = new UkuiMenuInterface;
this->setAttribute(Qt::WA_StyledBackground,true);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
m_functionBtnWid = new FunctionButtonWidget(this);
m_functionBtnWid=new FunctionButtonWidget(this);
m_functionBtnWid->hide();
connect(this, &FunctionWidget::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList);
connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &FunctionWidget::recvFunctionBtnSignal);
m_enterAnimation = new QPropertyAnimation;
connect(this,&FunctionWidget::sendClassificationbtnList,m_functionBtnWid,&FunctionButtonWidget::recvClassificationBtnList);
connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal);
m_enterAnimation=new QPropertyAnimation;
m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit());
m_leaveAnimation = new QPropertyAnimation;
m_leaveAnimation=new QPropertyAnimation;
m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit());
connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot);
connect(m_enterAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot);
connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot);
connect(m_enterAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot);
}
/**
@ -62,13 +62,12 @@ void FunctionWidget::initUi()
*/
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=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();
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);
connect(m_appListView,&ListView::sendItemClickedSignal,this,&FunctionWidget::recvItemClickedSlot);
connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&FunctionWidget::sendHideMainWindowSignal);
}
@ -77,118 +76,105 @@ void FunctionWidget::initAppListWidget()
*/
void FunctionWidget::fillAppListView(int type)
{
row = 0;
row=0;
m_data.clear();
m_classificationList.clear();
m_classificationBtnRowList.clear();
QVector<QStringList> vector = UkuiMenuInterface::functionalVector;
QStringList androidlist = vector.at(0);
if (!androidlist.isEmpty()) {
QVector<QStringList> vector=UkuiMenuInterface::functionalVector;
QStringList androidlist=vector.at(0);
if(!androidlist.isEmpty())
{
insertClassificationBtn(tr("Mobile"));
insertAppList(androidlist);
}
QStringList netlist = vector.at(1);
if (!netlist.isEmpty()) {
QStringList netlist=vector.at(1);
if(!netlist.isEmpty())
{
insertClassificationBtn(tr("Internet"));
insertAppList(netlist);
}
QStringList sociallist = vector.at(2);
if (!sociallist.isEmpty()) {
QStringList sociallist=vector.at(2);
if(!sociallist.isEmpty())
{
insertClassificationBtn(tr("Social"));
insertAppList(sociallist);
}
QStringList avlist = vector.at(3);
if (!avlist.isEmpty()) {
QStringList avlist=vector.at(3);
if(!avlist.isEmpty())
{
insertClassificationBtn(tr("Video"));
insertAppList(avlist);
}
QStringList developlist = vector.at(4);
if (!developlist.isEmpty()) {
QStringList developlist=vector.at(4);
if(!developlist.isEmpty())
{
insertClassificationBtn(tr("Development"));
insertAppList(developlist);
}
QStringList graphicslist = vector.at(5);
if (!graphicslist.isEmpty()) {
QStringList graphicslist=vector.at(5);
if(!graphicslist.isEmpty())
{
insertClassificationBtn(tr("Image"));
insertAppList(graphicslist);
}
QStringList gamelist = vector.at(6);
if (!gamelist.isEmpty()) {
QStringList gamelist=vector.at(6);
if(!gamelist.isEmpty())
{
insertClassificationBtn(tr("Game"));
insertAppList(gamelist);
}
QStringList officelist = vector.at(7);
if (!officelist.isEmpty()) {
QStringList officelist=vector.at(7);
if(!officelist.isEmpty())
{
insertClassificationBtn(tr("Office"));
insertAppList(officelist);
}
QStringList educationlist = vector.at(8);
if (!educationlist.isEmpty()) {
QStringList educationlist=vector.at(8);
if(!educationlist.isEmpty())
{
insertClassificationBtn(tr("Education"));
insertAppList(educationlist);
}
QStringList systemadminlist = vector.at(9);
if (!systemadminlist.isEmpty()) {
QStringList systemadminlist=vector.at(9);
if(!systemadminlist.isEmpty())
{
insertClassificationBtn(tr("System"));
insertAppList(systemadminlist);
}
QStringList otherlist = vector.at(10);
if (!otherlist.isEmpty()) {
QStringList otherlist=vector.at(10);
if(!otherlist.isEmpty())
{
insertClassificationBtn(tr("Others"));
insertAppList(otherlist);
}
if (type == 0) {
if(type==0)
m_appListView->addData(m_data);
} else {
else
m_appListView->updateData(m_data);
}
}
void FunctionWidget::insertClassificationBtn(QString btnname)
{
m_classificationList.append(btnname);
m_data.append(QStringList() << btnname << "0");
m_data.append(QStringList()<<btnname<<"0");
m_classificationBtnRowList.append(QString::number(row));
}
void FunctionWidget::insertAppList(QStringList appnamelist)
{
row += (appnamelist.count() + 1);
for (int i = 0; i < appnamelist.count(); i++) {
m_data.append(QStringList() << appnamelist.at(i) << "1");
}
row+=(appnamelist.count()+1);
for(int i=0;i<appnamelist.count();i++)
m_data.append(QStringList()<<appnamelist.at(i)<<"1");
}
void FunctionWidget::recvItemClickedSlot(QStringList arg)
{
if (arg.at(1).toInt() == 0) {
if(arg.at(1).toInt()==0)
appClassificationBtnClickedSlot();
} else {
else
execApplication(arg.at(0));
}
}
/**
@ -213,22 +199,23 @@ void FunctionWidget::updateAppListView()
*/
void FunctionWidget::appClassificationBtnClickedSlot()
{
m_leaveAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6));
// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40));
m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80));
m_enterAnimation->setEndValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2,
(this->height() - Style::LeftBtnHeight * 6 - 25) / 2,
Style::LeftBtnWidth * 2 + 5,
Style::LeftBtnHeight * 6 + 25));
m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6));
m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80));
m_enterAnimation->setEndValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2,
(this->height()-Style::LeftBtnHeight*6-25)/2,
Style::LeftBtnWidth*2+5,
Style::LeftBtnHeight*6+25));
m_leaveAnimation->setDuration(10);
m_enterAnimation->setDuration(100);
//加载FunctionButtonWidget界面
Q_EMIT sendClassificationbtnList();
m_leaveAnimation->setTargetObject(m_appListView);
m_enterAnimation->setTargetObject(m_functionBtnWid);
m_leaveAnimation->start();
m_widgetState = 1;
m_widgetState=1;
}
/**
@ -237,42 +224,44 @@ void FunctionWidget::appClassificationBtnClickedSlot()
void FunctionWidget::recvFunctionBtnSignal(QString btnname)
{
//此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端
int index = m_classificationList.indexOf(btnname);
if (index != -1) {
int row = m_classificationBtnRowList.at(index).toInt();
int index=m_classificationList.indexOf(btnname);
if(index!=-1)
{
int row=m_classificationBtnRowList.at(index).toInt();
m_appListView->verticalScrollBar()->setValue(row);
}
m_leaveAnimation->setStartValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2,
(this->height() - Style::LeftBtnHeight * 6 - 25) / 2,
Style::LeftBtnWidth * 2 + 5,
Style::LeftBtnHeight * 6 + 25));
m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80));
m_leaveAnimation->setStartValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2,
(this->height()-Style::LeftBtnHeight*6-25)/2,
Style::LeftBtnWidth*2+5,
Style::LeftBtnHeight*6+25));
m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80));
// m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40));
m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6));
m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6));
m_leaveAnimation->setDuration(100);
m_enterAnimation->setDuration(10);
m_leaveAnimation->setTargetObject(m_functionBtnWid);
m_enterAnimation->setTargetObject(m_appListView);
m_leaveAnimation->start();
m_widgetState = 0;
m_widgetState=0;
}
void FunctionWidget::animationFinishedSLot()
{
if (m_widgetState == 1) {
if(m_widgetState==1)
{
m_appListView->hide();
m_enterAnimation->start();
m_widgetState = -1;
m_widgetState=-1;
m_functionBtnWid->show();
}
if (m_widgetState == 0) {
if(m_widgetState==0)
{
m_functionBtnWid->hide();
m_enterAnimation->start();
m_widgetState = -1;
m_widgetState=-1;
m_appListView->show();
}
}
@ -280,24 +269,23 @@ void FunctionWidget::animationFinishedSLot()
void FunctionWidget::widgetMakeZero()
{
m_functionBtnWid->hide();
m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_appListView->show();
m_appListView->verticalScrollBar()->setValue(0);
}
void FunctionWidget::moveScrollBar(int type)
{
if (type == 0) {
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100);
} else {
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100);
}
if(type==0)
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100);
else
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100);
}
void FunctionWidget::repaintWidget()
{
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_appListView->show();
}

View File

@ -132,8 +132,6 @@ Q_SIGNALS:
* @brief Send a hidden main window signal to the MainViewWidget
*/
void sendHideMainWindowSignal();
void sendMainWinActiveSignal(bool flag);
};
#endif // FUNCTIONWIDGET_H

View File

@ -144,7 +144,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString& _filePath)
} while(i < list.size());
}
//获取系统desktop文件路径
//获取系统deskyop文件路径
QStringList UkuiMenuInterface::getDesktopFilePath()
{
filePathList.clear();
@ -176,6 +176,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath()
{
getAndroidApp();
recursiveSearchFile("/usr/share/applications/");
recursiveSearchFile(QDir::homePath()+"/.local/share/applications/");
recursiveSearchFile("/var/lib/snapd/desktop/applications/");
recursiveSearchFile("/var/lib/flatpak/exports/share/applications/");
QJsonArray blArray=obj.value("blacklist").toArray();
@ -191,6 +192,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath()
{
getAndroidApp();
recursiveSearchFile("/usr/share/applications/");
recursiveSearchFile(QDir::homePath()+"/.local/share/applications/");
recursiveSearchFile("/var/lib/snapd/desktop/applications/");
recursiveSearchFile("/var/lib/flatpak/exports/share/applications/");
}
@ -203,6 +205,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath()
{
getAndroidApp();
recursiveSearchFile("/usr/share/applications/");
recursiveSearchFile(QDir::homePath()+"/.local/share/applications/");
recursiveSearchFile("/var/lib/snapd/desktop/applications/");
recursiveSearchFile("/var/lib/flatpak/exports/share/applications/");
}
@ -247,21 +250,6 @@ QStringList UkuiMenuInterface::getDesktopFilePath()
filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop");
filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop");
QStringList desktopList;
for(int i = 0; i < filePathList.count(); ++i)
{
QString filepath = filePathList.at(i);
int list_index = filepath.lastIndexOf('/');
QString desktopName = filepath.right(filepath.length() - list_index - 1);
if(desktopList.contains(desktopName)){
filePathList.removeAll(filepath);
i--;
}
else
{
desktopList.append(desktopName);
}
}
return filePathList;
}
@ -289,7 +277,6 @@ QVector<QStringList> UkuiMenuInterface::createAppInfoVector()
QStringList appInfoList;
QString desktopfp=desktopfpList.at(i);
QString name=getAppName(desktopfpList.at(i));
if(!name.isEmpty())
{
QString englishName=getAppEnglishName(desktopfpList.at(i));
@ -847,21 +834,21 @@ void UkuiMenuInterface::getAndroidApp()
QByteArray fpbyte=filePathStr.toLocal8Bit();
char* filepath=fpbyte.data();
g_key_file_load_from_file(keyfile,filepath,flags,error);
// char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr);
// if(ret_1!=nullptr)
// {
// QString str=QString::fromLocal8Bit(ret_1);
// if(!str.contains("Android"))
// {
// i++;
// continue;
// }
// else
// {
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());

View File

@ -28,10 +28,9 @@ FullLetterWidget::FullLetterWidget(QWidget *parent) :
FullLetterWidget::~FullLetterWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
delete m_letterListBottomSpacer;
delete m_appListBottomSpacer;
}
/**
@ -40,28 +39,33 @@ FullLetterWidget::~FullLetterWidget()
void FullLetterWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setAttribute(Qt::WA_TranslucentBackground);
m_applistWid = new QWidget(this);
m_letterListWid = new QWidget(this);
m_applistWid=new QWidget(this);
m_letterListWid=new QWidget(this);
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
m_applistWid->setFixedSize(Style::AppListWidWidth, this->height());
m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height());
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
m_applistWid->setFixedSize(Style::AppListWidWidth,this->height());
m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height());
QHBoxLayout* mainLayout=new QHBoxLayout;
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->setSpacing(0);
mainLayout->addWidget(m_letterListWid);
mainLayout->addWidget(m_applistWid);
this->setLayout(mainLayout);
m_ukuiMenuInterface = new UkuiMenuInterface;
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
initLetterListWidget();
flag = true;
//翻页灵敏度时间调节
time = new QTimer(this);
connect(time, &QTimer::timeout, [ = ]() {
if (flag == false) {
connect(time,&QTimer::timeout,[=](){
if(flag == false)
{
flag = true;
time->stop();
}
@ -73,22 +77,24 @@ void FullLetterWidget::initUi()
*/
void FullLetterWidget::initAppListWidget()
{
QHBoxLayout *layout = new QHBoxLayout(m_applistWid);
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* layout=new QHBoxLayout(m_applistWid);
layout->setContentsMargins(0,0,0,0);
m_applistWid->setLayout(layout);
m_scrollArea = new ScrollArea;
m_scrollAreaWid = new ScrollAreaWid;
m_scrollArea=new ScrollArea;
m_scrollAreaWid=new ScrollAreaWid;
m_scrollArea->setWidget(m_scrollAreaWid);
m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height());
m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height());
m_scrollArea->setWidgetResizable(true);
m_scrollAreaWidLayout = new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout=new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWid->setLayout(m_scrollAreaWidLayout);
layout->addWidget(m_scrollArea);
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullLetterWidget::valueChangedSlot);
m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullLetterWidget::valueChangedSlot);
m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
fillAppList();
}
@ -105,52 +111,47 @@ void FullLetterWidget::setFocusToThis()
void FullLetterWidget::fillAppList()
{
m_letterList.clear();
QVector<QStringList> vector = UkuiMenuInterface::alphabeticVector;
for (int i = 0; i < vector.size(); i++) {
QStringList appList = vector.at(i);
if (!appList.isEmpty()) {
QVector<QStringList> vector=UkuiMenuInterface::alphabeticVector;
for(int i=0;i<vector.size();i++)
{
QStringList appList=vector.at(i);
if(!appList.isEmpty())
{
QString letterstr;
if (i < 26) {
letterstr = QString(QChar(static_cast<char>(i + 65)));
} else if (i == 26) {
letterstr = "&";
} else {
letterstr = "#";
}
if(i<26)
letterstr=QString(QChar(static_cast<char>(i+65)));
else if(i==26)
letterstr="&";
else
letterstr="#";
m_letterList.append(letterstr);//存储分类字符
//插入字母分类按钮
SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 16, 30, 1);
SplitBarFrame* letterbtn=new SplitBarFrame(this,letterstr,m_scrollArea->width()-12,30,1);
m_scrollAreaWidLayout->addWidget(letterbtn);
//插入应用列表
FullListView *listview = new FullListView(this, 1);
connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider);
FullListView* listview=new FullListView(this,1);
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();
connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){
listview->repaint(listview->rect());
});
m_scrollAreaWidLayout->addWidget(listview);
m_data.clear();
for (int i = 0; i < appList.count(); i++) {
for(int i=0;i<appList.count();i++)
m_data.append(appList.at(i));
}
listview->addData(m_data);
connect(listview, &FullListView::sendItemClickedSignal, this, &FullLetterWidget::execApplication);
connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullLetterWidget::sendHideMainWindowSignal);
}
}
connect(listview,&FullListView::sendItemClickedSignal,this,&FullLetterWidget::execApplication);
connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullLetterWidget::sendHideMainWindowSignal);
}
}
m_scrollAreaWidLayout->addItem(m_appListBottomSpacer);
resizeScrollAreaControls();
}
@ -171,27 +172,23 @@ void FullLetterWidget::updateAppListView()
//刷新应用列表界面
QLayoutItem *child;
m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer);
while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) {
QWidget *wid = child->widget();
QWidget* wid=child->widget();
m_scrollAreaWidLayout->removeWidget(wid);
wid->setParent(nullptr);
delete wid;
delete child;
}
fillAppList();
//刷新字母列表界面
Q_FOREACH (QAbstractButton *button, m_buttonList) {
Q_FOREACH (QAbstractButton* button, m_buttonList) {
m_btnGroup->removeButton(button);
}
m_buttonList.clear();
m_letterListScrollAreaWidLayout->removeItem(m_letterListBottomSpacer);
while ((child = m_letterListScrollAreaWidLayout->takeAt(0)) != 0) {
QWidget *wid = child->widget();
QWidget* wid=child->widget();
m_letterListScrollAreaWidLayout->removeWidget(wid);
wid->setParent(nullptr);
delete wid;
@ -207,27 +204,30 @@ void FullLetterWidget::updateAppListView()
*/
void FullLetterWidget::resizeScrollAreaControls()
{
int row = 0;
while (row < m_scrollAreaWidLayout->count() / 2) {
int row=0;
while(row<m_scrollAreaWidLayout->count()/2)
{
//应用界面
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1);
QWidget *wid = widItem->widget();
FullListView *listview = qobject_cast<FullListView *>(wid);
QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1);
QWidget* wid=widItem->widget();
FullListView* listview=qobject_cast<FullListView*>(wid);
listview->adjustSize();
int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
int rowcount = 0;
int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth;
int rowcount=0;
if(listview->model()->rowCount()%dividend>0)
{
rowcount=listview->model()->rowCount()/dividend+1;
}
else
{
rowcount=listview->model()->rowCount()/dividend;
if (listview->model()->rowCount() % dividend > 0) {
rowcount = listview->model()->rowCount() / dividend + 1;
} else {
rowcount = listview->model()->rowCount() / dividend;
}
listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount);
listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount);
row++;
}
m_scrollArea->widget()->adjustSize();
}
@ -236,21 +236,24 @@ void FullLetterWidget::resizeScrollAreaControls()
*/
void FullLetterWidget::initLetterListWidget()
{
m_letterListScrollArea = new ClassifyBtnScrollArea(m_letterListWid);
m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid;
m_letterListScrollAreaWidLayout = new QVBoxLayout;
m_letterListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_letterListScrollArea=new ClassifyBtnScrollArea(m_letterListWid);
m_letterListScrollAreaWid=new ClassifyBtnScrollAreaWid;
m_letterListScrollAreaWidLayout=new QVBoxLayout;
m_letterListScrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_letterListScrollAreaWidLayout->setSpacing(0);
m_letterListScrollAreaWid->setLayout(m_letterListScrollAreaWidLayout);
m_letterListScrollArea->setWidget(m_letterListScrollAreaWid);
m_letterListScrollArea->setWidgetResizable(true);
m_letterListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_btnGroup = new QButtonGroup(m_letterListScrollAreaWid);
m_letterListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
m_btnGroup=new QButtonGroup(m_letterListScrollAreaWid);
m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry");
m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value");
m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad);
connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot);
connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot);
initLetterListScrollArea();
}
@ -259,60 +262,56 @@ void FullLetterWidget::initLetterListWidget()
*/
void FullLetterWidget::initLetterListScrollArea()
{
if (m_letterList.contains("&")) {
m_letterList.replace(m_letterList.indexOf("&"), "&&");
}
for (int i = 0; i < m_letterList.size(); i++) {
LetterClassifyButton *letterbtn = new LetterClassifyButton(m_letterListScrollAreaWid,
if(m_letterList.contains("&"))
m_letterList.replace(m_letterList.indexOf("&"),"&&");
for(int i=0;i<m_letterList.size();i++)
{
LetterClassifyButton* letterbtn=new LetterClassifyButton(m_letterListScrollAreaWid,
true,
m_letterList.at(i));
letterbtn->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight);
letterbtn->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight);
m_buttonList.append(letterbtn);
m_letterListScrollAreaWidLayout->addWidget(letterbtn);
m_letterListScrollAreaWidLayout->setAlignment(letterbtn, Qt::AlignHCenter);
connect(letterbtn, &LetterClassifyButton::buttonClicked, m_btnGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked));
m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter);
connect(letterbtn,&LetterClassifyButton::buttonClicked,m_btnGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked));
}
m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer);
int id = 0;
Q_FOREACH (QAbstractButton *btn, m_buttonList) {
m_btnGroup->addButton(btn, id++);
int id=0;
Q_FOREACH (QAbstractButton* btn, m_buttonList) {
m_btnGroup->addButton(btn,id++);
}
connect(m_btnGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &FullLetterWidget::btnGroupClickedSlot);
connect(m_btnGroup,static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),this,&FullLetterWidget::btnGroupClickedSlot);
m_letterListScrollArea->widget()->adjustSize();
if (m_btnGroup->button(0) != nullptr) {
if(m_btnGroup->button(0)!=nullptr)
m_btnGroup->button(0)->click();
}
}
void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn)
{
disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullLetterWidget::valueChangedSlot);
Q_FOREACH (QAbstractButton *button, m_buttonList) {
LetterClassifyButton *letterbtn = qobject_cast<LetterClassifyButton *>(button);
if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) {
disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullLetterWidget::valueChangedSlot);
Q_FOREACH (QAbstractButton* button, m_buttonList) {
LetterClassifyButton* letterbtn=qobject_cast<LetterClassifyButton*>(button);
if(m_btnGroup->id(btn)==m_buttonList.indexOf(button))
{
letterbtn->setChecked(true);
//此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端
QString letterstr = letterbtn->text();
int num = m_letterList.indexOf(letterstr);
if (num != -1) {
m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition();
m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y();
QString letterstr=letterbtn->text();
int num=m_letterList.indexOf(letterstr);
if(num!=-1)
{
m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition();
m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y();
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollAnimation->stop();
m_scrollAnimation->setStartValue(m_beginPos);
m_scrollAnimation->setEndValue(m_endPos);
m_scrollAnimation->start();
}
} else {
}
else{
letterbtn->setChecked(false);
}
}
@ -320,58 +319,56 @@ void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn)
void FullLetterWidget::animationFinishSlot()
{
if (m_scrollArea->verticalScrollBar()->value() == m_endPos ||
m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) {
if(m_scrollArea->verticalScrollBar()->value()==m_endPos ||
m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum())
{
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullLetterWidget::valueChangedSlot);
connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,
this,&FullLetterWidget::valueChangedSlot);
}
}
void FullLetterWidget::animationValueChangedSlot(const QVariant &value)
{
Q_UNUSED(value);
if (sender() != m_scrollAnimation) {
if (sender() != m_scrollAnimation)
return;
}
QPropertyAnimation *ani = qobject_cast<QPropertyAnimation *>(sender());
if (m_endPos != ani->endValue()) {
if (m_endPos != ani->endValue())
ani->setEndValue(m_endPos);
}
}
void FullLetterWidget::valueChangedSlot(int value)
{
int index = 0;
int index=0;
while(index<=m_letterList.count()-1)
{
int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y();
int max=0;
if(index==m_letterList.count()-1)
max=m_scrollAreaWid->height();
else
max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y();
while (index <= m_letterList.count() - 1) {
int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y();
int max = 0;
if (index == m_letterList.count() - 1) {
max = m_scrollAreaWid->height();
} else {
max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y();
}
if (value >= min && value < max) {
Q_FOREACH (QAbstractButton *button, m_buttonList) {
LetterClassifyButton *letterbtn = qobject_cast<LetterClassifyButton *>(button);
if (index == m_buttonList.indexOf(button)) {
if(value>=min && value <max)
{
Q_FOREACH (QAbstractButton* button, m_buttonList) {
LetterClassifyButton* letterbtn=qobject_cast<LetterClassifyButton*>(button);
if(index==m_buttonList.indexOf(button))
{
letterbtn->setChecked(true);
} else {
}
else
{
letterbtn->setChecked(false);
}
}
break;
} else {
index++;
}
else
index++;
}
// //向下滚动
@ -380,23 +377,26 @@ void FullLetterWidget::valueChangedSlot(int value)
// int val=m_letterListScrollArea->verticalScrollBar()->sliderPosition()+m_buttonList.at(index)->height();
// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val);
// }
// //向上滚动
// if((m_buttonList.at(index)->pos().y()+m_letterListScrollArea->widget()->pos().y()) <= 0)
// {
// int val=m_letterListScrollArea->verticalScrollBar()->value()-m_buttonList.at(index)->height();
// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val);
// }
}
void FullLetterWidget::enterAnimation()
{
m_animation->setDuration(200);//动画总时间
m_animation->setStartValue(QRect(0, (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2,
0, (m_letterList.size() + 1)*Style::LeftLetterBtnHeight));
m_animation->setStartValue(QRect(0,(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2,
0,(m_letterList.size()+1)*Style::LeftLetterBtnHeight));
m_animation->setEndValue(QRect(Style::LeftMargin,
(m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2,
Style::LeftLetterBtnHeight * 2,
(m_letterList.size() + 1)*Style::LeftLetterBtnHeight));
(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2,
Style::LeftLetterBtnHeight*2,
(m_letterList.size()+1)*Style::LeftLetterBtnHeight));
m_animation->setEasingCurve(QEasingCurve::InQuart);
m_animation->start();
m_letterListScrollArea->show();
@ -405,9 +405,9 @@ void FullLetterWidget::enterAnimation()
void FullLetterWidget::setLetterBtnGeometry()
{
m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin,
(m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2,
Style::LeftLetterBtnHeight * 2,
(m_letterList.size() + 1)*Style::LeftLetterBtnHeight));
(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2,
Style::LeftLetterBtnHeight*2,
(m_letterList.size()+1)*Style::LeftLetterBtnHeight));
m_letterListScrollArea->show();
}
@ -415,37 +415,35 @@ void FullLetterWidget::repaintWidget()
{
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
m_applistWid->setFixedSize(Style::AppListWidWidth, this->height());
m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height());
m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height());
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();
}
void FullLetterWidget::widgetMakeZero()
{
Q_FOREACH (QAbstractButton *button, m_buttonList) {
QString letterstr = button->text().at(0);
int num = m_letterList.indexOf(letterstr);
if (num != -1) {
Q_FOREACH (QAbstractButton* button, m_buttonList) {
QString letterstr=button->text().at(0);
int num=m_letterList.indexOf(letterstr);
if(num!=-1)
{
m_btnGroup->button(num)->click();
m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0);
break;
}
}
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}
void FullLetterWidget::moveScrollBar(int type)
{
int height = Style::primaryScreenHeight;
if (type == 0) {
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080);
} else {
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080);
}
int height=Style::primaryScreenHeight;
if(type==0)
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080);
else
m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080);
}
void FullLetterWidget::onSetSlider(int value)
@ -459,70 +457,74 @@ void FullLetterWidget::onSetSlider(int value)
// }
}
QAbstractButton *FullLetterWidget::getCurLetterButton(int value)
QAbstractButton* FullLetterWidget::getCurLetterButton(int value)
{
return m_buttonList.at(value);
}
bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
QWidget *wid = widItem->widget();
FullListView *m_listview = qobject_cast<FullListView *>(wid);
QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1);
QWidget *widTop = widItemTop->widget();
FullListView *m_listviewTop = qobject_cast<FullListView *>(widTop);
QKeyEvent *ke = (QKeyEvent *)event;
if( event->type() == QEvent::KeyPress )
{
QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
QWidget* wid = widItem->widget();
FullListView* m_listview = qobject_cast<FullListView*>(wid);
if (ke->key() == Qt::Key_Tab) {
QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1);
QWidget* widTop = widItemTop->widget();
FullListView* m_listviewTop = qobject_cast<FullListView*>(widTop);
QKeyEvent *ke = (QKeyEvent *)event;
if( ke->key() == Qt::Key_Tab )
{
// m_letterListScrollAreaWid->setFocus();
// m_letterListScrollArea->setFocus();
// return true;
Q_EMIT setFocusToSideWin();
}
if (ke->key() == Qt::Key_Up) {
if (!m_listviewTop->hasFocus()) {
QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size());
if(ke->key() == Qt::Key_Up)
{
if(!m_listviewTop->hasFocus())
{
QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size());
btnGroupClickedSlot(buttonTop);
this->m_scrollArea->setFocusToPreChild();
} else {
}
else
{
m_listview->setFocus();
QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1);
QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1);
btnGroupClickedSlot(button);
m_index = m_buttonList.size() - 1;
}
Q_EMIT selectFirstItem();
return true;
}
if (ke->key() == Qt::Key_Down) {
if (!m_listview->hasFocus()) {
QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size());
if(ke->key() == Qt::Key_Down)
{
if(!m_listview->hasFocus())
{
QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size());
btnGroupClickedSlot(button);
this->m_scrollArea->setFocusToNextChild();
} else {
}
else
{
m_listviewTop->setFocus();
QAbstractButton *buttonTop = getCurLetterButton(0);
QAbstractButton* buttonTop = getCurLetterButton(0);
btnGroupClickedSlot(buttonTop);
m_index = 0;
}
Q_EMIT selectFirstItem();
return true;
}
}
return QWidget::eventFilter(watched, event);
return QWidget::eventFilter(watched,event);
}
void FullLetterWidget::letterButtonClick()
{
if (m_btnGroup->button(0) != nullptr) {
if(m_btnGroup->button(0)!=nullptr)
m_btnGroup->button(0)->click();
}
m_index = 0;
}

View File

@ -38,10 +38,7 @@ LetterWidget::LetterWidget(QWidget *parent) :
LetterWidget::~LetterWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
/**
@ -50,21 +47,24 @@ LetterWidget::~LetterWidget()
void LetterWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_StyledBackground, true);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_ukuiMenuInterface = new UkuiMenuInterface;
this->setAttribute(Qt::WA_StyledBackground,true);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_ukuiMenuInterface=new UkuiMenuInterface;
initAppListWidget();
m_letterBtnWid = new LetterButtonWidget(this);
m_letterBtnWid=new LetterButtonWidget(this);
m_letterBtnWid->hide();
connect(this, &LetterWidget::sendLetterBtnList, m_letterBtnWid, &LetterButtonWidget::recvLetterBtnList);
connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &LetterWidget::recvLetterBtnSlot);
m_enterAnimation = new QPropertyAnimation;
connect(this,&LetterWidget::sendLetterBtnList,m_letterBtnWid,&LetterButtonWidget::recvLetterBtnList);
connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal,this,&LetterWidget::recvLetterBtnSlot);
m_enterAnimation=new QPropertyAnimation;
m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit());
m_leaveAnimation = new QPropertyAnimation;
m_leaveAnimation=new QPropertyAnimation;
m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit());
connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot);
connect(m_enterAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot);
connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot);
connect(m_enterAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot);
}
/**
@ -72,13 +72,12 @@ void LetterWidget::initUi()
*/
void LetterWidget::initAppListWidget()
{
m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 1);
m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
m_appListView=new ListView(this,this->width()-6,this->height()-6,1);
m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_appListView->show();
fillAppListView();
connect(m_appListView, &ListView::sendItemClickedSignal, this, &LetterWidget::recvItemClickedSlot);
connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &LetterWidget::sendHideMainWindowSignal);
connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &LetterWidget::sendMainWinActiveSignal);
connect(m_appListView,&ListView::sendItemClickedSignal,this,&LetterWidget::recvItemClickedSlot);
connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&LetterWidget::sendHideMainWindowSignal);
}
@ -88,32 +87,27 @@ void LetterWidget::initAppListWidget()
void LetterWidget::fillAppListView()
{
m_data.clear();
int row = 0;
QVector<QStringList> vector = UkuiMenuInterface::alphabeticVector;
for (int i = 0; i < vector.size(); i++) {
QStringList appList = vector.at(i);
if (!appList.isEmpty()) {
int row=0;
QVector<QStringList> vector=UkuiMenuInterface::alphabeticVector;
for(int i=0;i<vector.size();i++)
{
QStringList appList=vector.at(i);
if(!appList.isEmpty())
{
QString letterstr;
if (i < 26) {
letterstr = QString(QChar(static_cast<char>(i + 65)));
} else if (i == 26) {
letterstr = "&";
} else {
letterstr = "#";
}
if(i<26)
letterstr=QString(QChar(static_cast<char>(i+65)));
else if(i==26)
letterstr="&";
else
letterstr="#";
m_letterList.append(letterstr);//存储分类字符
m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行
m_data.append(QStringList() << letterstr << "0");
m_data.append(QStringList()<<letterstr<<"0");
for(int i=0;i<appList.count();i++)
m_data.append(QStringList()<<appList.at(i)<<"1");
row+=(appList.count()+1);
for (int i = 0; i < appList.count(); i++) {
m_data.append(QStringList() << appList.at(i) << "1");
}
row += (appList.count() + 1);
}
}
@ -122,11 +116,10 @@ void LetterWidget::fillAppListView()
void LetterWidget::recvItemClickedSlot(QStringList arg)
{
if (arg.at(1).toInt() == 0) {
if(arg.at(1).toInt()==0)
appClassificationBtnClickedSlot();
} else {
else
execApplication(arg.at(0));
}
}
/**
@ -143,38 +136,32 @@ void LetterWidget::execApplication(QString desktopfp)
*/
void LetterWidget::updateAppListView()
{
int row = 0;
int row=0;
m_data.clear();
m_letterList.clear();
m_letterBtnRowList.clear();
QVector<QStringList> vector = UkuiMenuInterface::alphabeticVector;
for (int i = 0; i < vector.size(); i++) {
QStringList appList = vector.at(i);
if (!appList.isEmpty()) {
QVector<QStringList> vector=UkuiMenuInterface::alphabeticVector;
for(int i=0;i<vector.size();i++)
{
QStringList appList=vector.at(i);
if(!appList.isEmpty())
{
QString letterstr;
if (i < 26) {
letterstr = QString(QChar(static_cast<char>(i + 65)));
} else if (i == 26) {
letterstr = "&";
} else {
letterstr = "#";
}
if(i<26)
letterstr=QString(QChar(static_cast<char>(i+65)));
else if(i==26)
letterstr="&";
else
letterstr="#";
m_letterList.append(letterstr);//存储分类字符
m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行
m_data.append(QStringList() << letterstr << "0");
m_data.append(QStringList()<<letterstr<<"0");
for(int i=0;i<appList.count();i++)
m_data.append(QStringList()<<appList.at(i)<<"1");
row+=(appList.count()+1);
for (int i = 0; i < appList.count(); i++) {
m_data.append(QStringList() << appList.at(i) << "1");
}
row += (appList.count() + 1);
}
}
m_appListView->updateData(m_data);
}
@ -183,11 +170,12 @@ void LetterWidget::updateAppListView()
*/
void LetterWidget::appClassificationBtnClickedSlot()
{
m_leaveAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6));
m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6));
// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40));
m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80));
m_enterAnimation->setEndValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366));
m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80));
m_enterAnimation->setEndValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366));
//加载LetterBUttonWidget界面
m_enterAnimation->setDuration(100);
m_leaveAnimation->setDuration(10);
@ -195,7 +183,7 @@ void LetterWidget::appClassificationBtnClickedSlot()
m_leaveAnimation->setTargetObject(m_appListView);
m_enterAnimation->setTargetObject(m_letterBtnWid);
m_leaveAnimation->start();
m_widgetState = 1;
m_widgetState=1;
}
/**
@ -204,38 +192,40 @@ void LetterWidget::appClassificationBtnClickedSlot()
void LetterWidget::recvLetterBtnSlot(QString btnname)
{
//此处需实现将字母为btnname的应用列表移动到applistWid界面最顶端
int num = m_letterList.indexOf(QString(QChar(btnname.at(0))));
if (num != -1) {
int row = m_letterBtnRowList.at(num).toInt();
int num=m_letterList.indexOf(QString(QChar(btnname.at(0))));
if(num!=-1)
{
int row=m_letterBtnRowList.at(num).toInt();
m_appListView->verticalScrollBar()->setValue(row);
}
m_leaveAnimation->setStartValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366));
m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80));
m_leaveAnimation->setStartValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366));
m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80));
// m_enterAnimation->setStartValue(QRect(16,10,this->width()-20,this->height()-20));
m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6));
m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6));
m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6));
m_enterAnimation->setDuration(10);
m_leaveAnimation->setDuration(100);
m_leaveAnimation->setTargetObject(m_letterBtnWid);
m_enterAnimation->setTargetObject(m_appListView);
m_leaveAnimation->start();
m_widgetState = 0;
m_widgetState=0;
}
void LetterWidget::animationFinishedSLot()
{
if (m_widgetState == 1) {
if(m_widgetState==1)
{
m_enterAnimation->start();
m_widgetState = -1;
m_widgetState=-1;
m_appListView->hide();
m_letterBtnWid->show();
}
if (m_widgetState == 0) {
if(m_widgetState==0)
{
m_enterAnimation->start();
m_widgetState = -1;
m_widgetState=-1;
m_letterBtnWid->hide();
m_appListView->show();
}
@ -244,24 +234,23 @@ void LetterWidget::animationFinishedSLot()
void LetterWidget::widgetMakeZero()
{
m_letterBtnWid->hide();
m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_appListView->show();
m_appListView->verticalScrollBar()->setValue(0);
}
void LetterWidget::moveScrollBar(int type)
{
if (type == 0) {
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100);
} else {
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100);
}
if(type==0)
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100);
else
m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100);
}
void LetterWidget::repaintWidget()
{
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_appListView->show();
}

View File

@ -122,7 +122,6 @@ Q_SIGNALS:
* @brief Send a hidden main window signal to the MainViewWidget
*/
void sendHideMainWindowSignal();
void sendMainWinActiveSignal(bool flag);
};
#endif // LETTERWIDGET_H

View File

@ -23,38 +23,42 @@
DirectoryChangedThread::DirectoryChangedThread()
{
m_ukuiMenuInterface = new UkuiMenuInterface;
m_ukuiMenuInterface=new UkuiMenuInterface;
}
DirectoryChangedThread::~DirectoryChangedThread()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void DirectoryChangedThread::run()
{
closeDataBase("DirectoryChangedThread");
openDataBase("DirectoryChangedThread");
QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath();
if (desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装
for (int i = 0; i < desktopfpList.count(); i++) {
if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) {
QStringList desktopfpList=m_ukuiMenuInterface->getDesktopFilePath();
if(desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size())//有新的应用安装
{
for(int i=0;i<desktopfpList.count();i++)
{
if(!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i)))
{
QFileInfo fileInfo(desktopfpList.at(i));
QString desktopfn = fileInfo.fileName();
QString desktopfn=fileInfo.fileName();
updateDataBaseTableRecent(desktopfn);
//break;
}
}
} else { //软件卸载
for (int i = 0; i < UkuiMenuInterface::desktopfpVector.size(); i++) {
if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) {
QString desktopfp = UkuiMenuInterface::appInfoVector.at(i).at(0);
}
else//软件卸载
{
for(int i=0;i<UkuiMenuInterface::desktopfpVector.size();i++)
{
if(!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i)))
{
QString desktopfp=UkuiMenuInterface::appInfoVector.at(i).at(0);
QFileInfo fileInfo(desktopfp);
QString desktopfn = fileInfo.fileName();
QString desktopfn=fileInfo.fileName();
deleteAppRecord(desktopfn);
// break;
}
@ -64,8 +68,8 @@ 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();
UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector();
UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification();
UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification();
Q_EMIT requestUpdateSignal();
}

File diff suppressed because it is too large Load Diff

View File

@ -40,23 +40,9 @@
#include "src/SearchResultWidget/fullsearchresultwidget.h"
#include "src/SearchResultWidget/searchresultwidget.h"
#include "src/SearchResultWidget/searchappthread.h"
#include "src/UtilityFunction/convertdesktoptowinid.h"
#include "directorychangedthread.h"
#include "src/Style/style.h"
class MyLineEdit : public QLineEdit{
Q_OBJECT
public:
explicit MyLineEdit(QLineEdit *parent = nullptr){unsetCursor();}
~MyLineEdit(){}
void simulateFocusOutEvent(QKeyEvent *e){
QApplication::postEvent(this, new QEvent(QEvent::FocusOut));
this->focusOutEvent(new QFocusEvent(QEvent::FocusOut));
}
};
class MainViewWidget : public QWidget
{
Q_OBJECT
@ -88,6 +74,7 @@ public:
/**
* @brief changeFocuUp
*/
void repaintFullWidget();
void changeFocuUp();
/**
@ -105,8 +92,6 @@ public:
void resetQueryLine();
MyLineEdit* getQueryLineEditer() {return m_queryLineEdit;}
private:
UkuiMenuInterface *m_ukuiMenuInterface=nullptr;
QWidget *m_topWidget=nullptr;
@ -114,7 +99,7 @@ private:
QWidget *m_contentWid=nullptr;
MyLineEdit *m_queryLineEdit=nullptr;
QLineEdit *m_queryLineEdit=nullptr;
QWidget *m_queryWid=nullptr;
QLabel *m_queryIcon=nullptr;
QLabel *m_queryText=nullptr;
@ -251,8 +236,6 @@ Q_SIGNALS:
*/
void sendHideMainWindowSignal();
void sendMainWinActiveSignal(bool flag);
void setFocusToSideWin();
void selectFirstItem();
@ -260,8 +243,6 @@ Q_SIGNALS:
void selectFirstItemTab();
void setSlideBar(int value);
void setMainWinHideSignal();
};
#endif // MAINVIEWWIDGET_H

View File

@ -29,69 +29,63 @@
#include <QJsonParseError>
#include <QJsonValue>
#include "src/Style/style.h"
#include "src/UtilityFunction/utility.h"
#include <QPalette>
#include <QEvent>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
getCurrentCPU();
openDataBase("MainThread");
m_ukuiMenuInterface = new UkuiMenuInterface;
UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector();
m_ukuiMenuInterface=new UkuiMenuInterface;
UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector();
initDatabase();
UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification();
UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification();
UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification();
UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification();
UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification();
UkuiMenuInterface::allAppVector=m_ukuiMenuInterface->getAllClassification();
Style::initWidStyle();
initUi();
m_dbus = new DBus;
m_dbus=new DBus;
new MenuAdaptor(m_dbus);
QDBusConnection con = QDBusConnection::sessionBus();
if (!con.registerService("org.ukui.menu") ||
!con.registerObject("/org/ukui/menu", m_dbus)) {
qDebug() << "error:" << con.lastError().message();
QDBusConnection con=QDBusConnection::sessionBus();
if(!con.registerService("org.ukui.menu") ||
!con.registerObject("/org/ukui/menu",m_dbus))
{
qDebug()<<"error:"<<con.lastError().message();
}
connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] {
connect(m_dbus,&DBus::sendReloadSignal,this,[=]
{
UkuiMenuInterface::appInfoVector.clear();
UkuiMenuInterface::alphabeticVector.clear();
UkuiMenuInterface::functionalVector.clear();
UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector();
UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification();
UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification();
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, [ = ] {
if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit()))
connect(m_dbus,&DBus::winKeyResponseSignal,this,[=]{
if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit()))
{
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()) {
if(gsetting.keys().contains("win-key-release"))
if(gsetting.get("win-key-release").toBool())
return;
}
}
if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit()))
if(QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit()))
{
QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit());
if (gsetting.keys().contains("isrunning"))
if (gsetting.get("isrunning").toBool()) {
if(gsetting.keys().contains("isrunning"))
if(gsetting.get("isrunning").toBool())
return;
}
}
if (this->isVisible())
if(this->isVisible())
{
this->hide();
} else
{
}
else{
this->loadMainWindow();
this->show();
this->raise();
@ -104,11 +98,7 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow()
{
closeDataBase("MainThread");
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void MainWindow::initUi()
@ -117,115 +107,101 @@ void MainWindow::initUi()
this->setAttribute(Qt::WA_TranslucentBackground, true);
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);
// 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->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
this->setMinimumSize(Style::minw,Style::minh);
this->setContentsMargins(0,0,0,0);
m_frame=new QFrame;
m_mainViewWid=new MainViewWidget;
m_sideBarWid=new SideBarWidget;
this->setCentralWidget(m_frame);
QHBoxLayout *mainlayout = new QHBoxLayout;
mainlayout->setContentsMargins(0, 0, 0, 0);
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;
m_line=new QFrame;
m_line->installEventFilter(this);
m_line->setFrameShape(QFrame::VLine);
m_line->setFixedSize(1, this->height() - 1);
m_line->setFixedSize(1,this->height()-1);
m_line->setEnabled(false);
mainlayout->addWidget(m_line);
mainlayout->addWidget(m_sideBarWid);
m_sideBarWid->loadMinSidebar();
m_mainViewWid->loadMinMainView();
m_animation = new QPropertyAnimation(this, "geometry");
connect(m_animation, &QPropertyAnimation::finished, this, &MainWindow::animationValueFinishedSlot);
connect(m_animation,&QPropertyAnimation::finished,this,&MainWindow::animationValueFinishedSlot);
connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab);
connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget);
connect(m_sideBarWid, &SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget);
connect(m_sideBarWid,&SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget);
connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget);
connect(m_sideBarWid, &SideBarWidget::sendFullScreenCommonUseBtnSignal,
m_mainViewWid, &MainViewWidget::loadFullCommonUseWidget);
connect(m_sideBarWid, &SideBarWidget::sendFullScreenLetterBtnSignal,
m_mainViewWid, &MainViewWidget::loadFullLetterWidget);
connect(m_sideBarWid, &SideBarWidget::sendFullScreenFunctionBtnSignal,
m_mainViewWid, &MainViewWidget::loadFullFunctionWidget);
connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar);
connect(m_sideBarWid, &SideBarWidget::sendFullScreenBtnSignal, this, &MainWindow::showFullScreenWidget);
connect(m_sideBarWid, &SideBarWidget::sendDefaultBtnSignal, this, &MainWindow::showDefaultWidget);
connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt);
connect(m_mainViewWid, &MainViewWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot);
connect(m_sideBarWid, &SideBarWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot);
connect(m_mainViewWid, &MainViewWidget::setFocusToSideWin, m_sideBarWid, &SideBarWidget::setFocusToThis);
connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem);
connect(m_mainViewWid, &MainViewWidget::sendMainWinActiveSignal, this, &MainWindow::activeWindowSolt);
connect(m_mainViewWid, &MainViewWidget::setMainWinHideSignal, this, &MainWindow::mainWinHideSlot);
connect(m_sideBarWid,&SideBarWidget::sendFullScreenCommonUseBtnSignal,
m_mainViewWid,&MainViewWidget::loadFullCommonUseWidget);
connect(m_sideBarWid,&SideBarWidget::sendFullScreenLetterBtnSignal,
m_mainViewWid,&MainViewWidget::loadFullLetterWidget);
connect(m_sideBarWid,&SideBarWidget::sendFullScreenFunctionBtnSignal,
m_mainViewWid,&MainViewWidget::loadFullFunctionWidget);
connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar);
connect(m_sideBarWid,&SideBarWidget::sendFullScreenBtnSignal,this,&MainWindow::showFullScreenWidget);
connect(m_sideBarWid,&SideBarWidget::sendDefaultBtnSignal,this,&MainWindow::showDefaultWidget);
connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt);
connect(m_mainViewWid,&MainViewWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot);
connect(m_sideBarWid,&SideBarWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot);
connect(m_mainViewWid,&MainViewWidget::setFocusToSideWin,m_sideBarWid,&SideBarWidget::setFocusToThis);
connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem);
connect(QApplication::desktop(),&QDesktopWidget::resized,this, [=]{
repaintWidget();
primaryScreenChangeSlot();
});
connect(QApplication::desktop(),&QDesktopWidget::primaryScreenChanged,this,[=]{
repaintWidget();
primaryScreenChangeSlot();
});
connect(QApplication::desktop(),&QDesktopWidget::screenCountChanged,this,[=]{
repaintWidget();
primaryScreenChangeSlot();
});
QDBusConnection::sessionBus().connect(DBUS_NAME, DBUS_PATH, DBUS_INTERFACE, QString("PanelGeometryRefresh"), this, SLOT(primaryScreenChangeSlot()));
QDBusConnection::sessionBus().connect(DBUS_NAME,DBUS_PATH,DBUS_INTERFACE,QString("PanelGeometryRefresh"),this,SLOT(primaryScreenChangeSlot()));
//监听屏幕缩放
if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) {
QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit());
connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) {
if (key == "scalingFactor") {
if(QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()))
{
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();
}
});
}
if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) {
QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit());
connect(gsetting, &QGSettings::changed,
QGSettings *psetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit(), QByteArray(), this);
connect(psetting, &QGSettings::changed,
this, &MainWindow::panelChangedSlot);
}
}
void MainWindow::getCurrentCPU()
{
QProcess *processCpuInfo = new QProcess(this);
processCpuInfo->start(QString("cat /proc/cpuinfo"));
connect(processCpuInfo, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
processCpuInfo->deleteLater();
});
processCpuInfo->waitForFinished();
QString ctrCpuInfo = processCpuInfo->readAll();
if (ctrCpuInfo.contains("HUAWEI") || ctrCpuInfo.contains("Kirin")) {
isHuaWeiPC = true;
}
if (ctrCpuInfo.contains("PANGU")) {
isPANGU = true;
}
}
void MainWindow::paintEvent(QPaintEvent *event)
{
double transparency = getTransparency();
double transparency=getTransparency();
QRect rect = this->rect();
QPainterPath path;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
painter.setPen(Qt::transparent);
if (!m_isFullScreen) {
qreal radius = 6;
if(!m_isFullScreen)
{
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));
@ -235,13 +211,17 @@ void MainWindow::paintEvent(QPaintEvent *event)
path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
path.lineTo(rect.topRight() + QPointF(0, radius));
path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
painter.setBrush(this->palette().base());
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()));
} else { //全屏固定背景色(黑底白字)
}
else//全屏固定背景色(黑底白字)
{
// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit()))
// {
// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit());
@ -277,11 +257,11 @@ void MainWindow::paintEvent(QPaintEvent *event)
painter.setOpacity(transparency);
painter.drawRect(this->rect());
// }
QPainterPath path;
path.addRect(this->rect());
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
QMainWindow::paintEvent(event);
}
@ -290,31 +270,24 @@ 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::primaryScreenWidth;
// int height = Style::primaryScreenHeight;
int width = Style::widthavailable;
int height = Style::heightavailable;
QRect startRect;
QRect endRect;
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());
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);
} else {
startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh);
endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height());
startRect.setRect(x + 4, y + 4, Style::minw, Style::minh);
}
endRect.setRect(x, y, width, height);
this->centralWidget()->layout()->removeWidget(m_mainViewWid);
m_mainViewWid->setParent(nullptr);
@ -323,32 +296,17 @@ void MainWindow::showFullScreenWidget()
this->centralWidget()->layout()->removeWidget(m_sideBarWid);
m_sideBarWid->setParent(nullptr);
if (isPANGU || isHuaWeiPC) {
is_repaint = false;
this->hide();
QEventLoop loop;
QTimer::singleShot(150, &loop, SLOT(quit()));
loop.exec();
m_animation->setDuration(1);//动画总时间
m_animation->setStartValue(startRect);
m_animation->setEndValue(endRect);
m_animation->setEasingCurve(QEasingCurve::Linear);
m_animation->start();
this->show();
this->activateWindow();
is_repaint = true;
} else {
m_animation->setDuration(100);//动画总时间
m_animation->setStartValue(startRect);
m_animation->setEndValue(endRect);
m_animation->setEasingCurve(QEasingCurve::Linear);
m_animation->start();
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (m_isFullScreen && event->button() == Qt::LeftButton) {
if(m_isFullScreen && event->button()==Qt::LeftButton)
{
this->hide();
}
}
@ -358,30 +316,23 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event)
*/
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::primaryScreenWidth;
int height = Style::primaryScreenHeight;
int width = Style::widthavailable;
int height = Style::heightavailable;
QRect startRect;
QRect endRect;
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);
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);
} else {
endRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh);
startRect.setRect(x, y, width - panelSize, height);
endRect.setRect(x + 4, y + 4, Style::minw, Style::minh);
}
this->centralWidget()->layout()->removeWidget(m_mainViewWid);
@ -389,21 +340,17 @@ void MainWindow::showDefaultWidget()
this->centralWidget()->layout()->removeWidget(m_sideBarWid);
m_sideBarWid->setParent(nullptr);
if (isPANGU || isHuaWeiPC) {
this->setGeometry(endRect);
animationValueFinishedSlot();
} else {
m_animation->setDuration(100);//动画总时间
m_animation->setStartValue(startRect);
m_animation->setEndValue(endRect);
m_animation->setEasingCurve(QEasingCurve::Linear);
m_animation->start();
}
}
void MainWindow::animationValueChangedSlot(const QVariant &value)
{
if (m_isFullScreen) {
if(m_isFullScreen)
{
QPainterPath path;
path.addRect(this->rect());
// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
@ -413,90 +360,70 @@ void MainWindow::animationValueChangedSlot(const QVariant &value)
void MainWindow::animationValueFinishedSlot()
{
if (m_isFullScreen) {
if(m_isFullScreen)
{
this->centralWidget()->layout()->addWidget(m_mainViewWid);
this->centralWidget()->layout()->addWidget(m_sideBarWid);
m_sideBarWid->loadMaxSidebar();
m_mainViewWid->loadMaxMainView();
m_sideBarWid->enterAnimation();
} else {
}
else
{
this->centralWidget()->layout()->addWidget(m_mainViewWid);
this->centralWidget()->layout()->addWidget(m_line);
this->centralWidget()->layout()->addWidget(m_sideBarWid);
m_sideBarWid->loadMinSidebar();
m_mainViewWid->loadMinMainView();
}
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 (isPANGU || isHuaWeiPC) {
QTimer::singleShot(50, this, SLOT(mainWinShowSlot()));
}
QTimer::singleShot(30,this, SLOT(mainWinShowSlot()));
}
void MainWindow::mainWinShowSlot()
{
this->activateWindow();
if (!this->geometry().contains(QCursor::pos())) {
this->hide();
}
qDebug() << "void MainWindow::activeWindowSolt()";
}
/**
*
*/
bool MainWindow::event(QEvent *event)
bool MainWindow::event ( QEvent * event )
{
if (event->type() == QEvent::ActivationChange && is_repaint)
if (event->type() == QEvent::ActivationChange)
// if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用
{
qDebug() << " * 鼠标点击窗口外部事件";
if (QApplication::activeWindow() != this) {
if(QApplication::activeWindow() != this)
{
this->hide();
m_mainViewWid->widgetMakeZero();
}
}
if (event->type() == QEvent::KeyPress) {
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent *) event;
// 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 ||
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) {
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);
}
@ -513,13 +440,12 @@ void MainWindow::recvHideMainWindowSlot()
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::primaryScreenWidth;
int height = Style::primaryScreenHeight;
int width = Style::widthavailable;
int height = Style::heightavailable;
this->setFocus();
if (m_isFullScreen) {
@ -527,19 +453,14 @@ void MainWindow::loadMainWindow()
QRect startRect;
QRect endRect;
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());
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);
} else {
startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh);
endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height());
startRect.setRect(x + 4, y + 4, Style::minw, Style::minh);
}
endRect.setRect(x, y, width, height);
this->centralWidget()->layout()->removeWidget(m_mainViewWid);
m_mainViewWid->setParent(nullptr);
@ -547,156 +468,92 @@ 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 {
// 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));
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));
}
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);
Style::initWidStyle();
m_mainViewWid->repaintFullWidget();
repaintWidget();
}
void MainWindow::primaryScreenChangeSlot()
{
repaintWidget();
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::primaryScreenWidth;
int height = Style::primaryScreenHeight;
int width = Style::widthavailable;
int height = Style::heightavailable;
if (m_isFullScreen) {
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()));
}
this->setGeometry(x, y, width, height);
m_sideBarWid->loadMaxSidebar();
m_sideBarWid->setSideBarBtnGeometry();
m_mainViewWid->resizeControl();
} else {
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();
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));
}
m_sideBarWid->loadMinSidebar();
}
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()
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());
}
if(e->key() == Qt::Key_Backspace)
{
m_mainViewWid->setLineEditFocus("");
}
if(e->key() == Qt::Key_Escape)
{
this->hide();
m_mainViewWid->widgetMakeZero();
}
}
}

View File

@ -56,7 +56,6 @@ public:
* @brief Load the main window
*/
void loadMainWindow();
void getCurrentCPU();
private:
@ -70,7 +69,6 @@ private:
QPropertyAnimation *m_animation=nullptr;
bool m_winFlag = false;
bool is_repaint = true;
DBus *m_dbus=nullptr;
protected:
@ -83,7 +81,10 @@ protected:
/**
* @brief The query box responds to keyboard events
*/
void keyPressEvent(QKeyEvent* e);
/**
* @brief Repaint window
*/
void repaintWidget();
void resizeWidget();
@ -109,7 +110,6 @@ public Q_SLOTS:
void primaryScreenChangeSlot();
void activeWindowSolt(bool flag);
void mainWinShowSlot();
void mainWinHideSlot();
public:
Q_SIGNALS:

View File

@ -0,0 +1,109 @@
#include "fulllistdelegate.h"
#include "src/Style/style.h"
#include "src/UtilityFunction/utility.h"
#include <QPainter>
#include <QToolTip>
FullListDelegate::FullListDelegate(QObject *parent, int page): QStyledItemDelegate(parent)
{
m_page = page;
}
void FullListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QRectF rect;
rect.setX(option.rect.x());
rect.setY(option.rect.y());
rect.setWidth(option.rect.width());
rect.setHeight(option.rect.height());
//QPainterPath画圆角矩形
const qreal radius = 4;
QPainterPath path;
path.moveTo(rect.topRight() - QPointF(radius, 0));
path.lineTo(rect.topLeft() + QPointF(radius, 0));
path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius));
path.lineTo(rect.bottomLeft() + QPointF(0, -radius));
path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0));
path.lineTo(rect.bottomRight() - QPointF(radius, 0));
path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
path.lineTo(rect.topRight() + QPointF(0, radius));
path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
painter->setRenderHint(QPainter::Antialiasing);
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
painter->save();
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(Qt::white);
painter->setOpacity(0.15);
painter->drawPath(path);
painter->restore();
}
//绘制应用图标
painter->save();
painter->setOpacity(1);
QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
QRect iconRect;
iconRect = QRect(rect.x() + Style::AppLeftSpace,
rect.y() + Style::AppTopSpace,
Style::AppListIconSize,
Style::AppListIconSize);
icon.paint(painter, iconRect);
//绘制是否存在固定标志
QString desktopfp = index.data(Qt::AccessibleDescriptionRole).value<QString>();
QFileInfo fileInfo(desktopfp);
QString desktopfn = fileInfo.fileName();
bool isLocked = false;
if (m_page == COMMON_PAGE) {
if (checkIfLocked(desktopfn)) {
isLocked = true;
QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg"));
icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16));
}
}
//绘制应用名
QString appName = index.data(Qt::DisplayRole).value<QString>();
QFontMetrics fm = painter->fontMetrics();
QString appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic);
QRect textRect;
textRect = QRect(rect.x() + 5,
iconRect.bottom() + Style::AppSpaceBetweenIconText,
rect.width() - 10,
rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText);
//添加最近安装蓝色标签
bool isRecentapp = false;
if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) {
isRecentapp = true;
appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic);
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QColor("#4d94ff"));
int x = 0;
if (rect.width() < (10 + fm.boundingRect(appName).width())) {
x = rect.x() + 9;
} else {
x = rect.x() + (rect.width() - fm.boundingRect(appName).width()) / 2 - 8;
}
painter->drawEllipse(QPoint(x, textRect.y() + (fm.boundingRect(appName).height() - 8) / 2 + 4),
4, 4);
}
painter->restore();
painter->save();
painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText);
painter->restore();
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
int len = fm.boundingRect(appName).width() + 10;
if (len > rect.width()) {
QToolTip::showText(QCursor::pos(), appName);
} else {
QToolTip::hideText();
}
}
}
QSize FullListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth);
}

View File

@ -0,0 +1,19 @@
#ifndef FULLLISTDELEGATE_H
#define FULLLISTDELEGATE_H
#include <QObject>
#include <QStyledItemDelegate>
#include "src/Interface/ukuimenuinterface.h"
class FullListDelegate: public QStyledItemDelegate
{
Q_OBJECT
public:
FullListDelegate(QObject *parent, int page);
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
int m_page;
};
#endif // FULLLISTDELEGATE_H

View File

@ -0,0 +1,71 @@
#include "fulllistitem.h"
#include <QIcon>
#include <QFileInfo>
#include <qt5xdg/XdgIcon>
#include <qt5xdg/XdgDesktopFile>
FullListItem::FullListItem(QWidget *parent) : QWidget(parent)
{
}
void FullListItem::setAppList(QStringList list)
{
m_appList.clear();
m_appList = list;
}
QIcon FullListItem::getAppIcon(QString list)
{
XdgDesktopFile desktopfile;
desktopfile.load(list);
QString iconName = desktopfile.iconName();
QIcon icon = XdgIcon::fromTheme(iconName);
if (icon.isNull()) {
if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm"));
} else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png"));
} else {
icon = QIcon::fromTheme(QString("application-x-desktop"));
}
}
return icon;
}
QString FullListItem::getAppName(QString list)
{
XdgDesktopFile desktopfile;
desktopfile.load(list);
QString name = desktopfile.localizedValue("Name").toString();
return name;
}

View File

@ -0,0 +1,20 @@
#ifndef FULLLISTITEM_H
#define FULLLISTITEM_H
#include <QObject>
#include <QWidget>
class FullListItem: public QWidget
{
friend class FullListModel;
Q_OBJECT
public:
explicit FullListItem(QWidget *parent = nullptr);
void setAppList(QStringList list);
QIcon getAppIcon(QString list);
QString getAppName(QString list);
private:
QStringList m_appList;
};
#endif // FULLLISTITEM_H

View File

@ -0,0 +1,74 @@
#include "fulllistmodel.h"
#include "src/UtilityFunction/utility.h"
#include <QIcon>
#include <QDebug>
FullListModel::FullListModel(QObject *parent) : QAbstractItemModel(parent)
{
m_item = new FullListItem;
}
QModelIndex FullListModel::index(int row, int column, const QModelIndex &parent) const
{
return createIndex(row, column, m_item);
}
QModelIndex FullListModel::parent(const QModelIndex &child) const
{
return QModelIndex();
}
int FullListModel::rowCount(const QModelIndex &parent) const
{
return m_item->m_appList.count();
}
int FullListModel::columnCount(const QModelIndex &parent) const
{
return 1;
}
QVariant FullListModel::data(const QModelIndex &index, int role) const
{
if (m_item->m_appList.size() <= (index.row())) {
return QVariant();
}
switch (role) {
case Qt::DecorationRole: {
return m_item->getAppIcon(m_item->m_appList.at(index.row()));
}
case Qt::DisplayRole: {
return m_item->getAppName(m_item->m_appList.at(index.row()));
}
case Qt::AccessibleDescriptionRole:{
return m_item->m_appList.at(index.row());
}
default:
break;
}
return QVariant();
}
void FullListModel::setAppList(QStringList list)
{
m_item->setAppList(list);
}
void FullListModel::execAppDesktop(QModelIndex index)
{
execApp(m_item->m_appList.at(index.row()));
}
int FullListModel::showRightClickMenu(const QPoint &pos, QModelIndex index)
{
RightClickMenu menu;
return menu.showAppBtnMenu(pos, m_item->m_appList.at(index.row()));
}
void FullListModel::startChangeModel(QStringList list)
{
beginResetModel();
m_item->m_appList.clear();
m_item->m_appList = list;
endResetModel();
}

View File

@ -0,0 +1,30 @@
#ifndef FULLLISTMODEL_H
#define FULLLISTMODEL_H
#include <QObject>
#include <QAbstractItemModel>
#include "fulllistitem.h"
#include "src/RightClickMenu/rightclickmenu.h"
class FullListModel: public QAbstractItemModel
{
Q_OBJECT
public:
explicit FullListModel(QObject *parent = nullptr);
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
void setAppList(QStringList list);
void execAppDesktop(QModelIndex index);
void startChangeModel(QStringList list);
int showRightClickMenu(const QPoint &pos, QModelIndex index);
private:
FullListItem * m_item = nullptr;
Q_SIGNALS:
void sendItemClickedSignal(QString desktopfp);
};
#endif // FULLLISTMODEL_H

View File

@ -0,0 +1,141 @@
#include "fulllistview.h"
#include "src/Style/style.h"
#include <QScrollBar>
#include <QKeyEvent>
FullListView::FullListView(QWidget *parent, int page) : QListView(parent)
{
m_page = page;
initWidget();
}
void FullListView::initWidget()
{
m_model = new FullListModel(this);
this->setModel(m_model);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setViewMode(QListView::IconMode);
this->setResizeMode(QListView::Adjust);
this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth));
this->setFrameShape(QFrame::NoFrame);//移除边框,若不添加会存在晃动
this->setContextMenuPolicy(Qt::CustomContextMenu);
m_delegate = new FullListDelegate(this, m_page);
this->setItemDelegate(m_delegate);
connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot);
connect(this, &FullListView::clicked, this, &FullListView::onClicked);
}
void FullListView::setAppList(QStringList appList)
{
m_model->setAppList(appList);
}
void FullListView::startChangeModel(QStringList appList)
{
m_model->startChangeModel(appList);
}
void FullListView::selectFirstItem()
{
if (this->currentIndex().row() == -1) {
this->setCurrentIndex(this->model()->index(0, 0));
}
}
void FullListView::onClicked(QModelIndex index)
{
Q_EMIT sendHideMainWindowSignal();
m_model->execAppDesktop(index);
}
void FullListView::rightClickedSlot(const QPoint &pos)
{
Q_UNUSED(pos)
if (!(this->selectionModel()->selectedIndexes().isEmpty())) {
QModelIndex index = this->currentIndex();
int ret = m_model->showRightClickMenu(this->mapToGlobal(pos), index);
switch (ret) {
case 1:
Q_EMIT sendUpdateAppListSignal();
break;
case 2:
Q_EMIT sendUpdateAppListSignal();
break;
case 6:
Q_EMIT sendHideMainWindowSignal();
break;
case 7:
Q_EMIT sendHideMainWindowSignal();
break;
default:
break;
}
}
}
void FullListView::keyPressEvent(QKeyEvent *e)
{
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);
}
return QListView::keyPressEvent(e);
break;
}
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: {
return QListView::keyPressEvent(e);
break;
}
case Qt::Key_Down: {
return QListView::keyPressEvent(e);
break;
}
default:
return QListView::keyPressEvent(e);
break;
}
}
}
void FullListView::mouseReleaseEvent(QMouseEvent *event)
{
if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) {
Q_EMIT sendHideMainWindowSignal();
} else {
return QListView::mouseReleaseEvent(event);
}
}

View File

@ -0,0 +1,37 @@
#ifndef FULLLISTVIEW_H
#define FULLLISTVIEW_H
#include <QObject>
#include <QListView>
#include "fulllistdelegate.h"
#include "src/UtilityFunction/utility.h"
#include "src/RightClickMenu/rightclickmenu.h"
#include "fulllistmodel.h"
class FullListView : public QListView
{
Q_OBJECT
public:
FullListView(QWidget *parent = nullptr, int page = 0);
void setAppList(QStringList appList);
void startChangeModel(QStringList appList);
protected:
void initWidget();
void keyPressEvent(QKeyEvent *e);
void mouseReleaseEvent(QMouseEvent *event);
private:
FullListDelegate* m_delegate = nullptr;
FullListModel* m_model = nullptr;
int m_page;
public Q_SLOTS:
void selectFirstItem();
void onClicked(QModelIndex index);//点击item
void rightClickedSlot(const QPoint &pos);
Q_SIGNALS:
void sendSetslidebar(int value);
void sendHideMainWindowSignal();
void sendUpdateAppListSignal();
};
#endif // FULLLISTVIEW_H

View File

@ -1,19 +1 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "qtlockedfile.h"

View File

@ -1,19 +1 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "qtsingleapplication.h"

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "menubox.h"
#include <QDebug>
#include <QMouseEvent>

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MENUBOX_H
#define MENUBOX_H
#include <QMenu>

View File

@ -23,7 +23,8 @@
RightClickMenu::RightClickMenu(QWidget *parent):
QWidget(parent)
{
m_cmdProc = new QProcess;
m_cmdProc=new QProcess;
m_whiteList.append("kylin-screenshot.desktop");
m_whiteList.append("ukui-notebook.desktop");
m_whiteList.append("ukui-clock.desktop");
@ -43,69 +44,59 @@ RightClickMenu::RightClickMenu(QWidget *parent):
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_ukuiMenuInterface=new UkuiMenuInterface;
m_ukuiMenuInterface = new UkuiMenuInterface;
}
RightClickMenu::~RightClickMenu()
{
delete m_cmdProc;
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type)
{
const auto ratio = devicePixelRatioF();
const auto ratio=devicePixelRatioF();
QPixmap pixmap;
if (type == 0) {
pixmap = loadSvg(iconstr, 16 * ratio);
if(type==0)
{
pixmap=loadSvg(iconstr,16*ratio);
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
} else {
QIcon icon = QIcon::fromTheme(iconstr);
QPixmap pixmap_1 = icon.pixmap(QSize(16 * ratio, 16 * ratio));
pixmap = drawSymbolicColoredPixmap(pixmap_1);
}
else
{
QIcon icon=QIcon::fromTheme(iconstr);
QPixmap pixmap_1=icon.pixmap(QSize(16*ratio,16*ratio));
pixmap=drawSymbolicColoredPixmap(pixmap_1);
}
return pixmap;
}
void RightClickMenu::fixToAllActionTriggerSlot()
{
m_actionNumber = 1;
m_actionNumber=1;
QFileInfo fileInfo(m_desktopfp);
QString desktopfn = fileInfo.fileName();
updateDataBaseTableType(desktopfn, 1);
QString desktopfn=fileInfo.fileName();
updateDataBaseTableType(desktopfn,1);
}
void RightClickMenu::unfixedFromAllActionTriggerSlot()
{
m_actionNumber = 2;
m_actionNumber=2;
QFileInfo fileInfo(m_desktopfp);
QString desktopfn = fileInfo.fileName();
updateDataBaseTableType(desktopfn, 0);
QString desktopfn=fileInfo.fileName();
updateDataBaseTableType(desktopfn,0);
}
void RightClickMenu::fixToTaskbarActionTriggerSlot()
{
// QDBusInterface iface("com.ukui.panel.desktop",
// "/",
// "com.ukui.panel.desktop",
// QDBusConnection::sessionBus());
// QDBusReply<QVariant> 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;
QDBusInterface iface("com.ukui.panel.desktop",
"/",
"com.ukui.panel.desktop",
QDBusConnection::sessionBus());
QDBusReply<QVariant> ret=iface.call("AddToTaskbar",m_desktopfp);
m_actionNumber=3;
}
void RightClickMenu::unfixedFromTaskbarActionTriggerSlot()
@ -114,150 +105,146 @@ void RightClickMenu::unfixedFromTaskbarActionTriggerSlot()
"/",
"com.ukui.panel.desktop",
QDBusConnection::sessionBus());
QDBusReply<QVariant> ret = iface.call("RemoveFromTaskbar", m_desktopfp);
m_actionNumber = 4;
QDBusReply<QVariant> ret=iface.call("RemoveFromTaskbar",m_desktopfp);
m_actionNumber=4;
}
void RightClickMenu::addToDesktopActionTriggerSlot()
{
QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString path=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QFileInfo fileInfo(m_desktopfp);
QString desktopfn = fileInfo.fileName();
QString desktopfn=fileInfo.fileName();
QFile file(m_desktopfp);
QString newname = QString(path + "/" + desktopfn);
bool ret = file.copy(QString(path + "/" + desktopfn));
if (ret) {
QString newname=QString(path+"/"+desktopfn);
bool ret=file.copy(QString(path+"/"+desktopfn));
if(ret)
{
char command[200];
sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data());
sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data());
QProcess::startDetached(QString::fromLocal8Bit(command));
}
m_actionNumber = 5;
m_actionNumber=5;
}
void RightClickMenu::uninstallActionTriggerSlot()
{
// if(!checkOsRelease())
// {
QString cmd = QString("kylin-uninstaller %1")
if(!checkOsRelease())
{
QString cmd=QString("kylin-uninstaller %1")
.arg(m_desktopfp.toLocal8Bit().data());
bool ret = QProcess::startDetached(cmd);
qDebug() << "卸载:" << cmd << ret;
bool ret=QProcess::startDetached(cmd);
qDebug()<<"卸载:"<<cmd<<ret;
qDebug() << "kylin-uninstaller";
// }
// else
// {
// QString cmd=QString("dpkg -S "+m_desktopfp);
// m_cmdProc->start("sh",QStringList()<<"-c"<<cmd);
// m_cmdProc->waitForFinished();
// QString output=m_cmdProc->readAllStandardOutput().trimmed();
// QString packageName=output.split(":").at(0);
// cmd.clear();
// cmd=QString("kylin-installer -remove %1")
// .arg(packageName.toLocal8Bit().data());
// bool ret=QProcess::startDetached(cmd);
// qDebug()<<"卸载:"<<cmd<<ret;
// qDebug() << "dpkg -S";
// }
m_actionNumber = 6;
}
else
{
QString cmd=QString("dpkg -S "+m_desktopfp);
m_cmdProc->start("sh",QStringList()<<"-c"<<cmd);
m_cmdProc->waitForFinished();
QString output=m_cmdProc->readAllStandardOutput().trimmed();
QString packageName=output.split(":").at(0);
cmd.clear();
cmd=QString("kylin-installer -remove %1")
.arg(packageName.toLocal8Bit().data());
bool ret=QProcess::startDetached(cmd);
qDebug()<<"卸载:"<<cmd<<ret;
qDebug() << "dpkg -S";
}
m_actionNumber=6;
}
void RightClickMenu::attributeActionTriggerSlot()
{
char command[100];
sprintf(command, "ukui-menu-attr %s", m_desktopfp.toLocal8Bit().data());
sprintf(command,"ukui-menu-attr %s",m_desktopfp.toLocal8Bit().data());
QProcess::startDetached(command);
m_actionNumber = 7;
m_actionNumber=7;
}
void RightClickMenu::lockScreenActionTriggerSlot()
{
m_actionNumber = 10;
m_actionNumber=10;
}
void RightClickMenu::switchUserActionTriggerSlot()
{
m_actionNumber = 11;
m_actionNumber=11;
}
void RightClickMenu::logoutActionTriggerSlot()
{
m_actionNumber = 12;
m_actionNumber=12;
}
void RightClickMenu::rebootActionTriggerSlot()
{
m_actionNumber = 13;
m_actionNumber=13;
}
void RightClickMenu::shutdownActionTriggerSlot()
{
m_actionNumber = 14;
m_actionNumber=14;
}
void RightClickMenu::otherListActionTriggerSlot()
{
m_actionNumber = 15;
m_actionNumber=15;
}
void RightClickMenu::hibernateActionTriggerSlot()
{
m_actionNumber = 16;
m_actionNumber=16;
}
void RightClickMenu::sleepActionTriggerSlot()
{
m_actionNumber = 17;
m_actionNumber=17;
}
int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp)
{
m_actionNumber = 0;
m_actionNumber=0;
this->m_desktopfp.clear();
this->m_desktopfp = desktopfp;
this->m_desktopfp=desktopfp;
MenuBox m_showAppMenu;
connect(&m_showAppMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal);
m_showAppMenu.setWindowFlag(Qt::Popup);
//添加菜单项,指定图标、名称、响应函数
QFileInfo fileInfo(desktopfp);
QString desktopfn = fileInfo.fileName();
if (!checkIfLocked(desktopfn))
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to all"),
this, SLOT(fixToAllActionTriggerSlot()));
QString desktopfn=fileInfo.fileName();
if(!checkIfLocked(desktopfn))
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to all"),
this,SLOT(fixToAllActionTriggerSlot()));
else
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"),
this, SLOT(unfixedFromAllActionTriggerSlot()));
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from all"),
this,SLOT(unfixedFromAllActionTriggerSlot()));
QDBusInterface iface("com.ukui.panel.desktop",
"/",
"com.ukui.panel.desktop",
QDBusConnection::sessionBus());
QDBusReply<bool> 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()));
QDBusReply<bool> 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
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from taskbar"),
this, SLOT(unfixedFromTaskbarActionTriggerSlot()));
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from taskbar"),
this,SLOT(unfixedFromTaskbarActionTriggerSlot()));
m_showAppMenu.addAction(tr("Add to desktop shortcuts"),
this, SLOT(addToDesktopActionTriggerSlot()));
this,SLOT(addToDesktopActionTriggerSlot()));
//检查桌面快捷方式是否存在
QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString path = QString(desktopPath + "/" + QFileInfo(m_desktopfp).fileName());
if (QFile(path).exists()) {
m_showAppMenu.actions().at(2)->setEnabled(false); //存在时禁用
}
QString desktopPath=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString path=QString(desktopPath+"/"+QFileInfo(m_desktopfp).fileName());
if(QFile(path).exists())
m_showAppMenu.actions().at(2)->setEnabled(false);//存在时禁用
m_showAppMenu.addSeparator();
if (!m_whiteList.contains(desktopfn))
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg", 0)), tr("Uninstall"),
this, SLOT(uninstallActionTriggerSlot()));
if(!m_whiteList.contains(desktopfn))
m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg",0)),tr("Uninstall"),
this,SLOT(uninstallActionTriggerSlot()));
m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground);
m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose);
@ -268,18 +255,19 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp)
int RightClickMenu::showShutdownMenu(const QPoint &pos)
{
m_actionNumber = 0;
m_actionNumber=0;
MenuBox m_showShutMenu;
connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal);
m_showShutMenu.setWindowFlag(Qt::Popup);
m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic", 1)), tr("Sleep"),
this, SLOT(hibernateActionTriggerSlot())); //休眠睡眠相同
m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic", 1)), tr("Log Out"),
this, SLOT(logoutActionTriggerSlot()));
m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic", 1)), tr("Restart"),
this, SLOT(rebootActionTriggerSlot()));
m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic", 1)), tr("Power Off"),
this, SLOT(shutdownActionTriggerSlot()));
m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Sleep"),
this,SLOT(hibernateActionTriggerSlot()));//休眠睡眠相同
m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"),
this,SLOT(logoutActionTriggerSlot()));
m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"),
this,SLOT(rebootActionTriggerSlot()));
m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"),
this,SLOT(shutdownActionTriggerSlot()));
m_showShutMenu.setAttribute(Qt::WA_TranslucentBackground);
m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose);
m_showShutMenu.raise();
@ -290,9 +278,9 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos)
int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp)
{
m_actionNumber = 0;
m_actionNumber=0;
this->m_desktopfp.clear();
this->m_desktopfp = desktopfp;
this->m_desktopfp=desktopfp;
MenuBox m_showOtherMenu;
connect(&m_showOtherMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal);
m_showOtherMenu.setWindowFlag(Qt::Popup);
@ -300,6 +288,7 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp)
// "/",
// "com.ukui.panel.desktop",
// QDBusConnection::sessionBus());
// QDBusReply<bool> ret=iface.call("CheckIfExist",this->m_desktopfp);
// if(!ret)
// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"),
@ -307,11 +296,12 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp)
// else
// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"),
// this,SLOT(unfixedFromTaskbarActionTriggerSlot()));
m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg", 0)), tr("Personalize this list"),
this, SLOT(otherListActionTriggerSlot()));
m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"),
this,SLOT(otherListActionTriggerSlot()));
m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground);
m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose);
m_showOtherMenu.exec(pos);
qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)";
return m_actionNumber;
}

View File

@ -37,7 +37,6 @@
#include "src/Interface/ukuimenuinterface.h"
#include "src/Style/style.h"
#include "menubox.h"
#include <QWidget>
class RightClickMenu : public QWidget
{

View File

@ -0,0 +1,84 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "uninstallwhitelist.h"
#include "src/UtilityFunction/utility.h"
#include <QProcess>
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<void(QProcess::*)(int, QProcess::ExitStatus)>(&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;
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef UNINSTALLWHITELIST_H
#define UNINSTALLWHITELIST_H
#include <QObject>
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

View File

@ -30,43 +30,44 @@ FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) :
FullSearchResultWidget::~FullSearchResultWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void FullSearchResultWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_StyledBackground, true);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setAttribute(Qt::WA_StyledBackground,true);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setFixedSize(Style::MainViewWidWidth,
Style::AppListWidHeight);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed);
QHBoxLayout* mainLayout=new QHBoxLayout;
mainLayout->setContentsMargins(0,0,0,0);
m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed);
mainLayout->addItem(m_spaceItem);
m_listView = new FullListView(this, 3);
m_listView=new FullListView(this,3);
this->setLayout(mainLayout);
m_scrollArea = new ScrollArea;
m_scrollAreaWid = new ScrollAreaWid;
m_scrollArea=new ScrollArea;
m_scrollAreaWid=new ScrollAreaWid;
m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground);
m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height());
m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height());
m_scrollArea->setWidget(m_scrollAreaWid);
m_scrollArea->setWidgetResizable(true);
m_scrollAreaWidLayout = new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout=new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0,0,0,0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWid->setLayout(m_scrollAreaWidLayout);
mainLayout->addWidget(m_scrollArea);
m_scrollAreaWidLayout->addWidget(m_listView);
m_scrollAreaWidLayout->addItem(new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding));
m_scrollAreaWidLayout->addItem(new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding));
m_data.clear();
m_listView->addData(m_data);
m_ukuiMenuInterface = new UkuiMenuInterface;
connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication);
connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal);
m_ukuiMenuInterface=new UkuiMenuInterface;
connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication);
connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal);
}
/**
@ -81,31 +82,31 @@ void FullSearchResultWidget::execApplication(QString desktopfp)
void FullSearchResultWidget::updateAppListView(QVector<QStringList> arg)
{
m_data.clear();
Q_FOREACH (QStringList appinfo, arg) {
Q_FOREACH(QStringList appinfo,arg)
m_data.append(appinfo.at(0));
}
m_listView->updateData(m_data);
resizeScrollAreaControls();
}
void FullSearchResultWidget::resizeScrollAreaControls()
{
QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0);
QWidget *wid = widItem->widget();
FullListView *listview = qobject_cast<FullListView *>(wid);
QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0);
QWidget* wid=widItem->widget();
FullListView* listview=qobject_cast<FullListView*>(wid);
listview->adjustSize();
int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
int rowcount = 0;
int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth;
int rowcount=0;
if(listview->model()->rowCount()%dividend>0)
{
rowcount=listview->model()->rowCount()/dividend+1;
}
else
{
rowcount=listview->model()->rowCount()/dividend;
if (listview->model()->rowCount() % dividend > 0) {
rowcount = listview->model()->rowCount() / dividend + 1;
} else {
rowcount = listview->model()->rowCount() / dividend;
}
listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount);
listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount);
m_scrollArea->widget()->adjustSize();
}
@ -113,29 +114,27 @@ 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_scrollArea->setFixedSize(Style::AppListWidWidth,this->height());
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_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);
connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal);
connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication);
connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal);
}
void FullSearchResultWidget::moveScrollBar(int type)
{
int height = Style::primaryScreenHeight;
if (type == 0) {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080);
} else {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080);
}
int height=Style::primaryScreenHeight;
if(type==0)
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080);
else
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080);
}
void FullSearchResultWidget::setViewFocus()

View File

@ -6669,7 +6669,7 @@ gāng 冈
rǎn,nán,dān 冉
cè 冊
jiōng,jiǒng 冋
cè 册
,zhà
zài 再
guǎ 冎
jiǒng,jiōng 冏

View File

@ -6669,7 +6669,7 @@ gang 冈
dan,nan,ran 冉
ce 冊
jiong 冋
ce 册
zha,ce 册
zai 再
gua 冎
jiong 冏

View File

@ -22,127 +22,108 @@
SearchAppThread::SearchAppThread()
{
m_ukuiMenuInterface = new UkuiMenuInterface;
m_ukuiMenuInterface=new UkuiMenuInterface;
}
SearchAppThread::~SearchAppThread()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void SearchAppThread::run()
{
m_appInfoVector.clear();
m_appInfoVector = UkuiMenuInterface::appInfoVector;
m_appInfoVector=UkuiMenuInterface::appInfoVector;
m_searchResultVector.clear();
m_searchFirstVector.clear();
m_searchRestVector.clear();
if(!this->m_keyWord.isEmpty())
{
QString str=m_ukuiMenuInterface->getAppNamePinyin(m_keyWord);
int index=0;
if(str.size()==1)
{
int num=static_cast<int>(str.toLocal8Bit().at(0));
QStringList searchDesktopList;
searchDesktopList.clear();
if(num>=65 && num<=90)
{
for(int i=0;i<UkuiMenuInterface::alphabeticVector.at(num-65).size();i++)
searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(num-65).at(i));
}
else{
while(index<m_appInfoVector.size())
{
// QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1));
// QString appEnglishName=m_appInfoVector.at(index).at(2);
QString appNameFl=m_appInfoVector.at(index).at(3);
if (!this->m_keyWord.isEmpty()) {
QString str = m_ukuiMenuInterface->getAppNamePinyin(m_keyWord);
int index = 0;
// if(str.size()==1)
// {
// int num=static_cast<int>(str.toLocal8Bit().at(0));
// QStringList searchDesktopList;
// searchDesktopList.clear();
// if(num>=65 && num<=90)
// {
// for(int i=0;i<UkuiMenuInterface::alphabeticVector.at(num-65).size();i++)
// searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(num-65).at(i));
// }
// else{
// while(index<m_appInfoVector.size())
// {
//// QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(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;i<UkuiMenuInterface::alphabeticVector.at(26).size();i++)
//// searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(26).at(i));
//// else
//// for(int i=0;i<UkuiMenuInterface::alphabeticVector.at(27).size();i++)
//// searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(27).at(i));
// if(!searchDesktopList.isEmpty())
// {
// for(int i=0;i<searchDesktopList.size();i++)
// m_searchResultVector.append(QStringList()<<searchDesktopList.at(i)<<m_ukuiMenuInterface->getAppName(searchDesktopList.at(i)));
// }
// }
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;i<UkuiMenuInterface::alphabeticVector.at(26).size();i++)
// searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(26).at(i));
// else
//{
while (index < m_appInfoVector.size()) {
// for(int i=0;i<UkuiMenuInterface::alphabeticVector.at(27).size();i++)
// searchDesktopList.append(UkuiMenuInterface::alphabeticVector.at(27).at(i));
if(!searchDesktopList.isEmpty())
{
for(int i=0;i<searchDesktopList.size();i++)
m_searchResultVector.append(QStringList()<<searchDesktopList.at(i)<<m_ukuiMenuInterface->getAppName(searchDesktopList.at(i)));
}
}
else
{
while(index<m_appInfoVector.size())
{
// QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1));
QStringList appNameLs;
QStringList appNameFls;
QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords(m_appInfoVector.at(index).at(1));
// QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords("奇安信可信");
for (int i = 0; i < appNamePyLst.size() / 2; i++) {
for(int i = 0; i < appNamePyLst.size()/2; i++)
{
appNameLs.append(appNamePyLst.at(i * 2));
appNameFls.append(appNamePyLst.at(i * 2 + 1));
}
QString appName = m_appInfoVector.at(index).at(1);
QString appEnglishName = m_appInfoVector.at(index).at(2);
QString appEnglishName=m_appInfoVector.at(index).at(2);
//QString appNameFls=m_appInfoVector.at(index).at(4);
if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式
if (appName.toUpper().contains(m_keyWord.toUpper())) {
if(m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+")))//中文正则表达式
{
if(appName.toUpper().contains(m_keyWord.toUpper()))
m_searchResultVector.append(m_appInfoVector.at(index));
}
} else {
for (int var = 0; var < appNameLs.size(); ++var) {
if (appNameLs[var].left(str.length()).contains(str, Qt::CaseInsensitive) ||
appNameFls[var].left(str.length()).contains(str, Qt::CaseInsensitive)) {
m_searchFirstVector.append(m_appInfoVector.at(index));
break;
} else if (appNameLs[var].contains(str, Qt::CaseInsensitive) ||
appNameFls[var].contains(str, Qt::CaseInsensitive) ||
appEnglishName.contains(str, Qt::CaseInsensitive)) {
m_searchRestVector.append(m_appInfoVector.at(index));
else
{
for (int var = 0; var < appNameLs.size(); ++var)
{
if(appNameLs[var].contains(str,Qt::CaseInsensitive) ||
appNameFls[var].contains(str,Qt::CaseInsensitive) ||
appEnglishName.contains(str,Qt::CaseInsensitive))
{
m_searchResultVector.append(m_appInfoVector.at(index));
break;
}
}
}
index++;
//}
}
}
}
qSort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp);
qSort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp);
if (m_searchResultVector.size() != 0) {
qSort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp);
}
for (int i = 0; i < m_searchFirstVector.size(); i++) {
m_searchResultVector.append(m_searchFirstVector.at(i));
}
for (int i = 0; i < m_searchRestVector.size(); i++) {
m_searchResultVector.append(m_searchRestVector.at(i));
}
qSort(m_searchResultVector.begin(),m_searchResultVector.end(),UkuiMenuInterface::cmpApp);
Q_EMIT sendSearchResult(m_searchResultVector);
}
void SearchAppThread::recvSearchKeyword(QString arg)
{
this->m_keyWord.clear();
this->m_keyWord = arg;
this->m_keyWord=arg;
}

View File

@ -33,8 +33,6 @@ public:
private:
QString m_keyWord;
QVector<QStringList> m_searchResultVector;
QVector<QStringList> m_searchFirstVector;
QVector<QStringList> m_searchRestVector;
UkuiMenuInterface* m_ukuiMenuInterface=nullptr;
QVector<QStringList> m_appInfoVector;

View File

@ -30,28 +30,26 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
SearchResultWidget::~SearchResultWidget()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
}
void SearchResultWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_StyledBackground, true);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
this->setAttribute(Qt::WA_StyledBackground,true);
this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
this->setFocusPolicy(Qt::StrongFocus);
m_listView = new ListView(this, this->width() - 6, this->height() - 6, 3);
m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
m_listView=new ListView(this,this->width()-6,this->height()-6,3);
m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_listView->show();
m_data.clear();
m_listView->addData(m_data);
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);
m_ukuiMenuInterface=new UkuiMenuInterface;
connect(m_listView,&ListView::sendItemClickedSignal,this,&SearchResultWidget::execApplication);
connect(m_listView,&ListView::sendHideMainWindowSignal,this,&SearchResultWidget::sendHideMainWindowSignal);
}
/**
@ -60,34 +58,30 @@ void SearchResultWidget::initUi()
void SearchResultWidget::execApplication(QStringList arg)
{
Q_EMIT sendHideMainWindowSignal();
QString desktopfp = arg.at(0);
QString desktopfp=arg.at(0);
execApp(desktopfp);
}
void SearchResultWidget::updateAppListView(QVector<QStringList> arg)
{
m_data.clear();
Q_FOREACH (QStringList appinfo, arg) {
m_data.append(QStringList() << appinfo.at(0) << "1");
}
Q_FOREACH(QStringList appinfo,arg)
m_data.append(QStringList()<<appinfo.at(0)<<"1");
m_listView->updateData(m_data);
}
void SearchResultWidget::moveScrollBar(int type)
{
if (type == 0) {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100);
} else {
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100);
}
if(type==0)
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100);
else
m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100);
}
void SearchResultWidget::repaintWidget()
{
this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6));
this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6));
m_listView->show();
}

View File

@ -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<QStringList> m_data;
protected:
@ -81,8 +81,6 @@ Q_SIGNALS:
* @brief Send a hidden main window signal to the MainViewWidget
*/
void sendHideMainWindowSignal();
void sendMainWinActiveSignal(bool flag);
};
#endif // SEARCHRESULTWIDGET_H

File diff suppressed because it is too large Load Diff

View File

@ -61,34 +61,34 @@ public:
void setSideBarBtnGeometry();
private:
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
UkuiMenuInterface *m_ukuiMenuInterface=nullptr;
QWidget *m_mainWidget = nullptr;
QVBoxLayout *m_mainWidgetLayout = nullptr;
QWidget *m_mainWidget=nullptr;
QVBoxLayout *m_mainWidgetLayout=nullptr;
QWidget *m_minMaxWidget = nullptr;
QHBoxLayout *m_minMaxLayout = nullptr;
QPushButton *m_minMaxBtn = nullptr;
QWidget *m_minMaxWidget=nullptr;
QHBoxLayout *m_minMaxLayout=nullptr;
QPushButton *m_minMaxBtn=nullptr;
QList<QAbstractButton *> m_buttonList;
QList<QLabel *> m_labelList;
QList<QAbstractButton*> m_buttonList;
QList<QLabel*> m_labelList;
QStringList m_textList;
QPushButton *m_allBtn = nullptr;
QPushButton *m_letterBtn = nullptr;
QPushButton *m_functionBtn = nullptr;
QPushButton *m_allBtn=nullptr;
QPushButton *m_letterBtn=nullptr;
QPushButton *m_functionBtn=nullptr;
QPushButton *m_userIconBtn = nullptr;
QPushButton *m_computerBtn = nullptr;
QPushButton *m_personalBtn = nullptr;
QPushButton *m_controlBtn = nullptr;
QPushButton *m_trashBtn = nullptr;
QPushButton *m_shutDownBtn = nullptr;
QSpacerItem *m_verticalSpacer = nullptr;
bool m_isFullScreen = false;
QGSettings *m_gsetting = nullptr;
QPushButton *m_userIconBtn=nullptr;
QPushButton *m_computerBtn=nullptr;
QPushButton *m_personalBtn=nullptr;
QPushButton *m_controlBtn=nullptr;
QPushButton *m_trashBtn=nullptr;
QPushButton *m_shutDownBtn=nullptr;
QSpacerItem *m_verticalSpacer=nullptr;
bool m_isFullScreen=false;
QGSettings *m_gsetting=nullptr;
// RightClickMenu *m_shutDownMenu=nullptr;
// RightClickMenu *m_otherMenu=nullptr;
QPropertyAnimation *m_animation = nullptr;
QPropertyAnimation* m_animation=nullptr;
int m_btnWidth, m_btnheight;
@ -109,7 +109,7 @@ protected:
* @param text: Button text
* @param num: Button Number
*/
void initBtn(QPushButton *btn, QString btnicon, QString text, int num);
void initBtn(QPushButton *btn, QString btnicon,QString text,int num);
/**
* @brief Set the default sidebar button
* @param btn: QPushButton
@ -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
*/
@ -136,9 +136,9 @@ protected:
QPixmap PixmapToRound(const QPixmap &src, int radius);
void changeIconColor(bool isFullScreen);
// void mousePressEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *e);
void keyPressEvent(QKeyEvent* e);
bool eventFilter(QObject *target, QEvent *event);
bool eventFilter(QObject * target , QEvent * event );
private Q_SLOTS:
/**
@ -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
*/

View File

@ -41,7 +41,6 @@ int Style::defaultQueryLineEditHeight=0;
int Style::defaultQueryLineEditIconSize=0;
int Style::defaultContentWidHeight=0;
int Style::defaultSideBarWidWidth=0;
int Style::defaultIconSize=32;
/**
*
*/
@ -101,39 +100,28 @@ int Style::SideBarSpaceBetweenItem=0;
void Style::initWidStyle()
{
getScreenAvailableGeometry();
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 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();
}
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;
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;
}
primaryScreenWidth = qApp->primaryScreen()->geometry().width();
primaryScreenHeight = qApp->primaryScreen()->geometry().height();
if(primaryScreenWidth==800 && primaryScreenHeight==600)
{
@ -175,7 +163,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=14;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=15;
@ -221,7 +209,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=14;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=15;
@ -267,7 +255,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -313,7 +301,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -359,7 +347,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -405,7 +393,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -451,7 +439,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -497,7 +485,7 @@ void Style::initWidStyle()
RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth;
LeftFontSize=fontSize;
LeftLetterFontSize=11;
LeftIconSize=17;
LeftIconSize=19;
LeftSpaceIconLeft=15;
LeftSpaceIconText=14;
LeftSpaceBetweenItem=10;
@ -528,3 +516,40 @@ void Style::initWidStyle()
SideBarSpaceBetweenItem=16;
}
}
//不通过任务栏获取屏幕可用区域数据
void Style::getScreenAvailableGeometry()
{
QRect rect;
rect = qApp->primaryScreen()->geometry();
QDBusInterface iface(DBUS_NAME,
DBUS_PATH,
DBUS_INTERFACE,
QDBusConnection::sessionBus());
QDBusReply<QVariantList> reply = iface.call("GetPrimaryScreenPhysicalGeometry");
if (reply.isValid()) {
panelSize = reply.value().at(4).toInt();
panelPosition = reply.value().at(5).toInt();
}
QList<int> 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;
}

View File

@ -100,7 +100,6 @@ public:
static int minh;
static int defaultMainViewWidWidth;
static int defaultTopWidHeight;
static int defaultIconSize;
static int defaultQueryLineEditWidth;
static int defaultQueryLineEditHeight;
static int defaultQueryLineEditIconSize;
@ -165,6 +164,8 @@ public:
static int SideBarSpaceIconText; //按钮图标与文字内边距
static int SideBarSpaceBetweenItem; //item间距
private:
static void getScreenAvailableGeometry(); //获取屏幕可用区域
};
#endif // STYLE_H

View File

@ -32,35 +32,32 @@ QString ConvertDesktopToWinId::tranIdToDesktop(WId id)
{
KWindowInfo info(id, 0, NET::WM2AllProperties);
QString desktopName = confirmDesktopFile(info);
qDebug() << "desktopName is :" << desktopName;
myDebug() << "desktopName is :" << desktopName;
return desktopName;
}
QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info)
{
m_desktopfilePath = "";
m_dir = new QDir(DEKSTOP_FILE_PATH);
m_list = m_dir->entryInfoList();
QString desktopFilePath = nullptr;
QDir dir = QDir(DESKTOP_FILE_PATH);
QFileInfoList list = dir.entryInfoList();
//跳过 ./ 和 ../ 目录
m_list.removeAll(QFile(USR_SHARE_APP_CURRENT));
m_list.removeAll(QFile(USR_SHARE_APP_UPER));
list.removeAll(QFile(USR_SHARE_APP_CURRENT));
list.removeAll(QFile(USR_SHARE_APP_UPER));
//第一种方法获取点击应用时大部分desktop文件名
searchFromEnviron(info);
desktopFilePath = searchFromEnviron(info, list);
//第二种方法:比较名字一致性
if (m_desktopfilePath.isEmpty()) {
if (desktopFilePath.isEmpty()) {
m_classClass = info.windowClassClass().toLower();
m_className = info.windowClassName();
//匹配安卓兼容
if (m_className == "kylin-kmre-window") {
searchAndroidApp(info);
return m_desktopfilePath;
return searchAndroidApp(info);
}
QFile file(QString("/proc/%1/status").arg(info.pid()));
if (file.open(QIODevice::ReadOnly)) {
char buf[1024];
@ -69,11 +66,11 @@ QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info)
m_statusName = QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n");
}
}
compareClassName();
desktopFilePath = compareClassName(list);
}
//第三种方法比较cmd命令行操作一致性
if (m_desktopfilePath.isEmpty()) {
if (desktopFilePath.isEmpty()) {
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
if (file.open(QIODevice::ReadOnly)) {
char buf[1024];
@ -82,30 +79,30 @@ QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info)
m_cmdLine = QString::fromLocal8Bit(buf).remove("\n");
}
}
compareCmdExec();
desktopFilePath = compareCmdExec(list);
}
//第四种方法:匹配部分字段
if (m_desktopfilePath.isEmpty()) {
compareLastStrategy();
if (desktopFilePath.isEmpty()) {
desktopFilePath = compareLastStrategy(list);
}
return m_desktopfilePath;
return desktopFilePath;
}
void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info)
QString ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info)
{
m_androidDir = new QDir(QString(QDir::homePath() + ANDROID_FILE_PATH));
m_androidList = m_androidDir->entryInfoList();
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT);
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER);
QDir androidDir = QString(QDir::homePath() + ANDROID_FILE_PATH);
QFileInfoList androidList = androidDir.entryInfoList();
androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT);
androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER);
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
file.open(QIODevice::ReadOnly);
QByteArray cmd = file.readAll();
file.close();
QList<QByteArray> cmdList = cmd.split('\0');
for (int i = 0; i < m_androidList.size(); i++) {
QFileInfo fileInfo = m_androidList.at(i);
for (int i = 0; i < androidList.size(); i++) {
QFileInfo fileInfo = androidList.at(i);
QString desktopName = fileInfo.filePath();
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
@ -113,59 +110,65 @@ void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info)
desktopName = desktopName.mid(desktopName.lastIndexOf("/") + 1);
desktopName = desktopName.left(desktopName.lastIndexOf("."));
if(desktopName == cmdList.at(10)){
m_desktopfilePath = fileInfo.filePath();
return fileInfo.filePath();
}
}
return nullptr;
}
void ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info)
QString ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info, QFileInfoList list)
{
QFile file("/proc/" + QString::number(info.pid()) + "/environ");
file.open(QIODevice::ReadOnly);
QByteArray BA = file.readAll();
file.close();
QList<QByteArray> list_BA = BA.split('\0');
QString desktopFilePath = nullptr;
for (int i = 0; i < list_BA.length(); i++) {
if (list_BA.at(i).startsWith("GIO_LAUNCHED_DESKTOP_FILE=")) {
m_desktopfilePath = list_BA.at(i);
m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.indexOf("=") + 1);
desktopFilePath = list_BA.at(i);
desktopFilePath = desktopFilePath.mid(desktopFilePath.indexOf("=") + 1);
//desktop文件地址需要重写
m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.lastIndexOf("/") + 1);
desktopFilePath = desktopFilePath.mid(desktopFilePath.lastIndexOf("/") + 1);
break;
}
}
//desktop文件地址重写
if (!m_desktopfilePath.isEmpty()) {
for (int i = 0; i < m_list.size(); i++) {
QFileInfo fileInfo = m_list.at(i);;
if (fileInfo.filePath() == DEKSTOP_FILE_PATH + m_desktopfilePath) {
m_desktopfilePath = fileInfo.filePath();
if (!desktopFilePath.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
QFileInfo fileInfo = list.at(i);
if (fileInfo.filePath() == DESKTOP_FILE_PATH + desktopFilePath) {
desktopFilePath = fileInfo.filePath();
return desktopFilePath;
}
}
}
return desktopFilePath;
}
void ConvertDesktopToWinId::compareClassName()
QString ConvertDesktopToWinId::compareClassName(QFileInfoList list)
{
for (int i = 0; i < m_list.size(); i++) {
QFileInfo fileInfo = m_list.at(i);;
QString path_desktop_name = fileInfo.filePath();
for (int i = 0; i < list.size(); i++) {
QFileInfo fileInfo = list.at(i);;
QString pathDesktopName = fileInfo.filePath();
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
}
path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1);
path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf("."));
if (path_desktop_name == m_classClass || path_desktop_name == m_className || path_desktop_name == m_statusName) {
m_desktopfilePath = fileInfo.filePath();
pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
if (pathDesktopName == m_classClass || pathDesktopName == m_className || pathDesktopName == m_statusName) {
return fileInfo.filePath();
}
}
return nullptr;
}
void ConvertDesktopToWinId::compareCmdExec()
QString ConvertDesktopToWinId::compareCmdExec(QFileInfoList list)
{
for (int i = 0; i < m_list.size(); i++) {
for (int i = 0; i < list.size(); i++) {
QString cmd;
QFileInfo fileInfo = m_list.at(i);
QFileInfo fileInfo = list.at(i);
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
}
@ -177,38 +180,38 @@ void ConvertDesktopToWinId::compareCmdExec()
}
if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) {
m_desktopfilePath = fileInfo.filePath();
return fileInfo.filePath();
}
//仅仅是为了适配微信
if (m_desktopfilePath.isEmpty()) {
desktopFileExeName = "/usr/lib/" + desktopFileExeName;
if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) {
m_desktopfilePath = fileInfo.filePath();
}
return fileInfo.filePath();
}
}
return nullptr;
}
//最后的匹配策略汇总
void ConvertDesktopToWinId::compareLastStrategy()
QString ConvertDesktopToWinId::compareLastStrategy(QFileInfoList list)
{
compareCmdName();
QString desktopFilePath = compareCmdName(list);
if (m_desktopfilePath.isEmpty()) {
compareDesktopClass();
if (desktopFilePath.isEmpty()) {
desktopFilePath = compareDesktopClass(list);
}
if (m_desktopfilePath.isEmpty()) {
containsName();
if (desktopFilePath.isEmpty()) {
desktopFilePath = containsName(list);
}
return desktopFilePath;
}
void ConvertDesktopToWinId::compareCmdName()
QString ConvertDesktopToWinId::compareCmdName(QFileInfoList list)
{
for (int i = 0; i < m_list.size(); i++) {
for (int i = 0; i < list.size(); i++) {
QString cmd;
QFileInfo fileInfo = m_list.at(i);
QFileInfo fileInfo = list.at(i);
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
}
@ -220,37 +223,39 @@ void ConvertDesktopToWinId::compareCmdName()
}
if (desktopFileExeName.startsWith(m_className) || desktopFileExeName.endsWith(m_className)) {
m_desktopfilePath = fileInfo.filePath();
return fileInfo.filePath();
}
}
return nullptr;
}
void ConvertDesktopToWinId::compareDesktopClass()
QString ConvertDesktopToWinId::compareDesktopClass(QFileInfoList list)
{
for (int i = 0; i < m_list.size(); i++) {
QFileInfo fileInfo = m_list.at(i);
QString path_desktop_name = fileInfo.filePath();
for (int i = 0; i < list.size(); i++) {
QFileInfo fileInfo = list.at(i);
QString pathDesktopName = fileInfo.filePath();
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
}
path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1);
path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf("."));
pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
if (path_desktop_name.startsWith(m_className) || path_desktop_name.endsWith(m_className)) {
m_desktopfilePath = fileInfo.filePath();
if (pathDesktopName.startsWith(m_className) || pathDesktopName.endsWith(m_className)) {
return fileInfo.filePath();
}
else if (m_className.startsWith(path_desktop_name) || m_className.endsWith(path_desktop_name)) {
m_desktopfilePath = fileInfo.filePath();
else if (m_className.startsWith(pathDesktopName) || m_className.endsWith(pathDesktopName)) {
return fileInfo.filePath();
}
}
return nullptr;
}
void ConvertDesktopToWinId::containsName()
QString ConvertDesktopToWinId::containsName(QFileInfoList list)
{
for (int i = 0; i < m_list.size(); i++) {
for (int i = 0; i < list.size(); i++) {
QString cmd;
QFileInfo fileInfo = m_list.at(i);
QString path_desktop_name = fileInfo.filePath();
QFileInfo fileInfo = list.at(i);
QString pathDesktopName = fileInfo.filePath();
if (!fileInfo.filePath().endsWith(".desktop")) {
continue;
@ -259,13 +264,14 @@ void ConvertDesktopToWinId::containsName()
cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1);
path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf("."));
pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);
pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf("."));
if (path_desktop_name.contains(m_className) || desktopFileExeName.contains(m_className)) {
m_desktopfilePath = fileInfo.filePath();
if (pathDesktopName.contains(m_className) || desktopFileExeName.contains(m_className)) {
return fileInfo.filePath();
}
}
return nullptr;
}
//执行头文件中宏定义写好的终端指令获取对应的Exec字段
@ -284,12 +290,4 @@ QString ConvertDesktopToWinId::getDesktopFileName(QString cmd)
ConvertDesktopToWinId::~ConvertDesktopToWinId()
{
if (m_dir != nullptr) {
delete m_dir;
m_dir = nullptr;
}
if (m_androidDir) {
delete m_androidDir;
m_androidDir = nullptr;
}
}

View File

@ -23,7 +23,7 @@
#include <KWindowSystem>
#include <QDir>
#define DEKSTOP_FILE_PATH "/usr/share/applications/"
#define DESKTOP_FILE_PATH "/usr/share/applications/"
#define USR_SHARE_APP_CURRENT "/usr/share/applications/."
#define USR_SHARE_APP_UPER "/usr/share/applications/.."
#define PEONY_TRASH "/usr/share/applications/peony-trash.desktop"
@ -36,10 +36,11 @@
#define ANDROID_APP_CURRENT "/.local/share/applications/."
#define ANDROID_APP_UPER "/.local/share/applications/.."
/**
* @brief The ConvertDesktopToWinId class
* desktop文件与windowId的转换
* WindowId desktop文件路径
* desktop文件的路径(int)WindowId
*/
class ConvertDesktopToWinId: public QObject
@ -52,26 +53,20 @@ public:
QString tranIdToDesktop(WId id);
private:
QString m_desktopfilePath = nullptr;
QString m_classClass = nullptr;
QString m_className = nullptr;
QString m_statusName = nullptr;
QString m_cmdLine = nullptr;
QDir *m_dir = nullptr;
QDir *m_androidDir = nullptr;
QFileInfoList m_list;
QFileInfoList m_androidList;
QString confirmDesktopFile(KWindowInfo info);
void searchFromEnviron(KWindowInfo info);
void searchAndroidApp(KWindowInfo info);
void compareClassName();
void compareCmdExec();
void compareLastStrategy();
void compareCmdName();
void compareDesktopClass();
void containsName();
QString searchFromEnviron(KWindowInfo info, QFileInfoList list);
QString searchAndroidApp(KWindowInfo info);
QString compareClassName(QFileInfoList list);
QString compareCmdExec(QFileInfoList list);
QString compareLastStrategy(QFileInfoList list);
QString compareCmdName(QFileInfoList list);
QString compareDesktopClass(QFileInfoList list);
QString containsName(QFileInfoList list);
QString getDesktopFileName(QString cmd);
};

View File

@ -23,27 +23,27 @@
FullItemDelegate::FullItemDelegate(QObject *parent, int module):
QStyledItemDelegate(parent)
{
this->module = module;
m_ukuiMenuInterface = new UkuiMenuInterface;
this->module=module;
pUkuiMenuInterface=new UkuiMenuInterface;
}
FullItemDelegate::~FullItemDelegate()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
delete pUkuiMenuInterface;
}
void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.isValid()) {
if(index.isValid())
{
QStyleOptionViewItem viewOption(option);//用来在视图中画一个item
QRectF rect;
rect.setX(option.rect.x());
rect.setY(option.rect.y());
rect.setWidth(option.rect.width());
rect.setHeight(option.rect.height());
//QPainterPath画圆角矩形
const qreal radius = 4;
QPainterPath path;
@ -56,9 +56,10 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
path.lineTo(rect.topRight() + QPointF(0, radius));
path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
painter->setRenderHint(QPainter::Antialiasing);
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
painter->setRenderHint(QPainter::Antialiasing);
if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus))
{
// QColor color = option.palette.text().color();
// color.setAlphaF(0.15);
painter->save();
@ -71,136 +72,130 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->save();
painter->setOpacity(1);
QString desktopfp = index.data(Qt::DisplayRole).value<QString>();
QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfp);
QString desktopfp=index.data(Qt::DisplayRole).value<QString>();
QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp);
QIcon icon;
QFileInfo iconFileInfo(iconstr);
if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) {
icon = QIcon(iconstr);
} else {
if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg")))
icon=QIcon(iconstr);
else
{
iconstr.remove(".png");
iconstr.remove(".svg");
icon = QIcon::fromTheme(iconstr);
if (icon.isNull() || icon.actualSize(QSize(Style::AppListIconSize,
Style::AppListIconSize)).width() < Style::AppListIconSize) {
if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"));
} else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"));
} else {
icon = QIcon::fromTheme(QString("application-x-desktop"));
}
icon=QIcon::fromTheme(iconstr);
if(icon.isNull())
{
if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
else
icon=QIcon::fromTheme(QString("application-x-desktop"));
}
}
QString appname = m_ukuiMenuInterface->getAppName(desktopfp);
QString appname=pUkuiMenuInterface->getAppName(desktopfp);
QRect iconRect;
QRect textRect;
iconRect = QRect(rect.x() + Style::AppLeftSpace,
rect.y() + Style::AppTopSpace,
iconRect=QRect(rect.x()+Style::AppLeftSpace ,
rect.y()+Style::AppTopSpace,
Style::AppListIconSize,
Style::AppListIconSize);
icon.paint(painter, iconRect);
icon.paint(painter,iconRect);
painter->restore();
painter->save();
bool is_locked = false;
bool is_locked=false;
QFileInfo fileInfo(desktopfp);
QString desktopfn = fileInfo.fileName();
QString desktopfn=fileInfo.fileName();
//添加固定图标
if (module == 0) {
if (checkIfLocked(desktopfn)) {
is_locked = true;
if(module==0)
{
if(checkIfLocked(desktopfn))
{
is_locked=true;
QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg"));
icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16));
icon.paint(painter,QRect(iconRect.topRight().x()-14,iconRect.topRight().y()-2,16,16));
}
}
painter->restore();
textRect = QRect(rect.x() + 5,
iconRect.bottom() + Style::AppSpaceBetweenIconText,
rect.width() - 10,
rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText);
textRect=QRect(rect.x()+5,
iconRect.bottom()+Style::AppSpaceBetweenIconText,
rect.width()-10,
rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText);
painter->save();
//添加最近安装蓝色标签
bool is_recentapp = false;
QFontMetrics fm = painter->fontMetrics();
QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic);
bool is_recentapp=false;
QFontMetrics fm=painter->fontMetrics();
QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-10,Qt::TextShowMnemonic);
if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn))
{
is_recentapp=true;
appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-23,Qt::TextShowMnemonic);
textRect=QRect(rect.x()+18,
iconRect.bottom()+Style::AppSpaceBetweenIconText,
rect.width()-23,
rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText);
if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) {
is_recentapp = true;
appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic);
textRect = QRect(rect.x() + 18,
iconRect.bottom() + Style::AppSpaceBetweenIconText,
rect.width() - 23,
rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText);
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QColor("#4d94ff"));
int x = 0;
if (rect.width() < (23 + fm.boundingRect(appname).width())) {
x = rect.x() + 9;
} else {
x = rect.x() + (rect.width() - 13 - fm.boundingRect(appname).width()) / 2 + 4;
}
int x=0;
if(rect.width()<(23+fm.boundingRect(appname).width()))
x=rect.x()+9;
else
x=rect.x()+(rect.width()-13-fm.boundingRect(appname).width())/2+4;
painter->drawEllipse(QPoint(x,
textRect.y() + (fm.boundingRect(appname).height() - 8) / 2 + 4),
textRect.y()+(fm.boundingRect(appname).height()-8)/2+4),
4,
4);
}
}
painter->restore();
painter->save();
// painter->setPen(QPen(option.palette.text().color()));
painter->setPen(QPen(Qt::white));
painter->setBrush(Qt::NoBrush);
painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText);
painter->drawText(textRect,Qt::AlignHCenter |Qt::AlignTop,appnameElidedText);
// painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname);
painter->restore();
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
int len = 0;
if (!is_locked && is_recentapp) {
len = fm.boundingRect(appname).width() + 23;
} else {
len = fm.boundingRect(appname).width() + 10;
if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus))
{
int len=0;
if(!is_locked && is_recentapp)
len=fm.boundingRect(appname).width()+23;
else
len=fm.boundingRect(appname).width()+10;
if(len>rect.width())
{
QToolTip::showText(QCursor::pos(),appname);
}
if (len > rect.width()) {
QToolTip::showText(QCursor::pos(), appname);
} else {
else {
QToolTip::hideText();
}
}

View File

@ -27,20 +27,20 @@
#include <QToolTip>
#include <QHelpEvent>
#include "src/Interface/ukuimenuinterface.h"
#include "src/Style/style.h"
class FullItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
FullItemDelegate(QObject *parent, int module);
FullItemDelegate(QObject* parent,int module);
~FullItemDelegate();
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
int module = 0;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
int module=0;
UkuiMenuInterface* pUkuiMenuInterface=nullptr;
protected:
// bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index);

View File

@ -26,27 +26,22 @@
FullListView::FullListView(QWidget *parent, int module):
QListView(parent)
{
this->module = module;
this->module=module;
initWidget();
// inCurView = false;
m_ukuiMenuInterface = new UkuiMenuInterface;
pUkuiMenuInterface=new UkuiMenuInterface;
// menu=new RightClickMenu;
}
FullListView::~FullListView()
{
// delete menu;
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
delete pUkuiMenuInterface;
}
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
@ -59,35 +54,41 @@ void FullListView::initWidget()
// this->setFocusPolicy(Qt::StrongFocus);
this->setMovement(QListView::Static);
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth));
this->setGridSize(QSize(Style::AppListGridSizeWidth,Style::AppListGridSizeWidth));
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();
}
});
connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot);
connect(this,&FullListView::clicked,this,&FullListView::onClicked);
// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit()))
// {
// gsetting = new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit());
// if(gsetting->keys().contains(QString("transparency")))
// transparency = gsetting->get("transparency").toDouble();
// connect(gsetting,&QGSettings::changed,[this] (const QString &key)
// {
// if (key == "transparency")
// {
// transparency = gsetting->get("transparency").toDouble();
// }
// });
// }
}
void FullListView::addData(QStringList data)
{
listmodel = new QStandardItemModel(this);
listmodel=new QStandardItemModel(this);
this->setModel(listmodel);
Q_FOREACH (QString desktopfp, data) {
QStandardItem *item = new QStandardItem;
item->setData(QVariant::fromValue<QString>(desktopfp), Qt::DisplayRole);
Q_FOREACH(QString desktopfp,data)
{
QStandardItem* item=new QStandardItem;
item->setData(QVariant::fromValue<QString>(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
m_delegate = new FullItemDelegate(this, module);
m_delegate= new FullItemDelegate(this,module);
this->setItemDelegate(m_delegate);
}
@ -106,10 +107,10 @@ void FullListView::focusOutEvent(QFocusEvent *event)
void FullListView::updateData(QStringList data)
{
listmodel->clear();
Q_FOREACH (QString desktopfp, data) {
QStandardItem *item = new QStandardItem;
item->setData(QVariant::fromValue<QString>(desktopfp), Qt::DisplayRole);
Q_FOREACH(QString desktopfp,data)
{
QStandardItem* item=new QStandardItem;
item->setData(QVariant::fromValue<QString>(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
}
@ -117,60 +118,55 @@ void FullListView::updateData(QStringList data)
void FullListView::onClicked(QModelIndex index)
{
QVariant var = listmodel->data(index, Qt::DisplayRole);
if (var.isValid()) {
QString desktopfp = var.value<QString>();
if(var.isValid())
{
QString desktopfp=var.value<QString>();
Q_EMIT sendItemClickedSignal(desktopfp);
}
}
void FullListView::rightClickedSlot(const QPoint &pos)
{
Q_UNUSED(pos)
if (!(this->selectionModel()->selectedIndexes().isEmpty())) {
QModelIndex index = this->currentIndex();
QVariant var = listmodel->data(index, Qt::DisplayRole);
QString desktopfp = var.value<QString>();
if(!(this->selectionModel()->selectedIndexes().isEmpty()))
{
QModelIndex index=this->currentIndex();
QVariant var=listmodel->data(index, Qt::DisplayRole);
QString desktopfp=var.value<QString>();
RightClickMenu menu;
int ret = menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp);
if (module > 0) {
int ret=menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp);
if(module>0)
{
switch (ret) {
case 6:
Q_EMIT sendHideMainWindowSignal();
break;
case 7:
Q_EMIT sendHideMainWindowSignal();
break;
default:
break;
}
} else {
}
else{
switch (ret) {
case 1:
Q_EMIT sendUpdateAppListSignal();
break;
case 2:
Q_EMIT sendUpdateAppListSignal();
break;
case 6:
Q_EMIT sendHideMainWindowSignal();
break;
case 7:
Q_EMIT sendHideMainWindowSignal();
break;
default:
break;
}
}
//this->selectionModel()->clear();
}
}
@ -190,21 +186,22 @@ void FullListView::leaveEvent(QEvent *e)
// current_focus_widget = QApplication::focusWidget();
// current_focus_widget = QWidget::focusWidget();
// QPushButton *le= qobject_cast<QPushButton*>(current_focus_widget);
}
void FullListView::selectFirstItem()
{
qDebug() << "void FullListView::selectFirstItem()";
if (this->currentIndex().row() == -1) {
this->setCurrentIndex(this->model()->index(0, 0));
if(this->currentIndex().row() == -1)
{
this->setCurrentIndex(this->model()->index(0,0));
}
}
//void FullListView::paintEvent(QPaintEvent *e)
//{
// double transparency=getTransparency();
// QPainter painter(this->viewport());
void FullListView::paintEvent(QPaintEvent *e)
{
double transparency=getTransparency();
QPainter painter(this->viewport());
// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit()))
// {
@ -236,76 +233,72 @@ void FullListView::selectFirstItem()
// }
// 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());
// }
// QListView::paintEvent(e);
//}
QListView::paintEvent(e);
}
void FullListView::keyPressEvent(QKeyEvent *e)
void FullListView::keyPressEvent(QKeyEvent* e)
{
if (flag) { //避免长按按键界面滚动过快
flag = false;
time->start(100);
QRect center = visualRect(currentIndex());
if (e->type() == QEvent::KeyPress) {
switch (e->key()) {
if(e->type() == QEvent::KeyPress)
{
switch(e->key())
{
case Qt::Key_Enter:
case Qt::Key_Return: {
case Qt::Key_Return:
{
QModelIndex index = this->currentIndex();
Q_EMIT clicked(index);
break;
}
case Qt::Key_Left: {
case Qt::Key_Left:
{
this->clearFocus();
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;
}
case Qt::Key_Right:
{
case Qt::Key_Right: {
this->clearFocus();
if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) {
if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth))
{
Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth);
}
this->setFocus();
return QListView::keyPressEvent(e);
break;
}
case Qt::Key_Up: {
if (module == 0) {
if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) {
this->clearFocus();
case Qt::Key_Up:
{
if(module == 0)
{
if(mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth))
{
Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth);
this->setFocus();
}
}
return QListView::keyPressEvent(e);
break;
}
case Qt::Key_Down: {
if (module == 0) {
if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) {
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;
}
@ -315,14 +308,16 @@ void FullListView::keyPressEvent(QKeyEvent *e)
break;
}
}
}
}
void FullListView::mousePressEvent(QMouseEvent *event)
{
if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) {
if(!(this->indexAt(event->pos()).isValid()) && event->button()==Qt::LeftButton)
{
Q_EMIT sendHideMainWindowSignal();
} else {
}
else
{
return QListView::mousePressEvent(event);
}
}

View File

@ -33,7 +33,7 @@ class FullListView : public QListView
{
Q_OBJECT
public:
FullListView(QWidget *parent, int module);
FullListView(QWidget *parent,int module);
~FullListView();
void addData(QStringList data);//字母排序模块添加数据
@ -41,25 +41,23 @@ 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 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 mousePressEvent(QMouseEvent *event);
private:
FullItemDelegate *m_delegate = nullptr;
QStandardItemModel *listmodel = nullptr;
int module = 0;
FullItemDelegate* m_delegate=nullptr;
QStandardItemModel* listmodel=nullptr;
int module=0;
double transparency;
RightClickMenu *menu = nullptr; //右键菜单
RightClickMenu* menu=nullptr;//右键菜单
QStringList data;
QGSettings *gsetting;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
bool flag;
QTimer *time = nullptr;
QGSettings* gsetting;
UkuiMenuInterface* pUkuiMenuInterface=nullptr;
// bool inCurView;

View File

@ -22,30 +22,30 @@
#include <QToolTip>
#include "src/UtilityFunction/utility.h"
ItemDelegate::ItemDelegate(QObject *parent, int module):
ItemDelegate::ItemDelegate(QObject* parent, int module):
QStyledItemDelegate(parent)
{
this->module = module;
m_ukuiMenuInterface = new UkuiMenuInterface;
this->module=module;
pUkuiMenuInterface=new UkuiMenuInterface;
}
ItemDelegate::~ItemDelegate()
{
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
delete pUkuiMenuInterface;
}
void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.isValid()) {
if(index.isValid())
{
// QStyleOptionViewItem viewOption(option);//用来在视图中画一个item
QRectF rect;
rect.setX(option.rect.x());
rect.setY(option.rect.y());
rect.setWidth(option.rect.width());
rect.setHeight(option.rect.height() - 2);
rect.setHeight(option.rect.height()-2);
//QPainterPath画圆角矩形
const qreal radius = 4;
QPainterPath path;
@ -58,10 +58,11 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
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));
QStringList strlist = index.model()->data(index, Qt::DisplayRole).toStringList();
painter->setRenderHint(QPainter::Antialiasing);
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList();
painter->setRenderHint(QPainter::Antialiasing);
if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus))
{
QColor color = option.palette.text().color();
color.setAlphaF(0.15);
painter->save();
@ -70,185 +71,168 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->drawPath(path);
painter->restore();
}
painter->setOpacity(1);
if (module > 0) {
if (strlist.at(1).toInt() == 1) {
QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, Style::defaultIconSize, Style::defaultIconSize);
QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0));
if(module>0)
{
if(strlist.at(1).toInt()==1)
{
QRect iconRect=QRect(rect.x()+11,rect.y()+(rect.height()-32)/2,32,32);
QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0));
QIcon icon;
QFileInfo iconFileInfo(iconstr);
if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) {
icon = QIcon(iconstr);
} else {
if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg")))
icon=QIcon(iconstr);
else
{
iconstr.remove(".png");
iconstr.remove(".svg");
icon = QIcon::fromTheme(iconstr);
if (icon.isNull() || icon.actualSize(QSize(Style::defaultIconSize, Style::defaultIconSize)).width() < Style::defaultIconSize) {
if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"));
} else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"));
} else {
icon = QIcon::fromTheme(QString("application-x-desktop"));
icon=QIcon::fromTheme(iconstr);
if(icon.isNull())
{
if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
else
icon=QIcon::fromTheme(QString("application-x-desktop"));
}
}
}
painter->save();
icon.paint(painter, iconRect, Qt::AlignCenter);
QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0));
QFontMetrics fm = painter->fontMetrics();
QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic);
painter->drawText(QRect(iconRect.right() + 15, rect.y(),
rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText);
icon.paint(painter,iconRect,Qt::AlignLeft);
QString appname=pUkuiMenuInterface->getAppName(strlist.at(0));
QFontMetrics fm=painter->fontMetrics();
QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic);
painter->drawText(QRect(iconRect.right()+15,rect.y(),
rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText);
painter->restore();
painter->save();
QFileInfo fileInfo(strlist.at(0));
QString desktopfn = fileInfo.fileName();
if (checkIfRecent(desktopfn)) {
QString desktopfn=fileInfo.fileName();
if(checkIfRecent(desktopfn))
{
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QColor("#4d94ff"));
painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4);
painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4);
}
painter->restore();
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
int len = fm.boundingRect(appname).width();
if (len > rect.width() - 62) {
QToolTip::showText(QCursor::pos(), appname);
} else {
if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus))
{
int len=fm.boundingRect(appname).width();
if(len>rect.width()-62)
{
QToolTip::showText(QCursor::pos(),appname);
}
else {
QToolTip::hideText();
}
}
} else {
}
else
{
//绘制分割线
painter->save();
// QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height());
QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height());
painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0));
QRect textRect=QRect(rect.x()+11,rect.y(),rect.width(),rect.height());
painter->drawText(textRect,Qt::AlignVCenter,strlist.at(0));
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(QPen(QColor(option.palette.text().color()), 1));
painter->setPen(QPen(QColor(option.palette.text().color()),1));
painter->setOpacity(0.1);
painter->drawLine(QPoint(5, rect.bottom()), QPoint(rect.right(), rect.bottom()));
painter->drawLine(QPoint(5,rect.bottom()),QPoint(rect.right(),rect.bottom()));
painter->restore();
}
} else {
QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32);
QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0));
}
else
{
QRect iconRect=QRect(rect.left()+11,rect.y()+(rect.height()-32)/2,32,32);
QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0));
QIcon icon;
QFileInfo iconFileInfo(iconstr);
if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) {
icon = QIcon(iconstr);
} else {
if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg")))
icon=QIcon(iconstr);
else
{
iconstr.remove(".png");
iconstr.remove(".svg");
icon = QIcon::fromTheme(iconstr);
if (icon.isNull() || icon.actualSize(QSize(32, 32)).width() < 32) {
if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
} else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) {
icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"));
} else {
icon = QIcon::fromTheme(QString("application-x-desktop"));
icon=QIcon::fromTheme(iconstr);
if(icon.isNull())
{
if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"));
else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")))
icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"));
else
icon=QIcon::fromTheme(QString("application-x-desktop"));
}
}
}
icon.paint(painter, iconRect, Qt::AlignCenter);
QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0));
icon.paint(painter,iconRect,Qt::AlignLeft);
QString appname=pUkuiMenuInterface->getAppName(strlist.at(0));
QFileInfo fileInfo(strlist.at(0));
QString desktopfn = fileInfo.fileName();
if (checkIfLocked(desktopfn)) {
QString desktopfn=fileInfo.fileName();
if(checkIfLocked(desktopfn))
{
QIcon icon(QString(":/data/img/mainviewwidget/lock.svg"));
icon.paint(painter, QRect(rect.topRight().x() - 30, rect.y() + (rect.height() - 16) / 2, 16, 16));
icon.paint(painter,QRect(rect.topRight().x()-22,rect.y()+(rect.height()-16)/2,16,16));
}
painter->setOpacity(1);
painter->save();
if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) {
if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn))
{
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QColor("#4d94ff"));
painter->drawEllipse(QPoint(rect.topRight().x() - 30, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4);
painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4);
}
painter->restore();
painter->save();
painter->setPen(QPen(option.palette.text().color()));
painter->setBrush(Qt::NoBrush);
painter->setOpacity(1);
QFontMetrics fm = painter->fontMetrics();
QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic);
painter->drawText(QRect(iconRect.right() + 15, rect.y(),
rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText);
QFontMetrics fm=painter->fontMetrics();
QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic);
painter->drawText(QRect(iconRect.right()+15,rect.y(),
rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText);
painter->restore();
if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) {
int len = fm.boundingRect(appname).width();
if (len > rect.width() - 62) {
QToolTip::showText(QCursor::pos(), appname);
} else {
if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus))
{
int len=fm.boundingRect(appname).width();
if(len>rect.width()-62)
{
QToolTip::showText(QCursor::pos(),appname);
}
else {
QToolTip::hideText();
}
}
}
}
}
QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList();
// if(strlist.at(1).toInt()==1)
return QSize(298, 44);
return QSize(310,44);
// else
// return QSize(310,48);
}

View File

@ -32,14 +32,14 @@ public:
/**
* @param module为0时为常用模块123
*/
ItemDelegate(QObject *parent, int module);
ItemDelegate(QObject* parent,int module);
~ItemDelegate();
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
int module = 0;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
int module=0;
UkuiMenuInterface* pUkuiMenuInterface=nullptr;
};

View File

@ -36,7 +36,6 @@ LetterClassifyButton::LetterClassifyButton(QWidget *parent,
this->setText(letter);
this->setFocusPolicy(Qt::NoFocus);
this->setCheckable(true);
this->setStyleSheet("padding: 0px;");
connect(this,&LetterClassifyButton::toggled,this,&LetterClassifyButton::reactToToggle);
}

View File

@ -24,21 +24,18 @@
ListView::ListView(QWidget *parent, int width, int height, int module):
QListView(parent)
{
this->w = width;
this->h = height;
this->module = module;
this->w=width;
this->h=height;
this->module=module;
initWidget();
m_ukuiMenuInterface = new UkuiMenuInterface;
menu = new RightClickMenu;
pUkuiMenuInterface=new UkuiMenuInterface;
menu=new RightClickMenu;
}
ListView::~ListView()
{
delete menu;
if (m_ukuiMenuInterface != nullptr) {
delete m_ukuiMenuInterface;
m_ukuiMenuInterface = nullptr;
}
delete pUkuiMenuInterface;
}
void ListView::initWidget()
@ -62,94 +59,88 @@ void ListView::initWidget()
this->setMouseTracking(true);
this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
this->setFrameShape(QFrame::NoFrame);
this->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
this->verticalScrollBar()->setProperty("drawScrollBarGroove",false);
this->setFocus();
connect(this, &ListView::customContextMenuRequested, this, &ListView::rightClickedSlot);
connect(this, &ListView::clicked, this, &ListView::onClicked);
connect(this,&ListView::customContextMenuRequested,this,&ListView::rightClickedSlot);
connect(this,&ListView::clicked,this,&ListView::onClicked);
}
void ListView::addData(QVector<QStringList> data)
{
listmodel = new QStandardItemModel(this);
listmodel=new QStandardItemModel(this);
this->setModel(listmodel);
Q_FOREACH (QStringList desktopfp, data) {
QStandardItem *item = new QStandardItem;
item->setData(QVariant::fromValue<QStringList>(desktopfp), Qt::DisplayRole);
Q_FOREACH(QStringList desktopfp,data)
{
QStandardItem* item=new QStandardItem;
item->setData(QVariant::fromValue<QStringList>(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
m_delegate = new ItemDelegate(this, module);
m_delegate= new ItemDelegate(this,module);
this->setItemDelegate(m_delegate);
}
void ListView::updateData(QVector<QStringList> data)
{
listmodel->clear();
Q_FOREACH (QStringList desktopfp, data) {
QStandardItem *item = new QStandardItem;
item->setData(QVariant::fromValue<QStringList>(desktopfp), Qt::DisplayRole);
Q_FOREACH(QStringList desktopfp,data)
{
QStandardItem* item=new QStandardItem;
item->setData(QVariant::fromValue<QStringList>(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
// Q_EMIT dataChanged(createIndex(0,0), createIndex(listmodel->rowCount()-1,0));
}
void ListView::onClicked(QModelIndex index)
{
QVariant var = listmodel->data(index, Qt::DisplayRole);
if (var.isValid()) {
if(var.isValid())
{
Q_EMIT sendItemClickedSignal(var.value<QStringList>());
}
}
void ListView::rightClickedSlot(const QPoint &pos)
{
if (!this->selectionModel()->selectedIndexes().isEmpty()) {
QModelIndex index = this->currentIndex();
if(!this->selectionModel()->selectedIndexes().isEmpty())
{
QModelIndex index=this->currentIndex();
// QRect center = visualRect(index);
QVariant var = listmodel->data(index, Qt::DisplayRole);
QStringList strlist = var.value<QStringList>();
if (strlist.at(1).toInt() == 1) {
QVariant var=listmodel->data(index, Qt::DisplayRole);
QStringList strlist=var.value<QStringList>();
if(strlist.at(1).toInt()==1)
{
int ret = menu->showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0));
Q_EMIT sendMainWinActiveSignal(false);
if (module > 0) {
if (strlist.at(1).toInt() == 1) {
if(module>0)
{
if(strlist.at(1).toInt()==1)
{
switch (ret) {
case 6:
Q_EMIT sendHideMainWindowSignal();
break;
case 7:
Q_EMIT sendHideMainWindowSignal();
break;
default:
break;
}
}
} else {
}
else{
switch (ret) {
case 1:
Q_EMIT sendUpdateAppListSignal();
break;
case 2:
Q_EMIT sendUpdateAppListSignal();
break;
case 6:
Q_EMIT sendHideMainWindowSignal();
break;
case 7:
Q_EMIT sendHideMainWindowSignal();
break;
default:
break;
}
@ -185,18 +176,19 @@ void ListView::leaveEvent(QEvent *e)
void ListView::paintEvent(QPaintEvent *e)
{
double transparency = getTransparency();
double transparency=getTransparency();
QPainter painter(this->viewport());
painter.setOpacity(transparency);
painter.setPen(Qt::NoPen);
painter.setBrush(this->palette().base());
painter.fillRect(this->rect(), this->palette().base());
//滚动条
QPalette p = this->verticalScrollBar()->palette();
QPalette p=this->verticalScrollBar()->palette();
QColor color(255, 255, 255);
// QColor color=p.color(QPalette::Active,QPalette::Button);
color.setAlphaF(0.25);
p.setColor(QPalette::Active, QPalette::Button, color);
p.setColor(QPalette::Active,QPalette::Button,color);
this->verticalScrollBar()->setPalette(p);
QListView::paintEvent(e);
}
@ -207,14 +199,14 @@ void ListView::dragLeaveEvent(QDragLeaveEvent *e)
QStringList m_desktopfp = pressApp.value<QStringList>();
QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QFileInfo fileInfo(m_desktopfp.at(0));
QString desktopfn = fileInfo.fileName();
QString desktopfn=fileInfo.fileName();
QFile file(m_desktopfp.at(0));
QString newname = QString(path + "/" + desktopfn);
bool ret = file.copy(QString(path + "/" + desktopfn));
if (ret) {
QString newname=QString(path+"/"+desktopfn);
bool ret=file.copy(QString(path+"/"+desktopfn));
if(ret)
{
char command[200];
sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data());
sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data());
QProcess::startDetached(QString::fromLocal8Bit(command));
}
}
@ -225,37 +217,39 @@ void ListView::mousePressEvent(QMouseEvent *event)
return QListView::mousePressEvent(event);
}
void ListView::keyPressEvent(QKeyEvent *e)
void ListView::keyPressEvent(QKeyEvent* e)
{
if (e->type() == QEvent::KeyPress) {
switch (e->key()) {
if(e->type()==QEvent::KeyPress)
{
switch(e->key())
{
case Qt::Key_Enter:
case Qt::Key_Return: {
QModelIndex index = this->currentIndex();
case Qt::Key_Return:
{
QModelIndex index=this->currentIndex();
Q_EMIT clicked(index);
}
break;
case Qt::Key_Down: {
if (currentIndex().row() == this->model()->rowCount() - 1) {
setCurrentIndex(this->model()->index(0, 0));
case Qt::Key_Down:
{
if(currentIndex().row() == this->model()->rowCount() - 1)
{
setCurrentIndex(this->model()->index(0,0));
break;
}
return QListView::keyPressEvent(e);
break;
}
case Qt::Key_Up: {
if (currentIndex().row() == 0) {
setCurrentIndex(this->model()->index(this->model()->rowCount() - 1, 0));
case Qt::Key_Up:
{
if(currentIndex().row() == 0)
{
setCurrentIndex(this->model()->index(this->model()->rowCount()-1,0));
break;
}
return QListView::keyPressEvent(e);
break;
}
default:
return QListView::keyPressEvent(e);
break;

View File

@ -43,25 +43,25 @@ public:
protected:
void initWidget();
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 paintEvent(QPaintEvent *e) override;
void keyPressEvent(QKeyEvent *e);
void keyPressEvent(QKeyEvent* e);
void dropEvent(QDropEvent *event);
void mousePressEvent(QMouseEvent *event);
void dragLeaveEvent(QDragLeaveEvent *e);
void dragMoveEvent(QDragMoveEvent *event);
private:
QStandardItemModel *listmodel = nullptr;
int w = 0;
int h = 0;
int module = 0;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
QStandardItemModel* listmodel=nullptr;
int w=0;
int h=0;
int module=0;
UkuiMenuInterface* pUkuiMenuInterface=nullptr;
RightClickMenu *menu = nullptr; //右键菜单
RightClickMenu* menu=nullptr;//右键菜单
QVector<QStringList> data;
ItemDelegate *m_delegate = nullptr;
ItemDelegate* m_delegate=nullptr;
int m_preRowCount;
QPoint startPos;
// QMimeData *mimeData = nullptr;
@ -75,7 +75,6 @@ Q_SIGNALS:
void sendItemClickedSignal(QStringList arg);//发送item点击信号
void sendHideMainWindowSignal();
void sendUpdateAppListSignal();
void sendMainWinActiveSignal(bool flag);
};
#endif // LISTVIEW_H

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "proxystyle.h"
#include <QApplication>
#include <QDebug>

View File

@ -1,20 +1,3 @@
/*
* 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef INTERNALSTYLE_H
#define INTERNALSTYLE_H
#include <QProxyStyle>

View File

@ -0,0 +1,62 @@
#include "softwaredatabaseupdatethread.h"
#include <QDBusMessage>
#include <QDBusConnection>
#include <QGSettings>
#include <QDBusReply>
#include <QDBusInterface>
#include <QDir>
#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;
}

View File

@ -0,0 +1,27 @@
#ifndef SOFTWAREDATABASEUPDATETHREAD_H
#define SOFTWAREDATABASEUPDATETHREAD_H
#include <QObject>
#include <QWidget>
#include <QThread>
#include <QtCore>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
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

View File

@ -30,9 +30,6 @@
#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db"
bool isHuaWeiPC = false;
bool isPANGU = false;
const QPixmap loadSvg(const QString &fileName, const int size)
{
QPixmap pixmap(size, size);
@ -98,76 +95,6 @@ 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<QVariantList> 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<QVariantList> 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;

View File

@ -23,7 +23,6 @@
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QScreen>
#include <gio/gdesktopappinfo.h>
#include "src/Interface/ukuimenuinterface.h"
@ -31,8 +30,12 @@
#define DBUS_PATH "/panel/position"
#define DBUS_INTERFACE "org.ukui.panel"
extern bool isHuaWeiPC;
extern bool isPANGU;
enum PanelPositon{
BOTTOM = 0,
TOP = 1,
LEFT = 2,
RIGHT = 3
};
const QPixmap loadSvg(const QString &fileName, const int size);
@ -45,8 +48,6 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source);
//调试日志
void debugLog(QString strMsg);
QVariantList getScreenGeometry();
QRect getScreenAvailableGeometry();
double getTransparency();
QString getEnvOverriddenDesktopFile(int pid);
//数据库操作

View File

@ -0,0 +1,290 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN" sourcelanguage="en">
<context>
<name>FunctionClassifyButton</name>
<message>
<source>Mobile</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Internet</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Social</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Video</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Development</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Image</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Game</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Office</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Education</source>
<translation type="vanished"></translation>
</message>
<message>
<source>System</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Others</source>
<translation type="vanished"></translation>
</message>
</context>
<context>
<name>MainViewWidget</name>
<message>
<location filename="../src/MainViewWidget/mainviewwidget.cpp" line="242"/>
<source>Search</source>
<translation></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="29"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="49"/>
<source>Office</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="30"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="50"/>
<source>Development</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="31"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="51"/>
<source>Image</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="32"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="52"/>
<source>Video</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="33"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="53"/>
<source>Internet</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="34"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="54"/>
<source>Game</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="35"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="55"/>
<source>Education</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="36"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="56"/>
<source>Social</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="37"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="57"/>
<source>System</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="38"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="58"/>
<source>Safe</source>
<translation></translation>
</message>
<message>
<location filename="../src/FunctionWidget/functionbuttonwidget.cpp" line="39"/>
<location filename="../src/Interface/ukuimenuinterface.cpp" line="59"/>
<source>Others</source>
<translation></translation>
</message>
</context>
<context>
<name>RightClickMenu</name>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="217"/>
<source>Pin to all</source>
<translation> </translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="220"/>
<source>Unpin from all</source>
<translation> </translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="224"/>
<source>Pin to taskbar</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="227"/>
<source>Unpin from taskbar</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="230"/>
<source>Add to desktop shortcuts</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="243"/>
<source>Uninstall</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="258"/>
<source>Sleep</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="260"/>
<source>Log Out</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="262"/>
<source>Restart</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="264"/>
<source>Power Off</source>
<translation></translation>
</message>
<message>
<location filename="../src/RightClickMenu/rightclickmenu.cpp" line="292"/>
<source>Personalize this list</source>
<translation></translation>
</message>
</context>
<context>
<name>SideBarWidget</name>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="190"/>
<source>All</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="192"/>
<source>Letter</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="194"/>
<source>Function</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="211"/>
<source>Trash</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="213"/>
<source>Computer</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="629"/>
<source>Max</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="700"/>
<source>Min</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="209"/>
<source>Personal</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="215"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../src/SideBarWidget/sidebarwidget.cpp" line="217"/>
<source>Power</source>
<translation></translation>
</message>
</context>
<context>
<name>SplitBarFrame</name>
<message>
<source>Mobile</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Internet</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Social</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Video</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Development</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Image</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Game</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Office</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Education</source>
<translation type="vanished"></translation>
</message>
<message>
<source>System</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Safe</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Others</source>
<translation type="vanished"></translation>
</message>
</context>
</TS>

View File

@ -65,7 +65,6 @@ SOURCES += \
src/SideBarWidget/sidebarwidget.cpp \
src/Style/style.cpp \
src/UtilityFunction/classifybtnscrollarea.cpp \
src/UtilityFunction/convertdesktoptowinid.cpp \
src/UtilityFunction/fullitemdelegate.cpp \
src/UtilityFunction/fulllistview.cpp \
src/UtilityFunction/functionclassifybutton.cpp \
@ -104,7 +103,6 @@ HEADERS += \
src/SideBarWidget/sidebarwidget.h \
src/Style/style.h \
src/UtilityFunction/classifybtnscrollarea.h \
src/UtilityFunction/convertdesktoptowinid.h \
src/UtilityFunction/fullitemdelegate.h \
src/UtilityFunction/fulllistview.h \
src/UtilityFunction/functionclassifybutton.h \

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2022-05-10T09:42:06. -->
<!-- Written by QtCreator 7.0.0, 2022-04-20T17:17:54. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -8,7 +8,7 @@
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
@ -28,7 +28,7 @@
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
@ -37,6 +37,7 @@
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
@ -45,48 +46,58 @@
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{9d9f9a2c-403b-48c4-83ee-e52b4e889b83}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
@ -95,46 +106,37 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
@ -143,46 +145,38 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Profile</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
@ -191,117 +185,58 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>