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