Fix parents for all dialog windows
[quassel.git] / src / qtui / mainwin.cpp
index dae5029..b446130 100644 (file)
@@ -466,7 +466,14 @@ void MainWin::setupActions()
                      coll,
                      this,
                      &MainWin::onFormatUnderlineTriggered,
-                     QKeySequence::Underline)}});
+                     QKeySequence::Underline)},
+         {"FormatStrikethrough",
+          new Action(icon::get("format-text-strikethrough"),
+                     tr("Toggle strikethrough"),
+                     coll,
+                     this,
+                     &MainWin::onFormatStrikethroughTriggered,
+                     QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S))}});
 
     // Navigation
     coll = QtUi::actionCollection("Navigation", tr("Navigation"));
@@ -802,7 +809,7 @@ void MainWin::changeActiveBufferView(int bufferViewId)
 void MainWin::showPasswordChangeDlg()
 {
     if (Client::isCoreFeatureEnabled(Quassel::Feature::PasswordChange)) {
-        PasswordChangeDlg{}.exec();
+        PasswordChangeDlg{this}.exec();
     }
     else {
         QMessageBox box(QMessageBox::Warning,
@@ -911,17 +918,17 @@ void MainWin::hideCurrentBuffer()
 
 void MainWin::showNotificationsDlg()
 {
-    SettingsPageDlg{new NotificationsSettingsPage{}}.exec();
+    SettingsPageDlg{new NotificationsSettingsPage{}, this}.exec();
 }
 
 void MainWin::onConfigureNetworksTriggered()
 {
-    SettingsPageDlg{new NetworksSettingsPage{}}.exec();
+    SettingsPageDlg{new NetworksSettingsPage{}, this}.exec();
 }
 
 void MainWin::onConfigureViewsTriggered()
 {
-    SettingsPageDlg{new BufferViewSettingsPage{}}.exec();
+    SettingsPageDlg{new BufferViewSettingsPage{}, this}.exec();
 }
 
 void MainWin::onLockLayoutToggled(bool lock)
@@ -1348,7 +1355,7 @@ void MainWin::setDisconnectedState()
 void MainWin::userAuthenticationRequired(CoreAccount* account, bool* valid, const QString& errorMessage)
 {
     Q_UNUSED(errorMessage)
-    CoreConnectAuthDlg dlg(account);
+    CoreConnectAuthDlg dlg(account, this);
     *valid = (dlg.exec() == QDialog::Accepted);
 }
 
@@ -1377,8 +1384,14 @@ void MainWin::handleNoSslInCore(bool* accepted)
 void MainWin::handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently)
 {
     QString errorString = "<ul>";
-    foreach (const QSslError error, socket->sslErrors())
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+    for (const auto& error : socket->sslErrors()) {
+#else
+    for (const auto& error : socket->sslHandshakeErrors()) {
+#endif
         errorString += QString("<li>%1</li>").arg(error.errorString());
+    }
     errorString += "</ul>";
 
     QMessageBox box(QMessageBox::Warning,
@@ -1394,7 +1407,7 @@ void MainWin::handleSslErrors(const QSslSocket* socket, bool* accepted, bool* pe
         box.exec();
         role = box.buttonRole(box.clickedButton());
         if (role == QMessageBox::HelpRole) {
-            SslInfoDlg dlg(socket);
+            SslInfoDlg dlg(socket, this);
             dlg.exec();
         }
     } while (role == QMessageBox::HelpRole);
@@ -1419,7 +1432,7 @@ void MainWin::handleCoreConnectionError(const QString& error)
 
 void MainWin::showCoreConnectionDlg()
 {
-    CoreConnectDlg dlg;
+    CoreConnectDlg dlg{this};
     if (dlg.exec() == QDialog::Accepted) {
         AccountId accId = dlg.selectedAccount();
         if (accId.isValid())
@@ -1467,7 +1480,7 @@ void MainWin::showChannelList(NetworkId netId, const QString& channelFilters, bo
 
 void MainWin::showNetworkConfig(NetworkId netId)
 {
-    SettingsPageDlg dlg{new NetworksSettingsPage{}};
+    SettingsPageDlg dlg{new NetworksSettingsPage{}, this};
     if (netId.isValid())
         qobject_cast<NetworksSettingsPage*>(dlg.currentPage())->bufferList_Open(netId);
     dlg.exec();
@@ -1475,7 +1488,7 @@ void MainWin::showNetworkConfig(NetworkId netId)
 
 void MainWin::showIgnoreList(QString newRule)
 {
-    SettingsPageDlg dlg{new IgnoreListSettingsPage{}};
+    SettingsPageDlg dlg{new IgnoreListSettingsPage{}, this};
     // prepare config dialog for new rule
     if (!newRule.isEmpty())
         qobject_cast<IgnoreListSettingsPage*>(dlg.currentPage())->editIgnoreRule(newRule);
@@ -1484,7 +1497,7 @@ void MainWin::showIgnoreList(QString newRule)
 
 void MainWin::showCoreInfoDlg()
 {
-    CoreInfoDlg{}.exec();
+    CoreInfoDlg{this}.exec();
 }
 
 void MainWin::showAwayLog()
@@ -1506,7 +1519,7 @@ void MainWin::awayLogDestroyed()
 
 void MainWin::showSettingsDlg()
 {
-    auto dlg = new SettingsDlg();
+    auto dlg = new SettingsDlg(this);
 
     // Category: Interface
     dlg->registerSettingsPage(new AppearanceSettingsPage(dlg));
@@ -1520,8 +1533,15 @@ void MainWin::showSettingsDlg()
 #ifdef HAVE_SONNET
     dlg->registerSettingsPage(new SonnetSettingsPage(dlg));
 #endif
-    dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
-    dlg->registerSettingsPage(new CoreHighlightSettingsPage(dlg));
+    auto coreHighlightsPage = new CoreHighlightSettingsPage(dlg);
+    auto localHighlightsPage = new HighlightSettingsPage(dlg);
+    // Let CoreHighlightSettingsPage reload HighlightSettingsPage after doing an import with
+    // cleaning up.  Otherwise, HighlightSettingsPage won't show that the local rules were deleted.
+    connect(coreHighlightsPage, &CoreHighlightSettingsPage::localHighlightsChanged,
+            localHighlightsPage, &HighlightSettingsPage::load);
+    // Put core-side highlights before local/legacy highlights
+    dlg->registerSettingsPage(coreHighlightsPage);
+    dlg->registerSettingsPage(localHighlightsPage);
     dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
     dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
 
@@ -1544,7 +1564,7 @@ void MainWin::showSettingsDlg()
 
 void MainWin::showAboutDlg()
 {
-    AboutDlg{}.exec();
+    AboutDlg{this}.exec();
 }
 
 void MainWin::showShortcutsDlg()
@@ -1556,7 +1576,7 @@ void MainWin::showShortcutsDlg()
     }
     dlg.configure(true);
 #else
-    SettingsPageDlg{new ShortcutsSettingsPage{QtUi::actionCollections()}}.exec();
+    SettingsPageDlg{new ShortcutsSettingsPage{QtUi::actionCollections()}, this}.exec();
 #endif
 }
 
@@ -1834,6 +1854,15 @@ void MainWin::onFormatUnderlineTriggered()
     _inputWidget->toggleFormatUnderline();
 }
 
+void MainWin::onFormatStrikethroughTriggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->toggleFormatStrikethrough();
+}
+
+
 void MainWin::onJumpHotBufferTriggered()
 {
     if (!_bufferHotList->rowCount())