Merge pull request #178 from mammonsama666/0316-dev

fix bugs
This commit is contained in:
iaom 2021-03-16 16:57:33 +08:00 committed by GitHub
commit 941435ed6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 31 deletions

View File

@ -26,11 +26,18 @@
#include <QPainter>
#include <QDesktopServices>
#include <QUrl>
#include <QApplication>
HomePageItem::HomePageItem(QWidget *parent, const int& type, const QString& path) : QWidget(parent)
{
setupUi(type, path);
m_transparency = 0.06;
connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
if (m_namelabel) {
QString name = this->toolTip();
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 108));
}
});
}
HomePageItem::~HomePageItem()
@ -74,7 +81,6 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
});
m_iconlabel = new QLabel(m_widget);
m_namelabel = new QLabel(m_widget);
m_namelabel->setStyleSheet("QLabel{color: palette(text);}");
if (type == ItemType::Recent) {
m_widget->setFixedSize(300, 48);
QIcon icon;
@ -148,20 +154,20 @@ bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
if (watched == m_widget){
if (event->type() == QEvent::MouseButtonPress) {
m_transparency = 0.06;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::MouseButtonRelease) {
Q_EMIT this->onItemClicked();
m_transparency = 0.06;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::Enter) {
m_transparency = 0.15;
this->repaint();
this->update();
return true;
} else if (event->type() == QEvent::Leave) {
m_transparency = 0.06;
this->repaint();
this->update();
return true;
}
}
@ -171,12 +177,10 @@ bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
void HomePageItem::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Text));

View File

@ -90,6 +90,11 @@ MainWindow::MainWindow(QWidget *parent) :
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) {
this->setPalette(pal);
this->update();
Q_FOREACH (QWidget *widget, this->findChildren<QWidget *>()) {
if (widget) {
widget->update();
}
}
});
m_search_result_file = new QQueue<QString>;
@ -163,7 +168,6 @@ void MainWindow::initUi()
QVBoxLayout * mainlayout = new QVBoxLayout(m_frame);
mainlayout->setContentsMargins(8, 0, 8, 6);
m_frame->setLayout(mainlayout);
m_frame->setStyleSheet("QLabel{color: palette(text);}");
m_titleFrame = new QFrame(m_frame);//标题栏
m_titleFrame->setFixedHeight(40);
@ -190,8 +194,7 @@ void MainWindow::initUi()
m_settingsWidget->show();
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
QTimer::singleShot(100, this, [ = ] {
clearSearchResult();
// m_search_result_thread->start();
// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
this->raise();
this->showNormal();
@ -329,7 +332,7 @@ void MainWindow::moveToPanel()
"/org/ukui/SettingsDaemon/wayland",
"org.ukui.SettingsDaemon.wayland",
QDBusConnection::sessionBus());
if (primaryScreenInterface.isValid()) {
if (QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
QDBusReply<int> x = primaryScreenInterface.call("x");
QDBusReply<int> width = primaryScreenInterface.call("width");
QDBusReply<int> height = primaryScreenInterface.call("height");

View File

@ -286,7 +286,7 @@ void SettingsWidget::refreshIndexState()
void SettingsWidget::onBtnDelClicked(const QString& path) {
QMessageBox message(QMessageBox::Question, tr("Search"), tr("Whether to delete this directory?"));
QPushButton * buttonYes = message.addButton(tr("Yes"), QMessageBox::YesRole);
QPushButton * buttonNo = message.addButton(tr("No"), QMessageBox::NoRole);
message.addButton(tr("No"), QMessageBox::NoRole);
message.exec();
if (message.clickedButton() != buttonYes) {
return;
@ -517,6 +517,7 @@ void SettingsWidget::showWarningDialog(const int & errorCode)
break;
}
}
QMessageBox message(QMessageBox::Warning, tr("Search"), errorMessage, QMessageBox::Ok, this);
QMessageBox message(QMessageBox::Warning, tr("Search"), errorMessage);
message.addButton(tr("OK"), QMessageBox::AcceptRole);
message.exec();
}

View File

@ -121,7 +121,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="171"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation type="unfinished"></translation>
</message>
@ -137,27 +137,27 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="490"/>
<location filename="../../src/control/search-detail-view.cpp" line="494"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="498"/>
<location filename="../../src/control/search-detail-view.cpp" line="502"/>
<source>Last time modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="216"/>
<location filename="../../src/control/search-detail-view.cpp" line="220"/>
<source>Application</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="197"/>
<location filename="../../src/control/search-detail-view.cpp" line="201"/>
<source>Introduction: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="335"/>
<location filename="../../src/control/search-detail-view.cpp" line="339"/>
<source>Document</source>
<translation type="unfinished"></translation>
</message>
@ -317,6 +317,11 @@
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="521"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowMoreLabel</name>

View File

@ -121,7 +121,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="171"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation>ukui-bul zaten çalışıyor!</translation>
</message>
@ -137,27 +137,27 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="490"/>
<location filename="../../src/control/search-detail-view.cpp" line="494"/>
<source>Path</source>
<translation>Yol</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="498"/>
<location filename="../../src/control/search-detail-view.cpp" line="502"/>
<source>Last time modified</source>
<translation>Son değiştirilme zamanı</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="216"/>
<location filename="../../src/control/search-detail-view.cpp" line="220"/>
<source>Application</source>
<translation>Uygulama</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="197"/>
<location filename="../../src/control/search-detail-view.cpp" line="201"/>
<source>Introduction: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="335"/>
<location filename="../../src/control/search-detail-view.cpp" line="339"/>
<source>Document</source>
<translation>Belge</translation>
</message>
@ -321,6 +321,11 @@
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="521"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowMoreLabel</name>

View File

@ -121,7 +121,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="171"/>
<location filename="../../src/main.cpp" line="182"/>
<source>ukui-search is already running!</source>
<translation></translation>
</message>
@ -137,27 +137,27 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="490"/>
<location filename="../../src/control/search-detail-view.cpp" line="494"/>
<source>Path</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="498"/>
<location filename="../../src/control/search-detail-view.cpp" line="502"/>
<source>Last time modified</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="216"/>
<location filename="../../src/control/search-detail-view.cpp" line="220"/>
<source>Application</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="197"/>
<location filename="../../src/control/search-detail-view.cpp" line="201"/>
<source>Introduction: %1</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="335"/>
<location filename="../../src/control/search-detail-view.cpp" line="339"/>
<source>Document</source>
<translation></translation>
</message>
@ -272,6 +272,11 @@
<source>Set blocked folder failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="521"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="../../src/settings-widget.cpp" line="348"/>
<source>Creating ...</source>