add more spacing
[personal-kdebase.git] / apps / konsole / src / ProfileList.h
blobea2695b090c58253148cb8feabd56897de8ca6db
1 /*
2 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301 USA.
20 #ifndef PROFILELIST_H
21 #define PROFILELIST_H
23 #include <QtCore/QList>
24 #include <QtCore/QSet>
25 #include <QtCore/QObject>
27 #include "Profile.h"
29 class QAction;
30 class QActionGroup;
31 class QKeySequence;
33 namespace Konsole
36 class Profile;
38 /**
39 * ProfileList provides a list of actions which represent session profiles
40 * that a SessionManager can create a session from.
42 * These actions can be plugged into a GUI.
44 * Currently only profiles marked as favorites in the SessionManager are included.
46 * The user-data associated with each session can be passed to the createProfile() method of the
47 * SessionManager to create a new terminal session.
49 class ProfileList : public QObject
51 Q_OBJECT
53 public:
54 /**
55 * Constructs a new session list which displays sessions
56 * that can be created by @p manager
58 * @param addShortcuts True if the shortcuts associated with profiles
59 * in the session manager should be added to the actions
61 ProfileList(bool addShortcuts , QObject* parent);
63 /**
64 * Returns a list of actions representing the types of sessions which can be created by
65 * manager().
66 * The user-data associated with each action is the string key that can be passed to
67 * the manager to request creation of a new session.
69 QList<QAction*> actions();
71 /** TODO: Document me */
72 void syncWidgetActions(QWidget* widget,bool sync);
73 signals:
74 /**
75 * Emitted when the user selects an action from the list.
77 * @param key The profile key associated with the selected action.
79 void profileSelected(Profile::Ptr profile);
80 /**
81 * Emitted when the list of actions changes.
83 void actionsChanged(const QList<QAction*>& actions);
85 private slots:
86 void triggered(QAction* action);
87 void favoriteChanged(Profile::Ptr profile, bool isFavorite);
88 void profileChanged(Profile::Ptr profile);
89 void shortcutChanged(Profile::Ptr profile, const QKeySequence& sequence);
91 private:
92 QAction* actionForKey(Profile::Ptr profile) const;
93 void updateAction(QAction* action , Profile::Ptr profile);
94 void updateEmptyAction();
96 QActionGroup* _group;
97 bool _addShortcuts;
99 // action to show when the list is empty
100 QAction* _emptyListAction;
101 QSet<QWidget*> _registeredWidgets;
106 #endif // PROFILELIST_H