Add function of historycal record.
This commit is contained in:
parent
ef6c651d66
commit
20322d4cd3
|
@ -35,10 +35,25 @@ GlobalSettings *GlobalSettings::getInstance()
|
||||||
|
|
||||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_settings = new QSettings("org.ukui/ukui-search", "ukui-search", this);
|
m_settings = new QSettings(MAIN_SETTINGS, QSettings::IniFormat, this);
|
||||||
// m_settings->setAtomicSyncRequired(false);
|
// m_settings->setAtomicSyncRequired(false);
|
||||||
m_block_dirs_settings = new QSettings("org.ukui/ukui-search","ukui-search-block-dirs",this);
|
m_block_dirs_settings = new QSettings(BLOCK_DIRS,QSettings::IniFormat, this);
|
||||||
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
|
|
||||||
|
m_search_record_settings = new QSettings(SEARCH_HISTORY, QSettings::IniFormat , this);
|
||||||
|
m_search_record_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
|
for(QString i:m_search_record_settings->allKeys())
|
||||||
|
{
|
||||||
|
m_history.append(QUrl::fromPercentEncoding(i.toLocal8Bit()));
|
||||||
|
}
|
||||||
|
if(!QDBusConnection::sessionBus().connect("org.kylinssoclient.dbus",
|
||||||
|
"/org/kylinssoclient/path",
|
||||||
|
"org.freedesktop.kylinssoclient.interface",
|
||||||
|
"keyChanged",
|
||||||
|
this, SLOT(updateSearchHistory(QString))))
|
||||||
|
|
||||||
|
qWarning()<<"Kylinssoclient Dbus connect fail!";
|
||||||
|
|
||||||
this->forceSync();
|
this->forceSync();
|
||||||
//the default number of transparency in mainwindow is 0.7
|
//the default number of transparency in mainwindow is 0.7
|
||||||
//if someone changes the num in mainwindow, here should be modified too
|
//if someone changes the num in mainwindow, here should be modified too
|
||||||
|
@ -141,84 +156,88 @@ QStringList GlobalSettings::getBlockDirs()
|
||||||
return m_block_dirs_settings->allKeys();
|
return m_block_dirs_settings->allKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSettings::appendCloudData(const QString &key, const QString &value)
|
//void GlobalSettings::appendCloudData(const QString &key, const QString &value)
|
||||||
{
|
//{
|
||||||
QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
QStringList values = m_qSettings->value(key).toStringList();
|
// QStringList values = m_qSettings->value(key).toStringList();
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if (values.contains(value)) {
|
// if (values.contains(value)) {
|
||||||
values.removeOne(value);
|
// values.removeOne(value);
|
||||||
}
|
// }
|
||||||
values.insert(0,value);
|
// values.insert(0,value);
|
||||||
|
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
m_qSettings->setValue(key, values);
|
// m_qSettings->setValue(key, values);
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if (m_qSettings) {
|
// if (m_qSettings) {
|
||||||
delete m_qSettings;
|
// delete m_qSettings;
|
||||||
m_qSettings = NULL;
|
// m_qSettings = NULL;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
void GlobalSettings::setSearchRecord(const QString &word, const QDateTime &time)
|
||||||
|
{
|
||||||
|
QStringList keys = m_search_record_settings->allKeys();
|
||||||
|
if(keys.contains(QString(QUrl::toPercentEncoding(word))))
|
||||||
|
m_history.removeOne(word);
|
||||||
|
m_search_record_settings->setValue(QString(QUrl::toPercentEncoding(word)), time.toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
|
if(keys.size() >= 20)
|
||||||
|
m_search_record_settings->remove(QString(QUrl::toPercentEncoding(m_history.takeFirst())));
|
||||||
|
m_history.append(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSettings::setCloudData(const QString &key, const QStringList &values)
|
QStringList GlobalSettings::getSearchRecord()
|
||||||
{
|
{
|
||||||
QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
return m_history;
|
||||||
m_qSettings->beginGroup(key);
|
|
||||||
m_qSettings->setValue(key, values);
|
|
||||||
m_qSettings->endGroup();
|
|
||||||
if (m_qSettings) {
|
|
||||||
delete m_qSettings;
|
|
||||||
m_qSettings = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalSettings::removeOneCloudData(const QString &key, const QString &value)
|
//bool GlobalSettings::removeOneCloudData(const QString &key, const QString &value)
|
||||||
{
|
//{
|
||||||
if (!QFileInfo(CLOUD_FILE).isFile()) return false;
|
// if (!QFileInfo(CLOUD_FILE).isFile()) return false;
|
||||||
QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
QStringList values = m_qSettings->value(key).toStringList();
|
// QStringList values = m_qSettings->value(key).toStringList();
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if (values.contains(value)) {
|
// if (values.contains(value)) {
|
||||||
values.removeOne(value);
|
// values.removeOne(value);
|
||||||
} else return false;
|
// } else return false;
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
m_qSettings->setValue(key, values);
|
// m_qSettings->setValue(key, values);
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if (m_qSettings) {
|
// if (m_qSettings) {
|
||||||
delete m_qSettings;
|
// delete m_qSettings;
|
||||||
m_qSettings = NULL;
|
// m_qSettings = NULL;
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool GlobalSettings::removeAllCloudData(const QString &key)
|
//bool GlobalSettings::removeAllCloudData(const QString &key)
|
||||||
{
|
//{
|
||||||
if (!QFileInfo(CLOUD_FILE).isFile()) return false;
|
// if (!QFileInfo(CLOUD_FILE).isFile()) return false;
|
||||||
QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
m_qSettings->setValue(key, QStringList());
|
// m_qSettings->setValue(key, QStringList());
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if (m_qSettings) {
|
// if (m_qSettings) {
|
||||||
delete m_qSettings;
|
// delete m_qSettings;
|
||||||
m_qSettings = NULL;
|
// m_qSettings = NULL;
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
QStringList GlobalSettings::getCloudData(const QString &key)
|
//QStringList GlobalSettings::getCloudData(const QString &key)
|
||||||
{
|
//{
|
||||||
if (!QFileInfo(CLOUD_FILE).isFile()) return QStringList();
|
// if (!QFileInfo(CLOUD_FILE).isFile()) return QStringList();
|
||||||
QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
// QSettings * m_qSettings = new QSettings(CLOUD_FILE, QSettings::IniFormat);
|
||||||
m_qSettings->beginGroup(key);
|
// m_qSettings->beginGroup(key);
|
||||||
QStringList values = m_qSettings->value(key).toStringList();
|
// QStringList values = m_qSettings->value(key).toStringList();
|
||||||
m_qSettings->endGroup();
|
// m_qSettings->endGroup();
|
||||||
if(m_qSettings)
|
// if(m_qSettings)
|
||||||
delete m_qSettings;
|
// delete m_qSettings;
|
||||||
return values;
|
// return values;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//here should be override
|
//here should be override
|
||||||
//MouseZhangZh
|
//MouseZhangZh
|
||||||
|
@ -253,3 +272,16 @@ void GlobalSettings::forceSync(const QString &key)
|
||||||
m_cache.insert(key, m_settings->value(key));
|
m_cache.insert(key, m_settings->value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobalSettings::updateSearchHistory(QString key)
|
||||||
|
{
|
||||||
|
if(key == "search")
|
||||||
|
{
|
||||||
|
m_search_record_settings->sync();
|
||||||
|
m_history.clear();
|
||||||
|
for(QString i:m_search_record_settings->allKeys())
|
||||||
|
{
|
||||||
|
m_history.append(QUrl::fromPercentEncoding(i.toLocal8Bit()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
//My demo can build access yet.
|
//My demo can build access yet.
|
||||||
//MouseZhangZh
|
//MouseZhangZh
|
||||||
#include <QGSettings/QGSettings>
|
#include <QGSettings/QGSettings>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
#include "libsearch_global.h"
|
#include "libsearch_global.h"
|
||||||
|
|
||||||
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
|
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
|
||||||
|
@ -44,9 +46,11 @@
|
||||||
#define PATH_NOT_IN_HOME 2;
|
#define PATH_NOT_IN_HOME 2;
|
||||||
#define PATH_PARENT_BLOCKED 3;
|
#define PATH_PARENT_BLOCKED 3;
|
||||||
|
|
||||||
#define CLOUD_FILE QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-cloud.conf"
|
#define MAIN_SETTINGS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search.conf"
|
||||||
#define CLOUD_HISTORY "history"
|
#define BLOCK_DIRS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf"
|
||||||
#define CLOUD_APPLICATIONS "applications"
|
#define SEARCH_HISTORY QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-history.conf"
|
||||||
|
//#define CLOUD_HISTORY "history"
|
||||||
|
//#define CLOUD_APPLICATIONS "applications"
|
||||||
|
|
||||||
class LIBSEARCH_EXPORT GlobalSettings : public QObject
|
class LIBSEARCH_EXPORT GlobalSettings : public QObject
|
||||||
{
|
{
|
||||||
|
@ -74,13 +78,15 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
bool setBlockDirs(const QString& path, int &returnCode,bool remove = false);
|
bool setBlockDirs(const QString& path, int &returnCode,bool remove = false);
|
||||||
QStringList getBlockDirs();
|
QStringList getBlockDirs();
|
||||||
void appendCloudData(const QString& key, const QString& value);
|
// void appendCloudData(const QString& key, const QString& value);
|
||||||
void setCloudData(const QString& key, const QStringList& values);
|
void setSearchRecord(const QString &word, const QDateTime &time);
|
||||||
bool removeOneCloudData(const QString& key, const QString& value);
|
QStringList getSearchRecord();
|
||||||
bool removeAllCloudData(const QString& key);
|
// bool removeOneCloudData(const QString& key, const QString& value);
|
||||||
QStringList getCloudData(const QString& key);
|
// bool removeAllCloudData(const QString& key);
|
||||||
|
// QStringList getCloudData(const QString& key);
|
||||||
|
|
||||||
void forceSync(const QString& = nullptr);
|
void forceSync(const QString& = nullptr);
|
||||||
|
void updateSearchHistory(QString key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GlobalSettings(QObject *parent = nullptr);
|
explicit GlobalSettings(QObject *parent = nullptr);
|
||||||
|
@ -89,7 +95,9 @@ private:
|
||||||
QSettings* m_settings;
|
QSettings* m_settings;
|
||||||
QGSettings* m_gsettings;
|
QGSettings* m_gsettings;
|
||||||
QSettings *m_block_dirs_settings;
|
QSettings *m_block_dirs_settings;
|
||||||
|
QSettings *m_search_record_settings;
|
||||||
QMap<QString, QVariant> m_cache;
|
QMap<QString, QVariant> m_cache;
|
||||||
|
QStringList m_history;
|
||||||
|
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,7 @@ void ContentWidget::setupConnect(SearchListView * listview) {
|
||||||
connect(listview,&SearchListView::currentSelectPos,[=](QPoint pos){
|
connect(listview,&SearchListView::currentSelectPos,[=](QPoint pos){
|
||||||
m_resultListArea->ensureVisible(pos.x(),pos.y());
|
m_resultListArea->ensureVisible(pos.x(),pos.y());
|
||||||
});
|
});
|
||||||
|
connect(listview,&SearchListView::mousePressed,this,&ContentWidget::mousePressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,6 +109,7 @@ private:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentItemChanged();
|
void currentItemChanged();
|
||||||
|
void mousePressed();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void clearLayout(QLayout *);
|
void clearLayout(QLayout *);
|
||||||
|
|
|
@ -152,6 +152,15 @@ int SearchListView::getLength()
|
||||||
return m_item->getCurrentSize();
|
return m_item->getCurrentSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchListView::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
Q_EMIT mousePressed();
|
||||||
|
}
|
||||||
|
QTreeView::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
//获取当前选项所属搜索类型
|
//获取当前选项所属搜索类型
|
||||||
int SearchListView::getCurrentType() {
|
int SearchListView::getCurrentType() {
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include "model/search-item-model.h"
|
#include "model/search-item-model.h"
|
||||||
#include "model/search-item.h"
|
#include "model/search-item.h"
|
||||||
#include "highlight-item-delegate.h"
|
#include "highlight-item-delegate.h"
|
||||||
|
@ -60,6 +61,8 @@ public:
|
||||||
int getType();
|
int getType();
|
||||||
int getLength();
|
int getLength();
|
||||||
bool isHidden = false;
|
bool isHidden = false;
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
private:
|
private:
|
||||||
SearchItemModel * m_model = nullptr;
|
SearchItemModel * m_model = nullptr;
|
||||||
SearchItem * m_item = nullptr;
|
SearchItem * m_item = nullptr;
|
||||||
|
@ -72,6 +75,7 @@ private:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentRowChanged(const int&, const QString&);
|
void currentRowChanged(const int&, const QString&);
|
||||||
void currentSelectPos(QPoint pos);
|
void currentSelectPos(QPoint pos);
|
||||||
|
void mousePressed();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief ukui-search顶部搜索界面
|
* @brief ukui-search顶部搜索界面
|
||||||
*/
|
*/
|
||||||
SeachBarWidget::SeachBarWidget()
|
SeachBarWidget::SeachBarWidget(QWidget *parent):QWidget(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ SeachBar::~SeachBar()
|
||||||
/**
|
/**
|
||||||
* @brief 顶部搜索框所在界面的布局
|
* @brief 顶部搜索框所在界面的布局
|
||||||
*/
|
*/
|
||||||
SearchBarHLayout::SearchBarHLayout()
|
SearchBarHLayout::SearchBarHLayout(QWidget *parent):QHBoxLayout(parent)
|
||||||
{
|
{
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
|
@ -86,6 +86,11 @@ SearchBarHLayout::~SearchBarHLayout()
|
||||||
delete m_timer;
|
delete m_timer;
|
||||||
m_timer = NULL;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
|
if(m_queryLineEdit)
|
||||||
|
{
|
||||||
|
delete m_queryLineEdit;
|
||||||
|
m_queryLineEdit = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,12 +98,13 @@ SearchBarHLayout::~SearchBarHLayout()
|
||||||
*/
|
*/
|
||||||
void SearchBarHLayout::initUI()
|
void SearchBarHLayout::initUI()
|
||||||
{
|
{
|
||||||
m_queryLineEdit = new SearchLineEdit;
|
m_queryLineEdit = new SearchLineEdit();
|
||||||
m_queryLineEdit->installEventFilter(this);
|
m_queryLineEdit->installEventFilter(this);
|
||||||
m_queryLineEdit->setTextMargins(30,1,0,1);
|
m_queryLineEdit->setTextMargins(30,1,0,1);
|
||||||
this->setContentsMargins(0,0,0,0);
|
this->setContentsMargins(0,0,0,0);
|
||||||
this->setAlignment(m_queryLineEdit,Qt::AlignCenter);
|
this->setAlignment(m_queryLineEdit,Qt::AlignCenter);
|
||||||
this->addWidget(m_queryLineEdit);
|
this->addWidget(m_queryLineEdit);
|
||||||
|
|
||||||
m_queryWidget = new QWidget(m_queryLineEdit);
|
m_queryWidget = new QWidget(m_queryLineEdit);
|
||||||
m_queryWidget->setFocusPolicy(Qt::NoFocus);
|
m_queryWidget->setFocusPolicy(Qt::NoFocus);
|
||||||
m_queryWidget->setStyleSheet("border:0px;background:transparent");
|
m_queryWidget->setStyleSheet("border:0px;background:transparent");
|
||||||
|
@ -139,6 +145,11 @@ void SearchBarHLayout::initUI()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchBarHLayout::effectiveSearchRecord()
|
||||||
|
{
|
||||||
|
m_queryLineEdit->record();
|
||||||
|
}
|
||||||
|
|
||||||
void SearchBarHLayout::focusIn() {
|
void SearchBarHLayout::focusIn() {
|
||||||
m_queryLineEdit->setFocus();
|
m_queryLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -201,6 +212,14 @@ SearchLineEdit::SearchLineEdit()
|
||||||
// this->setContextMenuPolicy(Qt::NoContextMenu);
|
// this->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
this->setMaxLength(100);
|
this->setMaxLength(100);
|
||||||
|
|
||||||
|
m_completer = new QCompleter(this);
|
||||||
|
m_model = new QStringListModel(this);
|
||||||
|
m_model->setStringList(GlobalSettings::getInstance()->getSearchRecord());
|
||||||
|
m_completer->setModel(m_model);
|
||||||
|
m_completer->setCompletionMode(QCompleter::InlineCompletion);
|
||||||
|
m_completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
setCompleter(m_completer);
|
||||||
|
|
||||||
//这是搜索框图标,要改
|
//这是搜索框图标,要改
|
||||||
// QAction *searchAction = new QAction(this);
|
// QAction *searchAction = new QAction(this);
|
||||||
|
@ -213,6 +232,18 @@ SearchLineEdit::SearchLineEdit()
|
||||||
QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this,QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
|
QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this,QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
|
||||||
|
|
||||||
connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged);
|
connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged);
|
||||||
|
connect(this, &QLineEdit::textChanged, this, [=](){
|
||||||
|
m_isRecorded = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchLineEdit::record()
|
||||||
|
{
|
||||||
|
if(m_isRecorded == true||text().size() <= 1||text().isEmpty())
|
||||||
|
return;
|
||||||
|
GlobalSettings::getInstance()->setSearchRecord(text(),QDateTime::currentDateTime());
|
||||||
|
m_isRecorded = true;
|
||||||
|
m_model->setStringList(GlobalSettings::getInstance()->getSearchRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchLineEdit::~SearchLineEdit()
|
SearchLineEdit::~SearchLineEdit()
|
||||||
|
|
|
@ -26,13 +26,18 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
#include <QVector4D>
|
||||||
|
#include "global-settings.h"
|
||||||
|
|
||||||
class SearchLineEdit;
|
class SearchLineEdit;
|
||||||
|
|
||||||
class SeachBarWidget:public QWidget
|
class SeachBarWidget:public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SeachBarWidget();
|
SeachBarWidget(QWidget *parent = nullptr);
|
||||||
~SeachBarWidget();
|
~SeachBarWidget();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ class SearchBarHLayout : public QHBoxLayout
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SearchBarHLayout();
|
SearchBarHLayout(QWidget *parent = nullptr);
|
||||||
~SearchBarHLayout();
|
~SearchBarHLayout();
|
||||||
void clearText();
|
void clearText();
|
||||||
QString text();
|
QString text();
|
||||||
|
@ -74,6 +79,8 @@ private:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void textChanged(QString text);
|
void textChanged(QString text);
|
||||||
|
public Q_SLOTS:
|
||||||
|
void effectiveSearchRecord();
|
||||||
|
|
||||||
};
|
};
|
||||||
class SearchBarWidgetLayout : public QHBoxLayout
|
class SearchBarWidgetLayout : public QHBoxLayout
|
||||||
|
@ -97,8 +104,13 @@ class SearchLineEdit : public QLineEdit
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
|
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
|
||||||
public:
|
public:
|
||||||
SearchLineEdit();
|
SearchLineEdit();
|
||||||
|
void record();
|
||||||
~SearchLineEdit();
|
~SearchLineEdit();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void lineEditTextChanged(QString arg);
|
void lineEditTextChanged(QString arg);
|
||||||
|
private:
|
||||||
|
QStringListModel *m_model = nullptr;
|
||||||
|
QCompleter *m_completer= nullptr;
|
||||||
|
bool m_isRecorded = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -224,14 +224,15 @@ void MainWindow::initUi()
|
||||||
|
|
||||||
m_contentFrame = new ContentWidget(m_frame);//内容栏
|
m_contentFrame = new ContentWidget(m_frame);//内容栏
|
||||||
|
|
||||||
m_searchWidget = new SeachBarWidget;
|
m_searchWidget = new SeachBarWidget(this);
|
||||||
m_searchLayout = new SearchBarHLayout;
|
m_searchLayout = new SearchBarHLayout(this);
|
||||||
m_searchWidget->setLayout(m_searchLayout);
|
m_searchWidget->setLayout(m_searchLayout);
|
||||||
m_searchWidget->setFixedHeight(44);
|
m_searchWidget->setFixedHeight(44);
|
||||||
|
|
||||||
mainlayout->addWidget(m_titleFrame);
|
mainlayout->addWidget(m_titleFrame);
|
||||||
mainlayout->addWidget(m_contentFrame);
|
mainlayout->addWidget(m_contentFrame);
|
||||||
mainlayout->addWidget(m_searchWidget);
|
mainlayout->addWidget(m_searchWidget);
|
||||||
|
connect(m_contentFrame,&ContentWidget::mousePressed,m_searchLayout,&SearchBarHLayout::effectiveSearchRecord);
|
||||||
|
|
||||||
connect(QApplication::primaryScreen(), &QScreen::geometryChanged,
|
connect(QApplication::primaryScreen(), &QScreen::geometryChanged,
|
||||||
this, &MainWindow::monitorResolutionChange);
|
this, &MainWindow::monitorResolutionChange);
|
||||||
|
|
Loading…
Reference in New Issue