summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_externaltool.h
blob: a2c0e8a1c1b00e70f14931132a77837d4821dcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************
                          sq_externaltool.h  -  description
                             -------------------
    begin                : ??? ??? 12 2004
    copyright            : (C) 2004 by Baryshev Dmitry
    email                : ksquirrel.iv@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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SQ_EXTERNALTOOL_H
#define SQ_EXTERNALTOOL_H

#include <tqstring.h>
#include <tqobject.h>
#include <tqvaluevector.h>

#include <kfileitem.h>

class SQ_PopupMenu;

struct Tool
{
    Tool();
    Tool(const TQString &, const TQString &, const TQString &);

    TQString name, command;
    TQString icon;
};

/*
 *  Class which manages external tools. It store all available external tools
 *  in memory, and create popup menu where external tools been inserted.
 */

class SQ_ExternalTool : public TQObject, public TQValueVector<Tool>
{
    Q_OBJECT
  TQ_OBJECT

    public: 
        SQ_ExternalTool(TQObject *tqparent = 0);
        ~SQ_ExternalTool();

        /*
         *  Get pixmap, name or command of external tool.
         */
        TQString toolPixmap(const int i);
        TQString toolName(const int i);
        TQString toolCommand(const int i);

        void setItems(const KFileItemList &);

        /*
         *  Recreate current popop menu.
         */
        SQ_PopupMenu* newPopupMenu();

        /*
         *  Get current popup menu.
         */
        SQ_PopupMenu* constPopupMenu() const;

        /*
         *  Write tools to config file as TQStringLists
         */
        void writeEntries();

        static SQ_ExternalTool* instance() { return m_instance; }

    private slots:

        /*
         *  Invoked, when user executed popup menu with external tools.
         *  This slot will do some useful stuff.
         */
        void slotAboutToShowMenu();
        void slotActivateTool(int);

    private:
        /*
         *  Popup menu with all tools.
         */
        SQ_PopupMenu *menu;

        KFileItemList items;

        static SQ_ExternalTool *m_instance;
};

inline
void SQ_ExternalTool::setItems(const KFileItemList &itms)
{
    items = itms;
}

#endif