1 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 3 4 /* 5 Rosegarden 6 A MIDI and audio sequencer and musical notation editor. 7 Copyright 2000-2021 the Rosegarden development team. 8 9 Other copyrights also apply to some parts of this work. Please 10 see the AUTHORS file and individual file headers for details. 11 12 This program is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 2 of the 15 License, or (at your option) any later version. See the file 16 COPYING included with this distribution for more information. 17 */ 18 19 #ifndef RG_BASETOOL_H 20 #define RG_BASETOOL_H 21 22 #include <QObject> 23 #include <QString> 24 25 26 class QMenu; 27 28 29 namespace Rosegarden 30 { 31 32 /** 33 * BaseTool : base tool class, just handles RMB menu creation and 34 * handling by a BaseToolBox 35 * 36 */ 37 class BaseTool : public QObject 38 { 39 Q_OBJECT 40 41 friend class BaseToolBox; 42 43 public: 44 45 ~BaseTool() override; 46 47 /** 48 * Is called by the parent View (EditView or SegmentCanvas) when 49 * the tool is set as current. 50 * Add any setup here (e.g. setting the mouse cursor shape) 51 */ 52 virtual void ready(); 53 54 /** 55 * Is called by the parent View (EditView or SegmentCanvas) after 56 * the tool is put away. 57 * Add any cleanup here 58 */ 59 virtual void stow(); 60 61 /** 62 * Show the menu if there is one 63 */ 64 virtual void showMenu(); 65 66 /** 67 * Retrieve current status-line type help for the tool, if any 68 */ 69 virtual QString getCurrentContextHelp() const; 70 71 signals: 72 void showContextHelp(QString); 73 74 protected: 75 /** 76 * Create a new BaseTool 77 * 78 * \a menuName : the name of the menu defined in the XML rc file 79 */ 80 BaseTool(const QString &menuName, QObject *parent); 81 82 virtual void createMenu() = 0; hasMenu()83 virtual bool hasMenu() { return false; } 84 85 virtual void setContextHelp(const QString &help); clearContextHelp()86 virtual void clearContextHelp() { setContextHelp(""); } 87 88 //--------------- Data members --------------------------------- 89 90 QString m_menuName; 91 QMenu *m_menu; 92 93 QString m_contextHelp; 94 }; 95 96 97 98 } 99 100 #endif 101