forked from openkylin/ukui-search
feat(mainwindow): Show mainwindow when setting widget closed.
Description: 设置界面关闭时重新显示主界面 Log: 设置界面关闭时重新显示主界面
This commit is contained in:
parent
8b011bf847
commit
33608a71ab
|
@ -3,17 +3,17 @@
|
|||
#include <QPalette>
|
||||
#include "global-settings.h"
|
||||
|
||||
static GlobalSettingsZjp *global_instance = nullptr;
|
||||
static GlobalSettings *global_instance = nullptr;
|
||||
|
||||
GlobalSettingsZjp *GlobalSettingsZjp::getInstance()
|
||||
GlobalSettings *GlobalSettings::getInstance()
|
||||
{
|
||||
if (!global_instance) {
|
||||
global_instance = new GlobalSettingsZjp;
|
||||
global_instance = new GlobalSettings;
|
||||
}
|
||||
return global_instance;
|
||||
}
|
||||
|
||||
GlobalSettingsZjp::GlobalSettingsZjp(QObject *parent) : QObject(parent)
|
||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_settings = new QSettings("org.ukui", "ukui-search", this);
|
||||
//the default number of transparency in mainwindow is 0.7
|
||||
|
@ -33,22 +33,22 @@ GlobalSettingsZjp::GlobalSettingsZjp(QObject *parent) : QObject(parent)
|
|||
m_cache.insert(TRANSPARENCY_KEY, m_gsettings->get(TRANSPARENCY_KEY).toDouble());
|
||||
}
|
||||
|
||||
GlobalSettingsZjp::~GlobalSettingsZjp()
|
||||
GlobalSettings::~GlobalSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const QVariant GlobalSettingsZjp::getValue(const QString &key)
|
||||
const QVariant GlobalSettings::getValue(const QString &key)
|
||||
{
|
||||
return m_cache.value(key);
|
||||
}
|
||||
|
||||
bool GlobalSettingsZjp::isExist(const QString &key)
|
||||
bool GlobalSettings::isExist(const QString &key)
|
||||
{
|
||||
return !m_cache.value(key).isNull();
|
||||
}
|
||||
|
||||
void GlobalSettingsZjp::reset(const QString &key)
|
||||
void GlobalSettings::reset(const QString &key)
|
||||
{
|
||||
m_cache.remove(key);
|
||||
QtConcurrent::run([=]() {
|
||||
|
@ -61,7 +61,7 @@ void GlobalSettingsZjp::reset(const QString &key)
|
|||
Q_EMIT this->valueChanged(key);
|
||||
}
|
||||
|
||||
void GlobalSettingsZjp::resetAll()
|
||||
void GlobalSettings::resetAll()
|
||||
{
|
||||
QStringList tmp = m_cache.keys();
|
||||
m_cache.clear();
|
||||
|
@ -77,12 +77,12 @@ void GlobalSettingsZjp::resetAll()
|
|||
});
|
||||
}
|
||||
|
||||
QList<QString> GlobalSettingsZjp::getBlockDirs()
|
||||
QList<QString> GlobalSettings::getBlockDirs()
|
||||
{
|
||||
return m_cache.keys();
|
||||
}
|
||||
|
||||
void GlobalSettingsZjp::setValue(const QString &key, const QVariant &value)
|
||||
void GlobalSettings::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
m_cache.insert(key, value);
|
||||
QtConcurrent::run([=]() {
|
||||
|
@ -94,7 +94,7 @@ void GlobalSettingsZjp::setValue(const QString &key, const QVariant &value)
|
|||
});
|
||||
}
|
||||
|
||||
void GlobalSettingsZjp::forceSync(const QString &key)
|
||||
void GlobalSettings::forceSync(const QString &key)
|
||||
{
|
||||
m_settings->sync();
|
||||
if (key.isNull()) {
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#define CONTENT_INDEX_DATABASE_STATE "content_index_database_state"
|
||||
#define INDEX_GENERATOR_NORMAL_EXIT "index_generator_normal_exit"
|
||||
|
||||
class LIBSEARCH_EXPORT GlobalSettingsZjp : public QObject
|
||||
class LIBSEARCH_EXPORT GlobalSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static GlobalSettingsZjp *getInstance();
|
||||
static GlobalSettings *getInstance();
|
||||
const QVariant getValue(const QString&);
|
||||
bool isExist(const QString&);
|
||||
|
||||
|
@ -39,8 +39,8 @@ public Q_SLOTS:
|
|||
void forceSync(const QString& = nullptr);
|
||||
|
||||
private:
|
||||
explicit GlobalSettingsZjp(QObject *parent = nullptr);
|
||||
~GlobalSettingsZjp();
|
||||
explicit GlobalSettings(QObject *parent = nullptr);
|
||||
~GlobalSettings();
|
||||
|
||||
QSettings* m_settings;
|
||||
QGSettings* m_gsettings;
|
||||
|
|
30
src/main.cpp
30
src/main.cpp
|
@ -50,23 +50,23 @@ int main(int argc, char *argv[])
|
|||
//load chinese character and pinyin file to a Map
|
||||
FileUtils::loadHanziTable("://index/pinyinWithoutTone.txt");
|
||||
/*-------------InotyifyRefact Test Start---------------*/
|
||||
QTime t1 = QTime::currentTime();
|
||||
InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
|
||||
imr->start();
|
||||
QTime t2 = QTime::currentTime();
|
||||
qDebug() << t1;
|
||||
qDebug() << t2;
|
||||
// QTime t1 = QTime::currentTime();
|
||||
// InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
|
||||
// imr->start();
|
||||
// QTime t2 = QTime::currentTime();
|
||||
// qDebug() << t1;
|
||||
// qDebug() << t2;
|
||||
/*-------------InotyifyRefact Test End-----------------*/
|
||||
|
||||
/*-------------InotyifyRefact Test Start---------------*/
|
||||
QTime t3 = QTime::currentTime();
|
||||
FileTypeFilter* ftf = new FileTypeFilter("/home");
|
||||
ftf->Test();
|
||||
QTime t4 = QTime::currentTime();
|
||||
delete ftf;
|
||||
ftf = nullptr;
|
||||
qDebug() << t3;
|
||||
qDebug() << t4;
|
||||
// QTime t3 = QTime::currentTime();
|
||||
// FileTypeFilter* ftf = new FileTypeFilter("/home");
|
||||
// ftf->Test();
|
||||
// QTime t4 = QTime::currentTime();
|
||||
// delete ftf;
|
||||
// ftf = nullptr;
|
||||
// qDebug() << t3;
|
||||
// qDebug() << t4;
|
||||
/*-------------InotyifyRefact Test End-----------------*/
|
||||
|
||||
/*-------------文本搜索 Test start-----------------*/
|
||||
|
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
|
|||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
QtSingleApplication app("ukui-search", argc, argv);
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
|
||||
if(app.isRunning())
|
||||
|
|
|
@ -57,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
// im->start();
|
||||
/*-------------Inotify Test End-----------------*/
|
||||
|
||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
this->setAutoFillBackground(false);
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
@ -137,8 +137,10 @@ void MainWindow::initUi()
|
|||
m_settingsWidget->show();
|
||||
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
||||
QTimer::singleShot(100, this, [ = ] {
|
||||
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
|
||||
this->raise();
|
||||
this->showNormal();
|
||||
m_settingsWidget->deleteLater();
|
||||
this->activateWindow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue