summaryrefslogtreecommitdiffstats
path: root/krusader/UserMenu/usermenu.cpp
blob: 1ae7f4b0e7dc8395bce564c55d0b055749ae3e8a (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
/***************************************************************************
                      _expressionsu.cpp  -  description
                         -------------------
begin                : Sat Dec 6 2003
copyright            : (C) 2003 by Shie Erlich & Rafi Yanai
email                :
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kdebug.h>
#include <klocale.h>

#include "../krusader.h"
#include "../Konfigurator/konfigurator.h"
#include "../UserAction/kraction.h"
#include "../UserAction/useraction.h"
#include "usermenu.h"


void UserMenu::exec() {
   _popup->run();
}

UserMenu::UserMenu( TQWidget * parent, const char * name ) : TQWidget( parent, name ) {
   _popup = new UserMenuGui(this);
}

void UserMenu::update() {
   _popup->createMenu();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

UserMenuGui::UserMenuGui( UserMenu *, TQWidget * parent ) : KPopupMenu( parent ) {
   createMenu();
}

void UserMenuGui::createMenu() {
//    kdDebug() << "UserMenuGui::createMenu called" << endl;
   clear();
   insertTitle( i18n("User Menu") );

   // read entries from config file.
   readEntries();

   // add the "add new entry" command
   insertSeparator();
   insertItem( i18n("Manage user actions"), 0 );
}

void UserMenuGui::readEntries() {
   // Note: entries are marked 1..n, so that entry 0 is always
   // available. It is used by the "add new entry" command.
   int idx = 1;

   //FIXME: don't plug ALL useractions into the usermenu. TODO: read the usermenu-strukture from an other file (krusaderrc ?)
   UserAction::KrActionList list = krUserAction->actionList();
   for ( KrAction* action = list.first(); action; action = list.next() )
      action->plug( this, idx++ );

}

void UserMenuGui::run() {
   //disable unwanted actions:
   // disabled due to conflicts with the toolbar (a check on each file-cursor-movement would be nessesary; hit the performance)
//    krApp->userAction->setAvailability();

   int idx = exec();
   if ( idx == -1 ) // nothing was selected
     return;
   if ( idx == 0 ) {
      Konfigurator konfigurator( false, 7 ); // page 7 are the UserActions
      return;
   }
}