diff --git a/search-ukcc-plugin/search.cpp b/search-ukcc-plugin/search.cpp index d6d52d2..631c606 100644 --- a/search-ukcc-plugin/search.cpp +++ b/search-ukcc-plugin/search.cpp @@ -12,11 +12,17 @@ Search::Search() m_plugin_name = tr("Search"); m_plugin_type = SEARCH_F; - initUi(); - setupConnection(); + m_dirSettings = new QSettings(QDir::homePath() + CONFIG_FILE, QSettings::NativeFormat, this); m_dirSettings->setIniCodec(QTextCodec::codecForName("UTF-8")); initBlockDirsList(); + + const QByteArray id(UKUI_SEARCH_SCHEMAS); + if (QGSettings::isSchemaInstalled(id)) { + m_gsettings = new QGSettings(id, QByteArray(), this); + } else { + qCritical() << UKUI_SEARCH_SCHEMAS << " not installed!\n"; + } } QString Search::plugini18nName() @@ -31,11 +37,10 @@ int Search::pluginTypes() QWidget *Search::pluginUi() { - m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose); + initUi(); + connect(m_addBlockDirWidget, &QPushButton::clicked, this, &Search::onBtnAddFolderClicked); - const QByteArray id(UKUI_SEARCH_SCHEMAS); - if (QGSettings::isSchemaInstalled(id)) { - m_gsettings = new QGSettings(id, QByteArray(), this); + if (m_gsettings) { //按钮状态初始化 if (m_gsettings->keys().contains(SEARCH_METHOD_KEY)) { //当前是否使用索引搜索/暴力搜索 @@ -76,10 +81,11 @@ QWidget *Search::pluginUi() } }); } else { - qCritical() << UKUI_SEARCH_SCHEMAS << " not installed!\n"; + qCritical() << "Gsettings of the search plugin for ukcc is not initialized!"; m_searchMethodBtn->setEnabled(false); m_webEngineFrame->mCombox->setEnabled(false); } + return m_pluginWidget; } @@ -114,6 +120,7 @@ bool Search::isEnable() const void Search::initUi() { m_pluginWidget = new QWidget; + m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose); m_mainLyt = new QVBoxLayout(m_pluginWidget); m_pluginWidget->setLayout(m_mainLyt);