Comment 15 for bug 1299092

Revision history for this message
Gabriele Pacaccio (gabrielepacaccio01) wrote :

So I made a MyFunctions.hpp file with these lines of code

#ifndef _MYFUNCTIONS_HPP_
#define _MYFUNCTIONS_HPP_

#include "StelModule.hpp"
#include "StelProjector.hpp"
#include "StelObjectType.hpp"
#include "StelObjectModule.hpp"

class MyFunctions
{
public:
    MyFunctions();
    virtual ~MyFunctions();

    virtual void init();

public slots:
    void customShortcut();
};

#endif // _MYFUNCTIONS_HPP_

and another called MyFunctions.cpp with these lines

#include "MyFunctions.hpp"
#include "StelActionMgr.hpp"
#include "StelMainScriptAPI.hpp"
#include "StelMovementMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelTranslator.hpp"
#include "StelApp.hpp"
#include "StelCore.hpp"

#include <QString>
#include <QTextStream>
#include <QSettings>
#include <QKeyEvent>
#include <QDebug>

MyFunctions::MyFunctions()
{

}

MyFunctions::~MyFunctions()
{

}

void MyFunctions::init()
{
    StelCore* core = new StelCore;
    StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionManager();
    actionsMgr->addAction("actionCustom_Shortcut", N_("Miscellaneous"), N_("Custom shortcut"), core,
    "customShortcut()", "Shift+X");
}

void MyFunctions::customShortcut()
{
    StelMainScriptAPI* core = GETSTELMODULE(StelMainScriptAPI);
    StelMovementMgr* stelMovementMgr = GETSTELMODULE(StelMovementMgr);
    core->selectObjectByName("Sun", false);
    stelMovementMgr->setFlagTracking(true);
}

I've also added the file names in the CMakeLists file

The compilation goes well but when I can't see the shortcut in the Stellarium's shortcuts list and when I press the keys nothing appends. Why? What is wrong? Please, let me know what I have to change