From 18273e236fe8faff44d4bf63087d049e04f67799 Mon Sep 17 00:00:00 2001 From: SeeLook <945374+SeeLook@users.noreply.github.com> Date: Mon, 15 Dec 2014 22:25:14 +0100 Subject: [PATCH] All tree libraries have independent pointers to Tglobals initialized at executable launch --- TODO | 1 - src/libs/core/exam/texam.cpp | 12 ++-- src/libs/core/exam/tlevel.cpp | 34 +++++------ src/libs/core/level/tlevelpreview.cpp | 4 +- src/libs/core/level/tlevelsdefs.cpp | 34 +++++------ src/libs/core/level/tlevelselector.cpp | 25 ++++---- src/libs/core/music/tkeysignature.cpp | 4 +- src/libs/core/tinitcorelib.cpp | 24 ++++---- src/libs/core/tinitcorelib.h | 6 +- src/libs/misc/CMakeLists.txt | 11 ++-- src/libs/misc/help/thelpdialogbase.cpp | 5 +- src/libs/misc/main.cpp | 2 +- src/libs/misc/taboutnootka.cpp | 27 +++++---- src/libs/misc/tfirstrunwizzard.cpp | 80 +++++++++++++------------- src/libs/sound/CMakeLists.txt | 2 +- src/libs/sound/main.cpp | 2 +- src/libs/sound/tsound.cpp | 54 ++++++++--------- src/libs/sound/tsound.h | 4 +- src/main.cpp | 8 +-- src/mainwindow.cpp | 2 +- src/score/tcornerproxy.cpp | 2 +- src/settings/main.cpp | 3 + 22 files changed, 170 insertions(+), 176 deletions(-) diff --git a/TODO b/TODO index 5f3f9c621..0bcf7b682 100755 --- a/TODO +++ b/TODO @@ -30,7 +30,6 @@ Scaling issues: - bound window size (or score size) in single note mode and hidden guitar and/or rest widgets - revert to native style under MacOs when Qt5 -- misc library can crash under Win due to uninitialized Tglobals *gl - check setAmbitus of TsimpleScore - is it working properly with piano staff - There is unused class TnotePixmap only with default clef - use it or delete - vertical name layout is probably unused - clear it then diff --git a/src/libs/core/exam/texam.cpp b/src/libs/core/exam/texam.cpp index f95f12589..a22f81839 100644 --- a/src/libs/core/exam/texam.cpp +++ b/src/libs/core/exam/texam.cpp @@ -153,7 +153,7 @@ void Texam::setExercise() { qDebug() << "Exam has got questions already. Can't set is as an exercise!"; return; } - setFileName(QDir::toNativeSeparators(QFileInfo(Tglob::glob()->config->fileName()).absolutePath() + "/exercise.noo")); + setFileName(QDir::toNativeSeparators(QFileInfo(Tcore::gl()->config->fileName()).absolutePath() + "/exercise.noo")); m_isExercise = true; } @@ -256,7 +256,7 @@ bool Texam::loadFromBin(QDataStream& in, quint32 ev) { isExamFileOk = false; if ((qaUnit.questionAs == TQAtype::e_asName || qaUnit.answerAs == TQAtype::e_asName) && qaUnit.styleOfQuestion() < 0) { - qaUnit.setStyle(Tglob::glob()->S->nameStyleInNoteName, qaUnit.styleOfAnswer()); + qaUnit.setStyle(Tcore::gl()->S->nameStyleInNoteName, qaUnit.styleOfAnswer()); } /** In old versions, style was set to 0 so now it gives styleOfQuestion = -1 * Also in transition Nootka versions it was left unchanged. * Unfixed it invokes stupid names in charts. @@ -570,7 +570,7 @@ void Texam::convertToVersion2() { qsrand(QDateTime::currentDateTime().toTime_t()); if (m_level->requireStyle) { // prepare styles array to imitate switching randStyles[0] = Tnote::e_italiano_Si; - if (Tglob::glob()->S->seventhIs_B) { + if (Tcore::gl()->S->seventhIs_B) { randStyles[1] = Tnote::e_english_Bb; randStyles[2] = Tnote::e_nederl_Bis; } else { @@ -596,13 +596,13 @@ void Texam::convertToVersion2() { m_answList[i].setStyle(qSt, aSt); } else if (m_answList[i].questionAs == TQAtype::e_asName) { - m_answList[i].setStyle(randStyles[qrand() % 3], Tglob::glob()->S->nameStyleInNoteName); + m_answList[i].setStyle(randStyles[qrand() % 3], Tcore::gl()->S->nameStyleInNoteName); } else if (m_answList[i].questionAs == TQAtype::e_asName) { - m_answList[i].setStyle(Tglob::glob()->S->nameStyleInNoteName, randStyles[qrand() % 3]); + m_answList[i].setStyle(Tcore::gl()->S->nameStyleInNoteName, randStyles[qrand() % 3]); } } else // fixed style - we changing to user preferred - m_answList[i].setStyle(Tglob::glob()->S->nameStyleInNoteName, Tglob::glob()->S->nameStyleInNoteName); + m_answList[i].setStyle(Tcore::gl()->S->nameStyleInNoteName, Tcore::gl()->S->nameStyleInNoteName); } if (!m_answList[i].isCorrect()) { diff --git a/src/libs/core/exam/tlevel.cpp b/src/libs/core/exam/tlevel.cpp index cd90d9865..6ea93c2db 100644 --- a/src/libs/core/exam/tlevel.cpp +++ b/src/libs/core/exam/tlevel.cpp @@ -105,7 +105,7 @@ Tlevel::Tlevel() : desc = QObject::tr("All possible options are turned on"); bool hasGuitar = true; // QUESTIONS - if (Tglob::glob()->instrument == e_noInstrument) + if (Tcore::gl()->instrument == e_noInstrument) hasGuitar = false; questionAs = TQAtype(true, true, hasGuitar, true); answersAs[0] = TQAtype(true, true, hasGuitar, true); @@ -118,12 +118,12 @@ Tlevel::Tlevel() : * Since version 0.8.90 isNoteLo and isNoteHi are merged into Tclef. * It can store multiple clefs (maybe in unknown future it will be used) * 0 - no clef and up to 15 different clefs */ - clef = Tclef(Tglob::glob()->S->clef); + clef = Tclef(Tcore::gl()->S->clef); - instrument = Tglob::glob()->instrument; + instrument = Tcore::gl()->instrument; onlyLowPos = false; onlyCurrKey = false; - intonation = Tglob::glob()->A->intonation; + intonation = Tcore::gl()->A->intonation; // ACCIDENTALS withSharps = true; withFlats = true; @@ -140,12 +140,12 @@ Tlevel::Tlevel() : endsOnTonic = true; requireInTempo = true; // RANGE - for non guitar Tglobals will returns scale determined by clef - loNote = Tglob::glob()->loString(); - hiNote = Tnote(Tglob::glob()->hiString().chromatic() + Tglob::glob()->GfretsNumber); + loNote = Tcore::gl()->loString(); + hiNote = Tnote(Tcore::gl()->hiString().chromatic() + Tcore::gl()->GfretsNumber); loFret = 0; - hiFret = Tglob::glob()->GfretsNumber; + hiFret = Tcore::gl()->GfretsNumber; for (int i = 0; i < 6; i++) { - if (i <= Tglob::glob()->Gtune()->stringNr()) + if (i <= Tcore::gl()->Gtune()->stringNr()) usedStrings[i] = true; else usedStrings[i] = false; @@ -180,7 +180,7 @@ bool getLevelFromStream(QDataStream& in, Tlevel& lev, qint32 ver) { ok = false; } if (hi < 0 || hi > 24) { // max frets number - hi = Tglob::glob()->GfretsNumber; + hi = Tcore::gl()->GfretsNumber; ok = false; } lev.loFret = char(lo); @@ -496,7 +496,7 @@ Einstrument Tlevel::fixInstrument(quint8 instr) { if (instr == 255) { if (canBeGuitar() || canBeSound()) { hasInstrToFix = true; - return Tglob::glob()->instrument; + return Tcore::gl()->instrument; } else // instrument has no matter return e_noInstrument; } else if (instr == 0 || instr == 1) { @@ -509,7 +509,7 @@ Einstrument Tlevel::fixInstrument(quint8 instr) { return (Einstrument)instr; else { qDebug() << "Tlevel::instrument has some stupid value. FIXED"; - return Tglob::glob()->instrument; + return Tcore::gl()->instrument; } } @@ -638,7 +638,7 @@ bool Tlevel::inScaleOf(int loNoteNr, int hiNoteNr) { bool Tlevel::inScaleOf() { - return inScaleOf(Tglob::glob()->loString().chromatic(), Tglob::glob()->hiNote().chromatic()); + return inScaleOf(Tcore::gl()->loString().chromatic(), Tcore::gl()->hiNote().chromatic()); } @@ -646,17 +646,17 @@ bool Tlevel::adjustFretsToScale(char& loF, char& hiF) { if (!inScaleOf()) // when note range is not in an instrument scale return false; // get rid - makes no sense to further check - int lowest = Tglob::glob()->GfretsNumber, highest = 0; + int lowest = Tcore::gl()->GfretsNumber, highest = 0; for (int no = loNote.chromatic(); no <= hiNote.chromatic(); no++) { if (!withFlats && !withSharps) if (Tnote(no).alter) // skip note with accidental when not available in the level continue; - int tmpLow = Tglob::glob()->GfretsNumber; - for(int st = 0 ; st < Tglob::glob()->Gtune()->stringNr(); st++) { + int tmpLow = Tcore::gl()->GfretsNumber; + for(int st = 0 ; st < Tcore::gl()->Gtune()->stringNr(); st++) { if (!usedStrings[st]) continue; - int diff = no - Tglob::glob()->Gtune()->str(Tglob::glob()->strOrder(st) + 1).chromatic(); - if (diff >= 0 && diff <= Tglob::glob()->GfretsNumber) { // found + int diff = no - Tcore::gl()->Gtune()->str(Tcore::gl()->strOrder(st) + 1).chromatic(); + if (diff >= 0 && diff <= Tcore::gl()->GfretsNumber) { // found lowest = qMin<int>(lowest, diff); tmpLow = qMin<int>(tmpLow, diff); } diff --git a/src/libs/core/level/tlevelpreview.cpp b/src/libs/core/level/tlevelpreview.cpp index afc275d6d..e1701de3c 100644 --- a/src/libs/core/level/tlevelpreview.cpp +++ b/src/libs/core/level/tlevelpreview.cpp @@ -115,10 +115,10 @@ void TlevelPreview::setLevel(Tlevel& tl) { } if (tl.useKeySign) { S += "<tr><td>" + tr("key signature:") + " </td>" + tdAlign(); - S += tl.loKey.getMajorName().remove("-" + Tglob::glob()->S->majKeyNameSufix); + S += tl.loKey.getMajorName().remove("-" + Tcore::gl()->S->majKeyNameSufix); S += " (" + tl.loKey.accidNumber(true) +")"; if (!tl.isSingleKey) { - S += " - " + tl.hiKey.getMajorName().remove("-" + Tglob::glob()->S->majKeyNameSufix); + S += " - " + tl.hiKey.getMajorName().remove("-" + Tcore::gl()->S->majKeyNameSufix); S += " (" + tl.hiKey.accidNumber(true) + ")"; } S += "</td></tr>"; diff --git a/src/libs/core/level/tlevelsdefs.cpp b/src/libs/core/level/tlevelsdefs.cpp index 45cd6fb64..e4021dafc 100644 --- a/src/libs/core/level/tlevelsdefs.cpp +++ b/src/libs/core/level/tlevelsdefs.cpp @@ -17,18 +17,18 @@ ***************************************************************************/ #include "tlevelsdefs.h" -#include <tglobals.h> #include <exam/tlevel.h> #include <music/ttune.h> +#include <tinitcorelib.h> + -extern Tglobals *gl; void getExampleLevels(QList<Tlevel>& llist) { Tlevel l = Tlevel(); int octaveOffset = 0; // depends on guitar type and for bass drops range octave down - if (gl->instrument == e_bassGuitar) + if (Tcore::gl()->instrument == e_bassGuitar) octaveOffset = -1; - else if (gl->instrument == e_noInstrument) + else if (Tcore::gl()->instrument == e_noInstrument) octaveOffset = 1; //---------------------------------------------------------------------------- l.name = QObject::tr("open strings"); @@ -51,13 +51,13 @@ void getExampleLevels(QList<Tlevel>& llist) { l.intonation = 0; // do not check //clef default, user/tune defined //instrument default - selected by user - l.hiNote = Tnote(gl->hiString().chromatic()); + l.hiNote = Tnote(Tcore::gl()->hiString().chromatic()); //loNote is lowest by constructor l.hiFret = 0;// loFret is 0 by constuctor for (int i = 1; i < 7; i++) { //accids will be used if current tune requires it - if (gl->Gtune()->str(i).alter == 1) + if (Tcore::gl()->Gtune()->str(i).alter == 1) l.withSharps = true; - if (gl->Gtune()->str(i).alter == -1) + if (Tcore::gl()->Gtune()->str(i).alter == -1) l.withFlats = true; } if (l.instrument == e_noInstrument) // force instrument when not defined @@ -71,11 +71,11 @@ void getExampleLevels(QList<Tlevel>& llist) { l.desc = QObject::tr("In first position. No accidentals, no sound.<br>Octave required."); l.questionAs.setAsSound(false); bool isGuitar = true; - if (gl->instrument == e_noInstrument) { + if (Tcore::gl()->instrument == e_noInstrument) { isGuitar = false; l.desc = QObject::tr("Give note name in C-major scale or show note on the staff knowing its name."); } - l.instrument = gl->instrument; + l.instrument = Tcore::gl()->instrument; l.questionAs.setAsFret(isGuitar); l.answersAs[0] = TQAtype(false, true, isGuitar, false); l.answersAs[1] = TQAtype(true, false, isGuitar, false); @@ -115,11 +115,11 @@ void getExampleLevels(QList<Tlevel>& llist) { l.requireOctave = true; l.requireStyle = false; l.showStrNr = true; - l.loNote = gl->loString(); - l.hiNote = Tnote(gl->hiString().chromatic() + 5); + l.loNote = Tcore::gl()->loString(); + l.hiNote = Tnote(Tcore::gl()->hiString().chromatic() + 5); l.hiFret = 5;// loFret is 0 by constructor l.intonation = 0; // do not check - if (gl->instrument == e_noInstrument) // force instrument when not defined + if (Tcore::gl()->instrument == e_noInstrument) // force instrument when not defined l.instrument = e_classicalGuitar; l.melodyLen = 1; llist << l; @@ -179,10 +179,10 @@ void getExampleLevels(QList<Tlevel>& llist) { //instrument default - selected by user // l.loNote & l.hiNote from constructor // l.hiFret by constructor -// l.intonation = gl->A->intonation; // user preferences (in constructor) +// l.intonation = Tcore::gl()->A->intonation; // user preferences (in constructor) l.onlyLowPos = true; -// if (gl->instrument == e_noInstrument) // force instrument when not defined -// l.instrument = gl->instrument; +// if (Tcore::gl()->instrument == e_noInstrument) // force instrument when not defined +// l.instrument = Tcore::gl()->instrument; l.melodyLen = 10; llist << l; //---------------------------------------------------------------------------- @@ -202,7 +202,7 @@ void getExampleLevels(QList<Tlevel>& llist) { l.useKeySign = false; l.manualKey = false; l.clef = Tclef(Tclef::e_treble_G); - l.instrument = gl->instrument; + l.instrument = Tcore::gl()->instrument; l.loKey = 0; l.hiKey = 0; l.forceAccids = false; @@ -212,7 +212,7 @@ void getExampleLevels(QList<Tlevel>& llist) { l.loNote = Tnote(5, 0); // G contra l.hiNote = Tnote(6, 2); // a one-line // l.hiFret by constructor -// l.intonation = gl->A->intonation; // user preferences (in constructor) +// l.intonation = Tcore::gl()->A->intonation; // user preferences (in constructor) l.instrument = e_noInstrument; l.onlyLowPos = true; l.melodyLen = 5; diff --git a/src/libs/core/level/tlevelselector.cpp b/src/libs/core/level/tlevelselector.cpp index 490c5018b..692977f7b 100644 --- a/src/libs/core/level/tlevelselector.cpp +++ b/src/libs/core/level/tlevelselector.cpp @@ -21,25 +21,24 @@ #include "tlevelsdefs.h" #include <widgets/tquestionaswdg.h> #include <level/tlevelpreview.h> -#include <tglobals.h> #include <texamparams.h> #include <music/ttune.h> #include "tfixleveldialog.h" +#include <tinitcorelib.h> #include <QtWidgets> -extern Tglobals *gl; /*static*/ QString TlevelSelector::checkLevel(Tlevel& l) { QString warringText = ""; - if (gl->instrument == e_noInstrument && l.instrument != e_noInstrument) + if (Tcore::gl()->instrument == e_noInstrument && l.instrument != e_noInstrument) warringText = tr("Level is not suitable for current instrument type"); else if (l.canBeGuitar() || (l.instrument != e_noInstrument && l.canBeSound())) { - if (l.hiFret > gl->GfretsNumber || gl->Gtune()->stringNr() < 3 || - l.loNote.chromatic() < gl->loString().chromatic() || - l.hiNote.chromatic() > gl->hiNote().chromatic()) + if (l.hiFret > Tcore::gl()->GfretsNumber || Tcore::gl()->Gtune()->stringNr() < 3 || + l.loNote.chromatic() < Tcore::gl()->loString().chromatic() || + l.hiNote.chromatic() > Tcore::gl()->hiNote().chromatic()) warringText = tr("Level is not suitable for current tuning and/or fret number"); } return warringText; @@ -62,7 +61,7 @@ TlevelSelector::TlevelSelector(QWidget *parent) : m_loadBut = new QPushButton(tr("Load"), this); m_loadBut->setStatusTip(tr("Load level from file")); - m_loadBut->setIcon(QIcon(gl->path + "picts/nootka-level.png")); + m_loadBut->setIcon(QIcon(Tcore::gl()->path + "picts/nootka-level.png")); m_loadBut->setIconSize(QSize(22, 22)); m_removeButt = new QPushButton(tr("Remove"), this); m_removeButt->setStatusTip(TremoveLevel::removeTxt()); @@ -132,7 +131,7 @@ void TlevelSelector::findLevels() { addLevel(lev); m_levels.last().suitable = true; // from setting file - recent load/saved levels - QStringList recentLevels = gl->config->value("recentLevels").toStringList(); + QStringList recentLevels = Tcore::gl()->config->value("recentLevels").toStringList(); for (int i = recentLevels.size()-1; i >= 0; i--) { QFile file(recentLevels[i]); if (file.exists()) { @@ -145,7 +144,7 @@ void TlevelSelector::findLevels() { } else recentLevels.removeAt(i); } - gl->config->setValue("recentLevels", recentLevels); + Tcore::gl()->config->setValue("recentLevels", recentLevels); } @@ -213,11 +212,11 @@ void TlevelSelector::selectLevel() { void TlevelSelector::loadFromFile(QString levelFile) { if (levelFile == "") levelFile = QFileDialog::getOpenFileName(this, tr("Load exam's level"), - gl->E->levelsDir, levelFilterTxt() + " (*.nel)", 0 , QFileDialog::DontUseNativeDialog); + Tcore::gl()->E->levelsDir, levelFilterTxt() + " (*.nel)", 0 , QFileDialog::DontUseNativeDialog); QFile file(levelFile); Tlevel level = getLevelFromFile(file); if (level.name != "") { - gl->E->levelsDir = QFileInfo(levelFile).absoluteDir().absolutePath(); + Tcore::gl()->E->levelsDir = QFileInfo(levelFile).absoluteDir().absolutePath(); addLevel(level, levelFile, true); if (isSuitable(level)) selectLevel(); // select the last @@ -240,7 +239,7 @@ void TlevelSelector::updateRecentLevels() { if (m_levels[i].file != "") recentLevels << m_levels[i].file; } - gl->config->setValue("recentLevels", recentLevels); + Tcore::gl()->config->setValue("recentLevels", recentLevels); } @@ -301,7 +300,7 @@ Tlevel TlevelSelector::getLevelFromFile(QFile &file) { void TlevelSelector::fixInstrumentSlot() { if (fixLevelInstrument(m_levels[m_levelsListWdg->currentRow()].level, m_levels[m_levelsListWdg->currentRow()].file, - gl->instrumentToFix, this)) { + Tcore::gl()->instrumentToFix, this)) { if (!Tlevel::saveToFile(m_levels[m_levelsListWdg->currentRow()].level, m_levels[m_levelsListWdg->currentRow()].file)) qDebug() << "Failed when writing fixed level to:" << m_levels[m_levelsListWdg->currentRow()].file; else diff --git a/src/libs/core/music/tkeysignature.cpp b/src/libs/core/music/tkeysignature.cpp index d7a7acad5..f6c78f283 100644 --- a/src/libs/core/music/tkeysignature.cpp +++ b/src/libs/core/music/tkeysignature.cpp @@ -55,14 +55,14 @@ void TkeySignature::setNameStyle(Tnote::EnameStyle style, QString majSuf, QStrin QString majS = "", minS = ""; if (majSuf == "") { majS = "-" + majorSufixTxt(); - Tglob::glob()->S->majKeyNameSufix = majorSufixTxt(); + Tcore::gl()->S->majKeyNameSufix = majorSufixTxt(); } else if (majSuf != " ") majS = "-" + majSuf; if (minSuf == "") { minS = "-" + minorSufixTxt(); - Tglob::glob()->S->minKeyNameSufix = minorSufixTxt(); + Tcore::gl()->S->minKeyNameSufix = minorSufixTxt(); } else if (minSuf != " ") diff --git a/src/libs/core/tinitcorelib.cpp b/src/libs/core/tinitcorelib.cpp index eaeba98f9..03a705697 100755 --- a/src/libs/core/tinitcorelib.cpp +++ b/src/libs/core/tinitcorelib.cpp @@ -30,49 +30,49 @@ #include <QDebug> -Tglobals* Tglob::m_gl = 0; +Tglobals* Tcore::m_gl = 0; void initCoreLibrary(Tglobals* gl) { - Tglob::setGlobals(gl); + Tcore::setGlobals(gl); Ttune::prepareDefinedTunes(); Tcolor::setShadow(qApp->palette()); #if defined(Q_OS_MAC) - TpushButton::setCheckColor(gl->S->pointerColor, qApp->palette().base().color()); + TpushButton::setCheckColor(Tcore::gl()->S->pointerColor, qApp->palette().base().color()); #else TpushButton::setCheckColor(qApp->palette().highlight().color(), qApp->palette().highlightedText().color() ); #endif -// TkeySignature::setNameStyle(gl->S->nameStyleInKeySign, gl->S->majKeyNameSufix, gl->S->minKeyNameSufix); +// TkeySignature::setNameStyle(Tcore::gl()->S->nameStyleInKeySign, Tcore::gl()->S->majKeyNameSufix, Tcore::gl()->S->minKeyNameSufix); // moved to prepareTranslations() due to suffix translations have to be known } void prepareTranslations(QApplication* a, QTranslator& qt, QTranslator& qtBase, QTranslator& noo) { QString ll = ""; - if (Tglob::glob()) - ll = Tglob::glob()->lang; + if (Tcore::gl()) + ll = Tcore::gl()->lang; if (ll == "") ll = QLocale::system().name(); #if defined(Q_OS_LINUX) qt.load("qt_" + ll, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qtBase.load("qtbase_" + ll, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); #else - qt.load("qt_" + ll, Tglob::glob()->path + "lang"); - qtBase.load("qtbase_" + ll, Tglob::glob()->path + "lang"); + qt.load("qt_" + ll, Tcore::gl()->path + "lang"); + qtBase.load("qtbase_" + ll, Tcore::gl()->path + "lang"); #endif a->installTranslator(&qt); a->installTranslator(&qtBase); - noo.load("nootka_" + ll, Tglob::glob()->path + "lang"); + noo.load("nootka_" + ll, Tcore::gl()->path + "lang"); a->installTranslator(&noo); - TkeySignature::setNameStyle(Tglob::glob()->S->nameStyleInKeySign, Tglob::glob()->S->majKeyNameSufix, - Tglob::glob()->S->minKeyNameSufix); + TkeySignature::setNameStyle(Tcore::gl()->S->nameStyleInKeySign, Tcore::gl()->S->majKeyNameSufix, + Tcore::gl()->S->minKeyNameSufix); } bool loadNootkaFont(QApplication* a) { QFontDatabase fd; - int fid = fd.addApplicationFont(Tglob::glob()->path + "fonts/nootka.ttf"); + int fid = fd.addApplicationFont(Tcore::gl()->path + "fonts/nootka.ttf"); if (fid == -1) { QMessageBox::critical(0, "", a->translate("main", "<center>Can not load a font.<br>Try to install nootka.ttf manually.</center>")); return false; diff --git a/src/libs/core/tinitcorelib.h b/src/libs/core/tinitcorelib.h index ab2796af1..e579737b1 100755 --- a/src/libs/core/tinitcorelib.h +++ b/src/libs/core/tinitcorelib.h @@ -29,12 +29,12 @@ class QApplication; * Internal instance of Tglobals pointer used by in initCoreLibrary. * * It is set during invoking initCoreLibrary() */ -class NOOTKACORE_EXPORT Tglob +class NOOTKACORE_EXPORT Tcore { public: static void setGlobals(Tglobals *g) { m_gl = g; } - static Tglobals* glob() { return m_gl; } + static Tglobals* gl() { return m_gl; } /** static global pointer to Tglobals */ private: static Tglobals *m_gl; @@ -43,7 +43,7 @@ private: /** Initializes static values in library: * - pointer to Tglobals initialized by external executable !!! - * it is accessible through @p glob variable + * it is accessible through @p Tcore::gl() method * - tuning definitions * - TpushButton colors */ diff --git a/src/libs/misc/CMakeLists.txt b/src/libs/misc/CMakeLists.txt index 222eed13f..fc33d2a5c 100755 --- a/src/libs/misc/CMakeLists.txt +++ b/src/libs/misc/CMakeLists.txt @@ -8,6 +8,7 @@ add_definitions(-DNOOTKAMISC_LIBRARY) include_directories( . ../core ) set(LIB_NOOTKAMISC_SRC + tinitmisclib.cpp select7note.cpp taboutnootka.cpp tfirstrunwizzard.cpp @@ -21,11 +22,11 @@ set(LIB_NOOTKAMISC_SRC help/tmainhelp.cpp ) -IF(WIN32) - list(APPEND LIB_NOOTKAMISC_SRC - main.cpp - ) -endif(WIN32) +# IF(WIN32) +# list(APPEND LIB_NOOTKAMISC_SRC +# main.cpp +# ) +# endif(WIN32) add_library(NootkaMisc SHARED ${LIB_NOOTKAMISC_SRC} ) diff --git a/src/libs/misc/help/thelpdialogbase.cpp b/src/libs/misc/help/thelpdialogbase.cpp index a5e6147f5..389cd448b 100644 --- a/src/libs/misc/help/thelpdialogbase.cpp +++ b/src/libs/misc/help/thelpdialogbase.cpp @@ -18,11 +18,10 @@ #include "thelpdialogbase.h" #include <graphics/tnotepixmap.h> -#include <tglobals.h> +#include <tpath.h> #include <QApplication> #include <QtWidgets> -extern Tglobals *gl; QString ThelpDialogBase::m_path = ""; @@ -32,7 +31,7 @@ ThelpDialogBase::ThelpDialogBase(QWidget* parent, Qt::WindowFlags f) : m_checkBox(0), m_stateOfChB(0) { - m_path = gl->path; + m_path = Tpath::main; setWindowIcon(QIcon(path() + "picts/help.png")); setWindowTitle(tr("Nootka help")); m_helpText = new QTextEdit(this); diff --git a/src/libs/misc/main.cpp b/src/libs/misc/main.cpp index 9ac961bf0..d5913d122 100755 --- a/src/libs/misc/main.cpp +++ b/src/libs/misc/main.cpp @@ -22,5 +22,5 @@ Tglobals *gl; void initMiscLib() { - gl = Tglob::glob(); + gl = Tcore::gl(); } diff --git a/src/libs/misc/taboutnootka.cpp b/src/libs/misc/taboutnootka.cpp index c3e4f90fe..e4d79addf 100644 --- a/src/libs/misc/taboutnootka.cpp +++ b/src/libs/misc/taboutnootka.cpp @@ -21,11 +21,10 @@ #include "tsupportnootka.h" #include "tnootkalabel.h" #include "help/tmainhelp.h" +#include "tinitmisclib.h" #include <widgets/troundedlabel.h> -#include <tglobals.h> #include <QtWidgets> -extern Tglobals *gl; QString createLink(QString desc, QString href) { @@ -39,7 +38,7 @@ QString getHeader(QString text) { QString transRow (QString flag, QString lang, QString name, QString mailAndSite) { return QString("<tr valign=\"middle\" align=\"center\"><td> <img src=\"%1\"> </td><td> %2 </td><td> <b>%3</b> </td><td> %4 </td></tr>"). - arg(gl->path + "picts/flags-" + flag + ".png").arg(lang).arg(name).arg(mailAndSite); + arg(Tmisc::gl()->path + "picts/flags-" + flag + ".png").arg(lang).arg(name).arg(mailAndSite); } @@ -69,22 +68,22 @@ TaboutNootka::TaboutNootka(QWidget *parent) : setLayout(mainLay); m_navList->addItem(tr("About")); - m_navList->item(0)->setIcon(QIcon(gl->path+"picts/nootka.png")); + m_navList->item(0)->setIcon(QIcon(Tmisc::gl()->path+"picts/nootka.png")); m_navList->item(0)->setTextAlignment(Qt::AlignCenter); m_navList->addItem(tr("Help")); - m_navList->item(1)->setIcon(QIcon(gl->path+"picts/help.png")); + m_navList->item(1)->setIcon(QIcon(Tmisc::gl()->path+"picts/help.png")); m_navList->item(1)->setTextAlignment(Qt::AlignCenter); m_navList->addItem(authorsTxt()); - m_navList->item(2)->setIcon(QIcon(gl->path+"picts/author.png")); + m_navList->item(2)->setIcon(QIcon(Tmisc::gl()->path+"picts/author.png")); m_navList->item(2)->setTextAlignment(Qt::AlignCenter); m_navList->addItem(tr("License")); - m_navList->item(3)->setIcon(QIcon(gl->path+"picts/license.png")); + m_navList->item(3)->setIcon(QIcon(Tmisc::gl()->path+"picts/license.png")); m_navList->item(3)->setTextAlignment(Qt::AlignCenter); m_navList->addItem(tr("Support")); - m_navList->item(4)->setIcon(QIcon(gl->path+"picts/support.png")); + m_navList->item(4)->setIcon(QIcon(Tmisc::gl()->path+"picts/support.png")); m_navList->item(4)->setTextAlignment(Qt::AlignCenter); m_navList->addItem(tr("Changes")); - m_navList->item(5)->setIcon(QIcon(gl->path+"picts/chlog.png")); + m_navList->item(5)->setIcon(QIcon(Tmisc::gl()->path+"picts/chlog.png")); m_navList->item(5)->setTextAlignment(Qt::AlignCenter); m_timer = new QTimer(this); @@ -158,9 +157,9 @@ TaboutNootka::TaboutNootka(QWidget *parent) : // LICENSE GPL or Copyright for Debian based QTextEdit *licenseTxt = new QTextEdit(); licenseTxt->setReadOnly(true); - QFile file(gl->path + "gpl"); + QFile file(Tmisc::gl()->path + "gpl"); if (!file.exists()) { // Debian based - QDir d(gl->path); + QDir d(Tmisc::gl()->path); d.cdUp(); file.setFileName(d.path() + "/doc/nootka/copyright"); } @@ -176,7 +175,7 @@ TaboutNootka::TaboutNootka(QWidget *parent) : // CHANGESLOG QTextEdit *chLogTxt = new QTextEdit(); chLogTxt->setReadOnly(true); - QFile chfile(gl->path + "changes"); + QFile chfile(Tmisc::gl()->path + "changes"); if(chfile.open(QFile::ReadOnly | QFile::Text)) { QTextStream in(&chfile); in.setCodec("UTF-8"); @@ -244,13 +243,13 @@ Tabout::Tabout(QWidget *parent) : QWidget(parent) { QVBoxLayout *lay = new QVBoxLayout; - TnootkaLabel *nootkaLab = new TnootkaLabel(gl->path + "picts/logo.png", this, palette().highlight().color()); + TnootkaLabel *nootkaLab = new TnootkaLabel(Tmisc::gl()->path + "picts/logo.png", this, palette().highlight().color()); lay->addWidget(nootkaLab); QString info = tr("Welcome on board.<br>Nootka is an open source application to help you in learning (and in teaching) classical score notation.<br>It is specially designed for guitarists but others will find many usable features as well."); QString betaInfo = tr("This is a beta version and may contain bugs or behave in unexpected ways. Also, it has unfinished features.<br>In spite of that, you are welcome to try it!"); QString moreInfo = tr("See a <a href=\"http://nootka.sourceforge.net\">program site</a> for more details and further releases.</p><p>Any bugs, suggestions, translations and so on, report to: <a href=\"mailto:seelook.gmail.com\">seelook@gmail.com</a><p/><p>with respects<br>Author"); betaInfo = ""; // comment it to show info in beta releases - m_aboutLab = new TroundedLabel("<center><p style=\"background-color: palette(Base); border: 1px solid palette(Text); border-radius: 10px; font-size: 20px;\"><b>Nootka " + gl->version + "</b></p></center><p><br>" + info + "</p><p>" + betaInfo + "</p><p>" + moreInfo + "</p><br>" + m_aboutLab = new TroundedLabel("<center><p style=\"background-color: palette(Base); border: 1px solid palette(Text); border-radius: 10px; font-size: 20px;\"><b>Nootka " + Tmisc::gl()->version + "</b></p></center><p><br>" + info + "</p><p>" + betaInfo + "</p><p>" + moreInfo + "</p><br>" #if defined(Q_OS_WIN32) + tr("<br>To support this project and also to avoid infection of your PC<br><b>PLEASE, use the official project site to download updates, new releases and to see news.</b>") #endif diff --git a/src/libs/misc/tfirstrunwizzard.cpp b/src/libs/misc/tfirstrunwizzard.cpp index bb6b2113d..3e232427f 100644 --- a/src/libs/misc/tfirstrunwizzard.cpp +++ b/src/libs/misc/tfirstrunwizzard.cpp @@ -19,7 +19,8 @@ #include "tfirstrunwizzard.h" #include "taboutnootka.h" -#include "tglobals.h" +#include "tscalepreviewlabel.h" +#include "tinitmisclib.h" #include "select7note.h" #include "help/tmainhelp.h" #include <graphics/tnotepixmap.h> @@ -31,20 +32,17 @@ #include <score/tsimplescore.h> #include <taudioparams.h> #include <tscoreparams.h> -#include "tscalepreviewlabel.h" #include <QtWidgets> -extern Tglobals *gl; - TfirstRunWizzard::TfirstRunWizzard(QWidget *parent) : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint) { #if defined(Q_OS_LINUX) - setWindowIcon(QIcon(gl->path + "picts/nootka.svg")); + setWindowIcon(QIcon(Tmisc::gl()->path + "picts/nootka.svg")); #else - setWindowIcon(QIcon(gl->path + "picts/about.png")); + setWindowIcon(QIcon(Tmisc::gl()->path + "picts/about.png")); #endif setWindowTitle("Nootka " + tr("First run wizard")); QVBoxLayout *lay = new QVBoxLayout; @@ -86,19 +84,19 @@ TfirstRunWizzard::TfirstRunWizzard(QWidget *parent) : // grab 7-th note from translation if (Tpage_3::note7txt().toLower() == "b") { - gl->S->seventhIs_B = true; // rest S->nameStyleInNoteName + Tmisc::gl()->S->seventhIs_B = true; // rest S->nameStyleInNoteName if (m_page3->keyNameStyle() == "solfege") - gl->S->nameStyleInKeySign = Tnote::e_italiano_Si; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_italiano_Si; else - gl->S->nameStyleInKeySign = Tnote::e_nederl_Bis; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_nederl_Bis; } else { - gl->S->seventhIs_B = false; - gl->S->nameStyleInNoteName = Tnote::e_norsk_Hb; + Tmisc::gl()->S->seventhIs_B = false; + Tmisc::gl()->S->nameStyleInNoteName = Tnote::e_norsk_Hb; if (m_page3->keyNameStyle() == "solfege") - gl->S->nameStyleInKeySign = Tnote::e_italiano_Si; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_italiano_Si; else - gl->S->nameStyleInKeySign = Tnote::e_deutsch_His; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_deutsch_His; } connect(m_skipButt, SIGNAL(clicked()), this, SLOT(close())); @@ -148,35 +146,35 @@ void TfirstRunWizzard::nextSlot() { break; case 4 : if (m_page3->select7->is7th_B()) { - gl->S->seventhIs_B = true; - gl->S->nameStyleInNoteName = Tnote::e_english_Bb; + Tmisc::gl()->S->seventhIs_B = true; + Tmisc::gl()->S->nameStyleInNoteName = Tnote::e_english_Bb; if (m_page3->keyNameStyle() == "solfege") - gl->S->nameStyleInKeySign = Tnote::e_italiano_Si; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_italiano_Si; else - gl->S->nameStyleInKeySign = Tnote::e_nederl_Bis; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_nederl_Bis; } else { - gl->S->seventhIs_B = false; - gl->S->nameStyleInNoteName = Tnote::e_norsk_Hb; + Tmisc::gl()->S->seventhIs_B = false; + Tmisc::gl()->S->nameStyleInNoteName = Tnote::e_norsk_Hb; if (m_page3->keyNameStyle() == "solfege") - gl->S->nameStyleInKeySign = Tnote::e_italiano_Si; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_italiano_Si; else - gl->S->nameStyleInKeySign = Tnote::e_deutsch_His; + Tmisc::gl()->S->nameStyleInKeySign = Tnote::e_deutsch_His; } if (QLocale::system().name().contains("ru")) // override name style for Russian localization - gl->S->nameStyleInNoteName = Tnote::e_russian_Ci; - gl->S->doubleAccidentalsEnabled = m_page3->dblAccChB->isChecked(); - gl->S->showEnharmNotes = m_page3->enharmChB->isChecked(); - gl->S->keySignatureEnabled = m_page3->useKeyChB->isChecked(); - if (gl->instrument == e_bassGuitar) { - gl->setTune(Ttune::bassTunes[0]); - gl->S->clef = Tclef::e_bass_F_8down; - gl->A->audioInstrNr = (int)e_bassGuitar; - gl->GfretsNumber = 20; - } else if (gl->instrument == e_electricGuitar) { - gl->A->audioInstrNr = (int)e_electricGuitar; - gl->GfretsNumber = 23; - } else if (gl->instrument == e_noInstrument) { - gl->S->clef = m_notationWidget->score()->clef().type(); + Tmisc::gl()->S->nameStyleInNoteName = Tnote::e_russian_Ci; + Tmisc::gl()->S->doubleAccidentalsEnabled = m_page3->dblAccChB->isChecked(); + Tmisc::gl()->S->showEnharmNotes = m_page3->enharmChB->isChecked(); + Tmisc::gl()->S->keySignatureEnabled = m_page3->useKeyChB->isChecked(); + if (Tmisc::gl()->instrument == e_bassGuitar) { + Tmisc::gl()->setTune(Ttune::bassTunes[0]); + Tmisc::gl()->S->clef = Tclef::e_bass_F_8down; + Tmisc::gl()->A->audioInstrNr = (int)e_bassGuitar; + Tmisc::gl()->GfretsNumber = 20; + } else if (Tmisc::gl()->instrument == e_electricGuitar) { + Tmisc::gl()->A->audioInstrNr = (int)e_electricGuitar; + Tmisc::gl()->GfretsNumber = 23; + } else if (Tmisc::gl()->instrument == e_noInstrument) { + Tmisc::gl()->S->clef = m_notationWidget->score()->clef().type(); Tnote hiN, loN; // fix notes order if (m_notationWidget->score()->getNote(1).chromatic() < m_notationWidget->score()->getNote(0).chromatic()) { @@ -186,8 +184,8 @@ void TfirstRunWizzard::nextSlot() { hiN = m_notationWidget->score()->getNote(0); loN = m_notationWidget->score()->getNote(1); } - Ttune instrScale("scale", Tnote(hiN.chromatic() - gl->GfretsNumber), loN); - gl->setTune(instrScale); + Ttune instrScale("scale", Tnote(hiN.chromatic() - Tmisc::gl()->GfretsNumber), loN); + Tmisc::gl()->setTune(instrScale); } close(); break; @@ -196,7 +194,7 @@ void TfirstRunWizzard::nextSlot() { // To write notes of bass guitar this application uses <b>bass dropped clef</b> (bass clef with \"eight\" digit below) but common practice is to skip this digit and write it in ordinary bass clef. Remember, bass guitar sounds octave lower than notes written in 'normal' bass clef. void TfirstRunWizzard::whenInstrumentChanged(int instr) { - gl->instrument = Einstrument(instr); + Tmisc::gl()->instrument = Einstrument(instr); m_notationWidget->setNoteForInstrument(instr); if ((Einstrument)instr == e_bassGuitar) m_notationWidget->notationNote()->setHtml(QString("<center>%1<br>"). @@ -300,17 +298,17 @@ Tpage_3::Tpage_3(QWidget *parent) : dblAccChB = new QCheckBox(tr("I know about double sharps (x) and double flats (bb)"), this); lay->addWidget(dblAccChB, 0, Qt::AlignCenter); - dblAccChB->setChecked(gl->S->doubleAccidentalsEnabled); + dblAccChB->setChecked(Tmisc::gl()->S->doubleAccidentalsEnabled); // lay->addStretch(1); enharmChB = new QCheckBox(tr("I know that e# is the same as f"), this); lay->addWidget(enharmChB, 0, Qt::AlignCenter); - enharmChB->setChecked(gl->S->showEnharmNotes); + enharmChB->setChecked(Tmisc::gl()->S->showEnharmNotes); // lay->addStretch(1); useKeyChB = new QCheckBox(tr("I know about key signatures"), this); lay->addWidget(useKeyChB, 0, Qt::AlignCenter); - useKeyChB->setChecked(gl->S->keySignatureEnabled); + useKeyChB->setChecked(Tmisc::gl()->S->keySignatureEnabled); lay->addStretch(1); setLayout(lay); diff --git a/src/libs/sound/CMakeLists.txt b/src/libs/sound/CMakeLists.txt index fb9d97a80..ca4b7da1c 100755 --- a/src/libs/sound/CMakeLists.txt +++ b/src/libs/sound/CMakeLists.txt @@ -375,7 +375,7 @@ set(LIB_NOOTKASOUND_SRC IF(WIN32) list(APPEND LIB_NOOTKASOUND_SRC - main.cpp +# main.cpp rt/asio.cpp rt/asiodrivers.cpp rt/asiolist.cpp diff --git a/src/libs/sound/main.cpp b/src/libs/sound/main.cpp index d67b90ed9..4057ffd10 100755 --- a/src/libs/sound/main.cpp +++ b/src/libs/sound/main.cpp @@ -29,6 +29,6 @@ Tglobals *gl; * This function attaches to @p gl variable declared in nootkaCore library. */ void initSoundLibrary() { - gl = Tglob::glob(); + gl = Tcore::gl(); } diff --git a/src/libs/sound/tsound.cpp b/src/libs/sound/tsound.cpp index bf150668c..570e65057 100755 --- a/src/libs/sound/tsound.cpp +++ b/src/libs/sound/tsound.cpp @@ -26,29 +26,23 @@ #include <QPushButton> #include <QTimer> #include <QDebug> -#if defined (Q_OS_WIN) - #include <tinitcorelib.h> -#endif -extern Tglobals *gl; -Tsound::Tsound(QObject* parent) : +Tsound::Tsound(Tglobals* globals, QObject* parent) : QObject(parent), sniffer(0), player(0), + m_globals(globals), m_examMode(false), m_melodyNoteIndex(-1) { -#if defined (Q_OS_WIN) - gl = Tglob::glob(); -#endif - TrtAudio::initJACKorASIO(gl->A->JACKorASIO); - if (gl->A->OUTenabled) + TrtAudio::initJACKorASIO(m_globals->A->JACKorASIO); + if (m_globals->A->OUTenabled) createPlayer(); else player = 0; - if (gl->A->INenabled) { + if (m_globals->A->INenabled) { createSniffer(); } else { sniffer = 0; @@ -69,7 +63,7 @@ void Tsound::play(Tnote& note) { bool playing = false; if (player && note.note) playing = player->play(note.chromatic()); - if (playing && !gl->A->playDetected && player->type() == TabstractPlayer::e_midi) { + if (playing && !m_globals->A->playDetected && player->type() == TabstractPlayer::e_midi) { if (sniffer) { // pause sniffer if midi output was started if (!m_midiPlays) { // stop listening just once sniffer->stopListening(); @@ -95,11 +89,11 @@ void Tsound::playMelody(Tmelody* mel) { void Tsound::acceptSettings() { bool doParamsUpdated = false; // for output - if (gl->A->OUTenabled) { + if (m_globals->A->OUTenabled) { if (!player) createPlayer(); else { - if (gl->A->midiEnabled) { + if (m_globals->A->midiEnabled) { deletePlayer(); // it is safe to delete midi createPlayer(); // and create it again } else { // avoids deleting TaudioOUT instance and loading ogg file every acceptSettings call @@ -119,7 +113,7 @@ void Tsound::acceptSettings() { deletePlayer(); } // for input - if (gl->A->INenabled) { + if (m_globals->A->INenabled) { m_pitchView->setEnabled(true); if (!sniffer) { createSniffer(); @@ -128,8 +122,8 @@ void Tsound::acceptSettings() { setDefaultAmbitus(); doParamsUpdated = true; } - m_pitchView->setMinimalVolume(gl->A->minimalVol); - m_pitchView->setIntonationAccuracy(gl->A->intonation); + m_pitchView->setMinimalVolume(m_globals->A->minimalVol); + m_pitchView->setIntonationAccuracy(m_globals->A->intonation); } else { m_pitchView->setDisabled(true); if (sniffer) @@ -151,9 +145,9 @@ void Tsound::acceptSettings() { void Tsound::setPitchView(TpitchView* pView) { m_pitchView = pView; - m_pitchView->setPitchColor(gl->EanswerColor); - m_pitchView->setMinimalVolume(gl->A->minimalVol); - m_pitchView->setIntonationAccuracy(gl->A->intonation); + m_pitchView->setPitchColor(m_globals->EanswerColor); + m_pitchView->setMinimalVolume(m_globals->A->minimalVol); + m_pitchView->setIntonationAccuracy(m_globals->A->intonation); if (sniffer) { m_pitchView->setAudioInput(sniffer); m_pitchView->startVolume(); @@ -178,7 +172,7 @@ void Tsound::prepareToConf() { void Tsound::restoreAfterConf() { - if (gl->A->midiEnabled) { + if (m_globals->A->midiEnabled) { if (player) player->setMidiParams(); } @@ -219,7 +213,7 @@ void Tsound::go() { void Tsound::prepareAnswer() { - m_pitchView->setBgColor(QColor(gl->EanswerColor)); + m_pitchView->setBgColor(QColor(m_globals->EanswerColor)); m_pitchView->setDisabled(false); } @@ -288,8 +282,8 @@ bool Tsound::isPlayable() { void Tsound::setDefaultAmbitus() { if (sniffer) - sniffer->setAmbitus(Tnote(gl->loString().chromatic() - 5), // range extended about 4th up and down - Tnote(gl->hiString().chromatic() + gl->GfretsNumber + 5)); + sniffer->setAmbitus(Tnote(m_globals->loString().chromatic() - 5), // range extended about 4th up and down + Tnote(m_globals->hiString().chromatic() + m_globals->GfretsNumber + 5)); } @@ -309,17 +303,17 @@ QList<TnoteStruct>& Tsound::notes() { //------------------------------------------------------------------------------------ void Tsound::createPlayer() { - if (gl->A->midiEnabled) { - player = new TmidiOut(gl->A); + if (m_globals->A->midiEnabled) { + player = new TmidiOut(m_globals->A); connect(player, SIGNAL(noteFinished()), this, SLOT(playingFinishedSlot())); m_midiPlays = false; } else - player = new TaudioOUT(gl->A); + player = new TaudioOUT(m_globals->A); } void Tsound::createSniffer() { - sniffer = new TaudioIN(gl->A); + sniffer = new TaudioIN(m_globals->A); setDefaultAmbitus(); // sniffer->setAmbitus(Tnote(-31), Tnote(82)); // fixed ambitus bounded Tartini capacities connect(sniffer, &TaudioIN::noteStarted, this, &Tsound::noteStartedSlot); @@ -373,7 +367,7 @@ void Tsound::playMelodySlot() { void Tsound::noteStartedSlot(const TnoteStruct& note) { m_detectedPitch = note.pitch; emit noteStarted(m_detectedPitch); - if (player && gl->instrument != e_noInstrument && gl->A->playDetected) + if (player && m_globals->instrument != e_noInstrument && m_globals->A->playDetected) play(m_detectedPitch); } @@ -382,7 +376,7 @@ void Tsound::noteFinishedSlot(const TnoteStruct& note) { m_detectedPitch = note.pitch; Tchunk noteChunk(m_detectedPitch, Trhythm()); emit noteFinished(noteChunk); - if (player && gl->instrument == e_noInstrument && gl->A->playDetected) + if (player && m_globals->instrument == e_noInstrument && m_globals->A->playDetected) play(m_detectedPitch); } diff --git a/src/libs/sound/tsound.h b/src/libs/sound/tsound.h index 70a0a92d1..a773a8379 100644 --- a/src/libs/sound/tsound.h +++ b/src/libs/sound/tsound.h @@ -23,6 +23,7 @@ #include <QObject> #include <music/tnote.h> +class Tglobals; class Tchunk; class TnoteStruct; class Tmelody; @@ -42,7 +43,7 @@ class NOOTKASOUND_EXPORT Tsound : public QObject Q_OBJECT public: - explicit Tsound(QObject *parent = 0); + explicit Tsound(Tglobals* globals, QObject *parent = 0); virtual ~Tsound(); TabstractPlayer *player; @@ -94,6 +95,7 @@ private: void deletePlayer(); void deleteSniffer(); + Tglobals *m_globals; TpitchView *m_pitchView; Tnote m_detectedPitch; // detected note pitch bool m_examMode; diff --git a/src/main.cpp b/src/main.cpp index a8e1dccff..849e396f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,7 @@ ***************************************************************************/ #include "mainwindow.h" +#include <tinitmisclib.h> #include <tinitcorelib.h> #include <QPointer> #include <QFile> @@ -48,10 +49,6 @@ int main(int argc, char *argv[]) } resetConfig = false; a = new QApplication(argc, argv); -// #if defined (Q_OS_MAC) -// QApplication::setStyle(new QPlastiqueStyle); -// #endif -// qDebug() << a->style()->objectName(); gl = new Tglobals(); gl->path = Tglobals::getInstPath(qApp->applicationDirPath()); confFile = gl->config->fileName(); @@ -59,6 +56,9 @@ int main(int argc, char *argv[]) prepareTranslations(a, qtTranslator, qtbaseTranslator, nooTranslator); if (!loadNootkaFont(a)) return 111; +// initializing libraries + initMiscLibrary(gl); + // creating main window w = new MainWindow(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3fbb021ae..ae34f2de5 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -121,7 +121,7 @@ MainWindow::MainWindow(QWidget *parent) : gl->config->endGroup(); Tnote::defaultStyle = gl->S->nameStyleInNoteName; - sound = new Tsound(this); + sound = new Tsound(gl, this); m_messageTimer = new QTimer(this); connect(m_messageTimer, SIGNAL(timeout()), this, SLOT(restoreMessage())); diff --git a/src/score/tcornerproxy.cpp b/src/score/tcornerproxy.cpp index 45bd7b94f..df1aa7b28 100644 --- a/src/score/tcornerproxy.cpp +++ b/src/score/tcornerproxy.cpp @@ -112,7 +112,7 @@ void TcornerProxy::setSpotColor(const QColor& c) { QColor col(m_colorOfSpot); col.setAlpha(180); dse->setColor(col); - dse->setBlurRadius(side() / 4.0); + dse->setBlurRadius(side() / 8.0); if (proxy()) proxy()->setGraphicsEffect(dse); } diff --git a/src/settings/main.cpp b/src/settings/main.cpp index 00efedb86..1ee068985 100644 --- a/src/settings/main.cpp +++ b/src/settings/main.cpp @@ -21,6 +21,7 @@ #include <QTranslator> #include "tsettingsdialog.h" #include <tinitcorelib.h> +#include <tinitmisclib.h> #include <iostream> Tglobals *gl; @@ -42,6 +43,8 @@ int main(int argc, char *argv[]) prepareTranslations(&a, qtTranslator, qtbaseTranslator, nooTranslator); if (!loadNootkaFont(&a)) return 111; + // initializing libraries + initMiscLibrary(gl); QStringList args = a.arguments(); args.takeFirst(); -- GitLab