Skip to content

Port deprecated KDE functionality #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/configgeneralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void ConfigGeneralWidget::searchTikzDocumentation()
{
const QString tikzDocFile = TikzDocumentationController::searchTikzDocumentationInTexTree();
if (tikzDocFile.isEmpty())
MessageBox::sorry(this, tr("Cannot find TikZ documentation."),
MessageBox::error(this, tr("Cannot find TikZ documentation."),
KtikzApplication::applicationName());
else
ui.tikzDocEdit->setText(tikzDocFile);
Expand Down
3 changes: 3 additions & 0 deletions app/tikzktexteditorcompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void TikzKTextEditorCompletion::completionInvoked(
KTextEditor::View *view, const KTextEditor::Range &range,
KTextEditor::CodeCompletionModel::InvocationType it)
{
Q_UNUSED(view);
Q_UNUSED(range);
Q_UNUSED(it);
setRowCount(m_matches.rowCount());
}

Expand Down
11 changes: 3 additions & 8 deletions common/templatewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include "templatewidget.h"

#ifdef KTIKZ_USE_KDE
# include <KRun>
# include <kio_version.h>
# include <KIO/OpenUrlJob>
#endif

#include <QtCore/QProcess>
Expand Down Expand Up @@ -174,12 +173,8 @@ void TemplateWidget::editTemplateFile()
editorArguments << ui.templateCombo->currentText();

#ifdef KTIKZ_USE_KDE
# if ((KIO_VERSION_MAJOR >= 5) && (KIO_VERSION_MINOR > 31))
KRun::runUrl(Url(fileName()), QStringLiteral("text/plain"), NULL, KRun::RunExecutables,
QString());
# else
KRun::runUrl(Url(fileName()), QStringLiteral("text/plain"), NULL, 0);
# endif
KIO::OpenUrlJob *job = new KIO::OpenUrlJob(Url(fileName()), QStringLiteral("text/plain"));
job->start();
#else
QProcess process;
process.startDetached(m_editor, editorArguments);
Expand Down
3 changes: 2 additions & 1 deletion common/utils/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ bool File::fileExists(const QUrl &url)
if (!(url.isValid())) {
return false;
}
KIO::StatJob *existsJob = KIO::stat(url, KIO::StatJob::DestinationSide, 0);
KIO::StatJob *existsJob = KIO::statDetails(url, KIO::StatJob::DestinationSide, KIO::StatBasic,
KIO::HideProgressInfo);
existsJob->exec();
return (existsJob->error() == KJob::NoError);
}
Expand Down
28 changes: 18 additions & 10 deletions common/utils/messagebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@

#ifdef KTIKZ_USE_KDE
# include <KMessageBox>
# include <kwidgetsaddons_version.h>

int MessageBox::questionYesNo(QWidget *parent, const QString &text, const QString &caption,
const QString &yesButtonText, const QString &noButtonText)
{
int result;
# if ((KWIDGETSADDONS_VERSION_MAJOR >= 5) && (KWIDGETSADDONS_VERSION_MINOR >= 100))
if (!yesButtonText.isEmpty()) {
if (!noButtonText.isEmpty())
result = KMessageBox::questionTwoActions(
parent, text, caption, KGuiItem(yesButtonText, QLatin1String("dialog-ok")),
KGuiItem(noButtonText, QLatin1String("process-stop")));
else
result = KMessageBox::questionTwoActions(
parent, text, caption, KGuiItem(yesButtonText, QLatin1String("dialog-ok")),
KStandardGuiItem::cancel());
} else
result = KMessageBox::questionTwoActions(parent, text, caption, KStandardGuiItem::ok(),
KStandardGuiItem::cancel());

return (result == KMessageBox::PrimaryAction) ? Yes : No;
# else
if (!yesButtonText.isEmpty()) {
if (!noButtonText.isEmpty())
result = KMessageBox::questionYesNo(
Expand All @@ -37,11 +54,7 @@ int MessageBox::questionYesNo(QWidget *parent, const QString &text, const QStrin
result = KMessageBox::questionYesNo(parent, text, caption);

return (result == KMessageBox::Yes) ? Yes : No;
}

void MessageBox::sorry(QWidget *parent, const QString &text, const QString &caption)
{
KMessageBox::sorry(parent, text, caption);
# endif
}

void MessageBox::error(QWidget *parent, const QString &text, const QString &caption)
Expand Down Expand Up @@ -74,11 +87,6 @@ int MessageBox::questionYesNo(QWidget *parent, const QString &text, const QStrin
return (result == QMessageBox::Yes) ? Yes : No;
}

void MessageBox::sorry(QWidget *parent, const QString &text, const QString &caption)
{
QMessageBox::warning(parent, caption, text);
}

void MessageBox::error(QWidget *parent, const QString &text, const QString &caption)
{
QMessageBox::critical(parent, caption, text);
Expand Down
1 change: 0 additions & 1 deletion common/utils/messagebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class MessageBox
const QString &caption = QString(),
const QString &yesButtonText = QString(),
const QString &noButtonText = QString());
static void sorry(QWidget *parent, const QString &text, const QString &caption = QString());
static void error(QWidget *parent, const QString &text, const QString &caption = QString());
};

Expand Down
5 changes: 1 addition & 4 deletions part/part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args)
QTranslator *translator = createTranslator("qtikz");
qApp->installTranslator(translator);

setComponentData(KAboutData("ktikzpart", "KtikZ", APPVERSION));
// setComponentData(ktikzPartFactory::componentData()); // make sure that the actions of this
// kpart go in a separate section labeled "KtikZ Viewer" (as defined in K_EXPORT_PLUGIN above)
// in the "Configure Shortcuts" dialog
setComponentName("ktikzpart", "KtikZ");

m_configDialog = 0;

Expand Down