actioncollection.h 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
 * Copyright (C) 2004 Scott Wheeler <wheeler@kde.org>
 *
 * 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 2 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/>.
 */
16

17 18
#ifndef ACTIONCOLLECTION_H
#define ACTIONCOLLECTION_H
19 20

class KActionCollection;
21 22
class QAction;
class QString;
23 24 25 26 27 28 29 30 31 32 33 34

namespace ActionCollection
{
    /**
     * The global action collection for JuK.
     */
    KActionCollection *actions();

    /**
     * Returns the action for the associated key from the global action
     * collection.
     */
35
    QAction *action(const QString &key);
36 37 38 39 40

    /**
     * Returns the action for the associated key but includes a cast to the
     * type \a T.  i.e. KSelectAction *a = action<KSelectAction>("chooser");
     */
41
    template <class T> T *action(const QString &key)
42 43 44 45 46 47
    {
        return dynamic_cast<T *>(action(key));
    }
}

#endif
48 49

// vim: set et sw=4 tw=0 sta: