diff --git a/src/helpers.cpp b/src/helpers.cpp index e7b0eea3..01158be1 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -1,31 +1,27 @@ #include "helpers.h" -QHelpers::QHelpers(QObject *parent) : - QObject(parent) +#include +#include + +namespace qhelpers { - // Meow -} -void QHelpers::normalizeFont(QPlainTextEdit *edit) { +// TODO: wouldn't it be enough to setFont on the QWidget? + +void normalizeFont(QPlainTextEdit *edit) { #ifdef Q_OS_LINUX - // Add custom monospaced font - QFontDatabase fontDB; - fontDB.addApplicationFont(":/new/prefix1/fonts/Inconsolata-Regular.ttf"); - QFont anonFont("Inconsolata", 12); QTextDocument *out_doc = edit->document(); out_doc->setDefaultFont(anonFont); #endif } -void QHelpers::normalizeEditFont(QTextEdit *edit) { +void normalizeEditFont(QTextEdit *edit) { #ifdef Q_OS_LINUX - // Add custom monospaced font - QFontDatabase fontDB; - fontDB.addApplicationFont(":/new/prefix1/fonts/Inconsolata-Regular.ttf"); - QFont anonFont("Inconsolata", 12); QTextDocument *out_doc = edit->document(); out_doc->setDefaultFont(anonFont); #endif } + +} // end namespace diff --git a/src/helpers.h b/src/helpers.h index 77354e3e..ec209f72 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -1,24 +1,13 @@ #ifndef QHELPERS_H #define QHELPERS_H -#include -#include -#include +class QPlainTextEdit; +class QTextEdit; -#include "mainwindow.h" - -class QHelpers : public QObject +namespace qhelpers { - Q_OBJECT -public: - explicit QHelpers(QObject *parent = 0); void normalizeFont(QPlainTextEdit *edit); void normalizeEditFont(QTextEdit *edit); - -signals: - -public slots: - -}; +} #endif // HELPERS_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bdc9289f..6201ee50 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -34,29 +34,23 @@ #include #include -static void adjustColumns(QTreeWidget *tw) { - int count = tw->columnCount(); - for (int i = 0; i != count; ++i) { - tw->resizeColumnToContents(i); +#include + +namespace +{ + void registerCustomFonts() + { + int ret = QFontDatabase::addApplicationFont(":/new/prefix1/fonts/Anonymous Pro.ttf"); + assert(-1 != ret && "unable to register Anonymous Pro.ttf"); + + ret = QFontDatabase::addApplicationFont(":/new/prefix1/fonts/Inconsolata-Regular.ttf"); + assert(-1 != ret && "unable to register Inconsolata-Regular.ttf"); + + // do not issue a warning in release + Q_UNUSED(ret) } } -static void appendRow(QTreeWidget *tw, const QString &str, const QString &str2=NULL, - const QString &str3=NULL, const QString &str4=NULL, const QString &str5=NULL) { - QTreeWidgetItem *tempItem = new QTreeWidgetItem(); - // Fill dummy hidden column - tempItem->setText(0,"0"); - tempItem->setText(1,str); - if (str2!=NULL) - tempItem->setText(2, str2); - if (str3!=NULL) - tempItem->setText(3, str3); - if (str4!=NULL) - tempItem->setText(4, str4); - if (str5!=NULL) - tempItem->setText(5, str5); - tw->insertTopLevelItem(0, tempItem); -} MainWindow::MainWindow(QWidget *parent, QRCore *kore) : QMainWindow(parent), @@ -69,8 +63,8 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) : doLock = false; - // Add custom font - QFontDatabase::addApplicationFont(":/new/prefix1/fonts/Anonymous Pro.ttf"); + registerCustomFonts(); + /* * Toolbar @@ -134,8 +128,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) : addToolBar(graphicsBar); // Fix output panel font - QHelpers *help = new QHelpers(); - help->normalizeFont(ui->consoleOutputTextEdit); + qhelpers::normalizeFont(ui->consoleOutputTextEdit); /* * Dock Widgets diff --git a/src/widgets/memwidget/memorywidget.cpp b/src/widgets/memwidget/memorywidget.cpp index 4cb51a04..8e497279 100644 --- a/src/widgets/memwidget/memorywidget.cpp +++ b/src/widgets/memwidget/memorywidget.cpp @@ -74,11 +74,10 @@ MemoryWidget::MemoryWidget(MainWindow *main, QWidget *parent) : ui->fcnNameEdit->setTextMargins(5, 0, 0, 0); // Normalize fonts for other OS - QHelpers *help = new QHelpers(); - help->normalizeFont(this->disasTextEdit); - help->normalizeEditFont(this->hexOffsetText); - help->normalizeEditFont(this->hexHexText); - help->normalizeEditFont(this->hexASCIIText); + qhelpers::normalizeFont(this->disasTextEdit); + qhelpers::normalizeEditFont(this->hexOffsetText); + qhelpers::normalizeEditFont(this->hexHexText); + qhelpers::normalizeEditFont(this->hexASCIIText); // Popup menu on Settings toolbutton QMenu *memMenu = new QMenu();