chore: update changelog
This commit is contained in:
parent
9bdaae3dfa
commit
c08f62dfb3
|
@ -1,3 +1,12 @@
|
|||
ukui-control-center (3.22.1.25-ok13) yangtze; urgency=medium
|
||||
|
||||
* bug#无
|
||||
* 需求:无
|
||||
* 任务:重新编译代码,回退sdk搜索框
|
||||
* 其他改动:无
|
||||
|
||||
-- zhoubin <zhoubin@kylinos.cn> Mon, 03 Apr 2023 16:34:37 +0800
|
||||
|
||||
ukui-control-center (3.22.1.25-ok12) yangtze; urgency=medium
|
||||
|
||||
* bug#无
|
||||
|
|
|
@ -106,13 +106,6 @@ int main(int argc, char *argv[])
|
|||
translator.load("/usr/share/ukui-control-center/shell/res/i18n/" + QLocale::system().name());
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// sdk翻译加载
|
||||
QTranslator trans;
|
||||
if(trans.load(":/translations/gui_"+QLocale::system().name()+".qm"))
|
||||
{
|
||||
a.installTranslator(&trans);
|
||||
}
|
||||
|
||||
// 命令行参数
|
||||
QCoreApplication::setApplicationName(QObject::tr("ukui-control-center"));
|
||||
QCoreApplication::setApplicationVersion("2.0");
|
||||
|
|
|
@ -183,8 +183,22 @@ void MainWindow::bootOptionsFilter(QString opt, bool firstIn) {
|
|||
}
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event) {
|
||||
/* clear m_searchWidget's focus
|
||||
* MouseButtonPress event happened but not in m_searchWidget
|
||||
*/
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
QMouseEvent *mEvent = static_cast<QMouseEvent*>(event);
|
||||
QWidget *searchParentWid = static_cast<QWidget*>(m_searchWidget->parent());
|
||||
QPoint searchPoint = searchParentWid->mapFromGlobal(mEvent->globalPos());
|
||||
//qDebug()<<m_searchWidget->geometry()<< mWindowGlobalPoint << mouseGlobalPoint << tPoint;
|
||||
if (!m_searchWidget->geometry().contains(searchPoint)) {
|
||||
if (m_isSearching == true) {
|
||||
m_searchWidget->setFocus();
|
||||
m_searchWidget->clearFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (watched == scrollArea) {
|
||||
if (!Common::isTablet()) {
|
||||
if (event->type() == QEvent::Enter) {
|
||||
|
@ -212,6 +226,33 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (watched == m_searchWidget) {
|
||||
if (event->type() == QEvent::FocusIn) {
|
||||
if (m_searchWidget->text().isEmpty()) {
|
||||
m_animation->stop();
|
||||
m_queryWid->layout()->removeWidget(m_queryText);
|
||||
m_animation->setStartValue(m_queryWid->pos());
|
||||
if (m_queryWid->pos().x() > 20) {
|
||||
queryWidCenterPos = QPoint(m_queryWid->pos());
|
||||
}
|
||||
m_animation->setEndValue(QPoint(8,0));
|
||||
m_animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
m_animation->start();
|
||||
}
|
||||
m_isSearching = true;
|
||||
} else if (event->type() == QEvent::FocusOut) {
|
||||
m_searchKeyWords.clear();
|
||||
if (m_searchWidget->text().isEmpty()) {
|
||||
if (m_isSearching) {
|
||||
m_animation->setStartValue(m_queryWid->pos());
|
||||
m_animation->setEndValue(queryWidCenterPos);
|
||||
m_animation->setEasingCurve(QEasingCurve::InQuad);
|
||||
m_animation->start();
|
||||
m_queryWid->layout()->addWidget(m_queryText);
|
||||
}
|
||||
}
|
||||
m_isSearching = false;
|
||||
}
|
||||
} else if (watched == homepageWidget) {
|
||||
if (event->type() == QEvent::Paint) {
|
||||
QTimer::singleShot(1, this, [=]() {
|
||||
|
@ -330,7 +371,6 @@ void MainWindow::initUI() {
|
|||
homepageWidget = new HomePageWidget(this);
|
||||
homepageWidget->installEventFilter(this);
|
||||
ui->stackedWidget->addWidget(homepageWidget);
|
||||
ui->stackedWidget->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
//加载左侧边栏一级菜单
|
||||
initLeftsideBar();
|
||||
|
@ -422,8 +462,43 @@ void MainWindow::initTileBar() {
|
|||
titleLayout->setContentsMargins(8, 2, 5, 2);
|
||||
titleLayout->setSpacing(0);
|
||||
m_searchWidget = new SearchWidget(this);
|
||||
m_searchWidget->setFocusPolicy(Qt::ClickFocus);
|
||||
m_searchWidget->setTextMargins(30, 1, 0, 1);
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout(m_searchWidget);
|
||||
searchLayout->setMargin(0);
|
||||
|
||||
m_queryWid = new QWidget;
|
||||
searchLayout->addWidget(m_queryWid);
|
||||
searchLayout->setAlignment(m_queryWid, Qt::AlignHCenter);
|
||||
searchLayout->setContentsMargins(8, 0, 0, 0);
|
||||
m_queryWid->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QHBoxLayout* queryWidLayout = new QHBoxLayout;
|
||||
queryWidLayout->setContentsMargins(0, 0, 0, 0);
|
||||
queryWidLayout->setAlignment(Qt::AlignJustify);
|
||||
queryWidLayout->setSpacing(0);
|
||||
m_queryWid->setLayout(queryWidLayout);
|
||||
|
||||
QIcon searchIcon = QIcon::fromTheme("search-symbolic");
|
||||
m_queryIcon = new QLabel(this);
|
||||
m_queryIcon->setScaledContents(true);
|
||||
m_queryIcon->setPixmap(searchIcon.pixmap(QSize(16, 16)));
|
||||
m_queryIcon->setFixedSize(QSize(16, 16));
|
||||
|
||||
m_queryIcon->setProperty("useIconHighlightEffect",0x02);
|
||||
|
||||
m_queryText = new QLabel(this);
|
||||
m_queryText->setText(tr("Search"));
|
||||
reLoadText();
|
||||
|
||||
queryWidLayout->addWidget(m_queryIcon);
|
||||
queryWidLayout->addWidget(m_queryText);
|
||||
|
||||
m_searchWidget->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_animation = new QPropertyAnimation(m_queryWid, "pos", this);
|
||||
m_animation->setDuration(100);
|
||||
titleLayout->addWidget(m_searchWidget,Qt::AlignCenter);
|
||||
connect(m_animation,&QPropertyAnimation::finished,this,&MainWindow::animationFinishedSlot);
|
||||
|
||||
connect(m_searchWidget, &SearchWidget::notifyModuleSearch, this, &MainWindow::switchPage);
|
||||
|
||||
|
@ -489,6 +564,17 @@ void MainWindow::initTileBar() {
|
|||
|
||||
initUkccAbout();
|
||||
}
|
||||
void MainWindow::animationFinishedSlot()
|
||||
{
|
||||
if (m_isSearching) {
|
||||
m_searchWidget->layout()->setAlignment(m_queryWid, Qt::AlignLeft);
|
||||
} else if (!m_searchKeyWords.isEmpty()){
|
||||
m_searchWidget->setText(m_searchKeyWords);
|
||||
m_searchKeyWords.clear();
|
||||
} else {
|
||||
m_searchWidget->layout()->setAlignment(m_queryWid, Qt::AlignHCenter);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mainWindow_statusDbusSlot(bool tablet_mode)
|
||||
{
|
||||
|
@ -858,6 +944,7 @@ QPushButton * MainWindow::buildLeftsideBtn(QString bname,QString tipName, QIcon
|
|||
|
||||
connect(qtSettings, &QGSettings::changed, this, [=,&hoverColor](const QString &key) {
|
||||
if (key == "styleName") {
|
||||
reLoadText();
|
||||
iconBtn->reLoadIcon();
|
||||
hoverColor = this->pluginBtnHoverColor(qtSettings->get("style-name").toString(), true);
|
||||
clickColor = pluginBtnHoverColor(qtSettings->get("style-name").toString(), false);
|
||||
|
@ -1078,6 +1165,26 @@ void MainWindow::hideComponent()
|
|||
});
|
||||
}
|
||||
|
||||
void MainWindow::reLoadText()
|
||||
{
|
||||
QGSettings *qtSettings = nullptr;
|
||||
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
|
||||
qtSettings = new QGSettings("org.ukui.style", QByteArray(), this);
|
||||
} else {
|
||||
m_queryText->setStyleSheet("background:transparent;color:#626c6e;");
|
||||
return;
|
||||
}
|
||||
|
||||
if (qtSettings->get("style-name").toString() == "ukui-dark") {
|
||||
m_queryText->setStyleSheet("");
|
||||
m_queryText->setProperty("useIconHighlightEffect",0x02);
|
||||
} else {
|
||||
m_queryText->setStyleSheet("background:transparent;color:#626c6e;");
|
||||
}
|
||||
delete qtSettings;
|
||||
qtSettings = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::setModuleBtnHightLight(int id) {
|
||||
leftBtnGroup->button(id)->setChecked(true);
|
||||
leftMicBtnGroup->button(id)->setChecked(true);
|
||||
|
|
|
@ -102,6 +102,12 @@ private:
|
|||
QIcon m_titleIcon;
|
||||
QLabel *mLogoSetLabel;
|
||||
QTimer *timer;
|
||||
QLabel *m_queryIcon;
|
||||
QLabel *m_queryText = nullptr;
|
||||
QPropertyAnimation *m_animation = nullptr;
|
||||
QWidget *m_queryWid = nullptr;
|
||||
bool m_isSearching = false;
|
||||
QString m_searchKeyWords;
|
||||
QStringList m_updatePlugins;
|
||||
QVariantMap m_ModuleMap;
|
||||
QGSettings *m_fontSetting;
|
||||
|
@ -109,6 +115,7 @@ private:
|
|||
|
||||
QHBoxLayout *titleLayout;
|
||||
KNavigationBar *scrollArea = nullptr;
|
||||
QPoint queryWidCenterPos = QPoint(0,0);
|
||||
|
||||
QDBusInterface *m_statusSessionDbus;
|
||||
bool is_tabletmode;
|
||||
|
@ -134,12 +141,14 @@ private:
|
|||
void changeSearchSlot();
|
||||
void showGuide(QString pluName);
|
||||
void hideComponent();
|
||||
void reLoadText();
|
||||
|
||||
public slots:
|
||||
void pluginBtnClicked(QObject * plugin);
|
||||
void functionBtnClicked(QObject * plugin, QString jumpText = "");
|
||||
void sltMessageReceived(const QString &msg);
|
||||
void switchPage(QString moduleName, QString jumpMoudle, QString jumpText = "");
|
||||
void animationFinishedSlot();
|
||||
void mainWindow_statusDbusSlot(bool tablet_mode);
|
||||
void initUkccAbout();
|
||||
void onF1ButtonClicked();
|
||||
|
|
|
@ -30,8 +30,116 @@ const QStringList filterPathList = { "/Display/Auto Brightness", "/Display/Dynam
|
|||
|
||||
const QStringList openkylinFilterPathList = {"/Shortcut/Add", "/Shortcut/Customize Shortcut"};
|
||||
|
||||
|
||||
class ukCompleter : public QCompleter
|
||||
{
|
||||
public:
|
||||
ukCompleter(QAbstractItemModel *model, QObject *parent = nullptr)
|
||||
: QCompleter(model, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool eventFilter(QObject *o, QEvent *e) override;
|
||||
};
|
||||
|
||||
ListViewDelegate::ListViewDelegate(QObject *parent):QStyledItemDelegate(parent)
|
||||
{
|
||||
const QByteArray style_id("org.ukui.style");
|
||||
mgsetting = new QGSettings(style_id, QByteArray(), this);
|
||||
}
|
||||
|
||||
|
||||
void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QRect rect;
|
||||
rect.setX(option.rect.x());
|
||||
rect.setY(option.rect.y());
|
||||
rect.setWidth(option.rect.width());
|
||||
rect.setHeight(option.rect.height());
|
||||
|
||||
const qreal radius = 6;
|
||||
QPainterPath path;
|
||||
path.moveTo(rect.topRight() - QPointF(radius, 0));
|
||||
path.lineTo(rect.topLeft() + QPointF(radius, 0));
|
||||
path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius));
|
||||
path.lineTo(rect.bottomLeft() + QPointF(0, -radius));
|
||||
path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0));
|
||||
path.lineTo(rect.bottomRight() - QPointF(radius, 0));
|
||||
path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
|
||||
path.lineTo(rect.topRight() + QPointF(0, radius));
|
||||
path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
QColor color = Qt::transparent;
|
||||
QColor fontColor = qApp->palette().color(QPalette::ButtonText);
|
||||
|
||||
bool g_themeFlag = false;
|
||||
if(mgsetting && mgsetting->keys().contains("styleName")) {
|
||||
QString styleName = mgsetting->get("styleName").toString();
|
||||
if(styleName == "ukui-dark" || styleName == "ukui-black") {
|
||||
g_themeFlag = true;
|
||||
} else {
|
||||
g_themeFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!g_themeFlag){
|
||||
if(!(option.state & QStyle::State_Enabled)) {
|
||||
color=QColor("#FFB3B3B3");
|
||||
} else if(((option.state & QStyle::State_HasFocus) || (option.state & QStyle::State_Selected)|| (option.state & QStyle::State_MouseOver))) {
|
||||
if(option.state.testFlag(QStyle::State_HasFocus) && option.state.testFlag(QStyle::State_Selected)) {//QStyle::State_Enabled
|
||||
color = option.palette.highlight().color();
|
||||
} else if((option.state & QStyle::State_MouseOver)) {
|
||||
color = option.palette.highlight().color();
|
||||
fontColor = QColor(255,255,255);
|
||||
} else {
|
||||
color = option.palette.windowText().color();
|
||||
color.setAlphaF(0.05);
|
||||
}
|
||||
painter->save();
|
||||
painter->setPen(QPen(Qt::NoPen));
|
||||
painter->setBrush(color);
|
||||
painter->drawPath(path);
|
||||
painter->restore();
|
||||
}
|
||||
} else {
|
||||
|
||||
if(!(option.state & QStyle::State_Enabled)) {
|
||||
color=QColor("#FFB3B3B3");
|
||||
} else if(((option.state & QStyle::State_HasFocus) || (option.state & QStyle::State_Selected)|| (option.state & QStyle::State_MouseOver))) {
|
||||
if(option.state.testFlag(QStyle::State_HasFocus) && option.state.testFlag(QStyle::State_Selected)) { //QStyle::State_Enabled
|
||||
color = option.palette.highlight().color();
|
||||
} else if((option.state & QStyle::State_MouseOver)) {
|
||||
color = option.palette.highlight().color();
|
||||
fontColor = QColor(255,255,255);
|
||||
} else {
|
||||
color = option.palette.windowText().color();
|
||||
color.setAlphaF(0.15);
|
||||
}
|
||||
painter->save();
|
||||
painter->setPen(QPen(Qt::NoPen));
|
||||
painter->setBrush(color);
|
||||
painter->drawPath(path);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(fontColor);
|
||||
painter->setPen(pen);
|
||||
auto str = index.model()->data(index,Qt::DisplayRole).toString();
|
||||
painter->drawText(rect.adjusted(12,0,0,0),Qt::AlignLeft|Qt::AlignVCenter,str);
|
||||
}
|
||||
|
||||
QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
return QSize(option.widget->width(),36);
|
||||
}
|
||||
|
||||
|
||||
SearchWidget::SearchWidget(QWidget *parent)
|
||||
: KSearchLineEdit(parent)
|
||||
: QLineEdit(parent)
|
||||
, m_xmlExplain("")
|
||||
, m_bIsChinese(false)
|
||||
, m_searchValue("")
|
||||
|
@ -39,15 +147,17 @@ SearchWidget::SearchWidget(QWidget *parent)
|
|||
{
|
||||
initExcludeSearch();
|
||||
m_model = new QStandardItemModel(this);
|
||||
m_completer = this->completer();
|
||||
this->completer()->setModel(m_model);
|
||||
m_completer = new ukCompleter(m_model, this);
|
||||
QAbstractItemView *popup = m_completer->popup();
|
||||
this->reloadStyle();
|
||||
m_pListViewDelegate = new ListViewDelegate(popup);
|
||||
popup->setItemDelegate(m_pListViewDelegate);
|
||||
m_completer->popup()->setAttribute(Qt::WA_InputMethodEnabled);
|
||||
m_completer->setFilterMode(Qt::MatchContains);//设置QCompleter支持匹配字符搜索
|
||||
m_completer->setCaseSensitivity(Qt::CaseInsensitive);//这个属性可设置进行匹配时的大小写敏感性
|
||||
m_completer->setCompletionRole(Qt::UserRole); //设置ItemDataRole
|
||||
this->setCompleter(m_completer);
|
||||
m_completer->setWrapAround(false);
|
||||
m_completer->installEventFilter(this);
|
||||
|
||||
connect(this, &QLineEdit::textEdited, this, [ = ] {
|
||||
if (text() != "") {
|
||||
|
@ -60,6 +170,7 @@ SearchWidget::SearchWidget(QWidget *parent)
|
|||
connect(this, &QLineEdit::textChanged, this, [ = ] {
|
||||
QString retValue = text();
|
||||
|
||||
|
||||
if (popup->model()->rowCount() == 0) {
|
||||
if (m_model->data(m_model->index(m_model->rowCount() - 1, 0)) != tr("No search results"))
|
||||
m_model->appendRow(new QStandardItem(tr("No search results")));
|
||||
|
@ -593,3 +704,44 @@ void SearchWidget::onCompleterActivated(QString value) {
|
|||
qDebug() << Q_FUNC_INFO << value;
|
||||
Q_EMIT returnPressed();
|
||||
}
|
||||
|
||||
bool ukCompleter::eventFilter(QObject *o, QEvent *e) {
|
||||
if (e->type() == QEvent::FocusOut) {
|
||||
return QCompleter::eventFilter(o, e);
|
||||
}
|
||||
|
||||
if (e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
|
||||
QModelIndex keyIndex;
|
||||
switch (ke->key()) {
|
||||
case Qt::Key_Up: {
|
||||
if (popup()->currentIndex().row() == 0) {
|
||||
keyIndex = popup()->model()->index(popup()->model()->rowCount() - 1, 0);
|
||||
popup()->setCurrentIndex(keyIndex);
|
||||
} else {
|
||||
keyIndex = popup()->model()->index(popup()->currentIndex().row() - 1, 0);
|
||||
popup()->setCurrentIndex(keyIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Qt::Key_Down: {
|
||||
if (popup()->currentIndex().row() == popup()->model()->rowCount() - 1) {
|
||||
keyIndex = popup()->model()->index(0, 0);
|
||||
popup()->setCurrentIndex(keyIndex);
|
||||
} else {
|
||||
keyIndex = popup()->model()->index(popup()->currentIndex().row() + 1, 0);
|
||||
popup()->setCurrentIndex(keyIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Qt::Key_Enter: {
|
||||
if (popup()->isVisible() && !popup()->currentIndex().isValid()) {
|
||||
keyIndex = popup()->model()->index(0, 0);
|
||||
popup()->setCurrentIndex(keyIndex);
|
||||
}
|
||||
popup()->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QCompleter::eventFilter(o, e);
|
||||
}
|
||||
|
|
|
@ -21,15 +21,26 @@
|
|||
#include <QPainterPath>
|
||||
|
||||
#include <kysdk/kysdk-system/libkysysinfo.h>
|
||||
#include "ksearchlineedit.h"
|
||||
using namespace kdk;
|
||||
|
||||
const QString XML_Source = "source";
|
||||
const QString XML_Title = "translation";
|
||||
const QString XML_Numerusform = "numerusform";
|
||||
const QString XML_Explain_Path = "extra-contents_path";
|
||||
|
||||
class SearchWidget : public KSearchLineEdit
|
||||
class ListViewDelegate:public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
ListViewDelegate(QObject*parent);
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
QGSettings *mgsetting = nullptr;
|
||||
};
|
||||
|
||||
class SearchWidget : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -89,5 +100,6 @@ private:
|
|||
|
||||
QStringList mExcludeList;
|
||||
int count;
|
||||
ListViewDelegate *m_pListViewDelegate;
|
||||
};
|
||||
#endif // SEARCHWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue