Skip to content

Commit fcc0ba3

Browse files
committed
Avoid deprecation warnings with building doxywizard with Qt6
1 parent 1427ed3 commit fcc0ba3

3 files changed

Lines changed: 64 additions & 16 deletions

File tree

addon/doxywizard/doxywizard.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,27 @@ MainWindow::MainWindow()
133133
: m_settings(QString::fromLatin1("Doxygen.org"), QString::fromLatin1("Doxywizard"))
134134
{
135135
QMenu *file = menuBar()->addMenu(tr("File"));
136-
file->addAction(tr("Open..."),
137-
this, SLOT(openConfig()), QKeySequence{ Qt::CTRL | Qt::Key_O });
136+
{
137+
QAction *a = file->addAction(tr("Open..."));
138+
a->setShortcut(QKeySequence{ Qt::CTRL | Qt::Key_O });
139+
connect(a, SIGNAL(triggered()), this, SLOT(openConfig()));
140+
}
138141
m_recentMenu = file->addMenu(tr("Open recent"));
139-
file->addAction(tr("Save"),
140-
this, SLOT(saveConfig()), QKeySequence{ Qt::CTRL | Qt::Key_S });
141-
file->addAction(tr("Save as..."),
142-
this, SLOT(saveConfigAs()), QKeySequence{ Qt::SHIFT | Qt::CTRL | Qt::Key_S });
143-
file->addAction(tr("Quit"),
144-
this, SLOT(quit()), QKeySequence{ Qt::CTRL | Qt::Key_Q });
142+
{
143+
QAction *a = file->addAction(tr("Save"));
144+
a->setShortcut(QKeySequence{ Qt::CTRL | Qt::Key_S });
145+
connect(a, SIGNAL(triggered()), this, SLOT(saveConfig()));
146+
}
147+
{
148+
QAction *a = file->addAction(tr("Save as..."));
149+
a->setShortcut(QKeySequence{ Qt::SHIFT | Qt::CTRL | Qt::Key_S });
150+
connect(a, SIGNAL(triggered()), this, SLOT(saveConfigAs()));
151+
}
152+
{
153+
QAction *a = file->addAction(tr("Quit"));
154+
a->setShortcut(QKeySequence{ Qt::CTRL | Qt::Key_Q });
155+
connect(a, SIGNAL(triggered()), this, SLOT(quit()));
156+
}
145157

146158
QMenu *settings = menuBar()->addMenu(tr("Settings"));
147159
m_resetDefault = settings->addAction(tr("Reset to factory defaults"),
@@ -158,13 +170,17 @@ MainWindow::MainWindow()
158170
m_clearRecent = settings->addAction(tr("Clear recent list"),
159171
this,SLOT(clearRecent()));
160172
settings->addSeparator();
161-
m_runMenu = settings->addAction(tr("Run doxygen"),
162-
this, SLOT(runDoxygenMenu()), QKeySequence{ Qt::CTRL | Qt::Key_R });
173+
m_runMenu = settings->addAction(tr("Run doxygen"));
174+
m_runMenu->setShortcut(QKeySequence{ Qt::CTRL | Qt::Key_R });
175+
connect(m_runMenu, SIGNAL(triggered()), this, SLOT(runDoxygenMenu()));
163176
m_runMenu->setEnabled(false);
164177

165178
QMenu *help = menuBar()->addMenu(tr("Help"));
166-
help->addAction(tr("Online manual"),
167-
this, SLOT(manual()), Qt::Key_F1);
179+
{
180+
QAction *a = help->addAction(tr("Online manual"));
181+
a->setShortcut(Qt::Key_F1);
182+
connect(a, SIGNAL(triggered()), this, SLOT(manual()));
183+
}
168184
help->addAction(tr("About"),
169185
this, SLOT(about()) );
170186

@@ -652,7 +668,7 @@ void MainWindow::runDoxygen()
652668
if (!m_running)
653669
{
654670
QString doxygenPath;
655-
#if defined(Q_OS_MACX)
671+
#if defined(Q_OS_MACOS)
656672
doxygenPath = qApp->applicationDirPath()+QString::fromLatin1("/../Resources/");
657673
qDebug() << "Doxygen path: " << doxygenPath;
658674
if ( !QFile(doxygenPath + QString::fromLatin1("doxygen")).exists() )

addon/doxywizard/expert.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ static void translateTopics(QDomElement &configRoot,const QDomElement &translati
209209
}
210210
}
211211

212+
static bool xmlSetContent(QDomDocument &doc, QIODevice *dev, QString *err, int *errLine, int *errCol)
213+
{
214+
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
215+
auto result = doc.setContent(dev, QDomDocument::ParseOption::Default);
216+
if (!result)
217+
{
218+
*err = result.errorMessage;
219+
*errLine = static_cast<int>(result.errorLine);
220+
*errCol = static_cast<int>(result.errorColumn);
221+
}
222+
return bool(result);
223+
#else
224+
return doc.setContent(dev, false, err, errLine, errCol);
225+
#endif
226+
}
227+
212228
Expert::Expert()
213229
{
214230
// --- Search bar (top) ---
@@ -274,7 +290,7 @@ Expert::Expert()
274290
QString err = tr("Error");
275291
int errLine=0,errCol=0;
276292
QDomDocument configXml;
277-
if (!file.open(QIODevice::ReadOnly) || !configXml.setContent(&file,false,&err,&errLine,&errCol))
293+
if (!file.open(QIODevice::ReadOnly) || !xmlSetContent(configXml,&file,&err,&errLine,&errCol))
278294
{
279295
QString msg = tr("Error parsing internal config.xml at line %1 column %2.\n%3").
280296
arg(errLine).arg(errCol).arg(err);
@@ -288,7 +304,7 @@ Expert::Expert()
288304
if (trFile.open(QIODevice::ReadOnly))
289305
{
290306
QDomDocument trConfigXml;
291-
if (!trConfigXml.setContent(&trFile,false,&err,&errLine,&errCol))
307+
if (!xmlSetContent(trConfigXml,&trFile,&err,&errLine,&errCol))
292308
{
293309
QString msg = tr("Error parsing internal config_%1.xml at line %2 column %3.\n%4").
294310
arg(DoxygenWizard::langCode).arg(errLine).arg(errCol).arg(err);

addon/doxywizard/languagedialog.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@
2323
#include <QFileInfo>
2424
#include <QDomDocument>
2525

26+
static bool xmlSetContent(QDomDocument &doc, QIODevice *dev, QString *err, int *errLine, int *errCol)
27+
{
28+
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
29+
auto result = doc.setContent(dev, QDomDocument::ParseOption::Default);
30+
if (!result)
31+
{
32+
*err = result.errorMessage;
33+
*errLine = static_cast<int>(result.errorLine);
34+
*errCol = static_cast<int>(result.errorColumn);
35+
}
36+
return bool(result);
37+
#else
38+
return doc.setContent(dev, false, err, errLine, errCol);
39+
#endif
40+
}
41+
2642
LanguageDialog::LanguageDialog(const QString &currentLocale,
2743
QWidget *parent)
2844
: QDialog(parent)
@@ -64,7 +80,7 @@ LanguageDialog::LanguageDialog(const QString &currentLocale,
6480
QDomDocument trConfigXml;
6581
QString err = tr("Error");
6682
int errLine=0,errCol=0;
67-
if (trConfigXml.setContent(&trFile,false,&err,&errLine,&errCol))
83+
if (xmlSetContent(trConfigXml,&trFile,&err,&errLine,&errCol))
6884
{
6985
QString langLabel = trConfigXml.documentElement().attribute(QString::fromLatin1("lang"));
7086
auto *rb = new QRadioButton(langLabel, groupBox);

0 commit comments

Comments
 (0)