Skip to content

Commit

Permalink
Migrate almost all QMessagebox to qt6-friendly version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltca committed Oct 18, 2023
1 parent ff61da6 commit 9052018
Show file tree
Hide file tree
Showing 28 changed files with 193 additions and 216 deletions.
4 changes: 2 additions & 2 deletions src/kvirc/kernel/KviDefaultScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ void KviDefaultScriptManager::restore()
// Check data
if(!compareVersions(szGlobal, &szError))
{
QMessageBox::warning(nullptr, __tr2qs("Restore Default - KVIrc"), szError, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
QMessageBox::warning(nullptr, __tr2qs("Restore Default - KVIrc"), szError);
return;
}

if(m_bNoNeedToRestore)
{
if(QMessageBox::warning(nullptr, __tr2qs("Restore Default - KVIrc"), szError, QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
if(QMessageBox::question(nullptr, __tr2qs("Restore Default - KVIrc"), szError) != QMessageBox::Yes)
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/kvirc/kernel/KviMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ int main(int argc, char ** argv)
KviCString szTmp(KviCString::Format, "Another KVIrc session is already running on this display and with this user ID.\nUse %s -f if you want to force a new session.", argv[0]);
if(a.bShowPopup)
{
QMessageBox::information(nullptr, "Duplicate Session - KVIrc", szTmp.ptr(), QMessageBox::Ok);
QMessageBox::information(nullptr, "Duplicate Session - KVIrc", szTmp.ptr());
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/kvirc/ui/KviFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool KviFileDialog::askForSaveFileName(QString & szBuffer, const QString & szCap

QString szTmp = QString(__tr2qs("The file %1 already exists.<br>Do you wish to overwrite it?")).arg(szBuffer);

switch(QMessageBox::information(pParent, __tr2qs("File Already Exists - KVIrc"), szTmp, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape))
switch(QMessageBox::question(pParent, __tr2qs("File Already Exists - KVIrc"), szTmp, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel))
{
case QMessageBox::Cancel:
return false;
Expand Down Expand Up @@ -156,7 +156,7 @@ bool KviFileDialog::askForSaveFileName(QString & szBuffer, const QString & szCap
{
QString szTmp = QString(__tr2qs("The file %1 already exists.<br>Do you wish to overwrite it?")).arg(szBuffer);

switch(QMessageBox::information(pDialog, __tr2qs("File Already Exists - KVIrc"), szTmp, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape))
switch(QMessageBox::question(pDialog, __tr2qs("File Already Exists - KVIrc"), szTmp, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel))
{
case QMessageBox::Cancel:
delete pDialog;
Expand Down
2 changes: 1 addition & 1 deletion src/kvirc/ui/KviIrcView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ void KviIrcView::chooseBackground()
QPixmap p(f);
if(p.isNull())
{
QMessageBox::information(this, __tr2qs("Invalid Image - KVIrc"), __tr2qs("Failed to load the selected image!"), __tr2qs("OK"));
QMessageBox::information(this, __tr2qs("Invalid Image - KVIrc"), __tr2qs("Failed to load the selected image!"));
return;
}

Expand Down
31 changes: 17 additions & 14 deletions src/kvirc/ui/KviMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,21 +826,24 @@ void KviMainWindow::closeEvent(QCloseEvent * e)

if(bGotRunningConnection)
{
QString txt = __tr2qs("There are active connections, are you sure you wish to quit KVIrc?");

switch(QMessageBox::warning(this, __tr2qs("Confirm Close - KVIrc"), txt, __tr2qs("&Yes"), __tr2qs("&Always"), __tr2qs("&No"), 2, 2))
QMessageBox pMsgBox;
pMsgBox.setWindowTitle(__tr2qs("Confirm Close - KVIrc"));
pMsgBox.setText(__tr2qs("There are active connections, are you sure you wish to quit KVIrc?"));
pMsgBox.setIcon(QMessageBox::Question);
QAbstractButton * pYesButton = pMsgBox.addButton(__tr2qs("&Yes"), QMessageBox::YesRole);
QAbstractButton * pAlwaysButton = pMsgBox.addButton(__tr2qs("&Always"), QMessageBox::YesRole);
QAbstractButton * pNoButton = pMsgBox.addButton(__tr2qs("&No"), QMessageBox::NoRole);
pMsgBox.setDefaultButton(qobject_cast<QPushButton *>(pNoButton));
pMsgBox.exec();
if(pMsgBox.clickedButton() == pYesButton)
{
case 0:
// ok to close
break;
case 1:
// ok to close but don't ask again
KVI_OPTION_BOOL(KviOption_boolConfirmCloseWhenThereAreConnections) = false;
break;
case 2:
e->ignore();
return;
break;
// ok to close
} else if(pMsgBox.clickedButton() == pAlwaysButton) {
// ok to close but don't ask again
KVI_OPTION_BOOL(KviOption_boolConfirmCloseWhenThereAreConnections) = false;
} else if(pMsgBox.clickedButton() == pNoButton || pMsgBox.clickedButton() == nullptr) {
e->ignore();
return;
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/kvirc/ui/KviMessageBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ namespace KviMessageBox
KStandardGuiItem::cont(), KStandardGuiItem::stop())
== KMessageBox::PrimaryAction);
#else
bRet = (QMessageBox::information(0, caption, s,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape)
bRet = (QMessageBox::question(0, caption, s)
== QMessageBox::Yes);
#endif
return bRet;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/actioneditor/ActionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void ActionEditor::exportActions()

if(!KviFileUtils::writeFile(szFile, szCode))
{
QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the actions file.", "editor"), __tr2qs_ctx("OK", "editor"));
QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the actions file.", "editor"));
}
}

Expand All @@ -762,7 +762,7 @@ void ActionEditor::deleteActions()
if(l.isEmpty())
return;

//if(QMessageBox::question(this,__tr2qs_ctx("Confirm Actions Deletion - KVIrc","editor"),__tr2qs_ctx("Do you really want to delete the selected actions?","editor"),__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("No","editor")) != 0)
//if(QMessageBox::question(this,__tr2qs_ctx("Confirm Actions Deletion - KVIrc","editor"),__tr2qs_ctx("Do you really want to delete the selected actions?","editor")) != QMessageBox::Yes)
// return;

for(ActionEditorTreeWidgetItem * i = l.first(); i; i = l.next())
Expand Down
14 changes: 4 additions & 10 deletions src/modules/addon/AddonManagementDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ void AddonManagementDialog::uninstallScript()
if(QMessageBox::question(
this,
__tr2qs_ctx("Confirm Addon Uninstallation - KVIrc", "addon"),
txt, __tr2qs_ctx("Yes", "addon"), __tr2qs_ctx("No", "addon"), nullptr, 1)
!= 0)
txt)
!= QMessageBox::Yes)
return;

KviKvsScriptAddonManager::instance()->unregisterAddon(it->addon()->name(), g_pActiveWindow);
Expand Down Expand Up @@ -322,10 +322,7 @@ void AddonManagementDialog::installScript()
QMessageBox::critical(
this,
__tr2qs_ctx("Install Addon - KVIrc", "addon"),
szError,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
szError);
return;
}
}
Expand All @@ -337,10 +334,7 @@ void AddonManagementDialog::installScript()
QMessageBox::critical(
this,
__tr2qs_ctx("Install Addon - KVIrc", "addon"),
szError,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
szError);
}

fillListView();
Expand Down
9 changes: 3 additions & 6 deletions src/modules/addon/PackAddonDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ bool PackAddonDialog::packAddon()
if(QMessageBox::question(
this,
__tr2qs_ctx("Exporting Addon Confirmation - KVIrc", "addon"),
__tr2qs_ctx("File %1 already exists. Do you want to overwrite it?", "addon").arg(info.szSavePath),
QMessageBox::Yes,
QMessageBox::No)
__tr2qs_ctx("File %1 already exists. Do you want to overwrite it?", "addon").arg(info.szSavePath))
== QMessageBox::No)
return false;
}
Expand All @@ -177,12 +175,11 @@ bool PackAddonDialog::packAddon()
if(!AddonFunctions::pack(info, szError))
{
QMessageBox::critical(this,
__tr2qs_ctx("Addon Packaging - KVIrc", "addon"),
szError, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
__tr2qs_ctx("Addon Packaging - KVIrc", "addon"), szError);
return false;
}

QMessageBox::information(this, __tr2qs_ctx("Exporting Addon Completed - KVIrc", "addon"), __tr2qs_ctx("The package was saved successfully in %1", "addon").arg(info.szSavePath), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
QMessageBox::information(this, __tr2qs_ctx("Exporting Addon Completed - KVIrc", "addon"), __tr2qs_ctx("The package was saved successfully in %1", "addon").arg(info.szSavePath));

return true;
}
Expand Down
88 changes: 45 additions & 43 deletions src/modules/aliaseditor/AliasEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,8 @@ void AliasEditorWidget::aliasRefresh(const QString & szName)
return;
}
if(
QMessageBox::warning(nullptr, __tr2qs_ctx("Confirm Overwriting Current - KVIrc", "editor"),
__tr2qs_ctx("An external script has changed the alias you are currently editing. Do you want to accept the external changes?", "editor"),
QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape)
QMessageBox::question(nullptr, __tr2qs_ctx("Confirm Overwriting Current - KVIrc", "editor"),
__tr2qs_ctx("An external script has changed the alias you are currently editing. Do you want to accept the external changes?", "editor"))
!= QMessageBox::Yes)
return;
item->setBuffer(alias->code());
Expand Down Expand Up @@ -465,8 +464,7 @@ void AliasEditorWidget::renameItem()
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Name Already Exists - KVIrc", "editor"),
__tr2qs_ctx("This name is already in use. Please choose another one.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("This name is already in use. Please choose another one.", "editor"));
g_pAliasEditorModule->unlock();
return;
}
Expand All @@ -479,8 +477,7 @@ void AliasEditorWidget::renameItem()
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Name Already Exists - KVIrc", "editor"),
__tr2qs_ctx("This name is already in use. Please choose another one.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("This name is already in use. Please choose another one.", "editor"));
g_pAliasEditorModule->unlock();
return;
}
Expand Down Expand Up @@ -749,7 +746,7 @@ void AliasEditorWidget::exportSelectionInSinglesFiles(KviPointerList<AliasEditor
if(!l->first())
{
g_pAliasEditorModule->lock();
QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("Must select an entry from the list to export!", "editor"), __tr2qs_ctx("OK", "editor"));
QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("Must select an entry from the list to export!", "editor"));
g_pAliasEditorModule->unlock();
return;
}
Expand Down Expand Up @@ -783,14 +780,23 @@ void AliasEditorWidget::exportSelectionInSinglesFiles(KviPointerList<AliasEditor
QString szCompletePath = m_szDir + szFileName;
if(KviFileUtils::fileExists(szCompletePath) && !bReplaceAll)
{
QString szMsg;
szMsg = QString(__tr2qs_ctx("The file \"%1\" exists. Do you want to replace it?", "editor")).arg(szFileName);
int ret = QMessageBox::question(this, __tr2qs_ctx("Confirm Replacing File - KVIrc", "editor"), szMsg, __tr2qs_ctx("Yes", "editor"), __tr2qs_ctx("Yes to All", "editor"), __tr2qs_ctx("No", "editor"));
if(ret != 2)
QMessageBox pMsgBox;
pMsgBox.setWindowTitle(__tr2qs_ctx("Confirm Replacing File - KVIrc", "editor"));
pMsgBox.setText(QString(__tr2qs_ctx("The file \"%1\" exists. Do you want to replace it?", "editor")).arg(szFileName));
pMsgBox.setIcon(QMessageBox::Question);
QAbstractButton * pYesButton = pMsgBox.addButton(__tr2qs_ctx("Yes", "editor"), QMessageBox::YesRole);
QAbstractButton * pAlwaysButton = pMsgBox.addButton(__tr2qs_ctx("Yes to All", "editor"), QMessageBox::YesRole);
QAbstractButton * pNoButton = pMsgBox.addButton( __tr2qs_ctx("No", "editor"), QMessageBox::NoRole);
pMsgBox.setDefaultButton(qobject_cast<QPushButton *>(pNoButton));
pMsgBox.exec();
if(pMsgBox.clickedButton() == pYesButton)
{
KviFileUtils::writeFile(szCompletePath, tmp);
if(ret == 1)
bReplaceAll = true;
} else if(pMsgBox.clickedButton() == pAlwaysButton) {
KviFileUtils::writeFile(szCompletePath, tmp);
bReplaceAll = true;
} else if(pMsgBox.clickedButton() == pNoButton || pMsgBox.clickedButton() == nullptr) {
// nothing
}
}
else
Expand Down Expand Up @@ -832,7 +838,7 @@ void AliasEditorWidget::exportAliases(bool bSelectedOnly, bool bSingleFiles)
if(szOut.isEmpty())
{
g_pAliasEditorModule->lock();
QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("The exported file could be empty: cowardly refusing to write it.", "editor"), __tr2qs_ctx("OK", "editor"));
QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("The exported file could be empty: cowardly refusing to write it.", "editor"));
g_pAliasEditorModule->unlock();
return;
}
Expand Down Expand Up @@ -874,7 +880,7 @@ void AliasEditorWidget::exportAliases(bool bSelectedOnly, bool bSingleFiles)
if(!KviFileUtils::writeFile(szFile, szOut))
{
g_pAliasEditorModule->lock();
QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the aliases file.", "editor"), __tr2qs_ctx("OK", "editor"));
QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the aliases file.", "editor"));
g_pAliasEditorModule->unlock();
}
}
Expand Down Expand Up @@ -987,19 +993,23 @@ bool AliasEditorWidget::removeItem(AliasEditorTreeWidgetItem * it, bool * pbYesT
}

