Skip to content

Commit

Permalink
style: apply clang-format to the whole codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Mar 17, 2024
1 parent 73b9f89 commit bfa072a
Show file tree
Hide file tree
Showing 116 changed files with 7,807 additions and 7,705 deletions.
75 changes: 39 additions & 36 deletions app/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,48 @@

#include "ktikzapplication.h"

AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
{
QLabel *pixmapLabel = new QLabel;
pixmapLabel->setPixmap(QPixmap(QLatin1String(":/icons/qtikz-128.png")));
QLabel *label = new QLabel(QString(QLatin1String("<h1>%1 %2</h1><p>%3</p><p>%4</p>"))
.arg(KtikzApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(tr("Copyright 2007-2014 Florian Hackenberger and Glad Deschrijver"))
.arg(tr("This is a program for creating TikZ (from the LaTeX pgf package) diagrams.")));
label->setWordWrap(true);
QLabel *pixmapLabel = new QLabel;
pixmapLabel->setPixmap(QPixmap(QLatin1String(":/icons/qtikz-128.png")));
QLabel *label = new QLabel(
QString(QLatin1String("<h1>%1 %2</h1><p>%3</p><p>%4</p>"))
.arg(KtikzApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(tr("Copyright 2007-2014 Florian Hackenberger and Glad Deschrijver"))
.arg(tr("This is a program for creating TikZ (from the LaTeX pgf package) "
"diagrams.")));
label->setWordWrap(true);

QWidget *topWidget = new QWidget;
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(pixmapLabel);
topLayout->addWidget(label);
topWidget->setLayout(topLayout);
QWidget *topWidget = new QWidget;
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(pixmapLabel);
topLayout->addWidget(label);
topWidget->setLayout(topLayout);

QTextBrowser *textEdit = new QTextBrowser;
textEdit->setHtml(tr("<p>This program is free "
"software; you can redistribute it and/or modify it under the "
"terms of the GNU General Public License as published by the "
"Free Software Foundation; either version 2 of the License, "
"or (at your option) any later version.</p>"
"<p>This program is distributed in the hope that it will "
"be useful, but WITHOUT ANY WARRANTY; without even the implied "
"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
"See the <a href=\"http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\">GNU General Public License</a> for more details.</p>"));
textEdit->setReadOnly(true);
textEdit->setOpenExternalLinks(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QTextBrowser *textEdit = new QTextBrowser;
textEdit->setHtml(
tr("<p>This program is free "
"software; you can redistribute it and/or modify it under the "
"terms of the GNU General Public License as published by the "
"Free Software Foundation; either version 2 of the License, "
"or (at your option) any later version.</p>"
"<p>This program is distributed in the hope that it will "
"be useful, but WITHOUT ANY WARRANTY; without even the implied "
"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
"See the <a href=\"http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\">GNU "
"General Public License</a> for more details.</p>"));
textEdit->setReadOnly(true);
textEdit->setOpenExternalLinks(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(topWidget);
mainLayout->addWidget(textEdit);
mainLayout->addWidget(buttonBox);
mainLayout->setSpacing(10);
buttonBox->setFocus();
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(topWidget);
mainLayout->addWidget(textEdit);
mainLayout->addWidget(buttonBox);
mainLayout->setSpacing(10);
buttonBox->setFocus();

setWindowTitle(tr("About %1").arg(KtikzApplication::applicationName()));
setWindowTitle(tr("About %1").arg(KtikzApplication::applicationName()));
}
4 changes: 2 additions & 2 deletions app/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

class AboutDialog : public QDialog
{
Q_OBJECT
Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = 0);
explicit AboutDialog(QWidget *parent = 0);
};

#endif
86 changes: 41 additions & 45 deletions app/assistantcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,69 +26,65 @@

#include "ktikzapplication.h"

AssistantController::AssistantController()
: m_process(0)
{
}
AssistantController::AssistantController() : m_process(0) { }

AssistantController::~AssistantController()
{
if (m_process && m_process->state() == QProcess::Running)
{
m_process->terminate();
m_process->waitForFinished(3000);
}
delete m_process;
if (m_process && m_process->state() == QProcess::Running) {
m_process->terminate();
m_process->waitForFinished(3000);
}
delete m_process;
}

bool AssistantController::startAssistant()
{
if (!m_process)
m_process = new QProcess();
if (!m_process)
m_process = new QProcess();

if (m_process->state() != QProcess::Running)
{
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
if (m_process->state() != QProcess::Running) {
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
#if !defined(Q_OS_MAC)
app += QLatin1String("assistant");
app += QLatin1String("assistant");
#else
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
#endif

const QString ktikzDocFile = QString::fromLocal8Bit(KTIKZ_DOCUMENTATION_INSTALL_DIR) + QLatin1String("/qtikz.qhc");
if (!QFileInfo(ktikzDocFile).isReadable())
{
QMessageBox::critical(0, KtikzApplication::applicationName(),
QCoreApplication::translate("AssistantController", "Unable to open the help file (%1)").arg(ktikzDocFile));
return false;
}
const QString ktikzDocFile = QString::fromLocal8Bit(KTIKZ_DOCUMENTATION_INSTALL_DIR)
+ QLatin1String("/qtikz.qhc");
if (!QFileInfo(ktikzDocFile).isReadable()) {
QMessageBox::critical(0, KtikzApplication::applicationName(),
QCoreApplication::translate("AssistantController",
"Unable to open the help file (%1)")
.arg(ktikzDocFile));
return false;
}

QStringList args;
args << QLatin1String("-collectionFile")
<< ktikzDocFile
<< QLatin1String("-enableRemoteControl");
QStringList args;
args << QLatin1String("-collectionFile") << ktikzDocFile
<< QLatin1String("-enableRemoteControl");

m_process->start(app, args);
m_process->start(app, args);

if (!m_process->waitForStarted())
{
QMessageBox::critical(0, KtikzApplication::applicationName(),
QCoreApplication::translate("AssistantController", "Unable to launch Qt Assistant (%1)").arg(app));
return false;
}
}
return true;
if (!m_process->waitForStarted()) {
QMessageBox::critical(0, KtikzApplication::applicationName(),
QCoreApplication::translate("AssistantController",
"Unable to launch Qt Assistant (%1)")
.arg(app));
return false;
}
}
return true;
}

void AssistantController::showDocumentation(const QString &page)
{
if (!startAssistant())
return;
if (!startAssistant())
return;

if (!page.isEmpty())
{
QByteArray ba;
ba.append("setSource qthelp://hackenberger.qtikz/doc/");
m_process->write(ba + page.toLocal8Bit() + '\0');
}
if (!page.isEmpty()) {
QByteArray ba;
ba.append("setSource qthelp://hackenberger.qtikz/doc/");
m_process->write(ba + page.toLocal8Bit() + '\0');
}
}
10 changes: 5 additions & 5 deletions app/assistantcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class QProcess;
class AssistantController
{
public:
AssistantController();
~AssistantController();
AssistantController();
~AssistantController();

void showDocumentation(const QString &page = QString());
void showDocumentation(const QString &page = QString());

private:
bool startAssistant();
bool startAssistant();

QProcess *m_process;
QProcess *m_process;
};

#endif
Loading

0 comments on commit bfa072a

Please sign in to comment.