From 3f76ee000c3d38631d87df75ad301cde548f430e Mon Sep 17 00:00:00 2001 From: xarkes Date: Thu, 1 Nov 2018 23:23:01 +0100 Subject: [PATCH] Code cleaning (#898) --- src/CutterApplication.cpp | 14 ++++++++++++++ src/MainWindow.cpp | 25 +++---------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index ffcd63ff..c98d30fc 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -24,6 +24,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc, argv) { + // Load translations QTranslator *t = new QTranslator; QTranslator *qtBaseTranslator = new QTranslator; QTranslator *qtTranslator = new QTranslator; @@ -61,12 +62,25 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc } } + // Setup application information setOrganizationName("Cutter"); setApplicationName("Cutter"); setApplicationVersion(CUTTER_VERSION_FULL); setWindowIcon(QIcon(":/img/cutter.svg")); setAttribute(Qt::AA_DontShowIconsInMenus); + // Load fonts + int ret = QFontDatabase::addApplicationFont(":/fonts/Anonymous Pro.ttf"); + if (ret == -1) { + qWarning() << "Cannot load Anonymous Pro font."; + } + + ret = QFontDatabase::addApplicationFont(":/fonts/Inconsolata-Regular.ttf"); + if (ret == -1) { + qWarning() << "Cannot load Incosolata-Regular font."; + } + + // Set QString codec to UTF-8 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); #if QT_VERSION < QT_VERSION_CHECK(5,0,0) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 897b2327..11542015 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -85,20 +85,6 @@ #include #include -#include - -static void registerCustomFonts() -{ - int ret = QFontDatabase::addApplicationFont(":/fonts/Anonymous Pro.ttf"); - assert(-1 != ret && "unable to register Anonymous Pro.ttf"); - - ret = QFontDatabase::addApplicationFont(":/fonts/Inconsolata-Regular.ttf"); - assert(-1 != ret && "unable to register Inconsolata-Regular.ttf"); - - // Do not issue a warning in release - Q_UNUSED(ret) -} - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), core(Core()), @@ -117,12 +103,9 @@ void MainWindow::initUI() { ui->setupUi(this); - registerCustomFonts(); - /* - * Toolbar - */ - + * Toolbar + */ // Sepparator between undo/redo and goto lineEdit QWidget *spacer3 = new QWidget(); spacer3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -133,9 +116,7 @@ void MainWindow::initUI() DebugToolbar *debugToolbar = new DebugToolbar(this); ui->mainToolBar->addWidget(debugToolbar); // Debug menu - // ui->menuDebug->addAction(debugToolbar->actionStart); ui->menuDebug->addAction(debugToolbar->actionStartEmul); - // ui->menuDebug->addAction(debugToolbar->actionAttach); ui->menuDebug->addSeparator(); ui->menuDebug->addAction(debugToolbar->actionStep); ui->menuDebug->addAction(debugToolbar->actionStepOver); @@ -279,7 +260,7 @@ void MainWindow::initUI() connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this, &MainWindow::updateTasksIndicator); - /* Load plugins */ + /* Setup plugins interfaces */ QList plugins = core->getCutterPlugins(); for (auto plugin : plugins) { CutterDockWidget *pluginDock = plugin->setupInterface(this);