g_pAliasEditorModule->lock();
int ret = QMessageBox::question(this, __tr2qs_ctx("Confirm Removing Item - KVIrc", "editor"), szMsg, __tr2qs_ctx("Yes", "editor"), __tr2qs_ctx("Yes to All", "editor"), __tr2qs_ctx("No", "editor"));
QMessageBox pMsgBox;
pMsgBox.setWindowTitle(__tr2qs_ctx("Confirm Removing Item - KVIrc", "editor"));
pMsgBox.setText(szMsg);
pMsgBox.setIcon(QMessageBox::Question);
QAbstractButton * pYesButton = pMsgBox.addButton(__tr2qs_ctx("Yes", "editor"), QMessageBox::YesRole);
QAbstractButton * pAlwaysButton = pMsgBox.addButton(__tr2qs_ctx("Yes to All", "editor"), QMessageBox::YesRole);
QAbstractButton * pNoButton = pMsgBox.addButton(__tr2qs_ctx("No", "editor"), QMessageBox::NoRole);
pMsgBox.setDefaultButton(qobject_cast<QPushButton *>(pNoButton));
pMsgBox.exec();
g_pAliasEditorModule->unlock();
switch(ret)
if(pMsgBox.clickedButton() == pYesButton)
{
case 0:
// nothing
break;
case 1:
*pbYesToAll = true;
break;
default:
return false;
break;
// nothing
} else if(pMsgBox.clickedButton() == pAlwaysButton) {
*pbYesToAll = true;
} else if(pMsgBox.clickedButton() == pNoButton || pMsgBox.clickedButton() == nullptr) {
return false;
}
}

