forked from openkylin/ukui-search
Merge branch '0413-dev' into 'main'
Fix: Mainwindow will not refresh sometime theme changed. See merge request kylin-desktop/ukui-search!14
This commit is contained in:
commit
8f0b82f34d
|
@ -59,16 +59,26 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
|||
//if someone changes the num in mainwindow, here should be modified too
|
||||
m_cache.insert(TRANSPARENCY_KEY, 0.7);
|
||||
if (QGSettings::isSchemaInstalled(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID)) {
|
||||
m_gsettings = new QGSettings(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID, QByteArray(), this);
|
||||
connect(m_gsettings, &QGSettings::changed, this, [=](const QString& key) {
|
||||
m_trans_gsettings = new QGSettings(CONTROL_CENTER_PERSONALISE_GSETTINGS_ID, QByteArray(), this);
|
||||
connect(m_trans_gsettings, &QGSettings::changed, this, [=](const QString& key) {
|
||||
if (key == TRANSPARENCY_KEY) {
|
||||
m_cache.remove(TRANSPARENCY_KEY);
|
||||
m_cache.insert(TRANSPARENCY_KEY, m_gsettings->get(TRANSPARENCY_KEY).toDouble());
|
||||
m_cache.insert(TRANSPARENCY_KEY, m_trans_gsettings->get(TRANSPARENCY_KEY).toDouble());
|
||||
qApp->paletteChanged(qApp->palette());
|
||||
}
|
||||
});
|
||||
m_cache.remove(TRANSPARENCY_KEY);
|
||||
m_cache.insert(TRANSPARENCY_KEY, m_gsettings->get(TRANSPARENCY_KEY).toDouble());
|
||||
m_cache.insert(TRANSPARENCY_KEY, m_trans_gsettings->get(TRANSPARENCY_KEY).toDouble());
|
||||
}
|
||||
|
||||
if (QGSettings::isSchemaInstalled(THEME_GSETTINGS_ID)) {
|
||||
m_theme_gsettings = new QGSettings(THEME_GSETTINGS_ID, QByteArray(), this);
|
||||
connect(m_theme_gsettings, &QGSettings::changed, this, [=](const QString& key) {
|
||||
if (key == STYLE_NAME_KEY) {
|
||||
//当前主题改变时也发出paletteChanged信号,通知主界面刷新
|
||||
qApp->paletteChanged(qApp->palette());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
|
||||
#define TRANSPARENCY_KEY "transparency"
|
||||
#define THEME_GSETTINGS_ID "org.ukui.style"
|
||||
#define STYLE_NAME_KEY "styleName"
|
||||
#define INDEX_DATABASE_STATE "index_database_state"
|
||||
#define CONTENT_INDEX_DATABASE_STATE "content_index_database_state"
|
||||
#define INDEX_GENERATOR_NORMAL_EXIT "index_generator_normal_exit"
|
||||
|
@ -93,7 +95,8 @@ private:
|
|||
~GlobalSettings() = default;
|
||||
|
||||
QSettings* m_settings;
|
||||
QGSettings* m_gsettings;
|
||||
QGSettings* m_trans_gsettings;
|
||||
QGSettings* m_theme_gsettings;
|
||||
QSettings *m_block_dirs_settings;
|
||||
QSettings *m_search_record_settings;
|
||||
QMap<QString, QVariant> m_cache;
|
||||
|
|
|
@ -272,8 +272,8 @@ void ContentWidget::setupConnect(SearchListView * listview) {
|
|||
m_resultListArea->ensureVisible(pos.x(),pos.y());
|
||||
});
|
||||
connect(listview,&SearchListView::mousePressed,this,&ContentWidget::mousePressed);
|
||||
connect(listview, SIGNAL(currentRowChanged(SearchListView *,const int&, const QString&)), this, SLOT(onListViewRowChanged(SearchListView *, const int&, const QString&)));
|
||||
connect(listview, SIGNAL(onRowDoubleClicked(SearchListView *,const int&, const QString&)), this, SLOT(onListViewRowDoubleClicked(SearchListView *, const int&, const QString&)));
|
||||
connect(listview, &SearchListView::currentRowChanged, this, &ContentWidget::onListViewRowChanged);
|
||||
connect(listview, &SearchListView::onRowDoubleClicked, this, &ContentWidget::onListViewRowDoubleClicked);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -257,8 +257,6 @@ int main(int argc, char *argv[])
|
|||
// hints.decorations = MWM_DECOR_BORDER;
|
||||
// XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), hints);
|
||||
|
||||
//TODO
|
||||
//wait Ping jiang before 2021.04.10
|
||||
app.setActivationWindow(w);
|
||||
|
||||
// Processing startup parameters
|
||||
|
@ -269,9 +267,7 @@ int main(int argc, char *argv[])
|
|||
w->show();
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Wait Ping jiang before 2021.04.10
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),w, SLOT(bootOptionsFilter(const QString&)));
|
||||
QObject::connect(&app, &QtSingleApplication::messageReceived, w, &MainWindow::bootOptionsFilter);
|
||||
|
||||
// Start app search thread
|
||||
AppMatch::getAppMatch()->start();
|
||||
|
|
|
@ -74,8 +74,6 @@ public:
|
|||
// The position which mainwindow shows in the center of screen where the cursor in.
|
||||
void centerToScreen(QWidget* widget);
|
||||
|
||||
// TODO
|
||||
// Wait Ping jiang.
|
||||
MotifWmHints m_hints;
|
||||
|
||||
private:
|
||||
|
@ -83,10 +81,6 @@ private:
|
|||
// MainWindow quit when focus out.
|
||||
bool nativeEvent(const QByteArray&, void*, long*);
|
||||
|
||||
// TODO
|
||||
// Not use?
|
||||
QFrame * m_line = nullptr; // Vertical dividing line
|
||||
|
||||
QFrame * m_frame = nullptr; // Main frame
|
||||
QFrame * m_titleFrame = nullptr; // Title bar frame
|
||||
QHBoxLayout * m_titleLyt = nullptr; // Title layout
|
||||
|
@ -98,10 +92,6 @@ private:
|
|||
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
||||
SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
||||
|
||||
// TODO
|
||||
// Not use?
|
||||
bool m_winFlag = false;
|
||||
|
||||
QGSettings * m_transparency_gsettings = nullptr;
|
||||
double getTransparentData();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void SearchAppThread::startSearch(const QString & keyword)
|
|||
SearchApp *appsearch;
|
||||
appsearch = new SearchApp(keyword);
|
||||
// appsearch->setKeyword(keyword);
|
||||
connect(appsearch, SIGNAL(searchResultApp(const QVector<QStringList>&)), this, SIGNAL(searchResultApp(const QVector<QStringList>&)));
|
||||
connect(appsearch, &SearchApp::searchResultApp, this, &SearchAppThread::searchResultApp);
|
||||
m_pool.start(appsearch);
|
||||
}
|
||||
|
||||
|
|
|
@ -233,8 +233,8 @@ void SettingsWidget::setupBlackList(const QStringList& list) {
|
|||
Q_FOREACH(QString path, list) {
|
||||
FolderListItem * item = new FolderListItem(m_dirListWidget, path);
|
||||
m_dirListLyt->addWidget(item);
|
||||
item->setMaximumWidth(this->width() - 68);
|
||||
connect(item, SIGNAL(onDelBtnClicked(const QString&)), this, SLOT(onBtnDelClicked(const QString&)));
|
||||
item->setMaximumWidth(this->width() - 52);
|
||||
connect(item, &FolderListItem::onDelBtnClicked, this, &SettingsWidget::onBtnDelClicked);
|
||||
m_blockdirs ++;
|
||||
}
|
||||
this->resize();
|
||||
|
|
|
@ -69,10 +69,10 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
|||
#if defined(Q_OS_WIN)
|
||||
id = id.toLower();
|
||||
#endif
|
||||
prefix = id.section(QLatin1Char('/'), -1);
|
||||
prefix = id.section(QLatin1Char('/'), -1); //完整路径按‘/’分隔后取最后一个字段
|
||||
}
|
||||
prefix.remove(QRegExp("[^a-zA-Z]"));
|
||||
prefix.truncate(6);
|
||||
prefix.remove(QRegExp("[^a-zA-Z]")); //去掉名称中的非字母
|
||||
prefix.truncate(6); //取前六位
|
||||
|
||||
QByteArray idc = id.toUtf8();
|
||||
quint16 idNum = qChecksum(idc.constData(), idc.size());
|
||||
|
@ -96,7 +96,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
|||
server = new QLocalServer(this);
|
||||
QString lockName = QDir(QDir::tempPath()).absolutePath()
|
||||
+ QLatin1Char('/') + socketName
|
||||
+ QLatin1String("-lockfile");
|
||||
+ QLatin1String("-lockfile"); //tmp目录下的锁文件
|
||||
lockFile.setFileName(lockName);
|
||||
lockFile.open(QIODevice::ReadWrite);
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ bool QtLocalPeer::isClient()
|
|||
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
|
||||
return true;
|
||||
|
||||
//由于文件锁的存在,仅当本进程第一次启动时能执行到此并使server进行监听和关联槽函数
|
||||
bool res = server->listen(socketName);
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
|
||||
// ### Workaround
|
||||
|
@ -121,7 +122,7 @@ bool QtLocalPeer::isClient()
|
|||
#endif
|
||||
if (!res)
|
||||
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
|
||||
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
|
||||
QObject::connect(server, &QLocalServer::newConnection, this, &QtLocalPeer::receiveConnection);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -162,10 +163,12 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief QtLocalPeer::receiveConnection 当新进程启动时,会尝试连接此进程server,server接收到newConnection信号并触发此槽函数
|
||||
*/
|
||||
void QtLocalPeer::receiveConnection()
|
||||
{
|
||||
QLocalSocket* socket = server->nextPendingConnection();
|
||||
QLocalSocket* socket = server->nextPendingConnection(); //获取新进程的socket
|
||||
if (!socket)
|
||||
return;
|
||||
|
||||
|
@ -202,5 +205,5 @@ void QtLocalPeer::receiveConnection()
|
|||
socket->waitForBytesWritten(1000);
|
||||
socket->waitForDisconnected(1000); // make sure client reads ack
|
||||
delete socket;
|
||||
Q_EMIT messageReceived(message); //### (might take a long time to return)
|
||||
Q_EMIT messageReceived(message); //获取新进程的启动信息并作为信号发送给前端
|
||||
}
|
||||
|
|
|
@ -145,7 +145,8 @@ void QtSingleApplication::sysInit(const QString &appId)
|
|||
{
|
||||
actWin = 0;
|
||||
peer = new QtLocalPeer(this, appId);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
// connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::messageReceived);
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,10 +296,11 @@ QString QtSingleApplication::id() const
|
|||
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
|
||||
{
|
||||
actWin = aw;
|
||||
if (activateOnMessage)
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
else
|
||||
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
//目前不需要用到此处的置顶方法,故此信号槽暂时注释掉,若后续需要根据新起进程传递的信号执行部分操作时可以把这里放开
|
||||
// if (activateOnMessage)
|
||||
// connect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
|
||||
// else
|
||||
// disconnect(peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue