chore: sync code of 3.22

This commit is contained in:
zhoubin 2023-04-03 14:31:43 +08:00
parent f72638a887
commit 3ae4dedcac
13 changed files with 237 additions and 408 deletions

View File

@ -112,7 +112,9 @@ void Boot::setGrubPasswd(QString pwd, bool isOpen)
{
inhibit("shutdown", "com.control.center.qt.systemdbus", "update-grub", "block");
bootWidget->grubSwitchButton()->setEnabled(false);
QDBusPendingCall call = bootDbus->asyncCall("setGrupPasswd", "root", pwd, isOpen);
bootWidget->resetButton()->setEnabled(false);
QString lang = qgetenv("LANG");
QDBusPendingCall call = bootDbus->asyncCall("setGrupPasswd", "root", pwd, lang, isOpen);
if (!call.isValid()) {
qCritical() << "setGrupPasswd";
}
@ -140,6 +142,7 @@ void Boot::setGrubPasswd(QString pwd, bool isOpen)
}
}
bootWidget->grubSwitchButton()->setEnabled(true);
bootWidget->resetButton()->setEnabled(true);
});
}
@ -180,9 +183,12 @@ void Boot::resetPasswdSlot()
{
GrubVerify *dia = new GrubVerify(bootWidget);
QPushButton *confirmBtn = dia->getConfirmBtn();
QString lang = qgetenv("LANG");
connect(confirmBtn, &QPushButton::clicked, this, [=](){
inhibit("shutdown", "com.control.center.qt.systemdbus", "update-grub", "block");
QDBusPendingCall call = bootDbus->asyncCall("setGrupPasswd", "root", dia->getPwd(), true);
bootWidget->grubSwitchButton()->setEnabled(false);
bootWidget->resetButton()->setEnabled(false);
QDBusPendingCall call = bootDbus->asyncCall("setGrupPasswd", "root", dia->getPwd(), lang, true);
if (!call.isValid()) {
qCritical() << "setGrupPasswd";
}
@ -202,6 +208,8 @@ void Boot::resetPasswdSlot()
uninhibit();
}
}
bootWidget->grubSwitchButton()->setEnabled(true);
bootWidget->resetButton()->setEnabled(true);
});
});
dia->exec();

View File