Expand Down Expand Up @@ -1048,8 +1058,7 @@ QString AliasEditorWidget::askForAliasName(const QString & szAction, const QStri
g_pAliasEditorModule->lock();
QMessageBox::warning(this,
__tr2qs_ctx("Invalid or Missing Name - KVIrc", "editor"),
__tr2qs_ctx("You must specify a valid name for the alias.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("You must specify a valid name for the alias.", "editor"));
g_pAliasEditorModule->unlock();
continue;
}
Expand All @@ -1061,8 +1070,7 @@ QString AliasEditorWidget::askForAliasName(const QString & szAction, const QStri
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Aliases names can contain only letters, digits, underscores and '::' namespace separators.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Aliases names can contain only letters, digits, underscores and '::' namespace separators.", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand All @@ -1075,8 +1083,7 @@ QString AliasEditorWidget::askForAliasName(const QString & szAction, const QStri
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Stray ':' character in alias name: did you mean ...<namespace>::<name>?", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Stray ':' character in alias name: did you mean ...<namespace>::<name>?", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand All @@ -1086,8 +1093,7 @@ QString AliasEditorWidget::askForAliasName(const QString & szAction, const QStri
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Found an empty namespace in alias name.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Found an empty namespace in alias name.", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand Down Expand Up @@ -1117,8 +1123,7 @@ QString AliasEditorWidget::askForNamespaceName(const QString & szAction, const Q
g_pAliasEditorModule->lock();
QMessageBox::warning(this,
__tr2qs_ctx("Invalid or Missing Name - KVIrc", "editor"),
__tr2qs_ctx("You must specify a valid name for the namespace.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("You must specify a valid name for the namespace.", "editor"));
g_pAliasEditorModule->unlock();
continue;
}
Expand All @@ -1130,8 +1135,7 @@ QString AliasEditorWidget::askForNamespaceName(const QString & szAction, const Q
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Namespace names can contain only letters, digits, underscores and '::' namespace separators.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Namespace names can contain only letters, digits, underscores and '::' namespace separators.", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand All @@ -1144,8 +1148,7 @@ QString AliasEditorWidget::askForNamespaceName(const QString & szAction, const Q
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Stray ':' character in namespace name: did you mean... <namespace>::<name>?", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Stray ':' character in namespace name: did you mean... <namespace>::<name>?", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand All @@ -1155,8 +1158,7 @@ QString AliasEditorWidget::askForNamespaceName(const QString & szAction, const Q
g_pAliasEditorModule->lock();
QMessageBox::information(this,
__tr2qs_ctx("Invalid Name - KVIrc", "editor"),
__tr2qs_ctx("Found an empty namespace in namespace name.", "editor"),
__tr2qs_ctx("OK, Let me try again...", "editor"));
__tr2qs_ctx("Found an empty namespace in namespace name.", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
Expand Down
Loading

0 comments on commit 9052018

Please sign in to comment.