diff --git a/qt5/guiwrapper/mainwindow.cpp b/qt5/guiwrapper/mainwindow.cpp index 0acc0f0..f599973 100644 --- a/qt5/guiwrapper/mainwindow.cpp +++ b/qt5/guiwrapper/mainwindow.cpp @@ -9,10 +9,13 @@ #include "fcitxqtconfiguifactory.h" #include "fcitxqtcontrollerproxy.h" #include "fcitxqtwatcher.h" +#include #include #include #include #include +#include +#include #include #include @@ -20,7 +23,7 @@ namespace fcitx { MainWindow::MainWindow(const QString &path, FcitxQtConfigUIWidget *pluginWidget, QWidget *parent) - : QDialog(parent), path_(path), watcher_(new FcitxQtWatcher(this)), + : QWidget(parent), path_(path), watcher_(new FcitxQtWatcher(this)), pluginWidget_(pluginWidget), proxy_(0) { setupUi(this); watcher_->setConnection(QDBusConnection::sessionBus()); @@ -145,6 +148,12 @@ void MainWindow::showEvent(QShowEvent *event) { connect(this, &QObject::destroyed, mainWindow, &QObject::deleteLater); subWindow->setTransientParent(mainWindow); - QDialog::showEvent(event); + QWidget::showEvent(event); +} + +void MainWindow::closeEvent(QCloseEvent *event) { + QWidget::closeEvent(event); + + qApp->quit(); } } // namespace fcitx diff --git a/qt5/guiwrapper/mainwindow.h b/qt5/guiwrapper/mainwindow.h index a9a0698..10e944c 100644 --- a/qt5/guiwrapper/mainwindow.h +++ b/qt5/guiwrapper/mainwindow.h @@ -14,12 +14,13 @@ #include "fcitxqtconfiguiwidget.h" #include "ui_mainwindow.h" #include +#include namespace fcitx { class FcitxQtControllerProxy; class FcitxQtWatcher; -class MainWindow : public QDialog, public Ui::MainWindow { +class MainWindow : public QWidget, public Ui::MainWindow { Q_OBJECT public: explicit MainWindow(const QString &path, @@ -35,6 +36,7 @@ public Q_SLOTS: protected: void showEvent(QShowEvent *event) override; + void closeEvent(QCloseEvent *event) override; private Q_SLOTS: void saveFinished(); diff --git a/qt5/guiwrapper/wrapperapp.cpp b/qt5/guiwrapper/wrapperapp.cpp index 13b6942..854093e 100644 --- a/qt5/guiwrapper/wrapperapp.cpp +++ b/qt5/guiwrapper/wrapperapp.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace fcitx { @@ -69,15 +70,14 @@ void WrapperApp::init() { mainWindow_ = new MainWindow(path, widget); if (ok && winid) { mainWindow_->setParentWindow(winid); + mainWindow_->setWindowModality(Qt::WindowModal); + mainWindow_->setWindowFlag(Qt::Dialog); } QMetaObject::invokeMethod(this, "run", Qt::QueuedConnection); } } -void WrapperApp::run() { - mainWindow_->exec(); - QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); -} +void WrapperApp::run() { mainWindow_->show(); } WrapperApp::~WrapperApp() { if (mainWindow_) {