2017-03-29 10:18:37 +00:00
|
|
|
#include "helpers.h"
|
|
|
|
|
2017-04-05 08:56:59 +00:00
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QTextEdit>
|
2017-04-18 10:03:47 +00:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QCryptographicHash>
|
2017-04-05 08:56:59 +00:00
|
|
|
|
|
|
|
namespace qhelpers
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
// TODO: wouldn't it be enough to setFont on the QWidget?
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void normalizeFont(QPlainTextEdit *edit)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_LINUX
|
2017-03-29 10:18:37 +00:00
|
|
|
QFont anonFont("Inconsolata", 12);
|
|
|
|
QTextDocument *out_doc = edit->document();
|
|
|
|
out_doc->setDefaultFont(anonFont);
|
2017-04-09 19:55:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void normalizeEditFont(QTextEdit *edit)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_LINUX
|
2017-03-29 10:18:37 +00:00
|
|
|
QFont anonFont("Inconsolata", 12);
|
|
|
|
QTextDocument *out_doc = edit->document();
|
|
|
|
out_doc->setDefaultFont(anonFont);
|
2017-04-09 19:55:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-04-18 10:03:47 +00:00
|
|
|
QString uniqueProjectName(const QString &filename)
|
|
|
|
{
|
|
|
|
const QByteArray fullHash(QCryptographicHash::hash(filename.toUtf8(), QCryptographicHash::Sha1));
|
|
|
|
return QFileInfo(filename).fileName() + "_" + fullHash.toHex().left(10);
|
|
|
|
}
|
|
|
|
|
2017-04-05 08:56:59 +00:00
|
|
|
} // end namespace
|