summaryrefslogtreecommitdiffstats
path: root/src/menuhandler.h
blob: 8873c7ff8e05e08dc8903f4ab58839076fddfac3 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/***************************************************************************
 *   Copyright (C) 2006 by Marco Martin                                    *
 *   notmart@gmail.com                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the Lesser 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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef MENUHANDLER_H
#define MENUHANDLER_H

#include <kservicegroup.h>
#include <kservice.h>
#include <tdelistbox.h>
#include <tdelistview.h>
#include <tdelistviewsearchline.h>
#include <tdeapplication.h>
#include <kiconloader.h>
#include <kpushbutton.h>
#include <tderecentdocument.h>
#include <krun.h>
#include <dcopref.h>
#include <tqheader.h>
#include <tqimage.h>
#include <tqtoolbutton.h>
#include <tqpopupmenu.h>
#include <tqcombobox.h>
#include <kdirwatch.h>
#include <kdirlister.h>
#include <tqlayout.h>
#include <tdefileitem.h>

#include "dmctl.h"
#include "menu.h"
#include "prefs.h"
#include "tastylistview.h"

/**
 @author Marco Martin <notmart@gmail.com>
*/
class MenuHandler : public TQFrame{
    Q_OBJECT

public:
    MenuHandler( TQWidget *parent, Prefs *prefs, char *name=0, WFlags fl=WType_TopLevel );

    ~MenuHandler();

    void readConfig();
    void popup(TQPoint pos);
    void updateConfig();
    void focusNextChild(){focusNextPrevChild(true);}
    void focusPrevChild(){focusNextPrevChild(false);}
    void clearNewInstalledApplications()
     {newInstalledList.clear();newInstalledTimeStamps.clear();
      prefSkel->setNewInstalledApps( newInstalledList );
      prefSkel->setNewInstalledAppsTimeStamps( newInstalledTimeStamps );}

signals:
    void newApplications(int);
    void kickerConfChanged();
    void hidden();

protected:
    virtual bool eventFilter( TQObject *o, TQEvent * e );

    virtual void closeEvent ( TQCloseEvent *e);
    virtual void resizeEvent ( TQResizeEvent *e)
    { TQWidget::resizeEvent(e); menu->leftFrame->setMaximumWidth( (int)((width()-24)/3) ); }
    virtual void mousePressEvent( TQMouseEvent *e);

private:
    typedef TQMap<ulong, TQString> RecentlyUsedMap;
    typedef enum
    {
      Favourites = 0,
      MoreUsed = 1,
      RecentlyUsed = 2,
      RecentDocuments = 3
    } MenuMode;

    RecentlyUsedMap recentlyUsedMap;

    TQStringList moreUsedList, favouriteList;

    Menu * menu;
    MenuMode currentMenuMode;
    TDEIconLoader *iconLoader;
    TQPopupMenu *sessionsMenu;
    bool searchMode;
    Prefs *prefSkel;
    TDEConfig *kickerConf;
    KDirWatch *kickerConfWatch;
    //xdgMenuWatch for applications-kmenuedit.menu xdgMenuLister for all the desktop files
    KDirWatch *xdgMenuWatch;
    KDirLister *xdgMenuLister;
    int firstListing;
    TQStringList oldInstalledList, newInstalledList;
    TQValueList<int> newInstalledTimeStamps;

    TQPixmap bookMarkPix;
    TQVBoxLayout * MenuHandlerLayout;

//configuration items
    int _menuMode;
    TQString _currentCategory;
    int _numRecentEntries;
    int _iconSize1;
    int _iconSize2;
    int _iconSize3;
    int _actionIconSize;
    bool _displaySubText;
    bool _newAppsNotification;
    bool _strigiIntegration;
    double _menuWidth;
    double _menuHeight;
    bool _isNormalWindow;
    bool _showExpander;
    bool _alwaysCollapsed;
    bool _hideOneChild;
    bool _alphabetical;

    typedef TQMap<TQString, KServiceGroup::List> SListMap;
    SListMap sListMap;
    //KServiceGroup::List getServiceGroupList( KServiceGroup *serviceGroup );
    void setupColumns();
    void loadNewInstalledApps();
    void initOldInstalledApps(KServiceGroup::Ptr group);
    void initNewInstalledApps(KServiceGroup::Ptr group);
    void populateList( KServiceGroup *serviceGroup,
                       TastyListView *listView,
                       TastyListViewItem *listItemFather,
                       bool recursive, const TQString & query = NULL );

    void listClicked( TastyListViewItem * listItem, const TQPoint & coord );
    void fillRecentDocuments( );
    void fillMoreUsed( );
    void fillRecentlyUsed( );
    void fillFavourites( );
    void setupDynList( MenuMode mode );
    //FIXME: this thing is UBER HEAVY
    bool searchNewItems(KServiceGroup::Ptr group);

public slots:
    void slotUpdateApplications();

private slots:
    void dynListElemMoved( );
    void dynListClicked( TQListViewItem * listItem, const TQPoint & coord, int c );
    void slotContextMenu(TQListViewItem *listItem, const TQPoint &coord, int c );
    void initializeRecentlyUsed(  );
    void slotModKickerConf();
    void slotApplicationsAdded(const KFileItemList & newItems);
    void slotApplicationRemoved();
    void childListClicked( TQListViewItem * listItem, const TQPoint & coord, int c );
    void rootListClicked( TQListViewItem * listItem, const TQPoint & coord, int c );
    void doLogout();
    void doLock();
    void slotPopulateSessions();
    void slotSessionActivated( int ent );
    void doNewSession( bool lock );
    void runDialog();
    void initializeSearch( const TQString & query );
    void strigiSearch( const TQString & query );
    void clearDynList();
    void menuModeChanged( int index );
    void switchWindowMode();
};

#endif