Merge pull request #98 from mammonsama666/optimize
fix(frontend): Optimize code for frontend.
This commit is contained in:
commit
6a8afe8258
|
@ -35,19 +35,14 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
|
||||||
case SearchListView::ResType::Dir:
|
case SearchListView::ResType::Dir:
|
||||||
case SearchListView::ResType::File: {
|
case SearchListView::ResType::File: {
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(QString("xdg-open %1").arg(path));
|
process.startDetached(QString("xdg-open %1").arg(path));
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SearchListView::ResType::Setting: {
|
case SearchListView::ResType::Setting: {
|
||||||
//打开控制面板对应页面
|
//打开控制面板对应页面
|
||||||
QProcess * process = new QProcess;
|
QProcess process;
|
||||||
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
|
||||||
if (process) {
|
|
||||||
delete process;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
process->start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -253,20 +253,14 @@ bool SearchDetailView::openAction(const int& type, const QString& path) {
|
||||||
case SearchListView::ResType::Dir:
|
case SearchListView::ResType::Dir:
|
||||||
case SearchListView::ResType::File: {
|
case SearchListView::ResType::File: {
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(QString("xdg-open %1").arg(path));
|
process.startDetached(QString("xdg-open %1").arg(path));
|
||||||
process.waitForFinished();
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SearchListView::ResType::Setting: {
|
case SearchListView::ResType::Setting: {
|
||||||
//打开控制面板对应页面
|
//打开控制面板对应页面
|
||||||
QProcess * process = new QProcess;
|
QProcess process;
|
||||||
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
|
||||||
if (process) {
|
|
||||||
delete process;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
process->start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -391,8 +385,7 @@ bool SearchDetailView::addDesktopShortcut(const QString& path) {
|
||||||
if(ret)
|
if(ret)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(QString("chmod a+x %1").arg(newName));
|
process.startDetached(QString("chmod a+x %1").arg(newName));
|
||||||
process.waitForFinished();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -426,8 +419,7 @@ bool SearchDetailView::addPanelShortcut(const QString& path) {
|
||||||
*/
|
*/
|
||||||
bool SearchDetailView::openPathAction(const QString& path) {
|
bool SearchDetailView::openPathAction(const QString& path) {
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(QString("xdg-open %1").arg(path.left(path.lastIndexOf("/"))));
|
process.startDetached(QString("xdg-open %1").arg(path.left(path.lastIndexOf("/"))));
|
||||||
process.waitForFinished();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,16 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key() == Qt::Key_Escape) {
|
||||||
|
this->hide();
|
||||||
|
m_search_result_thread->requestInterruption();
|
||||||
|
m_search_result_thread->quit();
|
||||||
|
}
|
||||||
|
return QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::paintEvent(QPaintEvent *event) {
|
void MainWindow::paintEvent(QPaintEvent *event) {
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
@ -345,6 +355,6 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
||||||
p.setOpacity(trans);
|
p.setOpacity(trans);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.drawRoundedRect(rect, 6, 6);
|
p.drawRoundedRect(rect, 6, 6);
|
||||||
QWidget::paintEvent(event);
|
return QWidget::paintEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QKeyEvent>
|
||||||
#include <QGSettings/QGSettings>
|
#include <QGSettings/QGSettings>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include "content-widget.h"
|
#include "content-widget.h"
|
||||||
|
@ -94,6 +95,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void initUi();
|
void initUi();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
|
@ -19,37 +19,37 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="585"/>
|
<location filename="../../src/content-widget.cpp" line="586"/>
|
||||||
<source>Apps</source>
|
<source>Apps</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="587"/>
|
<location filename="../../src/content-widget.cpp" line="588"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="589"/>
|
<location filename="../../src/content-widget.cpp" line="590"/>
|
||||||
<source>Files</source>
|
<source>Files</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="591"/>
|
<location filename="../../src/content-widget.cpp" line="592"/>
|
||||||
<source>Dirs</source>
|
<source>Dirs</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="593"/>
|
<location filename="../../src/content-widget.cpp" line="594"/>
|
||||||
<source>File Contents</source>
|
<source>File Contents</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="595"/>
|
<location filename="../../src/content-widget.cpp" line="596"/>
|
||||||
<source>Best Matches</source>
|
<source>Best Matches</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="597"/>
|
<location filename="../../src/content-widget.cpp" line="598"/>
|
||||||
<source>Unknown</source>
|
<source>Unknown</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -65,12 +65,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>MainWindow</name>
|
<name>MainWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="108"/>
|
<location filename="../../src/mainwindow.cpp" line="110"/>
|
||||||
<source>Global Search</source>
|
<source>Global Search</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="161"/>
|
<location filename="../../src/mainwindow.cpp" line="163"/>
|
||||||
<source>Search</source>
|
<source>Search</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/main.cpp" line="104"/>
|
<location filename="../../src/main.cpp" line="106"/>
|
||||||
<source>ukui-search is already running!</source>
|
<source>ukui-search is already running!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -122,12 +122,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>SearchDetailView</name>
|
<name>SearchDetailView</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
|
||||||
<source>Path</source>
|
<source>Path</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
|
||||||
<source>Last time modified</source>
|
<source>Last time modified</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -19,37 +19,37 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="585"/>
|
<location filename="../../src/content-widget.cpp" line="586"/>
|
||||||
<source>Apps</source>
|
<source>Apps</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="587"/>
|
<location filename="../../src/content-widget.cpp" line="588"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="589"/>
|
<location filename="../../src/content-widget.cpp" line="590"/>
|
||||||
<source>Files</source>
|
<source>Files</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="591"/>
|
<location filename="../../src/content-widget.cpp" line="592"/>
|
||||||
<source>Dirs</source>
|
<source>Dirs</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="593"/>
|
<location filename="../../src/content-widget.cpp" line="594"/>
|
||||||
<source>File Contents</source>
|
<source>File Contents</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="595"/>
|
<location filename="../../src/content-widget.cpp" line="596"/>
|
||||||
<source>Best Matches</source>
|
<source>Best Matches</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="597"/>
|
<location filename="../../src/content-widget.cpp" line="598"/>
|
||||||
<source>Unknown</source>
|
<source>Unknown</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -65,12 +65,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>MainWindow</name>
|
<name>MainWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="108"/>
|
<location filename="../../src/mainwindow.cpp" line="110"/>
|
||||||
<source>Global Search</source>
|
<source>Global Search</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="161"/>
|
<location filename="../../src/mainwindow.cpp" line="163"/>
|
||||||
<source>Search</source>
|
<source>Search</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/main.cpp" line="104"/>
|
<location filename="../../src/main.cpp" line="106"/>
|
||||||
<source>ukui-search is already running!</source>
|
<source>ukui-search is already running!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -122,12 +122,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>SearchDetailView</name>
|
<name>SearchDetailView</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
|
||||||
<source>Path</source>
|
<source>Path</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
|
||||||
<source>Last time modified</source>
|
<source>Last time modified</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -19,37 +19,37 @@
|
||||||
<translation>常用</translation>
|
<translation>常用</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="585"/>
|
<location filename="../../src/content-widget.cpp" line="586"/>
|
||||||
<source>Apps</source>
|
<source>Apps</source>
|
||||||
<translation>应用</translation>
|
<translation>应用</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="587"/>
|
<location filename="../../src/content-widget.cpp" line="588"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation>配置项</translation>
|
<translation>配置项</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="589"/>
|
<location filename="../../src/content-widget.cpp" line="590"/>
|
||||||
<source>Files</source>
|
<source>Files</source>
|
||||||
<translation>文件</translation>
|
<translation>文件</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="591"/>
|
<location filename="../../src/content-widget.cpp" line="592"/>
|
||||||
<source>Dirs</source>
|
<source>Dirs</source>
|
||||||
<translation>文件夹</translation>
|
<translation>文件夹</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="593"/>
|
<location filename="../../src/content-widget.cpp" line="594"/>
|
||||||
<source>File Contents</source>
|
<source>File Contents</source>
|
||||||
<translation>文件内容</translation>
|
<translation>文件内容</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="595"/>
|
<location filename="../../src/content-widget.cpp" line="596"/>
|
||||||
<source>Best Matches</source>
|
<source>Best Matches</source>
|
||||||
<translation>最佳匹配</translation>
|
<translation>最佳匹配</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/content-widget.cpp" line="597"/>
|
<location filename="../../src/content-widget.cpp" line="598"/>
|
||||||
<source>Unknown</source>
|
<source>Unknown</source>
|
||||||
<translation>未知</translation>
|
<translation>未知</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -65,14 +65,14 @@
|
||||||
<context>
|
<context>
|
||||||
<name>MainWindow</name>
|
<name>MainWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="108"/>
|
<location filename="../../src/mainwindow.cpp" line="110"/>
|
||||||
<source>Global Search</source>
|
<source>Global Search</source>
|
||||||
<translation type="unfinished">搜索</translation>
|
<translation type="unfinished">搜索</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/mainwindow.cpp" line="161"/>
|
<location filename="../../src/mainwindow.cpp" line="163"/>
|
||||||
<source>Search</source>
|
<source>Search</source>
|
||||||
<translation>从列表搜索</translation>
|
<translation>搜索</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/main.cpp" line="104"/>
|
<location filename="../../src/main.cpp" line="106"/>
|
||||||
<source>ukui-search is already running!</source>
|
<source>ukui-search is already running!</source>
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -122,12 +122,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>SearchDetailView</name>
|
<name>SearchDetailView</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
|
||||||
<source>Path</source>
|
<source>Path</source>
|
||||||
<translation>路径</translation>
|
<translation>路径</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
|
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
|
||||||
<source>Last time modified</source>
|
<source>Last time modified</source>
|
||||||
<translation>上次修改时间</translation>
|
<translation>上次修改时间</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Loading…
Reference in New Issue