Merge pull request #98 from mammonsama666/optimize

fix(frontend): Optimize code for frontend.
This commit is contained in:
iaom 2021-01-21 15:06:12 +08:00 committed by GitHub
commit 6a8afe8258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 59 deletions

View File

@ -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:

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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>

View File

@ -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>

View File

@ -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>