forked from openkylin/ukui-search
Merge pull request #82 from mammonsama666/0114-fix
fix(frontend): Fix ui bugs for detail widget.
This commit is contained in:
commit
49083ae0ae
|
@ -111,11 +111,12 @@ QIcon FileUtils::getSettingIcon(const QString& setting, const bool& is_white) {
|
|||
if (file.exists()) {
|
||||
return QIcon(path);
|
||||
} else {
|
||||
if (is_white) {
|
||||
return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1White.svg").arg("About"));
|
||||
} else {
|
||||
return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1.svg").arg("About"));
|
||||
}
|
||||
return QIcon::fromTheme("ukui-control-center"); //无插件图标时,返回控制面板应用图标
|
||||
// if (is_white) {
|
||||
// return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1White.svg").arg("About"));
|
||||
// } else {
|
||||
// return QIcon(QString("/usr/share/ukui-control-center/shell/res/secondaryleftmenu/%1.svg").arg("About"));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -364,8 +364,11 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, const
|
|||
m_contentListView->appendItem(path);
|
||||
m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->rowheight);
|
||||
QString temp;
|
||||
for (auto s : contents){
|
||||
temp.append(s);
|
||||
for (int i = 0; i < contents.length(); i ++) {
|
||||
temp.append(contents.at(i));
|
||||
if (i != contents.length() - 1) {
|
||||
temp.append("\n");
|
||||
}
|
||||
}
|
||||
m_contentList.append(temp);
|
||||
return;
|
||||
|
|
|
@ -22,6 +22,7 @@ SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent)
|
|||
m_layout->setContentsMargins(16, 60, 16, 24);
|
||||
this->setObjectName("detailView");
|
||||
this->setStyleSheet("QWidget#detailView{background:transparent;}");
|
||||
this->setFixedWidth(360);
|
||||
}
|
||||
|
||||
SearchDetailView::~SearchDetailView()
|
||||
|
@ -136,8 +137,8 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
|
|||
QLabel * pathLabel_1 = new QLabel(pathFrame);
|
||||
QLabel * pathLabel_2 = new QLabel(pathFrame);
|
||||
pathLabel_1->setText(tr("Path"));
|
||||
pathLabel_2->setFixedWidth(240);
|
||||
pathLabel_2->setText(path);
|
||||
pathLabel_2->setMaximumWidth(500);
|
||||
pathLabel_2->setWordWrap(true);
|
||||
pathLyt->addWidget(pathLabel_1);
|
||||
pathLyt->addStretch();
|
||||
|
@ -176,7 +177,9 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
|
|||
case SearchListView::ResType::App : {
|
||||
QIcon icon = FileUtils::getAppIcon(path);
|
||||
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
|
||||
nameLabel->setText(FileUtils::getAppName(path));
|
||||
QFontMetrics fontMetrics = nameLabel->fontMetrics();
|
||||
QString name = fontMetrics.elidedText(FileUtils::getAppName(path), Qt::ElideRight, 215); //当字体长度超过215时显示为省略号
|
||||
nameLabel->setText(name);
|
||||
typeLabel->setText(tr("Application"));
|
||||
break;
|
||||
}
|
||||
|
@ -185,7 +188,9 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
|
|||
case SearchListView::ResType::File : {
|
||||
QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
|
||||
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
|
||||
nameLabel->setText(FileUtils::getFileName(path));
|
||||
QFontMetrics fontMetrics = nameLabel->fontMetrics();
|
||||
QString name = fontMetrics.elidedText(FileUtils::getFileName(path), Qt::ElideRight, 215);
|
||||
nameLabel->setText(name);
|
||||
typeLabel->setText(tr("Document"));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -163,12 +163,7 @@ void MainWindow::initUi()
|
|||
"QPushButton:hover:!pressed{background: transparent;}");
|
||||
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
if (m_settingsWidget) { //当此窗口已存在时,仅需置顶
|
||||
Qt::WindowFlags flags = m_settingsWidget->windowFlags();
|
||||
flags |= Qt::WindowStaysOnTopHint;
|
||||
m_settingsWidget->setWindowFlags(flags);
|
||||
flags &= ~Qt::WindowStaysOnTopHint;
|
||||
m_settingsWidget->setWindowFlags(flags);
|
||||
m_settingsWidget->show();
|
||||
m_settingsWidget->showWidget();
|
||||
return;
|
||||
}
|
||||
m_settingsWidget = new SettingsWidget();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QDebug>
|
||||
#include "folder-list-item.h"
|
||||
#include "global-settings.h"
|
||||
#include "file-utils.h"
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
|
||||
|
@ -13,12 +14,12 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
|
|||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
initUi();
|
||||
refreshIndexState();
|
||||
setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
|
||||
}
|
||||
|
||||
SettingsWidget::~SettingsWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,6 +51,7 @@ void SettingsWidget::initUi() {
|
|||
"QPushButton:hover:!pressed{background: transparent;}");
|
||||
connect(m_closeBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
Q_EMIT this->settingWidgetClosed();
|
||||
m_timer->stop();
|
||||
this->close();
|
||||
});
|
||||
m_titleLyt->addWidget(m_titleIcon);
|
||||
|
@ -202,6 +204,21 @@ void SettingsWidget::clearLayout(QLayout * layout) {
|
|||
child = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsWidget::refreshIndexState 定时刷新索引项
|
||||
*/
|
||||
void SettingsWidget::refreshIndexState()
|
||||
{
|
||||
m_indexStateLabel->setText(QString::number(FileUtils::_index_status));
|
||||
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count)));
|
||||
m_timer = new QTimer;
|
||||
connect(m_timer, &QTimer::timeout, this, [ = ]() {
|
||||
m_indexStateLabel->setText(QString::number(FileUtils::_index_status));
|
||||
m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count)));
|
||||
});
|
||||
m_timer->start(0.5 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsWidget::onBtnDelClicked 删除黑名单中的目录
|
||||
* @param path 文件夹路径
|
||||
|
@ -244,11 +261,26 @@ void SettingsWidget::setIndexNum(int num) {
|
|||
m_indexNumLabel->setText(QString(tr("Index Entry: %1")).arg(QString::number(num)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsWidget::showWidget 显示此窗口
|
||||
*/
|
||||
void SettingsWidget::showWidget()
|
||||
{
|
||||
Qt::WindowFlags flags = this->windowFlags();
|
||||
flags |= Qt::WindowStaysOnTopHint;
|
||||
this->setWindowFlags(flags);
|
||||
flags &= ~Qt::WindowStaysOnTopHint;
|
||||
this->setWindowFlags(flags);
|
||||
m_timer->start();
|
||||
this->show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsWidget::onBtnConfirmClicked 点击确认按钮的槽函数
|
||||
*/
|
||||
void SettingsWidget::onBtnConfirmClicked() {
|
||||
Q_EMIT this->settingWidgetClosed();
|
||||
m_timer->stop();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
@ -257,6 +289,7 @@ void SettingsWidget::onBtnConfirmClicked() {
|
|||
*/
|
||||
void SettingsWidget::onBtnCancelClicked() {
|
||||
Q_EMIT this->settingWidgetClosed();
|
||||
m_timer->stop();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QButtonGroup>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QTimer>
|
||||
|
||||
class SettingsWidget : public QWidget
|
||||
{
|
||||
|
@ -20,11 +21,13 @@ public:
|
|||
|
||||
void setIndexState(bool);
|
||||
void setIndexNum(int);
|
||||
void showWidget();
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void setupBlackList(const QStringList &);
|
||||
void clearLayout(QLayout *);
|
||||
void refreshIndexState();
|
||||
void paintEvent(QPaintEvent *);
|
||||
//标题栏
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
|
@ -69,6 +72,8 @@ private:
|
|||
QPushButton * m_cancelBtn = nullptr;
|
||||
QPushButton * m_confirmBtn = nullptr;
|
||||
|
||||
QTimer * m_timer;
|
||||
|
||||
Q_SIGNALS:
|
||||
void settingWidgetClosed();
|
||||
|
||||
|
|
Loading…
Reference in New Issue