diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg
new file mode 100644
index 0000000..7b506cb
--- /dev/null
+++ b/data/img/sidebarwidget/default.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/main.cpp b/main.cpp
index 05ffbaa..510c21d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -36,36 +36,42 @@ int main(int argc, char *argv[])
{
initUkuiLog4qt("ukui-menu");
qRegisterMetaType>("QVector");
+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
- QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
+
QtSingleApplication app("ukui-menu", argc, argv);
app.setQuitOnLastWindowClosed(false);
- 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();
}
diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp
index 3c49d1c..4196876 100644
--- a/src/CommonUseWidget/commonusewidget.cpp
+++ b/src/CommonUseWidget/commonusewidget.cpp
@@ -27,23 +27,23 @@ CommonUseWidget::CommonUseWidget(QWidget *parent) :
QWidget(parent)
{
initUi();
+
}
CommonUseWidget::~CommonUseWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
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()<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()<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();
}
diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h
index aeacf4b..16e571c 100644
--- a/src/CommonUseWidget/commonusewidget.h
+++ b/src/CommonUseWidget/commonusewidget.h
@@ -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
diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp
index a3afed2..035225c 100644
--- a/src/CommonUseWidget/fullcommonusewidget.cpp
+++ b/src/CommonUseWidget/fullcommonusewidget.cpp
@@ -30,87 +30,91 @@ FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) :
FullCommonUseWidget::~FullCommonUseWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
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(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(wid);
+ QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0);
+ QWidget* wid=widItem->widget();
+ FullListView* listview=qobject_cast(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();
}
@@ -126,28 +130,36 @@ void FullCommonUseWidget::execApplication(QString desktopfp)
void FullCommonUseWidget::selectFirstItem()
{
- // this->focusNextChild();
+ // 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) {
- m_scrollArea->verticalScrollBar()->setValue(0);
- } else {
- int curvalue = m_scrollArea->verticalScrollBar()->value();
- m_scrollArea->verticalScrollBar()->setValue(curvalue + value);
- }
+// if(flag)
+// {
+// flag = false;
+// time->start(100);
+ if(value == 0)
+ {
+ m_scrollArea->verticalScrollBar()->setValue(0);
+ }
+ 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);
}
diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/CommonUseWidget/fullcommonusewidget.h
index 1afe6f4..ded8e50 100644
--- a/src/CommonUseWidget/fullcommonusewidget.h
+++ b/src/CommonUseWidget/fullcommonusewidget.h
@@ -74,6 +74,8 @@ private:
ScrollArea* m_scrollArea=nullptr;
ScrollAreaWid* m_scrollAreaWid=nullptr;
QVBoxLayout* m_scrollAreaWidLayout=nullptr;
+ bool flag;
+ QTimer *time = nullptr;
protected:
/**
diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp
index 7196fc0..f8d79a6 100644
--- a/src/DBus/dbus.cpp
+++ b/src/DBus/dbus.cpp
@@ -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
#include
diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h
index 4a70f04..8f017fe 100644
--- a/src/DBus/dbus.h
+++ b/src/DBus/dbus.h
@@ -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 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 vector = UkuiMenuInterface::functionalVector;
- QStringList androidlist = vector.at(0);
-
- if (!androidlist.isEmpty()) {
+ QVector 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;iaddData(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();
- m_scrollAreaWidLayout->removeWidget(wid);
- wid->setParent(nullptr);
- delete wid;
- delete child;
- }
-
- fillAppList();
+ while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) {
+ QWidget* wid=child->widget();
+ m_scrollAreaWidLayout->removeWidget(wid);
+ wid->setParent(nullptr);
+ delete wid;
+ delete child;
+ }
+ fillAppList();
//刷新图标列表界面
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
+ 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(rowcount()/2)
+ {
//应用界面
- QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1);
- QWidget *wid = widItem->widget();
- FullListView *listview = qobject_cast(wid);
+ QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1);
+ QWidget* wid=widItem->widget();
+ FullListView* listview=qobject_cast(wid);
listview->adjustSize();
- int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
- int rowcount = 0;
+ 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,51 +314,48 @@ void FullFunctionWidget::initIconListWidget()
void FullFunctionWidget::initIconListScrollArea()
{
m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem);
-
- for (int i = 0; i < m_classificationList.size(); i++) {
- FunctionClassifyButton *iconbtn = new FunctionClassifyButton(
- Style::LeftBtnWidth,
- Style::LeftBtnHeight,
- Style::LeftIconSize,
- m_classificationList.at(i),
- true,
- true);
+ for(int i=0;isetChecked(false);
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(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot);
-
+ connect(m_btnGroup,static_cast(&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(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(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(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,12 +423,12 @@ 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,
- m_iconListWid->height()));
+ 0,
+ Style::LeftBtnWidth,
+ m_iconListWid->height()));
m_animation->setEasingCurve(QEasingCurve::InQuart);
m_animation->start();
m_iconListScrollArea->show();
@@ -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)
@@ -499,27 +480,29 @@ void FullFunctionWidget::onSetSlider(int value)
// {
// flag = false;
// time->start(100);
- int curvalue = m_scrollArea->verticalScrollBar()->value();
- m_scrollArea->verticalScrollBar()->setValue(curvalue + value);
+ int curvalue = m_scrollArea->verticalScrollBar()->value();
+ m_scrollArea->verticalScrollBar()->setValue(curvalue + value);
// qDebug() << "FullFunctionWidget::onSetSlider" << curvalue;
// }
}
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(wid);
- QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1);
- QWidget *widTop = widItemTop->widget();
- FullListView *m_listviewTop = qobject_cast(widTop);
+ if( event->type() == QEvent::KeyPress )
+ {
+ QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
+ QWidget* wid = widItem->widget();
+ FullListView* m_listview = qobject_cast(wid);
+
+ QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1);
+ QWidget* widTop = widItemTop->widget();
+ FullListView* m_listviewTop = qobject_cast(widTop);
+
QKeyEvent *ke = (QKeyEvent *)event;
-
- if (ke->key() == Qt::Key_Tab) {
- Q_EMIT setFocusToSideWin();
+ 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 {
- m_listview->setFocus();
- QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1);
- btnGroupClickedSlot(button);
- m_index = m_buttonList.size() - 1;
}
-
+ else
+ {
+ m_listview->setFocus();
+ 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;
}
diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp
index a70ec66..69dce44 100644
--- a/src/FunctionWidget/functionwidget.cpp
+++ b/src/FunctionWidget/functionwidget.cpp
@@ -28,10 +28,7 @@ FunctionWidget::FunctionWidget(QWidget *parent) :
FunctionWidget::~FunctionWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
/**
@@ -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 vector = UkuiMenuInterface::functionalVector;
- QStringList androidlist = vector.at(0);
-
- if (!androidlist.isEmpty()) {
+ QVector vector=UkuiMenuInterface::functionalVector;
+ QStringList androidlist=vector.at(0);
+ if(!androidlist.isEmpty())
+ {
insertClassificationBtn(tr("Mobile"));
insertAppList(androidlist);
}
-
- QStringList netlist = vector.at(1);
-
- if (!netlist.isEmpty()) {
+ 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()<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();
}
diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h
index beffaa3..6ecc01c 100644
--- a/src/FunctionWidget/functionwidget.h
+++ b/src/FunctionWidget/functionwidget.h
@@ -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
diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp
index ae5e94d..f435a63 100644
--- a/src/Interface/ukuimenuinterface.cpp
+++ b/src/Interface/ukuimenuinterface.cpp
@@ -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 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());
diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp
index d0aa93a..0fedf33 100644
--- a/src/LetterWidget/fullletterwidget.cpp
+++ b/src/LetterWidget/fullletterwidget.cpp
@@ -28,10 +28,9 @@ FullLetterWidget::FullLetterWidget(QWidget *parent) :
FullLetterWidget::~FullLetterWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
+ 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 vector = UkuiMenuInterface::alphabeticVector;
-
- for (int i = 0; i < vector.size(); i++) {
- QStringList appList = vector.at(i);
-
- if (!appList.isEmpty()) {
+ QVector vector=UkuiMenuInterface::alphabeticVector;
+ for(int i=0;i(i + 65)));
- } else if (i == 26) {
- letterstr = "&";
- } else {
- letterstr = "#";
- }
-
+ if(i<26)
+ letterstr=QString(QChar(static_cast(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;iaddData(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();
- m_scrollAreaWidLayout->removeWidget(wid);
- wid->setParent(nullptr);
- delete wid;
- delete child;
- }
-
- fillAppList();
+ while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) {
+ QWidget* wid=child->widget();
+ m_scrollAreaWidLayout->removeWidget(wid);
+ wid->setParent(nullptr);
+ delete wid;
+ delete child;
+ }
+ fillAppList();
//刷新字母列表界面
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
+ 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(rowcount()/2)
+ {
//应用界面
- QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1);
- QWidget *wid = widItem->widget();
- FullListView *listview = qobject_cast(wid);
+ QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1);
+ QWidget* wid=widItem->widget();
+ FullListView* listview=qobject_cast(wid);
listview->adjustSize();
- int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth;
- int rowcount = 0;
+ 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,
- true,
- m_letterList.at(i));
- letterbtn->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight);
+ if(m_letterList.contains("&"))
+ m_letterList.replace(m_letterList.indexOf("&"),"&&");
+ for(int i=0;isetFixedSize(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(&QButtonGroup::buttonClicked));
+ m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter);
+ connect(letterbtn,&LetterClassifyButton::buttonClicked,m_btnGroup, static_cast(&QButtonGroup::buttonClicked));
}
-
m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer);
- int id = 0;
- Q_FOREACH (QAbstractButton *btn, m_buttonList) {
- m_btnGroup->addButton(btn, id++);
+ int id=0;
+ Q_FOREACH (QAbstractButton* btn, m_buttonList) {
+ m_btnGroup->addButton(btn,id++);
}
- connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullLetterWidget::btnGroupClickedSlot);
+ connect(m_btnGroup,static_cast(&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(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(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(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(button);
-
- if (index == m_buttonList.indexOf(button)) {
+ if(value>=min && value (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)
@@ -454,75 +452,79 @@ void FullLetterWidget::onSetSlider(int value)
// {
// flag = false;
// time->start(100);
- int curvalue = m_scrollArea->verticalScrollBar()->value();
- m_scrollArea->verticalScrollBar()->setValue(curvalue + value);
+ int curvalue = m_scrollArea->verticalScrollBar()->value();
+ m_scrollArea->verticalScrollBar()->setValue(curvalue + 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(wid);
- QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1);
- QWidget *widTop = widItemTop->widget();
- FullListView *m_listviewTop = qobject_cast(widTop);
+ if( event->type() == QEvent::KeyPress )
+ {
+ QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1);
+ QWidget* wid = widItem->widget();
+ FullListView* m_listview = qobject_cast(wid);
+
+ QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1);
+ QWidget* widTop = widItemTop->widget();
+ FullListView* m_listviewTop = qobject_cast(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_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 {
- m_listview->setFocus();
- QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1);
- btnGroupClickedSlot(button);
- m_index = m_buttonList.size() - 1;
}
-
+ else
+ {
+ m_listview->setFocus();
+ 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;
}
diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp
index f029f1f..22670c0 100644
--- a/src/LetterWidget/letterwidget.cpp
+++ b/src/LetterWidget/letterwidget.cpp
@@ -38,10 +38,7 @@ LetterWidget::LetterWidget(QWidget *parent) :
LetterWidget::~LetterWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
/**
@@ -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 vector = UkuiMenuInterface::alphabeticVector;
-
- for (int i = 0; i < vector.size(); i++) {
- QStringList appList = vector.at(i);
-
- if (!appList.isEmpty()) {
+ int row=0;
+ QVector vector=UkuiMenuInterface::alphabeticVector;
+ for(int i=0;i(i + 65)));
- } else if (i == 26) {
- letterstr = "&";
- } else {
- letterstr = "#";
- }
-
+ if(i<26)
+ letterstr=QString(QChar(static_cast(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()< vector = UkuiMenuInterface::alphabeticVector;
-
- for (int i = 0; i < vector.size(); i++) {
- QStringList appList = vector.at(i);
-
- if (!appList.isEmpty()) {
+ QVector vector=UkuiMenuInterface::alphabeticVector;
+ for(int i=0;i(i + 65)));
- } else if (i == 26) {
- letterstr = "&";
- } else {
- letterstr = "#";
- }
-
+ if(i<26)
+ letterstr=QString(QChar(static_cast(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()<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();
}
diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h
index 215dbdd..4fbe4ba 100644
--- a/src/LetterWidget/letterwidget.h
+++ b/src/LetterWidget/letterwidget.h
@@ -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
diff --git a/src/MainViewWidget/directorychangedthread.cpp b/src/MainViewWidget/directorychangedthread.cpp
index 6ff4c21..1e6d156 100644
--- a/src/MainViewWidget/directorychangedthread.cpp
+++ b/src/MainViewWidget/directorychangedthread.cpp
@@ -23,40 +23,44 @@
DirectoryChangedThread::DirectoryChangedThread()
{
- m_ukuiMenuInterface = new UkuiMenuInterface;
+ m_ukuiMenuInterface=new UkuiMenuInterface;
}
DirectoryChangedThread::~DirectoryChangedThread()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
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;icreateAppInfoVector();
- 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();
}
diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp
index e3ef9a0..64f1b5c 100644
--- a/src/MainViewWidget/mainviewwidget.cpp
+++ b/src/MainViewWidget/mainviewwidget.cpp
@@ -34,52 +34,58 @@ MainViewWidget::MainViewWidget(QWidget *parent) :
MainViewWidget::~MainViewWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
+ delete m_fileWatcher;
+ delete m_directoryChangedThread;
+ delete m_animation;
+ delete m_searchAppThread;
+
}
void MainViewWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
- this->setAttribute(Qt::WA_StyledBackground, true);
+ this->setAttribute(Qt::WA_StyledBackground,true);
this->setAttribute(Qt::WA_TranslucentBackground);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->setContentsMargins(0, 0, 0, 0);
+ QVBoxLayout* mainLayout=new QVBoxLayout;
+ mainLayout->setContentsMargins(0,0,0,0);
mainLayout->setSpacing(0);
- m_topWidget = new QWidget;
- m_contentWid = new QWidget;
+ m_topWidget=new QWidget;
+ m_contentWid=new QWidget;
+
mainLayout->addWidget(m_topWidget);
mainLayout->addWidget(m_contentWid);
this->setLayout(mainLayout);
+
this->setFocusPolicy(Qt::NoFocus);
- m_commonUseWid = new CommonUseWidget(m_contentWid);
- m_fullCommonUseWid = new FullCommonUseWidget(m_contentWid);
- m_letterWid = new LetterWidget(m_contentWid);
- m_functionWid = new FunctionWidget(m_contentWid);
- m_fullLetterWid = new FullLetterWidget(m_contentWid);
- m_fullFunctionWid = new FullFunctionWidget(m_contentWid);
- m_fullSearchResultWid = new FullSearchResultWidget(m_contentWid);
- m_searchResultWid = new SearchResultWidget(m_contentWid);
+
+ m_commonUseWid=new CommonUseWidget(m_contentWid);
+ m_fullCommonUseWid=new FullCommonUseWidget(m_contentWid);
+ m_letterWid=new LetterWidget(m_contentWid);
+ m_functionWid=new FunctionWidget(m_contentWid);
+ m_fullLetterWid=new FullLetterWidget(m_contentWid);
+ m_fullFunctionWid=new FullFunctionWidget(m_contentWid);
+ m_fullSearchResultWid=new FullSearchResultWidget(m_contentWid);
+ m_searchResultWid=new SearchResultWidget(m_contentWid);
hideWidget();
- m_ukuiMenuInterface = new UkuiMenuInterface;
+
+ m_ukuiMenuInterface=new UkuiMenuInterface;
+
//监控.desktop文件目录
- m_fileWatcher = new QFileSystemWatcher(this);
- m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications")
- << QString(QDir::homePath() + "/.local/share/applications/")
- << QString("/var/lib/snapd/desktop/applications/")
- << QString("/var/lib/flatpak/exports/share/applications/"));
- connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainViewWidget::directoryChangedSlot);
- m_directoryChangedThread = new DirectoryChangedThread;
- m_directoryChangedThread->setParent(this);
- connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &MainViewWidget::requestUpdateSlot);
- connect(this, &MainViewWidget::directoryChangedSignal, m_letterWid, &LetterWidget::updateAppListView);
- connect(this, &MainViewWidget::directoryChangedSignal, m_fullLetterWid, &FullLetterWidget::updateAppListView);
- connect(this, &MainViewWidget::directoryChangedSignal, m_functionWid, &FunctionWidget::updateAppListView);
- connect(this, &MainViewWidget::directoryChangedSignal, m_fullFunctionWid, &FullFunctionWidget::updateAppListView);
- connect(this, &MainViewWidget::directoryChangedSignal, m_commonUseWid, &CommonUseWidget::updateListViewSlot);
- connect(this, &MainViewWidget::directoryChangedSignal, m_fullCommonUseWid, &FullCommonUseWidget::updateListViewSlot);
+ m_fileWatcher=new QFileSystemWatcher;
+ m_fileWatcher->addPaths(QStringList()<setFixedSize(Style::defaultMainViewWidWidth, Style::minh);
- m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight);
- m_topLayout->setContentsMargins(0, 0, 0, 0);
- m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter);
- m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight);
+ this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh);
+ m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight);
+ m_topLayout->setContentsMargins(0,0,0,0);
+ m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter);
+ m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight);
m_queryText->adjustSize();
- m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
+ m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
m_queryWid->show();
//内容区
- m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height());
- m_commonUseWid->setGeometry(0, 0, Style::defaultMainViewWidWidth, Style::defaultContentWidHeight);
+ m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height());
+ m_commonUseWid->setGeometry(0,0,Style::defaultMainViewWidWidth,Style::defaultContentWidHeight);
m_commonUseWid->show();
- m_widgetState = 1;
- m_saveCurrentWidState = 1;
- //监控应用进程开启
- connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) {
- ConvertDesktopToWinId reply;
- QString desktopfp = reply.tranIdToDesktop(id);
+ m_widgetState=1;
+ m_saveCurrentWidState=1;
- if (!desktopfp.isEmpty()) {
- ViewOpenedSlot(desktopfp);
- }
+ //监控应用进程开启
+ connect(KWindowSystem::self(),&KWindowSystem::windowAdded,[=](WId id)
+ {
+ KWindowInfo info(id,NET::WMPid);
+ int pid=info.pid();
+ QString desktopfp=getEnvOverriddenDesktopFile(pid);
+ if(!desktopfp.isEmpty())
+ ViewOpenedSlot(desktopfp);
+ else
+ {
+ //获取软件名(2种方式)
+ //法1
+ QStringList nameList;
+ KWindowInfo info(id,NET::WMName);
+ nameList.append(info.name());
+ //法2
+ QString path=QString("/proc/%1/status").arg(pid);
+ QFile file(path);
+ if(file.open(QIODevice::ReadOnly))
+ {
+ char buf[1024];
+ qint64 len=file.readLine(buf,sizeof(buf));
+ if(len!=-1)
+ {
+ QString name=QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n");
+ nameList.append(name);
+ }
+ }
+
+ QVector appInfoVector=UkuiMenuInterface::appInfoVector;
+ Q_FOREACH(QStringList list , appInfoVector)
+ {
+ if(list.at(1).contains(nameList.at(0),Qt::CaseInsensitive) ||
+ list.at(2).contains(nameList.at(0),Qt::CaseInsensitive) ||
+ list.at(5).contains(nameList.at(0),Qt::CaseInsensitive) ||
+ nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) ||
+ nameList.at(0).contains(list.at(2),Qt::CaseInsensitive))
+ {
+ ViewOpenedSlot(list.at(0));
+ break;
+ }
+ else if(nameList.size()==2 &&
+ (
+ list.at(1).contains(nameList.at(1),Qt::CaseInsensitive) ||
+ list.at(2).contains(nameList.at(1),Qt::CaseInsensitive) ||
+ list.at(5).contains(nameList.at(1),Qt::CaseInsensitive) ||
+ nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) ||
+ nameList.at(0).contains(list.at(2),Qt::CaseInsensitive))
+ )
+ {
+ ViewOpenedSlot(list.at(0));
+ break;
+ }
+ }
+ }
});
//监控图标主题
- if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) {
- m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit());
- connect(m_gsetting, &QGSettings::changed, this, &MainViewWidget::iconThemeChangeSlot);
+ if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit()))
+ {
+ m_gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit());
+ connect(m_gsetting,&QGSettings::changed,this,&MainViewWidget::iconThemeChangeSlot);
}
}
@@ -144,23 +198,23 @@ void MainViewWidget::initUi()
*/
void MainViewWidget::addTopControl()
{
- m_topLayout = new QHBoxLayout;
+ m_topLayout=new QHBoxLayout;
m_topLayout->setSpacing(0);
- m_queryLineEdit = new MyLineEdit;
+ m_queryLineEdit=new QLineEdit;
m_topLayout->addWidget(m_queryLineEdit);
m_topWidget->setLayout(m_topLayout);
char style[200];
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light")
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground);
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
+ QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground);
else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
-
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
m_queryLineEdit->setStyleSheet(style);
+
initQueryLineEdit();
+
}
//void MainViewWidget::focusInEvent(QFocusEvent *event)
@@ -178,155 +232,150 @@ void MainViewWidget::addTopControl()
*/
void MainViewWidget::initQueryLineEdit()
{
- m_queryWid = new QWidget;
+ m_queryWid=new QWidget;
m_queryWid->setParent(m_queryLineEdit);
m_queryWid->setFocusPolicy(Qt::NoFocus);
- QHBoxLayout *queryWidLayout = new QHBoxLayout;
- queryWidLayout->setContentsMargins(0, 0, 0, 0);
+ QHBoxLayout* queryWidLayout=new QHBoxLayout;
+ queryWidLayout->setContentsMargins(0,0,0,0);
queryWidLayout->setSpacing(5);
m_queryWid->setLayout(queryWidLayout);
- QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16);
+ QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16);
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light") { //反黑
- pixmap = drawSymbolicBlackColoredPixmap(pixmap);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- }
-
+ if(gsetting.get("style-name").toString()=="ukui-light")//反黑
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);
+ else
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
- m_queryIcon = new QLabel;
+ m_queryIcon=new QLabel;
m_queryIcon->setFixedSize(pixmap.size());
m_queryIcon->setPixmap(pixmap);
- m_queryText = new QLabel;
+ m_queryText=new QLabel;
m_queryText->setText(tr("Search"));
m_queryText->adjustSize();
queryWidLayout->addWidget(m_queryIcon);
queryWidLayout->addWidget(m_queryText);
- queryWidLayout->setAlignment(m_queryIcon, Qt::AlignVCenter);
- queryWidLayout->setAlignment(m_queryText, Qt::AlignVCenter);
+ queryWidLayout->setAlignment(m_queryIcon,Qt::AlignVCenter);
+ queryWidLayout->setAlignment(m_queryText,Qt::AlignVCenter);
m_queryLineEdit->setFocusPolicy(Qt::ClickFocus);
m_queryLineEdit->installEventFilter(this);
m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu);
- m_animation = new QPropertyAnimation(m_queryWid, "geometry", m_queryWid);
+
+ m_animation= new QPropertyAnimation(m_queryWid,"geometry");
m_animation->setDuration(100);
- connect(m_animation, &QPropertyAnimation::finished, this, &MainViewWidget::animationFinishedSlot);
- m_searchAppThread = new SearchAppThread;
- m_searchAppThread->setParent(this);
- connect(this, &MainViewWidget::sendSearchKeyword,
- m_searchAppThread, &SearchAppThread::recvSearchKeyword);
- connect(m_searchAppThread, &SearchAppThread::sendSearchResult,
- this, &MainViewWidget::recvSearchResult);
- connect(m_queryLineEdit, &MyLineEdit::textChanged, this, &MainViewWidget::searchAppSlot);
+ connect(m_animation,&QPropertyAnimation::finished,this,&MainViewWidget::animationFinishedSlot);
+
+ m_searchAppThread=new SearchAppThread;
+ connect(this,&MainViewWidget::sendSearchKeyword,
+ m_searchAppThread,&SearchAppThread::recvSearchKeyword);
+ connect(m_searchAppThread,&SearchAppThread::sendSearchResult,
+ this,&MainViewWidget::recvSearchResult);
+ connect(m_queryLineEdit, &QLineEdit::textChanged, this, &MainViewWidget::searchAppSlot);
}
bool MainViewWidget::eventFilter(QObject *watched, QEvent *event)
{
- if (watched == m_queryLineEdit) {
- if ((m_queryIcon->x() == 0) && (event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::InputMethod)) {
- if (m_queryLineEdit->text().isEmpty() || (m_queryWid->layout()->count() != 2)) {
- QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn));
- return false;
- }
- }
-
+ if(watched==m_queryLineEdit)
+ {
char style[200];
-
- if (event->type() == QEvent::FocusIn && m_queryLineEdit->hasFocus()) {
- if (!m_isFullScreen) {
+ if(event->type()==QEvent::FocusIn)
+ {
+ if(!m_isFullScreen)
+ {
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light")
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedBorderDefault, QueryLineEditClickedDefaultBackground);
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
+ QueryLineEditClickedBorderDefault,QueryLineEditClickedDefaultBackground);
else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditClickedBackground);
- } else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditClickedBackground);
-
- m_queryLineEdit->setStyleSheet(style);
-
- if (!m_queryLineEdit->text().isEmpty() && (m_queryLineEdit->text().size() >= 1)) {
- if (m_searchKeyWords.isEmpty()) {
- searchAppSlot(m_queryLineEdit->text());
- }
- } else {
- m_queryWid->layout()->removeWidget(m_queryText);
- m_queryText->setParent(nullptr);
- m_animation->stop();
- m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
- m_animation->setEndValue(QRect(0, 0,
- m_queryIcon->width() + 5, Style::QueryLineEditHeight));
- m_animation->setEasingCurve(QEasingCurve::OutQuad);
- m_animation->start();
- m_queryLineEdit->setTextMargins(-5, 0, 0, 0);
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditClickedBackground);
}
-
- m_isSearching = true;
- } else if (event->type() == QEvent::FocusOut) {
+ else
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditClickedBackground);
+ m_queryLineEdit->setStyleSheet(style);
+ if(!m_queryLineEdit->text().isEmpty())
+ {
+ if(m_searchKeyWords.isEmpty())
+ searchAppSlot(m_queryLineEdit->text());
+ }
+ else
+ {
+ m_queryWid->layout()->removeWidget(m_queryText);
+ m_queryText->setParent(nullptr);
+ m_animation->stop();
+ m_animation->setStartValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
+ m_animation->setEndValue(QRect(0,0,
+ m_queryIcon->width()+5,Style::QueryLineEditHeight));
+ m_animation->setEasingCurve(QEasingCurve::OutQuad);
+ m_animation->start();
+ m_queryLineEdit->setTextMargins(-5,0,0,0);
+ }
+ m_isSearching=true;
+ }
+ else if(event->type()==QEvent::FocusOut)
+ {
m_searchKeyWords.clear();
-
- if (m_queryLineEdit->text().isEmpty()) {
- if (m_isSearching || m_queryLineEdit->hasFocus()) {
- if (!m_isFullScreen) {
+ if(m_queryLineEdit->text().isEmpty())
+ {
+ if(m_isSearching)
+ {
+ if(!m_isFullScreen)
+ {
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light")
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground);
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
+ QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground);
else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
- } else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
-
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
+ }
+ else
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
m_queryLineEdit->setStyleSheet(style);
m_animation->stop();
m_queryText->adjustSize();
- m_animation->setStartValue(QRect(0, 0,
- m_queryIcon->width() + 5, Style::QueryLineEditHeight));
- m_animation->setEndValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
+ m_animation->setStartValue(QRect(0,0,
+ m_queryIcon->width()+5,Style::QueryLineEditHeight));
+ m_animation->setEndValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
m_animation->setEasingCurve(QEasingCurve::InQuad);
m_animation->start();
}
- } else {
- if (!m_isFullScreen) {
+ }
+ else
+ {
+ if(!m_isFullScreen)
+ {
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light")
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedDefaultBackground, QueryLineEditDefaultBackground);
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
+ QueryLineEditClickedDefaultBackground,QueryLineEditDefaultBackground);
else
- sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
- } else
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
+ }
+ else
sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
-
+ QueryLineEditClickedBorder,QueryLineEditBackground);
m_queryLineEdit->setStyleSheet(style);
}
-
- m_isSearching = false;
+ m_isSearching=false;
}
}
- return QWidget::eventFilter(watched, event); // 最后将事件交给上层对话框
+ return QWidget::eventFilter(watched,event); // 最后将事件交给上层对话框
}
void MainViewWidget::setLineEditFocus(QString arg)
{
- if (!m_queryLineEdit->hasFocus()) {
- m_searchKeyWords = arg;
+ if(!m_queryLineEdit->hasFocus())
+ {
+ m_searchKeyWords=arg;
m_queryLineEdit->setFocus();
-
- if (!m_queryLineEdit->text().isEmpty()) {
+ if(!m_queryLineEdit->text().isEmpty())
m_queryLineEdit->setText(arg);
- }
}
}
@@ -335,68 +384,48 @@ void MainViewWidget::setLineEditFocus(QString arg)
*/
void MainViewWidget::searchAppSlot(QString arg)
{
- if (!arg.isEmpty()) { //切换至搜索模块
- if (m_widgetState != 0) {
- m_widgetState = 0;
-
- if (!m_isFullScreen) {
+ if(!arg.isEmpty())//切换至搜索模块
+ {
+ if(m_widgetState!=0)
+ {
+ m_widgetState=0;
+ if(!m_isFullScreen)
loadSearchResultWidget();
- } else {
+ else
loadFullSearchResultWidget();
- }
}
-
- // 如果搜索时依然还有搜索框和搜索的文字描述两个组件,则进行处理;置为搜索状态
- if (m_queryWid->layout()->count() == 2) {
- QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn));
- m_queryWid->layout()->removeWidget(m_queryText);
- m_queryText->setParent(nullptr);
- m_animation->stop();
- m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
- m_animation->setEndValue(QRect(0, 0,
- m_queryIcon->width() + 5, Style::QueryLineEditHeight));
- m_animation->setEasingCurve(QEasingCurve::OutQuad);
- m_animation->start();
- m_queryLineEdit->setTextMargins(-5, 0, 0, 0);
- }
-
- qDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")";
Q_EMIT sendSearchKeyword(arg);
m_searchAppThread->start();
- } else { //搜索模块显示所有的软件
- if (m_isFullScreen) {
+ }
+ else{//搜索模块显示所有的软件
+ if(m_isFullScreen)
+ {
switch (m_saveCurrentWidState) {
- case 1:
- loadFullCommonUseWidget();
- break;
-
- case 2:
- loadFullLetterWidget();
- break;
-
- case 3:
- loadFullFunctionWidget();
-
- default:
- break;
+ case 1:
+ loadFullCommonUseWidget();
+ break;
+ case 2:
+ loadFullLetterWidget();
+ break;
+ case 3:
+ loadFullFunctionWidget();
+ default:
+ break;
}
- } else {
+ }
+ else {
switch (m_saveCurrentWidState) {
- case 1:
- loadCommonUseWidget();
- break;
-
- case 2:
- loadLetterWidget();
- break;
-
- case 3:
- loadFunctionWidget();
- break;
-
- default:
- break;
+ case 1:
+ loadCommonUseWidget();
+ break;
+ case 2:
+ loadLetterWidget();
+ break;
+ case 3:
+ loadFunctionWidget();
+ break;
+ default:
+ break;
}
}
}
@@ -412,32 +441,37 @@ void MainViewWidget::recvSearchResult(QVector arg)
void MainViewWidget::animationFinishedSlot()
{
- if (m_isSearching) { //进入搜索状态
+ if(m_isSearching)//进入搜索状态
+ {
// m_queryWid->layout()->removeWidget(m_queryText);
// m_queryText->setParent(nullptr);
- m_queryLineEdit->setTextMargins(20, 0, 0, 0);
-
- if (!m_searchKeyWords.isEmpty()) {
+ m_queryLineEdit->setTextMargins(20,0,0,0);
+ if(!m_searchKeyWords.isEmpty())
+ {
m_queryLineEdit->setText(m_searchKeyWords);
m_searchKeyWords.clear();
}
- } else { //退出搜索状态
+ }
+ else//退出搜索状态
+ {
m_queryWid->layout()->addWidget(m_queryText);
- m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter);
- m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter);
QPalette pe = m_queryText->palette();
-
- if (!m_isFullScreen) {
+ if(!m_isFullScreen)
+ {
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light") { //反黑
- pe.setColor(QPalette::Text, QColor(Qt::black));
- } else {
- pe.setColor(QPalette::Text, QColor(Qt::white));
+ if(gsetting.get("style-name").toString()=="ukui-light")//反黑
+ {
+ pe.setColor(QPalette::Text,QColor(Qt::black));
+ }
+ else
+ {
+ pe.setColor(QPalette::Text,QColor(Qt::white));
}
- } else {
- pe.setColor(QPalette::Text, QColor(Qt::white));
}
+ else
+ pe.setColor(QPalette::Text,QColor(Qt::white));
m_queryText->setPalette(pe);
}
@@ -448,62 +482,62 @@ void MainViewWidget::animationFinishedSlot()
*/
void MainViewWidget::loadMinMainView()
{
- this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh);
+ this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh);
//搜索区
- m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight);
- m_topLayout->setContentsMargins(0, 0, 0, 0);
- m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter);
- m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight);
-
- if (m_queryLineEdit->text().isEmpty()) {
- if (m_queryWid->layout()->count() == 1) {
+ m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight);
+ m_topLayout->setContentsMargins(0,0,0,0);
+ m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter);
+ m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight);
+ if(m_queryLineEdit->text().isEmpty())
+ {
+ if(m_queryWid->layout()->count()==1)
+ {
m_queryWid->layout()->addWidget(m_queryText);
- m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter);
- m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter);
}
-
m_queryText->adjustSize();
- m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
+ m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
m_queryWid->show();
}
char style[200];
QPalette pe = m_queryText->palette();
- const auto ratio = devicePixelRatioF();
- QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio);
+ QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16);
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light") {
- pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑
- pe.setColor(QPalette::Text, QColor(Qt::black));
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ {
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑
+ pe.setColor(QPalette::Text,QColor(Qt::black));
sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- pe.setColor(QPalette::Text, QColor(Qt::white));
- sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
+ QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground);
+ }
+ else
+ {
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
+ pe.setColor(QPalette::Text,QColor(Qt::white));
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
}
-
m_queryLineEdit->setStyleSheet(style);
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
m_queryIcon->setPixmap(pixmap);
m_queryText->setPalette(pe);
+
//内容区
- m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height());
-
- if (m_widgetState == 0) {
+ m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height());
+ if(m_widgetState==0)
+ {
loadSearchResultWidget();
- } else if (m_widgetState == 1) {
- loadCommonUseWidget();
- } else if (m_widgetState == 2) {
- loadLetterWidget();
- } else if (m_widgetState == 3) {
- loadFunctionWidget();
}
-
- m_isFullScreen = false;
+ else if(m_widgetState==1)
+ loadCommonUseWidget();
+ else if(m_widgetState==2)
+ loadLetterWidget();
+ else if(m_widgetState==3)
+ loadFunctionWidget();
+ m_isFullScreen=false;
}
/**
@@ -514,134 +548,140 @@ void MainViewWidget::loadMaxMainView()
this->setFixedSize(Style::MainViewWidWidth,
Style::heightavailable);
//搜索区
- m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight);
- m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight);
- m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth,
- 0,
- (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2,
- 0);
+ m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight);
+ m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight);
- if (m_queryLineEdit->text().isEmpty()) {
- if (m_queryWid->layout()->count() == 1) {
+ m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth,
+ 0,
+ (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2,
+ 0);
+
+ if(m_queryLineEdit->text().isEmpty())
+ {
+ if(m_queryWid->layout()->count()==1)
+ {
m_queryWid->layout()->addWidget(m_queryText);
- m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter);
- m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter);
}
-
m_queryText->adjustSize();
- m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
+ m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
m_queryWid->show();
}
char style[200];
sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
+ QueryLineEditClickedBorder,QueryLineEditBackground);
m_queryLineEdit->setStyleSheet(style);
- const auto ratio = devicePixelRatioF();
- QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio);
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
+
+ QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16);
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
QPalette pe = m_queryText->palette();
- pe.setColor(QPalette::Text, QColor(Qt::white));
+ pe.setColor(QPalette::Text,QColor(Qt::white));
m_queryText->setPalette(pe);
+
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
m_queryIcon->setPixmap(pixmap);
+
//内容区
- m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height());
-
- if (m_widgetState == 0) {
+ m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height());
+ if(m_widgetState==0)
+ {
loadFullSearchResultWidget();
- } else if (m_widgetState == 1) {
- loadFullCommonUseWidget();
- } else if (m_widgetState == 2) {
- loadFullLetterWidget();
- } else if (m_widgetState == 3) {
- loadFullFunctionWidget();
}
-
- m_isFullScreen = true;
+ else if(m_widgetState==1)
+ loadFullCommonUseWidget();
+ else if(m_widgetState==2)
+ loadFullLetterWidget();
+ else if(m_widgetState==3)
+ loadFullFunctionWidget();
+ m_isFullScreen=true;
}
void MainViewWidget::resizeControl()
{
- if (m_isFullScreen) {
- if (m_widgetState == 2) {
+ if(m_isFullScreen)
+ {
+ if(m_widgetState==2)
m_fullLetterWid->setLetterBtnGeometry();
- }
-
- if (m_widgetState == 3) {
+ if(m_widgetState==3)
m_fullFunctionWid->setFunctionBtnGeometry();
- }
this->setFixedSize(Style::MainViewWidWidth,
Style::heightavailable);
- m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight);
- m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight);
- m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth,
- 0,
- (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2,
- 0);
- m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height());
- } else {
- this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh);
- m_topWidget->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultTopWidHeight);
- m_topLayout->setContentsMargins(0, 0, 0, 0);
- m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter);
- m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height());
+ m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight);
+ m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight);
+
+ m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth,
+ 0,
+ (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2,
+ 0);
+ m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height());
}
+ else
+ {
+ this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh);
+ m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight);
+ m_topLayout->setContentsMargins(0,0,0,0);
+ m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter);
+ m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height());
+ }
+
}
void MainViewWidget::resetQueryLine()
{
- if (!m_queryLineEdit->text().isEmpty()) {
+ if(!m_queryLineEdit->text().isEmpty())
+ {
+ m_queryLineEdit->clearFocus();
m_queryLineEdit->clear();
m_isSearching = false;
- if (m_queryWid->layout()->count() == 1) {
+ if(m_queryWid->layout()->count()==1)
+ {
m_queryWid->layout()->addWidget(m_queryText);
- m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter);
- m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter);
+ m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter);
}
-
m_queryText->adjustSize();
- m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0,
- m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight));
+ m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0,
+ m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight));
char style[200];
- const auto ratio = devicePixelRatioF();
QPalette pe = m_queryText->palette();
- QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio);
+ QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16);
+ if(!m_isFullScreen)
+ {
- if (!m_isFullScreen) {
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (gsetting.get("style-name").toString() == "ukui-light") {
- pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑
- pe.setColor(QPalette::Text, QColor(Qt::black));
+ if(gsetting.get("style-name").toString()=="ukui-light")
+ {
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑
+ pe.setColor(QPalette::Text,QColor(Qt::black));
sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}",
- QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- pe.setColor(QPalette::Text, QColor(Qt::white));
- sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
+ QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground);
+ }
+ else
+ {
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
+ pe.setColor(QPalette::Text,QColor(Qt::white));
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
}
- } else {
- sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditBackground);
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- pe.setColor(QPalette::Text, QColor(Qt::white));
}
-
+ else
+ {
+ sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}",
+ QueryLineEditClickedBorder,QueryLineEditBackground);
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
+ pe.setColor(QPalette::Text,QColor(Qt::white));
+ }
m_queryLineEdit->setStyleSheet(style);
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
m_queryIcon->setPixmap(pixmap);
m_queryText->setPalette(pe);
}
- m_queryLineEdit->setFocus();
- QTimer::singleShot(1, this, [ = ]() {
- m_queryLineEdit->simulateFocusOutEvent(nullptr);
- });
}
/**
@@ -655,12 +695,12 @@ void MainViewWidget::loadCommonUseWidget()
m_functionWid->widgetMakeZero();
m_fullFunctionWid->widgetMakeZero();
hideWidget();
- m_commonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_commonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_commonUseWid->show();
m_commonUseWid->updateListView();
this->layout()->update();
- m_widgetState = 1;
- m_saveCurrentWidState = 1;
+ m_widgetState=1;
+ m_saveCurrentWidState=1;
resetQueryLine();
}
@@ -675,10 +715,10 @@ void MainViewWidget::loadLetterWidget()
m_functionWid->widgetMakeZero();
m_fullFunctionWid->widgetMakeZero();
hideWidget();
- m_letterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_letterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_letterWid->show();
- m_widgetState = 2;
- m_saveCurrentWidState = 2;
+ m_widgetState=2;
+ m_saveCurrentWidState=2;
resetQueryLine();
}
@@ -693,10 +733,10 @@ void MainViewWidget::loadFunctionWidget()
m_fullLetterWid->widgetMakeZero();
m_fullFunctionWid->widgetMakeZero();
hideWidget();
- m_functionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_functionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_functionWid->show();
- m_widgetState = 3;
- m_saveCurrentWidState = 3;
+ m_widgetState=3;
+ m_saveCurrentWidState=3;
resetQueryLine();
}
@@ -711,11 +751,11 @@ void MainViewWidget::loadFullCommonUseWidget()
m_functionWid->widgetMakeZero();
m_fullFunctionWid->widgetMakeZero();
hideWidget();
- m_fullCommonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_fullCommonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_fullCommonUseWid->show();
m_fullCommonUseWid->updateListView();
- m_widgetState = 1;
- m_saveCurrentWidState = 1;
+ m_widgetState=1;
+ m_saveCurrentWidState=1;
resetQueryLine();
}
@@ -730,12 +770,12 @@ void MainViewWidget::loadFullLetterWidget()
m_functionWid->widgetMakeZero();
m_fullFunctionWid->widgetMakeZero();
hideWidget();
- m_fullLetterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_fullLetterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_fullLetterWid->show();
// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2))
m_fullLetterWid->enterAnimation();
- m_widgetState = 2;
- m_saveCurrentWidState = 2;
+ m_widgetState=2;
+ m_saveCurrentWidState=2;
resetQueryLine();
}
@@ -750,26 +790,26 @@ void MainViewWidget::loadFullFunctionWidget()
m_fullLetterWid->widgetMakeZero();
m_functionWid->widgetMakeZero();
hideWidget();
- m_fullFunctionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_fullFunctionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_fullFunctionWid->show();
// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3))
m_fullFunctionWid->enterAnimation();
- m_widgetState = 3;
- m_saveCurrentWidState = 3;
+ m_widgetState=3;
+ m_saveCurrentWidState=3;
resetQueryLine();
}
void MainViewWidget::loadSearchResultWidget()
{
hideWidget();
- m_searchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_searchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_searchResultWid->show();
}
void MainViewWidget::loadFullSearchResultWidget()
{
hideWidget();
- m_fullSearchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height());
+ m_fullSearchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height());
m_fullSearchResultWid->show();
}
@@ -800,15 +840,17 @@ void MainViewWidget::changeFocuDown()
*/
void MainViewWidget::ViewOpenedSlot(QString desktopfp)
{
- QVector desktopfpVec = UkuiMenuInterface::desktopfpVector;
-
- if (desktopfpVec.contains(desktopfp)) {
+ qDebug()<<"open software:"< desktopfpVec=UkuiMenuInterface::desktopfpVector;
+ if(desktopfpVec.contains(desktopfp))
+ {
QFileInfo fileInfo(desktopfp);
- QString desktopfn = fileInfo.fileName();
+ QString desktopfn=fileInfo.fileName();
+
QString dateTimeKey;
dateTimeKey.clear();
-
- if (!desktopfn.isEmpty()) {
+ if(!desktopfn.isEmpty())
+ {
updateDataBaseTableTimes(desktopfn);
}
}
@@ -833,9 +875,8 @@ void MainViewWidget::requestUpdateSlot()
void MainViewWidget::iconThemeChangeSlot(QString key)
{
- if (key == "iconThemeName" || key == "icon-theme-name") {
+ if(key=="iconThemeName" || key=="icon-theme-name")
Q_EMIT directoryChangedSignal();
- }
}
void MainViewWidget::reloadUkuiMenu()
@@ -845,7 +886,7 @@ void MainViewWidget::reloadUkuiMenu()
void MainViewWidget::repaintWidget()
{
- this->setMinimumSize(Style::minw, Style::minh);
+ this->setMinimumSize(Style::minw,Style::minh);
m_commonUseWid->repaintWidget();
m_fullCommonUseWid->repaintWidget();
m_letterWid->repaintWidget();
@@ -856,10 +897,18 @@ void MainViewWidget::repaintWidget()
m_fullSearchResultWid->repaintWidget();
}
+void MainViewWidget::repaintFullWidget()
+{
+ m_fullCommonUseWid->repaintWidget();
+ m_fullLetterWid->repaintWidget();
+ m_fullFunctionWid->repaintWidget();
+ m_fullSearchResultWid->repaintWidget();
+}
+
void MainViewWidget::widgetMakeZero()
{
- m_isSearching = false;
- m_widgetState = m_saveCurrentWidState;
+ m_isSearching=false;
+ m_widgetState=m_saveCurrentWidState;
m_commonUseWid->widgetMakeZero();
m_fullCommonUseWid->widgetMakeZero();
m_letterWid->widgetMakeZero();
@@ -870,65 +919,64 @@ void MainViewWidget::widgetMakeZero()
m_queryLineEdit->clear();
m_queryLineEdit->clearFocus();
m_queryLineEdit->blockSignals(false);
- m_queryLineEdit->setTextMargins(0, 0, 0, 0);
+ m_queryLineEdit->setTextMargins(0,0,0,0);
}
void MainViewWidget::moveScrollBar(int type)
{
- if (m_widgetState == 0) {
- if (m_isFullScreen) {
+ if(m_widgetState==0)
+ {
+ if(m_isFullScreen)
m_fullSearchResultWid->moveScrollBar(type);
- } else {
+ else
m_searchResultWid->moveScrollBar(type);
- }
}
-
- if (m_widgetState == 1) {
- if (m_isFullScreen) {
+ if(m_widgetState==1)
+ {
+ if(m_isFullScreen)
m_fullCommonUseWid->moveScrollBar(type);
- } else {
+ else
m_commonUseWid->moveScrollBar(type);
- }
}
-
- if (m_widgetState == 2) {
- if (m_isFullScreen) {
+ if(m_widgetState==2)
+ {
+ if(m_isFullScreen)
m_fullLetterWid->moveScrollBar(type);
- } else {
+ else
m_letterWid->moveScrollBar(type);
- }
}
-
- if (m_widgetState == 3) {
- if (m_isFullScreen) {
+ if(m_widgetState==3)
+ {
+ if(m_isFullScreen)
m_fullFunctionWid->moveScrollBar(type);
- } else {
+ else
m_functionWid->moveScrollBar(type);
- }
}
}
void MainViewWidget::keyPressEvent(QKeyEvent *e)
{
- if (e->type() == QEvent::KeyPress) {
- if (e->key() == Qt::Key_Escape) {
- Q_EMIT setMainWinHideSignal();
- }
-
- switch (e->key()) {
+ if(e->type()==QEvent::KeyPress)
+ {
+ switch(e->key())
+ {
case Qt::Key_Enter:
case Qt::Key_Return:
- case Qt::Key_Down: {
- if (m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) {
- if (m_isFullScreen) {
+ case Qt::Key_Down:
+ {
+ if(m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty())
+ {
+ if(m_isFullScreen)
+ {
m_fullSearchResultWid->setViewFocus();
- } else {
+ }
+ else
+ {
m_searchResultWid->setViewFocus();
}
}
}
- break;
-
+ break;
default:
break;
}
diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h
index 67332c8..fe0af1c 100644
--- a/src/MainViewWidget/mainviewwidget.h
+++ b/src/MainViewWidget/mainviewwidget.h
@@ -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
diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp
index 69fc880..935fb7f 100644
--- a/src/MainWindow/mainwindow.cpp
+++ b/src/MainWindow/mainwindow.cpp
@@ -29,69 +29,63 @@
#include
#include
#include "src/Style/style.h"
-#include "src/UtilityFunction/utility.h"
#include
-#include
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:"<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;
- }
+ delete m_ukuiMenuInterface;
}
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(&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());
@@ -272,16 +252,16 @@ void MainWindow::paintEvent(QPaintEvent *event)
// }
// else
// {
- painter.setBrush(this->palette().base());
- painter.setPen(Qt::transparent);
- painter.setOpacity(transparency);
- painter.drawRect(this->rect());
+ painter.setBrush(this->palette().base());
+ painter.setPen(Qt::transparent);
+ painter.setOpacity(transparency);
+ painter.drawRect(this->rect());
// }
+
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();
- }
+ 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();
- }
+ 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,91 +360,71 @@ 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()";
+ this->activateWindow();
+ qDebug() << "void MainWindow::activeWindowSolt()";
}
/**
* 鼠标点击窗口外部事件
*/
-bool MainWindow::event(QEvent *event)
+bool MainWindow::event ( QEvent * event )
{
- if (event->type() == QEvent::ActivationChange && is_repaint)
- // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用
- {
- qDebug() << " * 鼠标点击窗口外部事件";
-
- if (QApplication::activeWindow() != this) {
+ if (event->type() == QEvent::ActivationChange)
+ // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用
+ {
+ qDebug() << " * 鼠标点击窗口外部事件";
+ if(QApplication::activeWindow() != this)
+ {
this->hide();
m_mainViewWid->widgetMakeZero();
}
- }
-
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = (QKeyEvent *) event;
+ }
+ 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 ||
- keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right ||
- keyEvent->key() == Qt::Key_Tab) {
- m_mainViewWid->setFocus();
- Q_EMIT setFocusSignal();
- // return true;
- }
- }
-
- if (event->type() == QEvent::FocusIn) {
- m_mainViewWid->getQueryLineEditer()->setFocus();
- QTimer::singleShot(1, this, [ = ]() {
- m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr);
- });
- }
-
- return QWidget::event(event);
+ if(keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down ||
+ keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right ||
+ keyEvent->key() == Qt::Key_Tab)
+ {
+ m_mainViewWid->setFocus();
+ Q_EMIT setFocusSignal();
+ // return true;
+ }
+ }
+ 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));
-
+ 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();
+ }
+ m_mainViewWid->resizeControl();
+ }
+}
+
+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();
}
}
}
-//void MainWindow::setFrameStyle()
-//{
-// int position=0;
-// int panelSize=0;
-// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit()))
-// {
-// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit());
-// if(gsetting->keys().contains(QString("panelposition")))
-// position=gsetting->get("panelposition").toInt();
-// else
-// position=0;
-// if(gsetting->keys().contains(QString("panelsize")))
-// panelSize=gsetting->get("panelsize").toInt();
-// else
-// panelSize=46;
-// }
-// else
-// {
-// position=0;
-// panelSize=46;
-// }
-
-// QRectF rect;
-// rect.setX(this->rect().x()+1);
-// rect.setY(this->rect().y()+1);
-// rect.setWidth(this->rect().width()-2);
-// rect.setHeight(this->rect().height()-2);
-// qreal radius = 0;
-// QPainterPath path;
-// if(!m_isFullScreen)
-// {
-// radius=12;
-// }
-// else
-// {
-// radius=0;
-// }
-
-// path.moveTo(rect.topRight() - QPointF(radius, 0));
-// path.lineTo(rect.topLeft() + QPointF(radius, 0));
-// path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius));
-// path.lineTo(rect.bottomLeft() + QPointF(0, -radius));
-// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0));
-// path.lineTo(rect.bottomRight() - QPointF(radius, 0));
-// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
-// path.lineTo(rect.topRight() + QPointF(0, radius));
-// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
-
-// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
-//}
-
-void MainWindow::mainWinHideSlot()
-{
- this->hide();
- m_mainViewWid->widgetMakeZero();
-}
diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h
index c848ce0..8dd145f 100644
--- a/src/MainWindow/mainwindow.h
+++ b/src/MainWindow/mainwindow.h
@@ -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:
diff --git a/src/ModelView/fulllistdelegate.cpp b/src/ModelView/fulllistdelegate.cpp
new file mode 100644
index 0000000..f7abd3f
--- /dev/null
+++ b/src/ModelView/fulllistdelegate.cpp
@@ -0,0 +1,109 @@
+#include "fulllistdelegate.h"
+#include "src/Style/style.h"
+#include "src/UtilityFunction/utility.h"
+#include
+#include
+
+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();
+ 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();
+ 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();
+ 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);
+}
diff --git a/src/ModelView/fulllistdelegate.h b/src/ModelView/fulllistdelegate.h
new file mode 100644
index 0000000..afbd1a6
--- /dev/null
+++ b/src/ModelView/fulllistdelegate.h
@@ -0,0 +1,19 @@
+#ifndef FULLLISTDELEGATE_H
+#define FULLLISTDELEGATE_H
+
+#include
+#include
+#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
diff --git a/src/ModelView/fulllistitem.cpp b/src/ModelView/fulllistitem.cpp
new file mode 100644
index 0000000..f4c1e46
--- /dev/null
+++ b/src/ModelView/fulllistitem.cpp
@@ -0,0 +1,71 @@
+#include "fulllistitem.h"
+#include
+#include
+#include
+#include
+
+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;
+}
diff --git a/src/ModelView/fulllistitem.h b/src/ModelView/fulllistitem.h
new file mode 100644
index 0000000..39b5b23
--- /dev/null
+++ b/src/ModelView/fulllistitem.h
@@ -0,0 +1,20 @@
+#ifndef FULLLISTITEM_H
+#define FULLLISTITEM_H
+
+#include
+#include
+
+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
diff --git a/src/ModelView/fulllistmodel.cpp b/src/ModelView/fulllistmodel.cpp
new file mode 100644
index 0000000..3f9192e
--- /dev/null
+++ b/src/ModelView/fulllistmodel.cpp
@@ -0,0 +1,74 @@
+#include "fulllistmodel.h"
+#include "src/UtilityFunction/utility.h"
+#include
+#include
+
+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();
+}
diff --git a/src/ModelView/fulllistmodel.h b/src/ModelView/fulllistmodel.h
new file mode 100644
index 0000000..0f6e893
--- /dev/null
+++ b/src/ModelView/fulllistmodel.h
@@ -0,0 +1,30 @@
+#ifndef FULLLISTMODEL_H
+#define FULLLISTMODEL_H
+
+#include
+#include
+#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
diff --git a/src/ModelView/fulllistview.cpp b/src/ModelView/fulllistview.cpp
new file mode 100644
index 0000000..cb2b349
--- /dev/null
+++ b/src/ModelView/fulllistview.cpp
@@ -0,0 +1,141 @@
+#include "fulllistview.h"
+#include "src/Style/style.h"
+#include
+#include
+
+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);
+ }
+}
diff --git a/src/ModelView/fulllistview.h b/src/ModelView/fulllistview.h
new file mode 100644
index 0000000..c019522
--- /dev/null
+++ b/src/ModelView/fulllistview.h
@@ -0,0 +1,37 @@
+#ifndef FULLLISTVIEW_H
+#define FULLLISTVIEW_H
+
+#include
+#include
+#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
diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile
index f22ce73..16b48ba 100644
--- a/src/QtSingleApplication/QtLockedFile
+++ b/src/QtSingleApplication/QtLockedFile
@@ -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
#include
diff --git a/src/RightClickMenu/menubox.h b/src/RightClickMenu/menubox.h
index caa87ba..627ed8f 100644
--- a/src/RightClickMenu/menubox.h
+++ b/src/RightClickMenu/menubox.h
@@ -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
diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp
index e7da0f9..5cda046 100644
--- a/src/RightClickMenu/rightclickmenu.cpp
+++ b/src/RightClickMenu/rightclickmenu.cpp
@@ -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;
- }
+ delete m_ukuiMenuInterface;
}
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 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 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 ret = iface.call("RemoveFromTaskbar", m_desktopfp);
- m_actionNumber = 4;
+ QDBusReply 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")
- .arg(m_desktopfp.toLocal8Bit().data());
- 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"<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()<<"卸载:"<start("sh",QStringList()<<"-c"<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()<<"卸载:"<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 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 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 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;
}
diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h
index 5760972..5714262 100644
--- a/src/RightClickMenu/rightclickmenu.h
+++ b/src/RightClickMenu/rightclickmenu.h
@@ -37,7 +37,6 @@
#include "src/Interface/ukuimenuinterface.h"
#include "src/Style/style.h"
#include "menubox.h"
-#include
class RightClickMenu : public QWidget
{
diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp
new file mode 100644
index 0000000..51e5cbe
--- /dev/null
+++ b/src/RightClickMenu/uninstallwhitelist.cpp
@@ -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
+
+UninstallWhitelist *UninstallWhitelist::instance = nullptr;
+
+UninstallWhitelist::UninstallWhitelist()
+{
+ m_whiteList.append("kylin-screenshot.desktop");
+ m_whiteList.append("ukui-notebook.desktop");
+ m_whiteList.append("ukui-clock.desktop");
+ m_whiteList.append("kylin-calculator.desktop");
+ m_whiteList.append("kylin-recorder.desktop");
+ m_whiteList.append("kylin-software-center.desktop");
+ m_whiteList.append("kylin-camera.desktop");
+ m_whiteList.append("biometric-manager.desktop");
+ m_whiteList.append("yhkylin-backup-tools.desktop");
+ m_whiteList.append("box-manager.desktop");
+ m_whiteList.append("ukui-system-monitor.desktop");
+ m_whiteList.append("ksc-defender.desktop");
+ m_whiteList.append("logview.desktop");
+ m_whiteList.append("kylin-service-support.desktop");
+ m_whiteList.append("kylin-user-guide.desktop");
+ m_whiteList.append("ukui-control-center.desktop");
+ m_whiteList.append("peony.desktop");
+ m_whiteList.append("engrampa.desktop");
+
+ if (isHuaWei9006C || isHuaWeiPC) {
+ m_whiteList.append("org.gnome.FileRoller.desktop");
+ m_whiteList.append("mate-terminal.desktop");
+ m_whiteList.append("hwaudioui.desktop");
+ }
+}
+
+UninstallWhitelist *UninstallWhitelist::getInstance()
+{
+ if (instance == nullptr) {
+ instance = new UninstallWhitelist();
+ }
+
+ return instance;
+}
+
+QStringList UninstallWhitelist::getPkgNameWhiteList()
+{
+ QStringList pkgNameList;
+
+ Q_FOREACH (QString desktop, m_whiteList) {
+ QProcess *processPkgName = new QProcess();
+ processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop));
+ connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() {
+ processPkgName->deleteLater();
+ });
+ processPkgName->waitForFinished();
+ QString pkgName = processPkgName->readAll();
+ pkgName = pkgName.left(pkgName.indexOf(":"));
+ pkgNameList.append(pkgName);
+ }
+
+ return pkgNameList;
+}
+
+QStringList UninstallWhitelist::getWhiteList()
+{
+ return m_whiteList;
+}
diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/RightClickMenu/uninstallwhitelist.h
new file mode 100644
index 0000000..a478292
--- /dev/null
+++ b/src/RightClickMenu/uninstallwhitelist.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+
+class UninstallWhitelist : public QObject
+{
+ Q_OBJECT
+
+public:
+ static UninstallWhitelist *getInstance();
+ /**
+ * @brief 获取不可卸载包名列表
+ * @return
+ */
+ QStringList getPkgNameWhiteList();
+ /**
+ * @brief 获取不可卸载desktop列表
+ * @return
+ */
+ QStringList getWhiteList();
+private:
+ UninstallWhitelist();
+private:
+ static UninstallWhitelist *instance;
+
+ QStringList m_whiteList;
+};
+
+#endif // UNINSTALLWHITELIST_H
diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp
index 49ee973..52c16f9 100644
--- a/src/SearchResultWidget/fullsearchresultwidget.cpp
+++ b/src/SearchResultWidget/fullsearchresultwidget.cpp
@@ -30,43 +30,44 @@ FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) :
FullSearchResultWidget::~FullSearchResultWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
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 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(wid);
+ QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0);
+ QWidget* wid=widItem->widget();
+ FullListView* listview=qobject_cast(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()
diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt
index ef4f6e3..41eaeec 100644
--- a/src/SearchResultWidget/pinyinWithTone.txt
+++ b/src/SearchResultWidget/pinyinWithTone.txt
@@ -6669,7 +6669,7 @@ gāng 冈
rǎn,nán,dān 冉
cè 冊
jiōng,jiǒng 冋
-cè 册
+cè,zhà 册
zài 再
guǎ 冎
jiǒng,jiōng 冏
diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt
index 7267609..07421f0 100644
--- a/src/SearchResultWidget/pinyinWithoutTone.txt
+++ b/src/SearchResultWidget/pinyinWithoutTone.txt
@@ -6669,7 +6669,7 @@ gang 冈
dan,nan,ran 冉
ce 冊
jiong 冋
-ce 册
+zha,ce 册
zai 再
gua 冎
jiong 冏
diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp
index a332168..d53a5e4 100644
--- a/src/SearchResultWidget/searchappthread.cpp
+++ b/src/SearchResultWidget/searchappthread.cpp
@@ -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;
- }
+ delete m_ukuiMenuInterface;
}
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(str.toLocal8Bit().at(0));
-// QStringList searchDesktopList;
-// searchDesktopList.clear();
-// if(num>=65 && num<=90)
-// {
-// for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1));
-//// QString appEnglishName=m_appInfoVector.at(index).at(2);
-// QString appNameFl=m_appInfoVector.at(index).at(3);
-
-// if(appNameFl==str)//匹配首字母
-// {
-// m_searchResultVector.append(m_appInfoVector.at(index));
-// }
-// index++;
-// }
-// }
-//// else if(num<48 || (num>57 && num<65) || num>90)
-//// for(int i=0;igetAppName(searchDesktopList.at(i)));
-// }
-// }
-// else
- //{
- while (index < m_appInfoVector.size()) {
- // QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1));
- QStringList appNameLs;
- 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++) {
- appNameLs.append(appNamePyLst.at(i * 2));
- appNameFls.append(appNamePyLst.at(i * 2 + 1));
+ if(!this->m_keyWord.isEmpty())
+ {
+ QString str=m_ukuiMenuInterface->getAppNamePinyin(m_keyWord);
+ int index=0;
+ if(str.size()==1)
+ {
+ int num=static_cast(str.toLocal8Bit().at(0));
+ QStringList searchDesktopList;
+ searchDesktopList.clear();
+ if(num>=65 && num<=90)
+ {
+ for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1));
+// QString appEnglishName=m_appInfoVector.at(index).at(2);
+ QString appNameFl=m_appInfoVector.at(index).at(3);
- QString appName = m_appInfoVector.at(index).at(1);
- 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())) {
- m_searchResultVector.append(m_appInfoVector.at(index));
+ if(appNameFl==str)//匹配首字母
+ {
+ m_searchResultVector.append(m_appInfoVector.at(index));
+ }
+ 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));
- break;
+ }
+// else if(num<48 || (num>57 && num<65) || num>90)
+// for(int i=0;igetAppName(searchDesktopList.at(i)));
+ }
+ }
+ else
+ {
+ while(indexgetAppNamePinyin(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++)
+ {
+ 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 appNameFls=m_appInfoVector.at(index).at(4);
+
+ 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].contains(str,Qt::CaseInsensitive) ||
+ appNameFls[var].contains(str,Qt::CaseInsensitive) ||
+ appEnglishName.contains(str,Qt::CaseInsensitive))
+ {
+ m_searchResultVector.append(m_appInfoVector.at(index));
+ break;
+ }
}
}
+ index++;
}
-
- 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;
}
diff --git a/src/SearchResultWidget/searchappthread.h b/src/SearchResultWidget/searchappthread.h
index 9447d73..12cd9ee 100644
--- a/src/SearchResultWidget/searchappthread.h
+++ b/src/SearchResultWidget/searchappthread.h
@@ -33,8 +33,6 @@ public:
private:
QString m_keyWord;
QVector m_searchResultVector;
- QVector m_searchFirstVector;
- QVector m_searchRestVector;
UkuiMenuInterface* m_ukuiMenuInterface=nullptr;
QVector m_appInfoVector;
diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp
index 691eff5..10c8853 100644
--- a/src/SearchResultWidget/searchresultwidget.cpp
+++ b/src/SearchResultWidget/searchresultwidget.cpp
@@ -30,28 +30,26 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
SearchResultWidget::~SearchResultWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
}
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 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()<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();
}
diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h
index ce3b5ec..2897b23 100644
--- a/src/SearchResultWidget/searchresultwidget.h
+++ b/src/SearchResultWidget/searchresultwidget.h
@@ -59,8 +59,8 @@ public:
void setViewFocus();
private:
- UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
- ListView *m_listView = nullptr;
+ UkuiMenuInterface* m_ukuiMenuInterface=nullptr;
+ ListView* m_listView=nullptr;
QVector m_data;
protected:
@@ -81,8 +81,6 @@ Q_SIGNALS:
* @brief Send a hidden main window signal to the MainViewWidget
*/
void sendHideMainWindowSignal();
-
- void sendMainWinActiveSignal(bool flag);
};
#endif // SEARCHRESULTWIDGET_H
diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp
index a14ce78..9177982 100644
--- a/src/SideBarWidget/sidebarwidget.cpp
+++ b/src/SideBarWidget/sidebarwidget.cpp
@@ -35,10 +35,9 @@ SideBarWidget::SideBarWidget(QWidget *parent) :
SideBarWidget::~SideBarWidget()
{
- if (m_ukuiMenuInterface != nullptr) {
- delete m_ukuiMenuInterface;
- m_ukuiMenuInterface = nullptr;
- }
+ delete m_ukuiMenuInterface;
+// delete m_shutDownMenu;
+// delete m_otherMenu;
}
/**
@@ -47,8 +46,9 @@ SideBarWidget::~SideBarWidget()
void SideBarWidget::initUi()
{
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
- this->setAttribute(Qt::WA_StyledBackground, true);
+ this->setAttribute(Qt::WA_StyledBackground,true);
this->setFocusPolicy(Qt::NoFocus);
+
addSidebarBtn();
loadMinSidebar();
m_minMaxBtn->installEventFilter(this);
@@ -61,36 +61,39 @@ void SideBarWidget::initUi()
m_controlBtn->installEventFilter(this);
m_trashBtn->installEventFilter(this);
m_shutDownBtn->installEventFilter(this);
- m_ukuiMenuInterface = new UkuiMenuInterface;
-// m_shutDownMenu=new RightClickMenu;
-// m_otherMenu=new RightClickMenu;
+ m_ukuiMenuInterface=new UkuiMenuInterface;
+ // m_shutDownMenu=new RightClickMenu;
+ // m_otherMenu=new RightClickMenu;
}
-bool SideBarWidget::eventFilter(QObject *target, QEvent *event)
+bool SideBarWidget::eventFilter(QObject * target , QEvent * event )
{
- if (event->type() == QEvent::KeyPress) {
+
+ if( event->type() == QEvent::KeyPress )
+ {
QKeyEvent *ke = (QKeyEvent *)event;
-
- if (ke->key() == Qt::Key_Tab) {
+ if( ke->key() == Qt::Key_Tab )
+ {
Q_EMIT setFocusToMainWin();
- // return true;
+ // return true;
}
-
- if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left) {
- if (m_minMaxBtn->hasFocus()) {
+ if(ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left)
+ {
+ if(m_minMaxBtn->hasFocus())
+ {
m_shutDownBtn->setFocus();
return true;
}
}
-
- if (ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right) {
- if (m_shutDownBtn->hasFocus()) {
- this->setFocus();
+ if(ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right)
+ {
+ if(m_shutDownBtn->hasFocus())
+ {
+ this->setFocus();
}
}
}
-
- return QWidget::eventFilter(target, event);
+ return QWidget::eventFilter(target , event);
}
@@ -100,21 +103,21 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event)
*/
void SideBarWidget::addSidebarBtn()
{
- m_mainWidget = new QWidget;
+ m_mainWidget=new QWidget;
m_mainWidget->setParent(this);
- m_mainWidgetLayout = new QVBoxLayout;
- m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6);
+ m_mainWidgetLayout=new QVBoxLayout;
+ m_mainWidgetLayout->setContentsMargins(0,0,0,6);
m_mainWidgetLayout->setSpacing(10);
m_mainWidget->setLayout(m_mainWidgetLayout);
- // m_mainWidget->setFocusPolicy(Qt::StrongFocus);
+ // m_mainWidget->setFocusPolicy(Qt::StrongFocus);
// m_mainWidget->setAutoFillBackground(true);
// QPalette palette;
// palette.setBrush(QPalette::Background,Qt::red);
// m_mainWidget->setPalette(palette);
//放大缩小按钮界面
- m_minMaxWidget = new QWidget;
- m_minMaxLayout = new QHBoxLayout;
- m_minMaxBtn = new QPushButton;
+ m_minMaxWidget=new QWidget;
+ m_minMaxLayout=new QHBoxLayout;
+ m_minMaxBtn=new QPushButton;
m_minMaxBtn->setFlat(true);
m_minMaxBtn->setProperty("useButtonPalette", true);
// m_minMaxBtn->setProperty("doNotAnimate",true);
@@ -122,6 +125,7 @@ void SideBarWidget::addSidebarBtn()
// m_minMaxBtn->setFlat(true);
// m_minMaxBtn->setProperty("doNotAnimate",true);
// m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator);
+
// m_minMaxBtn->setShortcut(Qt::Key_Enter);
// m_minMaxBtn->setShortcut(Qt::Key_Return);
// QShortcut *key_1 = new QShortcut(QKeySequence(Qt::Key_Enter),this);
@@ -132,101 +136,97 @@ void SideBarWidget::addSidebarBtn()
m_minMaxWidget->setLayout(m_minMaxLayout);
// m_minMaxWidget->setAttribute(Qt::WA_StyledBackground,true);
// m_minMaxWidget->hasFocus();
+
//分类按钮
m_buttonList.clear();
- m_allBtn = new QPushButton;
- initBtn(m_allBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"), tr("All"), 0);
- m_letterBtn = new QPushButton;
- initBtn(m_letterBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"), tr("Letter"), 1);
- m_functionBtn = new QPushButton;
- initBtn(m_functionBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"), tr("Function"), 2);
- int id = 0;
-
- Q_FOREACH (QAbstractButton *btn, m_buttonList) {
- // m_btnGroup->addButton(btn,id++);
+ m_allBtn=new QPushButton;
+ initBtn(m_allBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"),tr("All"),0);
+ m_letterBtn=new QPushButton;
+ initBtn(m_letterBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"),tr("Letter"),1);
+ m_functionBtn=new QPushButton;
+ initBtn(m_functionBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"),tr("Function"),2);
+ int id=0;
+ Q_FOREACH (QAbstractButton* btn, m_buttonList) {
+ // m_btnGroup->addButton(btn,id++);
btn->setCheckable(true);
}
- QString usericon = getUserIcon();
- QString username = getUserName();
- m_userIconBtn = new QPushButton;
- initBtn(m_userIconBtn, usericon, username, 3);
- m_personalBtn = new QPushButton;
- initBtn(m_personalBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"), tr("Personal"), 4);
- m_trashBtn = new QPushButton;
- initBtn(m_trashBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"), tr("Trash"), 5);
- m_computerBtn = new QPushButton;
- initBtn(m_computerBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"), tr("Computer"), 6);
- m_controlBtn = new QPushButton;
- initBtn(m_controlBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"), tr("Settings"), 7);
- m_shutDownBtn = new QPushButton;
- initBtn(m_shutDownBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"), tr("Power"), 8);
+ QString usericon=getUserIcon();
+ QString username=getUserName();
+ m_userIconBtn=new QPushButton;
+ initBtn(m_userIconBtn,usericon,username,3);
+ m_personalBtn=new QPushButton;
+ initBtn(m_personalBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"),tr("Personal"),4);
+ m_trashBtn=new QPushButton;
+ initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Trash"),5);
+ m_computerBtn=new QPushButton;
+ initBtn(m_computerBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"),tr("Computer"),6);
+ m_controlBtn=new QPushButton;
+ initBtn(m_controlBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"),tr("Settings"),7);
+ m_shutDownBtn=new QPushButton;
+ initBtn(m_shutDownBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"),tr("Power"),8);
connect(m_allBtn, &QPushButton::clicked, this, &SideBarWidget::btnAllClickedSlot);
- connect(m_letterBtn, &QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot);
+ connect(m_letterBtn ,&QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot);
connect(m_functionBtn, &QPushButton::clicked, this, &SideBarWidget::btnFuncClickedSlot);
- connect(m_computerBtn, &QPushButton::clicked, this, &SideBarWidget::computerBtnClickedSlot);
- connect(m_personalBtn, &QPushButton::clicked, this, &SideBarWidget::personalBtnClickedSlot);
- connect(m_controlBtn, &QPushButton::clicked, this, &SideBarWidget::controlBtnClickedSlot);
- connect(m_trashBtn, &QPushButton::clicked, this, &SideBarWidget::trashBtnClickedSlot);
- connect(m_shutDownBtn, &QPushButton::clicked, this, &SideBarWidget::shutdownBtnClickedSlot);
- connect(m_userIconBtn, &QPushButton::clicked, this, &SideBarWidget::userIconBtnClickedSlot);
-// Q_FOREACH (QAbstractButton *button, m_buttonList) {
-// QPushButton *btn = qobject_cast(button);
-// if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) {
-// button->setCheckable(false);
-// addRightClickMenu(btn);
-// }
-// }
+ connect(m_computerBtn,&QPushButton::clicked,this,&SideBarWidget::computerBtnClickedSlot);
+ connect(m_personalBtn,&QPushButton::clicked,this,&SideBarWidget::personalBtnClickedSlot);
+ connect(m_controlBtn,&QPushButton::clicked,this,&SideBarWidget::controlBtnClickedSlot);
+ connect(m_trashBtn,&QPushButton::clicked,this,&SideBarWidget::trashBtnClickedSlot);
+ connect(m_shutDownBtn,&QPushButton::clicked,this,&SideBarWidget::shutdownBtnClickedSlot);
+ connect(m_userIconBtn,&QPushButton::clicked,this,&SideBarWidget::userIconBtnClickedSlot);
+
+ Q_FOREACH(QAbstractButton* button,m_buttonList)
+ {
+ QPushButton* btn=qobject_cast(button);
+ if(m_buttonList.indexOf(button)>3 && m_buttonList.indexOf(button)setCheckable(false);
+ addRightClickMenu(btn);
+ }
+ }
m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(m_shutDownBtn, &QPushButton::customContextMenuRequested, this,
+ connect(m_shutDownBtn,&QPushButton::customContextMenuRequested,this,
&SideBarWidget::shutdownBtnRightClickSlot);
+
//监控用户账户信息更改
- qint64 uid = static_cast(getuid());
+ qint64 uid=static_cast(getuid());
QDBusInterface iface("org.freedesktop.Accounts",
"/org/freedesktop/Accounts",
"org.freedesktop.Accounts",
QDBusConnection::systemBus());
- QDBusReplyobjPath = iface.call("FindUserById", uid);
+ QDBusReplyobjPath=iface.call("FindUserById",uid);
QDBusConnection::systemBus().connect("org.freedesktop.Accounts",
- objPath.value().path(),
- "org.freedesktop.Accounts.User",
- QString("Changed"), this, SLOT(userAccountsChanged()));
+ objPath.value().path(),
+ "org.freedesktop.Accounts.User",
+ QString("Changed"),this,SLOT(userAccountsChanged()));
+
m_mainWidgetLayout->addWidget(m_minMaxWidget);
m_mainWidgetLayout->addWidget(m_buttonList.at(0));
m_mainWidgetLayout->addWidget(m_buttonList.at(1));
m_mainWidgetLayout->addWidget(m_buttonList.at(2));
- m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding);
+ m_verticalSpacer = new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_mainWidgetLayout->addItem(m_verticalSpacer);
m_mainWidgetLayout->addWidget(m_buttonList.at(3));
-
- if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) {
- m_gsetting = new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit());
-
- if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) {
+ if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit()))
+ {
+ m_gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit());
+ if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(4));
- }
-
- if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(5));
- }
-
- if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(6));
- }
-
- if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(7));
- }
-
- connect(m_gsetting, &QGSettings::changed,
- this, &SideBarWidget::resetSidebarBtnSlot);
+ connect(m_gsetting,&QGSettings::changed,
+ this,&SideBarWidget::resetSidebarBtnSlot);
}
-
m_mainWidgetLayout->addWidget(m_buttonList.at(8));
- if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) {
- QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit());
- connect(gsetting, &QGSettings::changed, this, &SideBarWidget::themeModeChangeSlot);
+ if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit()))
+ {
+ QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit());
+ connect(gsetting,&QGSettings::changed,this,&SideBarWidget::themeModeChangeSlot);
}
m_animation = new QPropertyAnimation(m_mainWidget, "geometry");
@@ -235,32 +235,24 @@ void SideBarWidget::addSidebarBtn()
void SideBarWidget::resetSidebarBtnSlot()
{
QLayoutItem *child;
-
while ((child = m_mainWidgetLayout->takeAt(6)) != 0) {
- QWidget *wid = child->widget();
+ QWidget* wid=child->widget();
m_mainWidgetLayout->removeWidget(wid);
wid->setParent(nullptr);
delete child;
}
- if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) {
- if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) {
+ if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit()))
+ {
+ if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(4));
- }
-
- if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(5));
- }
-
- if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(6));
- }
-
- if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) {
+ if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool())
m_mainWidgetLayout->addWidget(m_buttonList.at(7));
- }
}
-
m_mainWidgetLayout->addWidget(m_buttonList.at(8));
}
@@ -270,37 +262,34 @@ void SideBarWidget::resetSidebarBtnSlot()
void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num)
{
btn->setFlat(true);
- btn->setProperty("useButtonPalette", true);
- QHBoxLayout *btnLayout = new QHBoxLayout;
- QLabel *labelicon = new QLabel;
+ btn->setProperty("useButtonPalette",true);
+ QHBoxLayout* btnLayout=new QHBoxLayout;
+ QLabel* labelicon=new QLabel;
labelicon->setAlignment(Qt::AlignCenter);
- const auto ratio = devicePixelRatioF();
+ const auto ratio=devicePixelRatioF();
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
-
- if (num != 3) {
- QPixmap pixmap = loadSvg(btnicon, Style::SideBarIconSize * ratio);
-
- if (gsetting.get("style-name").toString() == "ukui-light") { //反黑
- pixmap = drawSymbolicBlackColoredPixmap(pixmap);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- }
-
+ if(num!=3)
+ {
+ QPixmap pixmap=loadSvg(btnicon,Style::SideBarIconSize*ratio);
+ if(gsetting.get("style-name").toString()=="ukui-light")//反黑
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);
+ else
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
- labelicon->setFixedSize(Style::SideBarIconSize, Style::SideBarIconSize);
+ labelicon->setFixedSize(Style::SideBarIconSize,Style::SideBarIconSize);
labelicon->setPixmap(pixmap);
- } else {
- if (!QFile::exists(btnicon)) {
- btnicon = QString("/usr/share/ukui/faces/default.png");
- }
-
+ }
+ else {
+ if(!QFile::exists(btnicon))
+ btnicon=QString("/usr/share/ukui/faces/default.png");
labelicon->setObjectName("faceLabel");
labelicon->setFocusPolicy(Qt::NoFocus);
labelicon->setAlignment(Qt::AlignCenter);
- labelicon->setFixedSize(Style::SideBarIconSize + 4, Style::SideBarIconSize + 4);
+ labelicon->setFixedSize(Style::SideBarIconSize+4,Style::SideBarIconSize+4);
+
QPixmap facePixmap(btnicon);
- facePixmap = facePixmap.scaled((Style::SideBarIconSize + 4) * ratio, (Style::SideBarIconSize + 4) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 4) * ratio / 2);
+ facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2);
facePixmap.setDevicePixelRatio(qApp->devicePixelRatio());
labelicon->setPixmap(facePixmap);
}
@@ -308,19 +297,20 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int
btnLayout->setSpacing(0);
btnLayout->addWidget(labelicon);
// btnLayout->addStretch();
- QLabel *textLabel = new QLabel;
- if (num == 3) {
+ QLabel* textLabel=new QLabel;
+ if(num==3)
textLabel->setObjectName("nameLabel");
- }
-
textLabel->setText(text);
btnLayout->addWidget(textLabel);
btnLayout->addStretch();
+
btn->setLayout(btnLayout);
btn->setFocusPolicy(Qt::StrongFocus);
+
m_buttonList.append(btn);
m_textList.append(text);
+
m_labelList.append(textLabel);
}
@@ -331,14 +321,14 @@ QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius)
}
QPixmap pixmapa(src);
- QPixmap pixmap(radius * 2, radius * 2);
+ QPixmap pixmap(radius*2,radius*2);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QPainterPath path;
- path.addEllipse(0, 0, radius * 2, radius * 2);
+ path.addEllipse(0, 0, radius*2, radius*2);
painter.setClipPath(path);
- painter.drawPixmap(0, 0, radius * 2, radius * 2, pixmapa);
+ painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa);
return pixmap;
}
@@ -348,96 +338,84 @@ QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius)
*/
void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos)
{
+
RightClickMenu m_otherMenu(this);
- int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos));
+ connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal);
Q_EMIT sendShowMainWindowSignal(false);
+ int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos));
qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始";
-
- if (ret >= 10 && ret <= 17) {
+ if(ret>=10 && ret<=17)
+ {
Q_EMIT sendHideMainWindowSignal();
-
switch (ret) {
- case 10:
- QProcess::startDetached(QString("ukui-screensaver-command -l"));
- break;
-
- case 11:
- QProcess::startDetached(QString("ukui-session-tools --switchuser"));
- break;
-
- case 12:
- QProcess::startDetached(QString("ukui-session-tools --logout"));
- break;
-
- case 13:
- QProcess::startDetached(QString("ukui-session-tools --reboot"));
- break;
-
- case 14:
- QProcess::startDetached(QString("ukui-session-tools --shutdown"));
- break;
-
- case 16:
- QProcess::startDetached(QString("ukui-session-tools --suspend"));
- break;
-
- case 17:
- QProcess::startDetached(QString("ukui-session-tools --sleep"));
- break;
-
- default:
- break;
+ case 10:
+ QProcess::startDetached(QString("ukui-screensaver-command -l"));
+ break;
+ case 11:
+ QProcess::startDetached(QString("ukui-session-tools --switchuser"));
+ break;
+ case 12:
+ QProcess::startDetached(QString("ukui-session-tools --logout"));
+ break;
+ case 13:
+ QProcess::startDetached(QString("ukui-session-tools --reboot"));
+ break;
+ case 14:
+ QProcess::startDetached(QString("ukui-session-tools --shutdown"));
+ break;
+ case 16:
+ QProcess::startDetached(QString("ukui-session-tools --suspend"));
+ break;
+ case 17:
+ QProcess::startDetached(QString("ukui-session-tools --sleep"));
+ break;
+ default:
+ break;
}
- }
+ }
qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 结束";
}
-//void SideBarWidget::addRightClickMenu(QPushButton *btn)
-//{
-// btn->setContextMenuPolicy(Qt::CustomContextMenu);
-// connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot);
-//}
+void SideBarWidget::addRightClickMenu(QPushButton *btn)
+{
+ btn->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot);
+}
-//void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos)
-//{
-// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始";
-// QPushButton *btn = dynamic_cast(QObject::sender());
-// int index = m_buttonList.indexOf(btn);
-// QString desktopfp;
-
-// switch (index) {
-// case 4:
-// desktopfp = QString("/usr/share/applications/peony-home.desktop");
-// break;
-
-// case 5:
-// desktopfp = QString("/usr/share/applications/peony-trash.desktop");
-// break;
-
-// case 6:
-// desktopfp = QString("/usr/share/applications/peony-computer.desktop");
-// break;
-
-// case 7:
-// desktopfp = QString("/usr/share/applications/ukui-control-center.desktop");
-// break;
-
-// default:
-// break;
-// }
-
-// RightClickMenu m_otherMenu;
-// int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp);
-// Q_EMIT sendShowMainWindowSignal(false);
-
-// if (ret == 15) {
-// Q_EMIT sendHideMainWindowSignal();
-// QProcess::startDetached(QString("ukui-control-center -d"));
-// }
-
-// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束";
-//}
+void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos)
+{
+ qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始";
+ QPushButton* btn=dynamic_cast(QObject::sender());
+ int index=m_buttonList.indexOf(btn);
+ QString desktopfp;
+ switch (index) {
+ case 4:
+ desktopfp=QString("/usr/share/applications/peony-home.desktop");
+ break;
+ case 5:
+ desktopfp=QString("/usr/share/applications/peony-trash.desktop");
+ break;
+ case 6:
+ desktopfp=QString("/usr/share/applications/peony-computer.desktop");
+ break;
+ case 7:
+ desktopfp=QString("/usr/share/applications/ukui-control-center.desktop");
+ break;
+ default:
+ break;
+ }
+ RightClickMenu m_otherMenu;
+ connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal);
+ int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp);
+ Q_EMIT sendShowMainWindowSignal(false);
+ if(ret==15)
+ {
+ Q_EMIT sendHideMainWindowSignal();
+ QProcess::startDetached(QString("ukui-control-center -d"));
+ }
+ qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束";
+}
void SideBarWidget::computerBtnClickedSlot()
{
@@ -455,6 +433,7 @@ void SideBarWidget::controlBtnClickedSlot()
{
Q_EMIT sendHideMainWindowSignal();
execApp("/usr/share/applications/ukui-control-center.desktop");
+
}
void SideBarWidget::trashBtnClickedSlot()
@@ -472,28 +451,26 @@ void SideBarWidget::shutdownBtnClickedSlot()
void SideBarWidget::userIconBtnClickedSlot()
{
Q_EMIT sendHideMainWindowSignal();
- QProcess::startDetached(QString("ukui-control-center -m Userinfo"));
+ QProcess::startDetached(QString("ukui-control-center -u"));
}
void SideBarWidget::userAccountsChanged()
{
- const auto ratio = devicePixelRatioF();
- QString usericon = getUserIcon();
-
- if (!QFile::exists(usericon)) {
- usericon = QString("/usr/share/ukui/faces/default.png");
- }
-
+ const auto ratio=devicePixelRatioF();
+ QString usericon=getUserIcon();
+ if(!QFile::exists(usericon))
+ usericon=QString("/usr/share/ukui/faces/default.png");
QPixmap facePixmap(usericon);
- facePixmap = facePixmap.scaled((Style::SideBarIconSize + 2) * ratio, (Style::SideBarIconSize + 2) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 2) * ratio / 2);
- QLabel *labelicon = m_userIconBtn->findChild("faceLabel");
+ facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2);
+
+ QLabel* labelicon=m_userIconBtn->findChild("faceLabel");
facePixmap.setDevicePixelRatio(qApp->devicePixelRatio());
labelicon->setPixmap(facePixmap);
- QLabel *labelname = m_userIconBtn->findChild("nameLabel");
- QString userName = fontMetrics().elidedText(getUserName(), Qt::ElideRight, labelname->width() - 10, Qt::TextShowMnemonic);
+ QLabel* labelname=m_userIconBtn->findChild("nameLabel");
+ QString userName = fontMetrics().elidedText(getUserName(),Qt::ElideRight,labelname->width()-10,Qt::TextShowMnemonic);
labelname->setText(userName);//更新用户名
- m_textList.replace(3, getUserName()); //更新用户名
+ m_textList.replace(3,getUserName());//更新用户名
}
/**
@@ -501,25 +478,30 @@ void SideBarWidget::userAccountsChanged()
*/
void SideBarWidget::loadMinSidebar()
{
- m_isFullScreen = false;
+ m_isFullScreen=false;
setMaxBtn();
- m_animation->stop();
- this->setFixedSize(Style::defaultSideBarWidWidth, Style::minh);
- m_mainWidget->setGeometry(QRect(0, 0, this->width(), this->height()));
- m_mainWidget->show();
- m_minMaxWidget->setFixedSize(37, 70);
- m_minMaxLayout->setContentsMargins(0, 0, 0, 0);
- m_mainWidgetLayout->setContentsMargins(8, 0, 10, 6);
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
- QPushButton *btn = qobject_cast(button);
+ m_animation->stop();
+ this->setFixedSize(Style::defaultSideBarWidWidth,Style::minh);
+ m_mainWidget->setGeometry(QRect(0,0,this->width(),this->height()));
+ m_mainWidget->show();
+ m_minMaxWidget->setFixedSize(37,70);
+ m_minMaxLayout->setContentsMargins(0,0,0,0);
+
+ m_mainWidgetLayout->setContentsMargins(8,0,10,6);
+
+ Q_FOREACH(QAbstractButton* button,m_buttonList)
+ {
+ QPushButton* btn=qobject_cast(button);
setMinSidebarBtn(btn);
btn->setToolTip(m_textList.at(m_buttonList.indexOf(button)));
}
+
changeIconColor(false);
- disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal);
- connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal);
+
+ disconnect(m_minMaxBtn,&QToolButton::clicked,this, &SideBarWidget::sendDefaultBtnSignal);
+ connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal);
}
/**
@@ -527,38 +509,36 @@ void SideBarWidget::loadMinSidebar()
*/
void SideBarWidget::setMaxBtn()
{
- const auto ratio = devicePixelRatioF();
+ const auto ratio=devicePixelRatioF();
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
- QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/max.svg"), 14 * ratio);
-
- if (gsetting.get("style-name").toString() == "ukui-light") { //反黑
- pixmap = drawSymbolicBlackColoredPixmap(pixmap);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- }
-
+ QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/max.svg"),14*ratio);
+ if(gsetting.get("style-name").toString()=="ukui-light")//反黑
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);
+ else
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
- m_minMaxBtn->setFixedSize(37, 37);
+
+ m_minMaxBtn->setFixedSize(37,37);
m_minMaxBtn->setIcon(QIcon(pixmap));
m_minMaxBtn->setToolTip(tr("Max"));
+
// m_minMaxBtn->setFocus();
}
/**
* 设置默认侧边栏按钮
*/
-void SideBarWidget::setMinSidebarBtn(QPushButton *btn)
+void SideBarWidget::setMinSidebarBtn(QPushButton* btn)
{
- btn->setFixedSize(37, 37);
-
- if (m_buttonList.indexOf(btn) == 3) {
- btn->layout()->setContentsMargins(7, 0, 17, 0);
- } else {
- btn->layout()->setContentsMargins(9, 0, 17, 0);
- }
-
+ btn->setFixedSize(37,37);
+ if(m_buttonList.indexOf(btn)==3)
+ btn->layout()->setContentsMargins(7,0,17,0);
+ else
+ btn->layout()->setContentsMargins(9,0,17,0);
btn->layout()->setSpacing(0);
+
m_labelList.at(m_buttonList.indexOf(btn))->setVisible(false);
+
//移除按钮文本
// QLayoutItem *child;
// if((child = btn->layout()->takeAt(1)) != nullptr) {
@@ -578,26 +558,32 @@ void SideBarWidget::setMinSidebarBtn(QPushButton *btn)
*/
void SideBarWidget::loadMaxSidebar()
{
- m_isFullScreen = true;
+ m_isFullScreen=true;
setMinBtn();
- this->setFixedSize(Style::SideBarWidWidth, Style::heightavailable);
- m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth, Style::MinMaxWidHeight);
- m_minMaxLayout->setContentsMargins(m_minMaxWidget->width() - m_minMaxBtn->width(), 0, 0, 0);
- m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6);
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
- QPushButton *btn = qobject_cast(button);
+ this->setFixedSize(Style::SideBarWidWidth,Style::heightavailable);
+
+ m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth,Style::MinMaxWidHeight);
+ m_minMaxLayout->setContentsMargins(m_minMaxWidget->width()-m_minMaxBtn->width(),0,0,0);
+
+ m_mainWidgetLayout->setContentsMargins(0,0,0,6);
+
+ Q_FOREACH(QAbstractButton* button,m_buttonList)
+ {
+ QPushButton* btn=qobject_cast(button);
setMaxSidebarBtn(btn);
}
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
- QPushButton *btn = qobject_cast(button);
- btn->setFixedSize(m_btnWidth, Style::SideBarBtnHeight);
+ Q_FOREACH(QAbstractButton* button,m_buttonList)
+ {
+ QPushButton* btn=qobject_cast(button);
+ btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight);
}
changeIconColor(true);
- disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal);
- connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal);
+
+ disconnect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal);
+ connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendDefaultBtnSignal);
}
/**
@@ -605,13 +591,15 @@ void SideBarWidget::loadMaxSidebar()
*/
void SideBarWidget::setMinBtn()
{
- const auto ratio = devicePixelRatioF();
- QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/min.svg"), 14 * ratio);
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
+ const auto ratio=devicePixelRatioF();
+ QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/min.svg"),14*ratio);
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
- m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth, Style::MinMaxBtnWidth);
+
+ m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth,Style::MinMaxBtnWidth);
m_minMaxBtn->setIcon(QIcon(pixmap));
m_minMaxBtn->setToolTip("");
+
// m_minMaxBtn->setFocus();
}
@@ -620,18 +608,20 @@ void SideBarWidget::setMinBtn()
*/
void SideBarWidget::setMaxSidebarBtn(QPushButton *btn)
{
- QHBoxLayout *layout = qobject_cast(btn->layout());
-
- if (m_buttonList.indexOf(btn) == 3) {
- layout->setContentsMargins(13, 0, 0, 0);
+ QHBoxLayout* layout=qobject_cast(btn->layout());
+ if(m_buttonList.indexOf(btn)==3)
+ {
+ layout->setContentsMargins(13,0,0,0);
layout->setSpacing(8);
- } else {
- layout->setContentsMargins(15, 0, 0, 0);
+ }
+ else
+ {
+ layout->setContentsMargins(15,0,0,0);
layout->setSpacing(10);
}
- QLabel *labeltext = m_labelList.at(m_buttonList.indexOf(btn));
- labeltext->setVisible(true);
+ QLabel* labeltext=m_labelList.at(m_buttonList.indexOf(btn));
+ labeltext->setVisible(true);
//修复修改字体大小时获取文本Label大小无效
//移除按钮文本
@@ -648,30 +638,30 @@ void SideBarWidget::setMaxSidebarBtn(QPushButton *btn)
// }
//添加文本
// QLabel* labeltext=new QLabel;
- if (m_buttonList.indexOf(btn) <= 2) {
+ if(m_buttonList.indexOf(btn)<=2)
+ {
labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
labeltext->setText(m_textList.at(m_buttonList.indexOf(btn)));
labeltext->adjustSize();
- m_btnWidth = 44 + labeltext->width() + 10;
+ m_btnWidth=44+labeltext->width()+10;
btn->setToolTip("");
- } else {
- QFont ft;
- QFontMetrics fm(ft);
- QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth - 44);
- labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
- labeltext->setText(text);
- labeltext->setFixedSize(m_btnWidth - 44, Style::SideBarBtnHeight);
- labeltext->adjustSize();
-
- if (fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width() > labeltext->width()) {
- btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn)));
- } else {
- btn->setToolTip("");
- }
}
-
+ else
+ {
+ QFont ft;
+ QFontMetrics fm(ft);
+ QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth-44);
+ labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ labeltext->setText(text);
+ labeltext->setFixedSize(m_btnWidth-44,Style::SideBarBtnHeight);
+ labeltext->adjustSize();
+ if(fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width()>labeltext->width())
+ btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn)));
+ else
+ btn->setToolTip("");
+ }
QPalette pe = labeltext->palette();
- pe.setColor(QPalette::ButtonText, QColor(Qt::white));
+ pe.setColor(QPalette::ButtonText,QColor(Qt::white));
labeltext->setPalette(pe);
// btn->layout()->addWidget(labeltext);
}
@@ -681,11 +671,13 @@ void SideBarWidget::btnAllClickedSlot()
m_allBtn->setChecked(true);
m_letterBtn->setChecked(false);
m_functionBtn->setChecked(false);
-
- if (m_isFullScreen) {
+ if(m_isFullScreen)
+ {
Q_EMIT sendFullScreenCommonUseBtnSignal();
Q_EMIT setSlideBar(0);
- } else {
+ }
+ else
+ {
Q_EMIT sendCommonUseBtnSignal();
}
}
@@ -695,10 +687,12 @@ void SideBarWidget::btnLetterClickedSlot()
m_allBtn->setChecked(false);
m_letterBtn->setChecked(true);
m_functionBtn->setChecked(false);
-
- if (m_isFullScreen) {
+ if(m_isFullScreen)
+ {
Q_EMIT sendFullScreenLetterBtnSignal();
- } else {
+ }
+ else
+ {
Q_EMIT sendLetterBtnSignal();
}
}
@@ -709,75 +703,66 @@ void SideBarWidget::btnFuncClickedSlot()
m_letterBtn->setChecked(false);
m_functionBtn->setChecked(true);
- if (m_isFullScreen) {
+ if(m_isFullScreen)
+ {
Q_EMIT sendFullScreenFunctionBtnSignal();
- } else {
+ }
+ else
+ {
Q_EMIT sendFunctionBtnSignal();
}
}
void SideBarWidget::themeModeChangeSlot(QString styleName)
{
- if (styleName == "styleName") {
- QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit());
-
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
- QPushButton *btn = qobject_cast(button);
- QLayoutItem *item = btn->layout()->itemAt(0);
- QLabel *label = qobject_cast(item->widget());
+ if(styleName=="styleName")
+ {
+ QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit());
+ Q_FOREACH(QAbstractButton *button,m_buttonList)
+ {
+ QPushButton *btn=qobject_cast(button);
+ QLayoutItem *item=btn->layout()->itemAt(0);
+ QLabel *label=qobject_cast(item->widget());
QString iconStr;
-
switch (m_buttonList.indexOf(button)) {
- case 0:
- iconStr = QString(":/data/img/sidebarwidget/commonuse.svg");
- break;
-
- case 1:
- iconStr = QString(":/data/img/sidebarwidget/letter.svg");
- break;
-
- case 2:
- iconStr = QString(":/data/img/sidebarwidget/function.svg");
- break;
-
- case 3:
- userAccountsChanged();
- break;
-
- case 4:
- iconStr = QString(":/data/img/sidebarwidget/personal.svg");
- break;
-
- case 5:
- iconStr = QString(":/data/img/sidebarwidget/trash.svg");
- break;
-
- case 6:
- iconStr = QString(":/data/img/sidebarwidget/computer.svg");
- break;
-
- case 7:
- iconStr = QString(":/data/img/sidebarwidget/setting.svg");
- break;
-
- case 8:
- iconStr = QString(":/data/img/sidebarwidget/shutdown.svg");
- break;
-
- default:
- break;
+ case 0:
+ iconStr=QString(":/data/img/sidebarwidget/commonuse.svg");
+ break;
+ case 1:
+ iconStr=QString(":/data/img/sidebarwidget/letter.svg");
+ break;
+ case 2:
+ iconStr=QString(":/data/img/sidebarwidget/function.svg");
+ break;
+ case 3:
+ userAccountsChanged();
+ break;
+ case 4:
+ iconStr=QString(":/data/img/sidebarwidget/personal.svg");
+ break;
+ case 5:
+ iconStr=QString(":/data/img/sidebarwidget/trash.svg");
+ break;
+ case 6:
+ iconStr=QString(":/data/img/sidebarwidget/computer.svg");
+ break;
+ case 7:
+ iconStr=QString(":/data/img/sidebarwidget/setting.svg");
+ break;
+ case 8:
+ iconStr=QString(":/data/img/sidebarwidget/shutdown.svg");
+ break;
+ default:
+ break;
}
-
- if (m_buttonList.indexOf(button) != 3) {
- const auto ratio = devicePixelRatioF();
- QPixmap pixmap = loadSvg(iconStr, 19 * ratio);
-
- if (gsetting->get("style-name").toString() == "ukui-light") { //反黑
- pixmap = drawSymbolicBlackColoredPixmap(pixmap);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- }
-
+ if(m_buttonList.indexOf(button)!=3)
+ {
+ const auto ratio=devicePixelRatioF();
+ QPixmap pixmap=loadSvg(iconStr,19*ratio);
+ if(gsetting->get("style-name").toString()=="ukui-light")//反黑
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);
+ else
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
label->setPixmap(pixmap);
}
@@ -787,65 +772,52 @@ void SideBarWidget::themeModeChangeSlot(QString styleName)
void SideBarWidget::changeIconColor(bool isFullScreen)
{
- QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit());
-
- Q_FOREACH (QAbstractButton *button, m_buttonList) {
- QPushButton *btn = qobject_cast(button);
- QLayoutItem *item = btn->layout()->itemAt(0);
- QLabel *label = qobject_cast(item->widget());
+ QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit());
+ Q_FOREACH(QAbstractButton *button,m_buttonList)
+ {
+ QPushButton *btn=qobject_cast(button);
+ QLayoutItem *item=btn->layout()->itemAt(0);
+ QLabel *label=qobject_cast(item->widget());
QString iconStr;
-
switch (m_buttonList.indexOf(button)) {
- case 0:
- iconStr = QString(":/data/img/sidebarwidget/commonuse.svg");
- break;
-
- case 1:
- iconStr = QString(":/data/img/sidebarwidget/letter.svg");
- break;
-
- case 2:
- iconStr = QString(":/data/img/sidebarwidget/function.svg");
- break;
-
- case 3:
- userAccountsChanged();
- break;
-
- case 4:
- iconStr = QString(":/data/img/sidebarwidget/personal.svg");
- break;
-
- case 5:
- iconStr = QString(":/data/img/sidebarwidget/trash.svg");
- break;
-
- case 6:
- iconStr = QString(":/data/img/sidebarwidget/computer.svg");
- break;
-
- case 7:
- iconStr = QString(":/data/img/sidebarwidget/setting.svg");
- break;
-
- case 8:
- iconStr = QString(":/data/img/sidebarwidget/shutdown.svg");
- break;
-
- default:
- break;
+ case 0:
+ iconStr=QString(":/data/img/sidebarwidget/commonuse.svg");
+ break;
+ case 1:
+ iconStr=QString(":/data/img/sidebarwidget/letter.svg");
+ break;
+ case 2:
+ iconStr=QString(":/data/img/sidebarwidget/function.svg");
+ break;
+ case 3:
+ userAccountsChanged();
+ break;
+ case 4:
+ iconStr=QString(":/data/img/sidebarwidget/personal.svg");
+ break;
+ case 5:
+ iconStr=QString(":/data/img/sidebarwidget/trash.svg");
+ break;
+ case 6:
+ iconStr=QString(":/data/img/sidebarwidget/computer.svg");
+ break;
+ case 7:
+ iconStr=QString(":/data/img/sidebarwidget/setting.svg");
+ break;
+ case 8:
+ iconStr=QString(":/data/img/sidebarwidget/shutdown.svg");
+ break;
+ default:
+ break;
}
-
- if (m_buttonList.indexOf(button) != 3) {
- const auto ratio = devicePixelRatioF();
- QPixmap pixmap = loadSvg(iconStr, 18 * ratio);
-
- if (gsetting->get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑
- pixmap = drawSymbolicBlackColoredPixmap(pixmap);
- } else {
- pixmap = drawSymbolicColoredPixmap(pixmap); //反白
- }
-
+ if(m_buttonList.indexOf(button)!=3)
+ {
+ const auto ratio=devicePixelRatioF();
+ QPixmap pixmap=loadSvg(iconStr,19*ratio);
+ if(gsetting->get("style-name").toString()=="ukui-light" && !isFullScreen)//反黑
+ pixmap=drawSymbolicBlackColoredPixmap(pixmap);
+ else
+ pixmap=drawSymbolicColoredPixmap(pixmap);//反白
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
label->setPixmap(pixmap);
}
@@ -856,10 +828,10 @@ void SideBarWidget::enterAnimation()
{
m_animation->stop();
m_animation->setDuration(200);//动画总时间
- m_animation->setStartValue(QRect(this->width(), 0,
- 0, this->height()));
- m_animation->setEndValue(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0,
- m_btnWidth, this->height()));
+ m_animation->setStartValue(QRect(this->width(),0,
+ 0,this->height()));
+ m_animation->setEndValue(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0,
+ m_btnWidth,this->height()));
m_animation->setEasingCurve(QEasingCurve::InQuart);
m_animation->start();
m_mainWidget->show();
@@ -867,8 +839,8 @@ void SideBarWidget::enterAnimation()
void SideBarWidget::setSideBarBtnGeometry()
{
- m_mainWidget->setGeometry(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0,
- m_btnWidth, this->height()));
+ m_mainWidget->setGeometry(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0,
+ m_btnWidth,this->height()));
m_mainWidget->show();
}
@@ -889,30 +861,39 @@ void SideBarWidget::setSideBarBtnGeometry()
// }
//}
-void SideBarWidget::keyPressEvent(QKeyEvent *e)
+void SideBarWidget::keyPressEvent(QKeyEvent* e)
{
- if (e->type() == QEvent::KeyPress) {
- switch (e->key()) {
- case Qt::Key_Enter:
- case Qt::Key_Return: {
- if (m_allBtn->hasFocus()) {
- m_allBtn->click();
- } else if (m_letterBtn->hasFocus()) {
- m_letterBtn->click();
- } else if (m_functionBtn->hasFocus()) {
- m_functionBtn->click();
- } else {
- QWidget *current_focus_widget;
- current_focus_widget = QWidget::focusWidget();
- QPushButton *le = qobject_cast(current_focus_widget);
- le->clicked();
- }
+ if(e->type()==QEvent::KeyPress)
+ {
+ switch(e->key())
+ {
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ {
+ if(m_allBtn->hasFocus())
+ {
+ m_allBtn->click();
}
+ else if(m_letterBtn->hasFocus())
+ {
+ m_letterBtn->click();
+ }
+ else if(m_functionBtn->hasFocus())
+ {
+ m_functionBtn->click();
+ }
+ else
+ {
+ QWidget *current_focus_widget;
+ current_focus_widget = QWidget::focusWidget();
+ QPushButton *le= qobject_cast(current_focus_widget);
+ le->clicked();
+ }
+ }
break;
-
- case Qt::Key_Down:
- qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down";
- // focusNextChild();
+ case Qt::Key_Down:
+ qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down";
+ // focusNextChild();
// if(m_buttonList.at(2)->hasFocus())
// {
// m_buttonList.at(3)->setFocus();
@@ -921,20 +902,19 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e)
// {
// m_minMaxBtn->setFocus();
// }
- break;
- case Qt::Key_Up:
- qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up";
- // /* focusPreviousChild();
+ break;
+ case Qt::Key_Up:
+ qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up";
+ // /* focusPreviousChild();
// if(m_buttonList.at(0)->hasFocus())
// {
// m_minMaxBtn->setFocus();
// }
- break;
-
- default:
- return QWidget::keyPressEvent(e);
- break;
+ break;
+ default:
+ return QWidget::keyPressEvent(e);
+ break;
}
}
}
diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h
index 6e800d1..2dffe52 100644
--- a/src/SideBarWidget/sidebarwidget.h
+++ b/src/SideBarWidget/sidebarwidget.h
@@ -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 m_buttonList;
- QList m_labelList;
+ QList m_buttonList;
+ QList 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;
- // RightClickMenu *m_shutDownMenu=nullptr;
- // RightClickMenu *m_otherMenu=nullptr;
- QPropertyAnimation *m_animation = nullptr;
+ QPushButton *m_userIconBtn=nullptr;
+ QPushButton *m_computerBtn=nullptr;
+ QPushButton *m_personalBtn=nullptr;
+ QPushButton *m_controlBtn=nullptr;
+ QPushButton *m_trashBtn=nullptr;
+ QPushButton *m_shutDownBtn=nullptr;
+ QSpacerItem *m_verticalSpacer=nullptr;
+ bool m_isFullScreen=false;
+ QGSettings *m_gsetting=nullptr;
+ // RightClickMenu *m_shutDownMenu=nullptr;
+ // RightClickMenu *m_otherMenu=nullptr;
+ QPropertyAnimation* m_animation=nullptr;
int m_btnWidth, m_btnheight;
@@ -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
*/
diff --git a/src/Style/style.cpp b/src/Style/style.cpp
index 71719e8..31dd831 100644
--- a/src/Style/style.cpp
+++ b/src/Style/style.cpp
@@ -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 reply = iface.call("GetPrimaryScreenPhysicalGeometry");
+ if (reply.isValid()) {
+ panelSize = reply.value().at(4).toInt();
+ panelPosition = reply.value().at(5).toInt();
+ }
+
+ QList posIndex;
+ switch (panelPosition) {
+ case BOTTOM:
+ posIndex = {0, 0, 0, -1};
+ break;
+ case TOP:
+ posIndex = {0, 1, 0, -1};
+ break;
+ case LEFT:
+ posIndex = {1, 0, -1, 0};
+ break;
+ case RIGHT:
+ posIndex = {0, 0, -1, 0};
+ }
+
+ primaryScreenX = rect.x() + posIndex[0] * panelSize;
+ primaryScreenY = rect.y() + posIndex[1] * panelSize;
+ widthavailable = rect.width() + posIndex[2] * panelSize;
+ heightavailable = rect.height() + posIndex[3] * panelSize;
+}
diff --git a/src/Style/style.h b/src/Style/style.h
index 548a846..93bcfee 100644
--- a/src/Style/style.h
+++ b/src/Style/style.h
@@ -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
diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp
index 672f8d1..bf1d89e 100644
--- a/src/UtilityFunction/convertdesktoptowinid.cpp
+++ b/src/UtilityFunction/convertdesktoptowinid.cpp
@@ -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 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 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();
- }
+ desktopFileExeName = "/usr/lib/" + desktopFileExeName;
+ if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) {
+ 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;
- }
}
diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/UtilityFunction/convertdesktoptowinid.h
index 09d99f4..109c14a 100644
--- a/src/UtilityFunction/convertdesktoptowinid.h
+++ b/src/UtilityFunction/convertdesktoptowinid.h
@@ -23,7 +23,7 @@
#include
#include
-#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);
};
diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp
index c471d7c..2c0c45f 100644
--- a/src/UtilityFunction/fullitemdelegate.cpp
+++ b/src/UtilityFunction/fullitemdelegate.cpp
@@ -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 iconstr = m_ukuiMenuInterface->getAppIcon(desktopfp);
+ QString desktopfp=index.data(Qt::DisplayRole).value();
+ QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp);
QIcon icon;
QFileInfo iconFileInfo(iconstr);
-
- if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) {
- icon = QIcon(iconstr);
- } else {
+ 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,
- Style::AppListIconSize,
- Style::AppListIconSize);
- icon.paint(painter, iconRect);
+ iconRect=QRect(rect.x()+Style::AppLeftSpace ,
+ rect.y()+Style::AppTopSpace,
+ Style::AppListIconSize,
+ Style::AppListIconSize);
+ icon.paint(painter,iconRect);
painter->restore();
- painter->save();
- bool is_locked = false;
- QFileInfo fileInfo(desktopfp);
- QString desktopfn = fileInfo.fileName();
+ painter->save();
+ bool is_locked=false;
+ QFileInfo fileInfo(desktopfp);
+ 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();
}
}
diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UtilityFunction/fullitemdelegate.h
index c845642..0e24425 100644
--- a/src/UtilityFunction/fullitemdelegate.h
+++ b/src/UtilityFunction/fullitemdelegate.h
@@ -27,20 +27,20 @@
#include
#include
#include "src/Interface/ukuimenuinterface.h"
-
+#include "src/Style/style.h"
class FullItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- FullItemDelegate(QObject *parent, int module);
+ FullItemDelegate(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);
diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp
index 9bc0aa3..b2eb8a6 100644
--- a/src/UtilityFunction/fulllistview.cpp
+++ b/src/UtilityFunction/fulllistview.cpp
@@ -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
@@ -56,38 +51,44 @@ void FullListView::initWidget()
this->setResizeMode(QListView::Adjust);
this->setTextElideMode(Qt::ElideRight);
this->setMouseTracking(true);
- // this->setFocusPolicy(Qt::StrongFocus);
+ // 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(desktopfp), Qt::DisplayRole);
+ Q_FOREACH(QString desktopfp,data)
+ {
+ QStandardItem* item=new QStandardItem;
+ item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
-
- m_delegate = new FullItemDelegate(this, module);
+ m_delegate= new FullItemDelegate(this,module);
this->setItemDelegate(m_delegate);
}
@@ -106,71 +107,66 @@ 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(desktopfp), Qt::DisplayRole);
+ Q_FOREACH(QString desktopfp,data)
+ {
+ QStandardItem* item=new QStandardItem;
+ item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole);
listmodel->appendRow(item);
}
}
void FullListView::onClicked(QModelIndex index)
{
- QVariant var = listmodel->data(index, Qt::DisplayRole);
+ QVariant var = listmodel->data(index, Qt::DisplayRole);
+ if(var.isValid())
+ {
+ QString desktopfp=var.value();
+ Q_EMIT sendItemClickedSignal(desktopfp);
- if (var.isValid()) {
- QString desktopfp = var.value();
- 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();
+ if(!(this->selectionModel()->selectedIndexes().isEmpty()))
+ {
+ QModelIndex index=this->currentIndex();
+ QVariant var=listmodel->data(index, Qt::DisplayRole);
+ QString desktopfp=var.value();
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 {
- 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;
+ case 6:
+ Q_EMIT sendHideMainWindowSignal();
+ break;
+ case 7:
+ Q_EMIT sendHideMainWindowSignal();
+ break;
+ default:
+ break;
+ }
+ }
+ 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();
}
}
@@ -187,24 +183,25 @@ void FullListView::leaveEvent(QEvent *e)
Q_UNUSED(e);
this->verticalScrollBar()->setVisible(false);
// QWidget *current_focus_widget;
- // current_focus_widget = QApplication::focusWidget();
+ // current_focus_widget = QApplication::focusWidget();
// current_focus_widget = QWidget::focusWidget();
// QPushButton *le= qobject_cast(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,93 +233,91 @@ 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()) {
- case Qt::Key_Enter:
- case Qt::Key_Return: {
- QModelIndex index = this->currentIndex();
- Q_EMIT clicked(index);
- break;
- }
-
- case Qt::Key_Left: {
- this->clearFocus();
-
- 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: {
- this->clearFocus();
-
- 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();
- 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();
- Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth);
- this->setFocus();
- }
- }
-
- return QListView::keyPressEvent(e);
- break;
- }
-
- default:
- return QListView::keyPressEvent(e);
- break;
+ 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:
+ {
+ this->clearFocus();
+ 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:
+ {
+
+ this->clearFocus();
+ 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))
+ {
+ Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth);
+ }
+ }
+ return QListView::keyPressEvent(e);
+ break;
+ }
+ case Qt::Key_Down:
+ {
+ if(module == 0)
+ {
+ if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth))
+ {
+ Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth);
+ }
+ }
+ return QListView::keyPressEvent(e);
+ break;
+ }
+
+ default:
+ return QListView::keyPressEvent(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);
}
}
diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h
index c5c87d5..1cff017 100644
--- a/src/UtilityFunction/fulllistview.h
+++ b/src/UtilityFunction/fulllistview.h
@@ -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;
diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp
index bd525e5..c031c4a 100644
--- a/src/UtilityFunction/itemdelegate.cpp
+++ b/src/UtilityFunction/itemdelegate.cpp
@@ -22,30 +22,30 @@
#include
#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);
+
}
diff --git a/src/UtilityFunction/itemdelegate.h b/src/UtilityFunction/itemdelegate.h
index 8906406..7c00340 100644
--- a/src/UtilityFunction/itemdelegate.h
+++ b/src/UtilityFunction/itemdelegate.h
@@ -32,14 +32,14 @@ public:
/**
* @param module为0时为常用模块,1为字母模块、2为功能模块、3为搜索模块
*/
- 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;
};
diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp
index 403281a..62c4ab4 100644
--- a/src/UtilityFunction/letterclassifybutton.cpp
+++ b/src/UtilityFunction/letterclassifybutton.cpp
@@ -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);
}
diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp
index f554276..4fc0850 100644
--- a/src/UtilityFunction/listview.cpp
+++ b/src/UtilityFunction/listview.cpp
@@ -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,100 +59,94 @@ 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 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(desktopfp), Qt::DisplayRole);
+ Q_FOREACH(QStringList desktopfp,data)
+ {
+ QStandardItem* item=new QStandardItem;
+ item->setData(QVariant::fromValue(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 data)
{
listmodel->clear();
-
- Q_FOREACH (QStringList desktopfp, data) {
- QStandardItem *item = new QStandardItem;
- item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole);
+ Q_FOREACH(QStringList desktopfp,data)
+ {
+ QStandardItem* item=new QStandardItem;
+ item->setData(QVariant::fromValue(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()) {
- Q_EMIT sendItemClickedSignal(var.value());
- }
+ QVariant var = listmodel->data(index, Qt::DisplayRole);
+ if(var.isValid())
+ {
+ Q_EMIT sendItemClickedSignal(var.value());
+ }
}
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();
-
- if (strlist.at(1).toInt() == 1) {
+ QVariant var=listmodel->data(index, Qt::DisplayRole);
+ QStringList strlist=var.value();
+ 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 {
- 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;
+ }
+ }
+ }
+ 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();
+ // this->selectionModel()->clear();
}
}
}
@@ -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();
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,40 +217,42 @@ 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()) {
- case Qt::Key_Enter:
- case Qt::Key_Return: {
- QModelIndex index = this->currentIndex();
- Q_EMIT clicked(index);
- }
+ 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_Down: {
- if (currentIndex().row() == this->model()->rowCount() - 1) {
- setCurrentIndex(this->model()->index(0, 0));
- break;
- }
-
- return QListView::keyPressEvent(e);
+ case Qt::Key_Down:
+ {
+ if(currentIndex().row() == this->model()->rowCount() - 1)
+ {
+ setCurrentIndex(this->model()->index(0,0));
break;
}
-
- case Qt::Key_Up: {
- if (currentIndex().row() == 0) {
- setCurrentIndex(this->model()->index(this->model()->rowCount() - 1, 0));
- break;
- }
-
- return QListView::keyPressEvent(e);
+ return QListView::keyPressEvent(e);
+ break;
+ }
+ case Qt::Key_Up:
+ {
+ if(currentIndex().row() == 0)
+ {
+ setCurrentIndex(this->model()->index(this->model()->rowCount()-1,0));
break;
}
-
- default:
- return QListView::keyPressEvent(e);
- break;
+ return QListView::keyPressEvent(e);
+ break;
+ }
+ default:
+ return QListView::keyPressEvent(e);
+ break;
}
}
}
diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h
index b20f468..b63147e 100644
--- a/src/UtilityFunction/listview.h
+++ b/src/UtilityFunction/listview.h
@@ -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 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
diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp
index 0ffa9ef..1ccd581 100644
--- a/src/UtilityFunction/proxystyle.cpp
+++ b/src/UtilityFunction/proxystyle.cpp
@@ -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
#include
diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h
index 93403a0..397e74a 100644
--- a/src/UtilityFunction/proxystyle.h
+++ b/src/UtilityFunction/proxystyle.h
@@ -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
diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.cpp b/src/UtilityFunction/softwaredatabaseupdatethread.cpp
new file mode 100644
index 0000000..68429d2
--- /dev/null
+++ b/src/UtilityFunction/softwaredatabaseupdatethread.cpp
@@ -0,0 +1,62 @@
+#include "softwaredatabaseupdatethread.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include "src/UtilityFunction/utility.h"
+
+#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db"
+
+SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent):
+ QThread(parent)
+{
+}
+
+SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread()
+{
+}
+
+void SoftwareDatabaseUpdateThread::run()
+{
+ QSqlDatabase db;
+ db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase");
+ db.setDatabaseName(DATABASENAME);
+
+ if (false == db.open()) {
+ qDebug() << db.lastError().text();
+ }
+
+ QSqlQuery sql(db);
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data());
+ QJsonObject jsonObject = jsonDocument.object();
+ QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray();
+
+ int number = 0;
+ db.transaction();
+
+ Q_FOREACH(QJsonValue jsonValue, jsonArray){
+ QJsonObject arrObject = jsonValue.toObject();
+ QString execline = QString("replace into appCategory values(\"%0\", \"%1\", \"%2\")")
+ .arg(arrObject[arrObject.keys()[0]].toString())
+ .arg(arrObject[arrObject.keys()[1]].toString())
+ .arg(arrObject[arrObject.keys()[2]].toString());
+ sql.exec(execline);
+
+ ++number;
+ if (number % 5000 == 0) {
+ db.commit();
+ db.transaction();
+ }
+ }
+ db.commit();
+
+ myDebug() << "数据库已经更新";
+ Q_EMIT updateDatabaseSignal();
+}
+
+void SoftwareDatabaseUpdateThread::getDatabaseList(QString category)
+{
+ this->m_category = category;
+}
diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h
new file mode 100644
index 0000000..44b460d
--- /dev/null
+++ b/src/UtilityFunction/softwaredatabaseupdatethread.h
@@ -0,0 +1,27 @@
+#ifndef SOFTWAREDATABASEUPDATETHREAD_H
+#define SOFTWAREDATABASEUPDATETHREAD_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+class SoftwareDatabaseUpdateThread: public QThread
+{
+ Q_OBJECT
+public:
+ SoftwareDatabaseUpdateThread(QObject *parent = nullptr);
+ ~SoftwareDatabaseUpdateThread();
+ void run();
+ void getDatabaseList(QString category);
+Q_SIGNALS:
+ void updateDatabaseSignal();
+
+private:
+ QString m_category;
+};
+
+#endif // SOFTWAREDATABASEUPDATETHREAD_H
diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp
index d10fc82..d01f6af 100644
--- a/src/UtilityFunction/utility.cpp
+++ b/src/UtilityFunction/utility.cpp
@@ -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 reply=iface.call("GetPrimaryScreenAvailableGeometry");
- if(iface.isValid() && reply.isValid())
- {
- list=reply.value();
- rect = QRect(list.at(0).toInt(),list.at(1).toInt(),list.at(2).toInt(),list.at(3).toInt());
-
- }
- else
- {
- rect = qApp->primaryScreen()->availableGeometry();
- }
- return rect;
-}
-
-QVariantList getScreenGeometry()
-{
- QVariantList list;
- list.clear();
- QDBusInterface iface(DBUS_NAME,
- DBUS_PATH,
- DBUS_INTERFACE,
- QDBusConnection::sessionBus());
- QDBusReply reply=iface.call("GetPrimaryScreenPhysicalGeometry");
- if(iface.isValid() && reply.isValid())
- {
- list=reply.value();
- }
- else
- {
- QRect rect=QApplication::desktop()->screenGeometry(0);
- list.append(QString::number(rect.x()));
- list.append(QString::number(rect.y()));
- list.append(QString::number(rect.width()));
- list.append(QString::number(rect.height()));
-
- int position=0;
- int panelSize=0;
- if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit()))
- {
- QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit());
- if(gsetting->keys().contains(QString("panelposition")))
- position=gsetting->get("panelposition").toInt();
- else
- position=0;
- if(gsetting->keys().contains(QString("panelsize")))
- panelSize=gsetting->get("panelsize").toInt();
- else
- panelSize=46;
- delete gsetting;
- }
- else
- {
- position=0;
- panelSize=46;
- }
- list.append(QString::number(panelSize));
- list.append(QString::number(position));
- }
- return list;
-}
-
double getTransparency()
{
double transparency=0.0;
diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h
index 33fcc5a..db30fee 100644
--- a/src/UtilityFunction/utility.h
+++ b/src/UtilityFunction/utility.h
@@ -23,7 +23,6 @@
#include
#include
#include
-#include
#include
#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);
//数据库操作
diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo_CN.ts
new file mode 100644
index 0000000..091d0ea
--- /dev/null
+++ b/translations/ukui-menu_bo_CN.ts
@@ -0,0 +1,290 @@
+
+
+
+
+ FunctionClassifyButton
+
+
+ གནས་སྤོར།
+
+
+
+ སྦྲེལ་རེས་དྲ་རྒྱ།
+
+
+
+ འབྲེལ་འདྲིས།
+
+
+
+ བརྙན་ཟློས།
+
+
+
+ གསར་སྤེལ།
+
+
+
+ པར་རིས།།
+
+
+
+ རོལ་རྩེད།
+
+
+
+ གཞུང་ལས།དྲ་རྒྱ།
+
+
+
+ སློབ་གསོ།
+
+
+
+ རྒྱུད་ཁོངས།
+
+
+
+ གཞན་དག
+
+
+
+ MainViewWidget
+
+
+
+ འཚོལ་བ།
+
+
+
+ QObject
+
+
+
+
+ གཞུང་ལས།དྲ་རྒྱ།
+
+
+
+
+
+ གསར་སྤེལ།
+
+
+
+
+
+ པར་རིས།།
+
+
+
+
+
+ བརྙན་ཟློས།
+
+
+
+
+
+ སྦྲེལ་རེས་དྲ་རྒྱ།
+
+
+
+
+
+ རོལ་རྩེད།
+
+
+
+
+
+ སློབ་གསོ།
+
+
+
+
+
+ འབྲེལ་འདྲིས།
+
+
+
+
+
+ རྒྱུད་ཁོངས།
+
+
+
+
+
+
+
+
+
+
+
+ གཞན་དག
+
+
+
+ RightClickMenu
+
+
+
+ “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ།
+
+
+
+
+ “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ།
+
+
+
+
+ འགན་བྱང་དུ་འཇོག་པ།
+
+
+
+
+ འགན་བྱང་ནས་ལེན་པ།
+
+
+
+
+ ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ།
+
+
+
+
+ ལྷུ་གཏོར
+
+
+
+
+ མལ་གསོ།
+
+
+
+
+ རྩིས་ཐེམ་ནས་བསུབ་པ།
+
+
+
+
+ བསྐྱར་སློང་།
+
+
+
+
+ འཁོར་ཁ་རྒྱག་པ།
+
+
+
+
+ མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ།
+
+
+
+ SideBarWidget
+
+
+
+ མཉེན་ཆས་ཚང་མ།
+
+
+
+
+ འཕྲིན་ཡིག
+
+
+
+
+ བྱེད་ནུས།
+
+
+
+
+ སྙིགས་སྒམ།
+
+
+
+
+ རྩིས་ཆས།
+
+
+
+
+ ཆེས་ཆེ་བ།
+
+
+
+
+
+
+
+
+
+ མི་སྒེར།
+
+
+
+
+ སྒྲིག་འགོད།
+
+
+
+
+ ཁ་རྒྱག་པ།
+
+
+
+ SplitBarFrame
+
+
+ གནས་སྤོར།
+
+
+
+ སྦྲེལ་རེས་དྲ་རྒྱ།
+
+
+
+ འབྲེལ་འདྲིས།
+
+
+
+ བརྙན་ཟློས།
+
+
+
+ གསར་སྤེལ།
+
+
+
+ པར་རིས།།
+
+
+
+ རོལ་རྩེད།
+
+
+
+ གཞུང་ལས།དྲ་རྒྱ།
+
+
+
+ སློབ་གསོ།
+
+
+
+ རྒྱུད་ཁོངས།
+
+
+
+ सुरक्षा
+
+
+
+ གཞན་དག
+
+
+
diff --git a/ukui-menu.pro b/ukui-menu.pro
index a5b48e5..a6658eb 100644
--- a/ukui-menu.pro
+++ b/ukui-menu.pro
@@ -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 \
diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user
index a5cc0fd..48d277d 100644
--- a/ukui-menu.pro.user
+++ b/ukui-menu.pro.user
@@ -1,6 +1,6 @@
-
+
EnvironmentId
@@ -8,7 +8,7 @@
ProjectExplorer.Project.ActiveTarget
- 0
+ 0
ProjectExplorer.Project.EditorSettings
@@ -28,7 +28,7 @@
QmlJSGlobal
- 2
+ 2
UTF-8
false
4
@@ -37,6 +37,7 @@
true
true
1
+ false
true
false
0
@@ -45,48 +46,58 @@
0
8
true
+ false
1
true
true
true
+ *.md, *.MD, Makefile
false
+ true
ProjectExplorer.Project.PluginSettings
-
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+
+ 0
+ true
+
ProjectExplorer.Project.Target.0
+ Desktop
桌面
桌面
{9d9f9a2c-403b-48c4-83ee-e52b4e889b83}
- 0
- 0
- 0
+ 0
+ 0
+ 0
- /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug
+ 0
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug
true
QtProjectManager.QMakeBuildStep
- true
-
false
- false
- false
+
true
Qt4ProjectManager.MakeStep
-
- false
-
-
- false
- 2
+ 2
Build
Build
ProjectExplorer.BuildSteps.Build
@@ -95,46 +106,37 @@
true
Qt4ProjectManager.MakeStep
-
- true
clean
-
- false
- 1
+ 1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
+
+ false
Debug
Qt4ProjectManager.Qt4BuildConfiguration
2
- /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Release
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release
true
QtProjectManager.QMakeBuildStep
- false
-
false
- false
- true
+
true
Qt4ProjectManager.MakeStep
-
- false
-
-
- false
- 2
+ 2
Build
Build
ProjectExplorer.BuildSteps.Build
@@ -143,46 +145,38 @@
true
Qt4ProjectManager.MakeStep
-
- true
clean
-
- false
- 1
+ 1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
+
+ false
Release
Qt4ProjectManager.Qt4BuildConfiguration
0
- /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Profile
+ 0
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile
+ /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile
true
QtProjectManager.QMakeBuildStep
- true
-
false
- true
- true
+
true
Qt4ProjectManager.MakeStep
-
- false
-
-
- false
- 2
+ 2
Build
Build
ProjectExplorer.BuildSteps.Build
@@ -191,117 +185,58 @@
true
Qt4ProjectManager.MakeStep
-
- true
clean
-
- false
- 1
+ 1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
+
+ false
Profile
Qt4ProjectManager.Qt4BuildConfiguration
0
+ 0
- 3
+ 3
- 0
+ 0
Deploy
Deploy
ProjectExplorer.BuildSteps.Deploy
1
+
+ false
ProjectExplorer.DefaultDeployConfiguration
- 1
-
+ 1
- dwarf
-
- cpu-cycles
-
-
- 250
-
- -e
- cpu-cycles
- --call-graph
- dwarf,4096
- -F
- 250
-
- -F
true
- 4096
- false
- false
- 1000
-
true
-
- false
- false
- false
- false
- true
- 0.01
- 10
- true
- kcachegrind
- 1
- 25
-
- 1
true
- false
- true
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
+
2
- Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro
- /home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro
-
- false
-
+ Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro
+ /home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro
false
true
true
- false
false
true
-
- /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug
- 1
+ 1
ProjectExplorer.Project.TargetCount
- 1
+ 1
ProjectExplorer.Project.Updater.FileVersion