Skip to content
Snippets Groups Projects
tnootkaqml.cpp 2.72 KiB
Newer Older
  • Learn to ignore specific revisions
  • /***************************************************************************
     *   Copyright (C) 2017 by Tomasz Bojczuk                                  *
     *   seelook@gmail.com                                                     *
     *                                                                         *
     *   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 3 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     *   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         *
     *   GNU General Public License for more details.                          *
     *                                                                         *
     *  You should have received a copy of the GNU General Public License      *
     *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
     ***************************************************************************/
    
    
    #include "tnootkaqml.h"
    #include "ttickcolors.h"
    #include "nootkaconfig.h"
    #include "music/tmeter.h"
    
    #include <QtQml/qqmlengine.h>
    #include <QtCore/qdebug.h>
    
    TnootkaQML* TnootkaQML::m_instance = nullptr;
    
    TnootkaQML::TnootkaQML(QObject* parent) :
      QObject(parent)
    
      if (m_instance) {
        qDebug() << "TnootkaQML instance already exists!";
        return;
      }
      m_instance = this;
    
      qRegisterMetaType<Tclef>();
      qmlRegisterUncreatableType<Tclef>("Score", 1, 0, "Tclef", "You cannot create an instance of the Tclef.");
      qmlRegisterUncreatableType<Tmeter>("Score", 1, 0, "Tmeter", "You cannot create an instance of the Tmeter.");
      qmlRegisterType<TtickColors>("TtickColors", 1, 0, "TtickColors");
    }
    
    TnootkaQML::~TnootkaQML()
    {
      m_instance = nullptr;
    }
    
    //#################################################################################################
    //###################       INVOKABLE METHODS          ############################################
    //#################################################################################################
    
    QString TnootkaQML::version() { return NOOTKA_VERSION; }
    
    Tclef TnootkaQML::clef(int type) {
      return Tclef(static_cast<Tclef::EclefType>(type));
    }
    
    
    QString TnootkaQML::majorKeyName(int key) {
      return TkeySignature(static_cast<char>(key)).getMajorName();
    }
    
    
    QString TnootkaQML::minorKeyName(int key) {
      return TkeySignature(static_cast<char>(key)).getMinorName();
    }