Skip to content

Commit 08e831b

Browse files
authored
Fix issue with qt6.8 (#66)
It seems that dialog->exec() may have some issue if a dialog opens another dialog. Try avoid use QDialog::exec() to show main window, use show() instead.
1 parent 47b3f67 commit 08e831b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

qt5/guiwrapper/mainwindow.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
#include "fcitxqtconfiguifactory.h"
1010
#include "fcitxqtcontrollerproxy.h"
1111
#include "fcitxqtwatcher.h"
12+
#include <QCloseEvent>
1213
#include <QDebug>
1314
#include <QLocale>
1415
#include <QMessageBox>
1516
#include <QPushButton>
17+
#include <QShowEvent>
18+
#include <QWidget>
1619
#include <QWindow>
1720
#include <fcitx-utils/i18n.h>
1821

1922
namespace fcitx {
2023

2124
MainWindow::MainWindow(const QString &path, FcitxQtConfigUIWidget *pluginWidget,
2225
QWidget *parent)
23-
: QDialog(parent), path_(path), watcher_(new FcitxQtWatcher(this)),
26+
: QWidget(parent), path_(path), watcher_(new FcitxQtWatcher(this)),
2427
pluginWidget_(pluginWidget), proxy_(0) {
2528
setupUi(this);
2629
watcher_->setConnection(QDBusConnection::sessionBus());
@@ -145,6 +148,12 @@ void MainWindow::showEvent(QShowEvent *event) {
145148
connect(this, &QObject::destroyed, mainWindow, &QObject::deleteLater);
146149
subWindow->setTransientParent(mainWindow);
147150

148-
QDialog::showEvent(event);
151+
QWidget::showEvent(event);
152+
}
153+
154+
void MainWindow::closeEvent(QCloseEvent *event) {
155+
QWidget::closeEvent(event);
156+
157+
qApp->quit();
149158
}
150159
} // namespace fcitx

qt5/guiwrapper/mainwindow.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#include "fcitxqtconfiguiwidget.h"
1515
#include "ui_mainwindow.h"
1616
#include <QDBusPendingCallWatcher>
17+
#include <QWidget>
1718

1819
namespace fcitx {
1920

2021
class FcitxQtControllerProxy;
2122
class FcitxQtWatcher;
22-
class MainWindow : public QDialog, public Ui::MainWindow {
23+
class MainWindow : public QWidget, public Ui::MainWindow {
2324
Q_OBJECT
2425
public:
2526
explicit MainWindow(const QString &path,
@@ -35,6 +36,7 @@ public Q_SLOTS:
3536

3637
protected:
3738
void showEvent(QShowEvent *event) override;
39+
void closeEvent(QCloseEvent *event) override;
3840

3941
private Q_SLOTS:
4042
void saveFinished();

qt5/guiwrapper/wrapperapp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QWindow>
1515
#include <fcitx-utils/i18n.h>
1616
#include <fcitx-utils/standardpath.h>
17+
#include <qnamespace.h>
1718

1819
namespace fcitx {
1920

@@ -69,15 +70,14 @@ void WrapperApp::init() {
6970
mainWindow_ = new MainWindow(path, widget);
7071
if (ok && winid) {
7172
mainWindow_->setParentWindow(winid);
73+
mainWindow_->setWindowModality(Qt::WindowModal);
74+
mainWindow_->setWindowFlag(Qt::Dialog);
7275
}
7376
QMetaObject::invokeMethod(this, "run", Qt::QueuedConnection);
7477
}
7578
}
7679

77-
void WrapperApp::run() {
78-
mainWindow_->exec();
79-
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
80-
}
80+
void WrapperApp::run() { mainWindow_->show(); }
8181

8282
WrapperApp::~WrapperApp() {
8383
if (mainWindow_) {

0 commit comments

Comments
 (0)