feat(frontend): Adjust layout & controls for homepage.

Description: 根据最新需求调整主界面布局和快速打开应用

Log: 根据最新需求调整主界面布局和快速打开应用
This commit is contained in:
zhangjiaping 2021-03-02 17:22:26 +08:00
parent 87d70b4ae0
commit da0bce0e48
5 changed files with 20 additions and 11 deletions

View File

@ -28,8 +28,13 @@ ContentWidget::ContentWidget(QWidget * parent):QStackedWidget(parent)
{
initUI();
initListView();
// m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"Background/背景/更改壁纸";
m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/ksc-defender.desktop";
//快速入口应用列表
// m_quicklyOpenList<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/ksc-defender.desktop";
m_quicklyOpenList << "/usr/share/applications/ksc-defender.desktop"
<< "/usr/share/applications/ukui-notebook.desktop"
<< "/usr/share/applications/eom.desktop"
<< "/usr/share/applications/pluma.desktop"
<< "/usr/share/applications/claws-mail.desktop" ;
}
ContentWidget::~ContentWidget()
@ -353,9 +358,10 @@ void ContentWidget::initHomePage() {
commonlyList = map.value("Commonly");
QStringList recentlyList;
recentlyList = map.value("Recently");
lists.append(commonlyList);
lists.append(recentlyList);
lists.append(m_quicklyOpenList);
lists.append(recentlyList);
lists.append(commonlyList);
for (int i = 0; i < lists.count(); i++) {
if (lists.at(i).isEmpty())
@ -390,7 +396,7 @@ void ContentWidget::initHomePage() {
itemWidget->setLayout(layout);
int shownItem = lists.at(i).length();
Q_FOREACH(QString path, lists.at(i)){
if (i && QString::compare(FileUtils::getAppName(path),"Unknown App") == 0) {
if (i == 0 && QString::compare(FileUtils::getAppName(path),"Unknown App") == 0) {
shownItem --;
continue;
}
@ -403,7 +409,7 @@ void ContentWidget::initHomePage() {
emptyItem->setFixedSize(100, 100); //占位用widget,少于5项会补全后方占位
layout->addWidget(emptyItem);
}
if (i && shownItem) titleLabel->setText(tr("Open Quickly"));
if (i == 0 && shownItem) titleLabel->setText(tr("Open Quickly"));
else titleLabel->setText(tr("Commonly Used"));
}
itemWidgetLyt->setSpacing(6);

View File

@ -123,8 +123,9 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
} else if (type == ItemType::Quick) {
QIcon icon = FileUtils::getAppIcon(path);
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));
m_namelabel->setText(FileUtils::getAppName(path));
this->setToolTip(FileUtils::getAppName(path));
QString name = FileUtils::getAppName(path);
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, 96));
this->setToolTip(name);
} else {
QIcon icon = FileUtils::getAppIcon(path);
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));

View File

@ -36,9 +36,9 @@ public:
~HomePageItem();
enum ItemType { //homepage中item的类型包括常用应用、最近打开、快捷打开
Common,
Quick,
Recent,
Quick
Common
};
protected:

View File

@ -126,6 +126,7 @@ MainWindow::MainWindow(QWidget *parent) :
clearSearchResult();
this->moveToPanel();
this->show();
this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入
this->raise();
this->activateWindow();
}
@ -256,6 +257,7 @@ void MainWindow::bootOptionsFilter(QString opt)
clearSearchResult();
this->moveToPanel();
this->show();
this->m_searchLayout->focusIn();
this->raise();
this->activateWindow();
// m_search_result_thread->start();

View File

@ -11,7 +11,7 @@
<message>
<location filename="../../src/content-widget.cpp" line="406"/>
<source>Open Quickly</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="407"/>