@ -6,6 +6,9 @@
#include <QRegExp>
#include <QDebug>
#include <QRegExpValidator>
#include <regex>
#include <string>
using namespace std;
HostNameDialog::HostNameDialog(QWidget *parent):
QDialog(parent)
@ -95,6 +98,23 @@ void HostNameDialog::initConnect()
mTipLabel->setVisible(false);
mConfirmBtn->setEnabled(true);
}
if (pwd.isEmpty()) {
mTipLabel->setText(tr("Must be 1-64 characters long"));
mTipLabel->setVisible(true);
} else if (pwd.length() > 64) {
mTipLabel->setText(tr("Must be 1-64 characters long"));
mHostNameEdit->setText(pwd.mid(0, 64));
mTipLabel->setVisible(true);
} else {
mTipLabel->setVisible(!isMatch(pwd));
}
if (mTipLabel->isVisible()) {
mConfirmBtn->setEnabled(false);
} else {
mConfirmBtn->setEnabled(true);
}
});
connect(mCancelBtn, &QPushButton::clicked, this, [=]() {
@ -111,7 +131,7 @@ void HostNameDialog::initConnect()
void HostNameDialog::setEdit()
{
QRegExp rx("[a-z][a-zA-Z0-9.-]*");
QRegExp rx("[a-zA-Z0-9.-]*");
QRegExpValidator *validator = new QRegExpValidator(rx , this);
mHostNameEdit->setValidator(validator);
}
@ -144,3 +164,35 @@ void HostNameDialog::setHostname(QString hostname)
sethostnameDbus = nullptr;
}
bool HostNameDialog::isMatch(QString hostname)
{
bool ismatch = true;
string str = hostname.toStdString();
string::const_iterator iter_begin = str.cbegin();
string::const_iterator iter_end = str.cend();
if (regex_search(iter_begin, iter_end, regex("^[-.]")) || regex_search(iter_begin, iter_end, regex("[-.]$"))) {
mTipLabel->setText(tr("Hostname must start or end with a number and a letter"));
ismatch = false;
}
if (regex_search(iter_begin, iter_end, regex("[-][.]")) || regex_search(iter_begin, iter_end, regex("[.][-]"))) {
int position = mHostNameEdit->cursorPosition();
if (regex_search(iter_begin, iter_end, regex("[-][.]"))) {
mHostNameEdit->setText(regex_replace(str, regex("[-][.]"), "-").c_str());
} else {
mHostNameEdit->setText(regex_replace(str, regex("[.][-]"), ".").c_str());
}
mHostNameEdit->setCursorPosition(position - 1);
mTipLabel->setText(tr("Hostname cannot have consecutive ' - ' and ' . '"));
ismatch = false;
}
if (regex_search(iter_begin, iter_end, regex("[.][.]"))) {
int position = mHostNameEdit->cursorPosition();
mHostNameEdit->setText(regex_replace(str, regex("[.][.]"), ".").c_str());
mHostNameEdit->setCursorPosition(position - 1);
mTipLabel->setText(tr("Hostname cannot have consecutive ' . '"));
ismatch = false;
}
return ismatch;
}

View File

@ -24,6 +24,7 @@ private:
void setEdit();
void setupComponent();
void setHostname(QString hostname);
bool isMatch(QString hostname);
private:

View File

@ -1064,7 +1064,7 @@ bool SysdbusRegister::copyFile(const QString &srcfile, const QString &dstfile)
return QFile::copy(srcfile, dstfile);
}
bool SysdbusRegister::setGrupPasswd(QString username, QString passwd, bool status)
bool SysdbusRegister::setGrupPasswd(QString username, QString passwd, QString lang, bool status)
{
//密码校验
QDBusConnection conn = connection();
@ -1076,9 +1076,9 @@ bool SysdbusRegister::setGrupPasswd(QString username, QString passwd, bool statu
QString cmd;
if(true == status){
cmd = QString("grub-password -u %1 %2 && update-grub").arg(username).arg(passwd);
cmd = QString("grub-password -u %1 %2 && export LANG=%3 && update-grub").arg(username).arg(passwd).arg(lang);
} else{
cmd = QString("grub-password -d && update-grub");
cmd = QString("grub-password -d && export LANG=%1 && update-grub").arg(lang);
}
qDebug() << "cmd= " << cmd;

View File

@ -167,7 +167,7 @@ public slots:
Q_SCRIPTABLE bool copyFile(const QString &srcfile, const QString &dstfile);
// 设置 grub 密码
Q_SCRIPTABLE bool setGrupPasswd(QString username, QString passwd, bool status);
Q_SCRIPTABLE bool setGrupPasswd(QString username, QString passwd, QString lang, bool status);
// 获取 grub 密码是否开启
Q_SCRIPTABLE bool getGrupPasswdStatus();

View File

@ -106,6 +106,13 @@ 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");

View File

@ -183,22 +183,8 @@ void MainWindow::bootOptionsFilter(QString opt, bool firstIn) {
}
}
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();
}
}
}
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (watched == scrollArea) {
if (!Common::isTablet()) {
if (event->type() == QEvent::Enter) {
@ -226,33 +212,6 @@ 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, [=]() {
@ -371,6 +330,7 @@ void MainWindow::initUI() {
homepageWidget = new HomePageWidget(this);
homepageWidget->installEventFilter(this);
ui->stackedWidget->addWidget(homepageWidget);
ui->stackedWidget->setFocusPolicy(Qt::ClickFocus);
//加载左侧边栏一级菜单
initLeftsideBar();
@ -462,43 +422,8 @@ 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);
@ -564,17 +489,6 @@ 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)
{
@ -944,7 +858,6 @@ 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);
@ -1165,26 +1078,6 @@ 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);

View File

@ -102,12 +102,6 @@ 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;
@ -115,7 +109,6 @@ private:
QHBoxLayout *titleLayout;
KNavigationBar *scrollArea = nullptr;
QPoint queryWidCenterPos = QPoint(0,0);
QDBusInterface *m_statusSessionDbus;
bool is_tabletmode;
@ -141,14 +134,12 @@ 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();

View File

@ -2201,13 +2201,13 @@ change system settings</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="327"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="326"/>
<source>Add Timezone</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="196"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="329"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="328"/>
<source>Change Timezone</source>
<translation></translation>
</message>
@ -2862,30 +2862,47 @@ change system settings</source>
<context>
<name>HostNameDialog</name>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="14"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="17"/>
<source>Set HostName</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="43"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="46"/>
<source>HostName</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="55"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="58"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="103"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="106"/>
<source>Must be 1-64 characters long</source>
<translation>1-64</translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="69"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="72"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="73"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="76"/>
<source>Confirm</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="176"/>
<source>Hostname must start or end with a number and a letter</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="187"/>
<source>Hostname cannot have consecutive &apos; - &apos; and &apos; . &apos;</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="194"/>
<source>Hostname cannot have consecutive &apos; . &apos;</source>
<translation></translation>
</message>
</context>
<context>
<name>InputPwdDialog</name>
@ -3190,81 +3207,80 @@ change system settings</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="214"/>
<location filename="../../mainwindow.cpp" line="200"/>
<source>Normal</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="217"/>
<location filename="../../mainwindow.cpp" line="533"/>
<location filename="../../mainwindow.cpp" line="203"/>
<location filename="../../mainwindow.cpp" line="458"/>
<source>Maximize</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="456"/>
<location filename="../../mainwindow.cpp" line="511"/>
<location filename="../../mainwindow.cpp" line="659"/>
<location filename="../../mainwindow.cpp" line="1107"/>
<location filename="../../mainwindow.cpp" line="416"/>
<location filename="../../mainwindow.cpp" line="436"/>
<location filename="../../mainwindow.cpp" line="573"/>
<location filename="../../mainwindow.cpp" line="1020"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="491"/>
<source>Search</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<source>Main menu</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="531"/>
<location filename="../../mainwindow.cpp" line="456"/>
<source>Option</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="532"/>
<location filename="../../mainwindow.cpp" line="457"/>
<source>Minimize</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="534"/>
<location filename="../../mainwindow.cpp" line="459"/>
<source>Close</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="647"/>
<location filename="../../mainwindow.cpp" line="561"/>
<source>Help</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="649"/>
<location filename="../../mainwindow.cpp" line="563"/>
<source>About</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="651"/>
<location filename="../../mainwindow.cpp" line="565"/>
<source>Exit</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="660"/>
<location filename="../../mainwindow.cpp" line="574"/>
<source>Version: </source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="795"/>
<location filename="../../mainwindow.cpp" line="709"/>
<source>Specified</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="182"/>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>This function has been controlled</source>
<translation></translation>
</message>
@ -3749,9 +3765,8 @@ change system settings</source>
</message>
<message>
<location filename="../../../plugins/system/display/outputconfig.cpp" line="569"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="282"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="289"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="398"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="279"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="408"/>
<source>%1 Hz</source>
<translation>%1 Hz</translation>
</message>
@ -4572,7 +4587,7 @@ II.Javaལག་རྩལ་གྱི་ཚད་བཀག
<translation></translation>
</message>
<message>
<location filename="../../main.cpp" line="110"/>
<location filename="../../main.cpp" line="117"/>
<source>ukui-control-center</source>
<translation></translation>
</message>
@ -4817,7 +4832,7 @@ II.Javaལག་རྩལ་གྱི་ཚད་བཀག
<context>
<name>Screensaver</name>
<message>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="37"/>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="36"/>
<source>Screensaver</source>
<translation></translation>
</message>
@ -5079,11 +5094,11 @@ II.Javaལག་རྩལ་གྱི་ཚད་བཀག
<context>
<name>SearchWidget</name>
<message>
<location filename="../../searchwidget.cpp" line="175"/>
<location filename="../../searchwidget.cpp" line="176"/>
<location filename="../../searchwidget.cpp" line="183"/>
<location filename="../../searchwidget.cpp" line="184"/>
<location filename="../../searchwidget.cpp" line="189"/>
<location filename="../../searchwidget.cpp" line="64"/>
<location filename="../../searchwidget.cpp" line="65"/>
<location filename="../../searchwidget.cpp" line="72"/>
<location filename="../../searchwidget.cpp" line="73"/>
<location filename="../../searchwidget.cpp" line="78"/>
<source>No search results</source>
<translation></translation>
</message>

View File

@ -1781,13 +1781,13 @@ change system settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="327"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="326"/>
<source>Add Timezone</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="196"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="329"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="328"/>
<source>Change Timezone</source>
<translation type="unfinished"></translation>
</message>
@ -2388,30 +2388,47 @@ change system settings</source>
<context>
<name>HostNameDialog</name>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="14"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="17"/>
<source>Set HostName</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="43"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="46"/>
<source>HostName</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="55"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="58"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="103"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="106"/>
<source>Must be 1-64 characters long</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="69"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="72"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="73"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="76"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="176"/>
<source>Hostname must start or end with a number and a letter</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="187"/>
<source>Hostname cannot have consecutive &apos; - &apos; and &apos; . &apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="194"/>
<source>Hostname cannot have consecutive &apos; . &apos;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InputPwdDialog</name>
@ -2594,76 +2611,71 @@ change system settings</source>
</message>
<message>
<location filename="../../mainwindow.cpp" line="182"/>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>This function has been controlled</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="214"/>
<location filename="../../mainwindow.cpp" line="200"/>
<source>Normal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="217"/>
<location filename="../../mainwindow.cpp" line="533"/>
<location filename="../../mainwindow.cpp" line="203"/>
<location filename="../../mainwindow.cpp" line="458"/>
<source>Maximize</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="456"/>
<location filename="../../mainwindow.cpp" line="511"/>
<location filename="../../mainwindow.cpp" line="659"/>
<location filename="../../mainwindow.cpp" line="1107"/>
<location filename="../../mainwindow.cpp" line="416"/>
<location filename="../../mainwindow.cpp" line="436"/>
<location filename="../../mainwindow.cpp" line="573"/>
<location filename="../../mainwindow.cpp" line="1020"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="491"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="531"/>
<location filename="../../mainwindow.cpp" line="456"/>
<source>Option</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="532"/>
<location filename="../../mainwindow.cpp" line="457"/>
<source>Minimize</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="534"/>
<location filename="../../mainwindow.cpp" line="459"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="647"/>
<location filename="../../mainwindow.cpp" line="561"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="649"/>
<location filename="../../mainwindow.cpp" line="563"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="651"/>
<location filename="../../mainwindow.cpp" line="565"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="660"/>
<location filename="../../mainwindow.cpp" line="574"/>
<source>Version: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="795"/>
<location filename="../../mainwindow.cpp" line="709"/>
<source>Specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
@ -3090,9 +3102,8 @@ change system settings</source>
</message>
<message>
<location filename="../../../plugins/system/display/outputconfig.cpp" line="569"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="282"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="289"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="398"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="279"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="408"/>
<source>%1 Hz</source>
<translation type="unfinished"></translation>
</message>
@ -3577,7 +3588,7 @@ Fax:
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../main.cpp" line="110"/>
<location filename="../../main.cpp" line="117"/>
<source>ukui-control-center</source>
<translation type="unfinished"></translation>
</message>
@ -3690,7 +3701,7 @@ Fax:
<context>
<name>Screensaver</name>
<message>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="37"/>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="36"/>
<source>Screensaver</source>
<translation type="unfinished"></translation>
</message>
@ -3858,11 +3869,11 @@ Fax:
<context>
<name>SearchWidget</name>
<message>
<location filename="../../searchwidget.cpp" line="175"/>
<location filename="../../searchwidget.cpp" line="176"/>
<location filename="../../searchwidget.cpp" line="183"/>
<location filename="../../searchwidget.cpp" line="184"/>
<location filename="../../searchwidget.cpp" line="189"/>
<location filename="../../searchwidget.cpp" line="64"/>
<location filename="../../searchwidget.cpp" line="65"/>
<location filename="../../searchwidget.cpp" line="72"/>
<location filename="../../searchwidget.cpp" line="73"/>
<location filename="../../searchwidget.cpp" line="78"/>
<source>No search results</source>
<translation type="unfinished"></translation>
</message>

View File

@ -3758,7 +3758,7 @@ change system settings</source>
<extra-contents_path>/Date/Sync Server</extra-contents_path>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="327"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="326"/>
<source>Add Timezone</source>
<translation></translation>
</message>
@ -3822,7 +3822,7 @@ change system settings</source>
</message>
<message>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="196"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="329"/>
<location filename="../../../plugins/time-language/datetime/datetime.cpp" line="328"/>
<source>Change Timezone</source>
<translation></translation>
</message>
@ -5363,30 +5363,47 @@ folder will be deleted!</source>
<context>
<name>HostNameDialog</name>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="14"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="17"/>
<source>Set HostName</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="43"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="46"/>
<source>HostName</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="55"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="58"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="103"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="106"/>
<source>Must be 1-64 characters long</source>
<translation>1-64</translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="69"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="72"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="73"/>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="76"/>
<source>Confirm</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="176"/>
<source>Hostname must start or end with a number and a letter</source>
<translation></translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="187"/>
<source>Hostname cannot have consecutive &apos; - &apos; and &apos; . &apos;</source>
<translation> - . </translation>
</message>
<message>
<location filename="../../../plugins/system/about/hostnamedialog.cpp" line="194"/>
<source>Hostname cannot have consecutive &apos; . &apos;</source>
<translation> . </translation>
</message>
</context>
<context>
<name>InputPwdDialog</name>
@ -6387,29 +6404,28 @@ Please retry or relogin!</source>
<context>
<name>MainWindow</name>
<message>
<location filename="../../mainwindow.cpp" line="491"/>
<source>Search</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<source>UKCC</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="456"/>
<location filename="../../mainwindow.cpp" line="511"/>
<location filename="../../mainwindow.cpp" line="659"/>
<location filename="../../mainwindow.cpp" line="1107"/>
<location filename="../../mainwindow.cpp" line="416"/>
<location filename="../../mainwindow.cpp" line="436"/>
<location filename="../../mainwindow.cpp" line="573"/>
<location filename="../../mainwindow.cpp" line="1020"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="531"/>
<location filename="../../mainwindow.cpp" line="456"/>
<source>Option</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="532"/>
<location filename="../../mainwindow.cpp" line="457"/>
<source>Minimize</source>
<translation></translation>
</message>
@ -6423,43 +6439,43 @@ Please retry or relogin!</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="214"/>
<location filename="../../mainwindow.cpp" line="200"/>
<source>Normal</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="217"/>
<location filename="../../mainwindow.cpp" line="533"/>
<location filename="../../mainwindow.cpp" line="203"/>
<location filename="../../mainwindow.cpp" line="458"/>
<source>Maximize</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="534"/>
<location filename="../../mainwindow.cpp" line="459"/>
<source>Close</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="647"/>
<location filename="../../mainwindow.cpp" line="561"/>
<source>Help</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="649"/>
<location filename="../../mainwindow.cpp" line="563"/>
<source>About</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="651"/>
<location filename="../../mainwindow.cpp" line="565"/>
<source>Exit</source>
<translation>退</translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="660"/>
<location filename="../../mainwindow.cpp" line="574"/>
<source>Version: </source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="795"/>
<location filename="../../mainwindow.cpp" line="709"/>
<source>Specified</source>
<translation></translation>
</message>
@ -6468,13 +6484,13 @@ Please retry or relogin!</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="182"/>
<location filename="../../mainwindow.cpp" line="1271"/>
<location filename="../../mainwindow.cpp" line="1164"/>
<source>This function has been controlled</source>
<translation></translation>
</message>
@ -7355,9 +7371,8 @@ Please retry or relogin!</source>
</message>
<message>
<location filename="../../../plugins/system/display/outputconfig.cpp" line="569"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="282"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="289"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="398"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="279"/>
<location filename="../../../plugins/system/display_hw/outputconfig.cpp" line="408"/>
<source>%1 Hz</source>
<translation type="unfinished"></translation>
</message>
@ -9716,7 +9731,7 @@ E-mail: support@kylinos.cn</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../main.cpp" line="110"/>
<location filename="../../main.cpp" line="117"/>
<source>ukui-control-center</source>
<translation></translation>
</message>
@ -10277,7 +10292,7 @@ E-mail: support@kylinos.cn</source>
<context>
<name>Screensaver</name>
<message>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="37"/>
<location filename="../../../plugins/personalized/screensaver/screensaver.cpp" line="36"/>
<source>Screensaver</source>
<translation></translation>
</message>
@ -10706,11 +10721,11 @@ E-mail: support@kylinos.cn</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="../../searchwidget.cpp" line="175"/>
<location filename="../../searchwidget.cpp" line="176"/>
<location filename="../../searchwidget.cpp" line="183"/>
<location filename="../../searchwidget.cpp" line="184"/>
<location filename="../../searchwidget.cpp" line="189"/>
<location filename="../../searchwidget.cpp" line="64"/>
<location filename="../../searchwidget.cpp" line="65"/>
<location filename="../../searchwidget.cpp" line="72"/>
<location filename="../../searchwidget.cpp" line="73"/>
<location filename="../../searchwidget.cpp" line="78"/>
<source>No search results</source>
<translation></translation>
</message>

View File

@ -30,116 +30,8 @@ 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)
: QLineEdit(parent)
: KSearchLineEdit(parent)
, m_xmlExplain("")
, m_bIsChinese(false)
, m_searchValue("")
@ -147,17 +39,15 @@ SearchWidget::SearchWidget(QWidget *parent)
{
initExcludeSearch();
m_model = new QStandardItemModel(this);
m_completer = new ukCompleter(m_model, this);
m_completer = this->completer();
this->completer()->setModel(m_model);
QAbstractItemView *popup = m_completer->popup();
m_pListViewDelegate = new ListViewDelegate(popup);
popup->setItemDelegate(m_pListViewDelegate);
this->reloadStyle();
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() != "") {
@ -170,7 +60,6 @@ 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")));
@ -704,44 +593,3 @@ 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);
}

View File

@ -21,26 +21,15 @@
#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 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
class SearchWidget : public KSearchLineEdit
{
Q_OBJECT
public:
@ -100,6 +89,5 @@ private:
QStringList mExcludeList;
int count;
ListViewDelegate *m_pListViewDelegate;
};
#endif // SEARCHWIDGET_H