~ubuntu-branches/ubuntu/hardy/krusader/hardy

« back to all changes in this revision

Viewing changes to krusader/krusader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Angel Ramos
  • Date: 2004-12-30 16:18:26 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041230161826-wx99gkdypyalazpv
Tags: 1.51-1
* New upstream release (Closes: #280037, #287015).
* Moved from section utils to kde (Closes: #286748).
* Renamed dk.po to da.po (Closes: #269414).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
                                krusader.cpp
3
 
                             -------------------
4
 
    copyright            : (C) 2000 by Shie Erlich & Rafi Yanai
5
 
    e-mail               : krusader@users.sourceforge.net
6
 
    web site             : http://krusader.sourceforge.net
7
 
 ---------------------------------------------------------------------------
8
 
  Description 
9
 
 ***************************************************************************
10
 
 
11
 
  A 
12
 
 
13
 
     db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.
14
 
     88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D
15
 
     88,8P   88oobY' 88    88 `8bo.   88ooo88 88   88 88ooooo 88oobY'
16
 
     88`8b   88`8b   88    88   `Y8b. 88~~~88 88   88 88~~~~~ 88`8b
17
 
     88 `88. 88 `88. 88b  d88 db   8D 88   88 88  .8D 88.     88 `88.
18
 
     YP   YD 88   YD ~Y8888P' `8888Y' YP   YP Y8888D' Y88888P 88   YD
19
 
 
20
 
                                                     S o u r c e    F i l e
21
 
 
22
 
 ***************************************************************************
23
 
 *                                                                         *
24
 
 *   This program is free software; you can redistribute it and/or modify  *
25
 
 *   it under the terms of the GNU General Public License as published by  *
26
 
 *   the Free Software Foundation; either version 2 of the License, or     *
27
 
 *   (at your option) any later version.                                   *
28
 
 *                                                                         *
29
 
 ***************************************************************************/
30
 
#include <sys/types.h>
31
 
#include <sys/stat.h>
 
2
                          krusader.cpp
 
3
                       -------------------
 
4
copyright            : (C) 2000 by Shie Erlich & Rafi Yanai
 
5
e-mail               : krusader@users.sourceforge.net
 
6
web site             : http://krusader.sourceforge.net
 
7
---------------------------------------------------------------------------
 
8
Description 
 
9
***************************************************************************
 
10
 
 
11
 
12
 
 
13
db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.
 
14
88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D
 
15
88,8P   88oobY' 88    88 `8bo.   88ooo88 88   88 88ooooo 88oobY'
 
16
88`8b   88`8b   88    88   `Y8b. 88~~~88 88   88 88~~~~~ 88`8b
 
17
88 `88. 88 `88. 88b  d88 db   8D 88   88 88  .8D 88.     88 `88.
 
18
YP   YD 88   YD ~Y8888P' `8888Y' YP   YP Y8888D' Y88888P 88   YD
 
19
 
 
20
                                               S o u r c e    F i l e
 
21
 
 
22
***************************************************************************
 
23
*                                                                         *
 
24
*   This program is free software; you can redistribute it and/or modify  *
 
25
*   it under the terms of the GNU General Public License as published by  *
 
26
*   the Free Software Foundation; either version 2 of the License, or     *
 
27
*   (at your option) any later version.                                   *
 
28
*                                                                         *
 
29
***************************************************************************/
 
30
#include <sys/types.h>
 
31
#include <sys/stat.h> 
 
32
#include <sys/param.h>
 
33
#include <unistd.h>
 
34
#ifdef BSD
 
35
#include <sys/types.h>
 
36
#endif
32
37
// KDE includes
33
38
#include <kmessagebox.h>
34
39
#include <kaction.h>
35
40
#include <kcursor.h>
36
41
#include <ksystemtray.h>
37
42
#include <kmenubar.h>
38
 
#include <kapp.h>
 
43
#include <kapplication.h>
39
44
#include <dcopclient.h>
 
45
#include <kcmdlineargs.h>
40
46
#include <kglobal.h>
41
47
#include <klocale.h>
 
48
#include <kaccelmanager.h>
 
49
#include <kwin.h>
 
50
 
 
51
#if KDE_IS_VERSION(3,2,0)
 
52
#include <kactionclasses.h>
 
53
#endif
 
54
 
 
55
#include <kdeversion.h> 
42
56
// QT includes
43
57
#include <qpixmap.h>
44
58
#include <qstringlist.h>
46
60
#include <qprinter.h>
47
61
#include <qprogressdialog.h>
48
62
#include <qvaluelist.h>
 
63
#include <qwhatsthis.h> 
49
64
// Krusader includes
50
65
#include "krusader.h"
 
66
#include "kicons.h"
51
67
#include "VFS/krpermhandler.h"
52
 
#include "BookMan/bookman.h"
53
68
#include "GUI/krusaderstatus.h"
54
69
#include "RemoteMan/remoteman.h"
55
70
#include "Dialogs/krpleasewait.h"
56
71
#include "krusaderview.h"
57
 
#include "Panel/kvfspanel.h"
 
72
#include "Panel/listpanel.h"
 
73
#include "Panel/panelfunc.h"
58
74
#include "Konfigurator/konfigurator.h"
 
75
#include "Konfigurator/kgprotocols.h"
59
76
#include "MountMan/kmountman.h"
 
77
#include "Panel/panelpopup.h"
60
78
#include "defaults.h"
61
79
#include "resources.h"
62
80
#include "GUI/kfnkeys.h"
63
81
#include "GUI/kcmdline.h"
64
82
#include "krslots.h"
 
83
#include "krservices.h"
 
84
#include "UserAction/useraction.h"
 
85
#include "UserAction/expander.h"
 
86
#include "UserMenu/usermenu.h"
 
87
#include "panelmanager.h"
 
88
#include "MountMan/kmountman.h"
 
89
#include "BookMan/krbookmarkhandler.h"
65
90
 
66
91
// define the static members
67
 
Krusader *Krusader::App=0;
68
 
KAction  *Krusader::actProperties=0;    KAction  *Krusader::actPack=0;
69
 
KAction  *Krusader::actUnpack=0;        KAction  *Krusader::actTest=0;
70
 
KAction  *Krusader::actCompare=0;       KAction  *Krusader::actCalculate=0;
71
 
KAction  *Krusader::actSelect=0;        KAction  *Krusader::actSelectAll=0;
72
 
KAction  *Krusader::actUnselect=0;      KAction  *Krusader::actUnselectAll=0;
73
 
KAction  *Krusader::actInvert=0;        KAction  *Krusader::actSysInfo=0;
74
 
KAction  *Krusader::actSync=0;          KAction  *Krusader::actHomeTerminal=0;
75
 
KAction  *Krusader::actFTPConnect=0;    KAction  *Krusader::actFTPNewConnect=0;
76
 
KAction  *Krusader::actFTPDisconnect=0; KAction  *Krusader::actFullPanel=0;
77
 
KAction  *Krusader::actTreePanel=0;     KAction  *Krusader::actQuickPanel=0;
78
 
KAction  *Krusader::actAllFilter=0;     KAction  *Krusader::actExecFilter=0;
79
 
KAction  *Krusader::actCustomFilter=0;  KAction  *Krusader::actMountMan=0;
80
 
KAction  *Krusader::actBookMan=0;       KAction  *Krusader::actNewTool=0;
81
 
KAction  *Krusader::actKonfigurator=0;  KAction  *Krusader::actToolsSetup=0;
82
 
KAction  *Krusader::actBack=0;          KAction  *Krusader::actRoot=0;
83
 
KAction  *Krusader::actFind=0;          KAction  *Krusader::actAddBookmark=0;
84
 
KAction  *Krusader::actSavePosition=0;  KAction  *Krusader::actSelectColorMask=0;
85
 
KToggleAction *Krusader::actToggleTerminal=0;
86
 
 
 
92
Krusader *Krusader::App = 0;
 
93
KAction *Krusader::actProperties = 0;
 
94
KAction *Krusader::actPack = 0;
 
95
KAction *Krusader::actUnpack = 0;
 
96
KAction *Krusader::actTest = 0;
 
97
KAction *Krusader::actCompare = 0;
 
98
KAction *Krusader::actCalculate = 0;
 
99
KAction *Krusader::actSelect = 0;
 
100
KAction *Krusader::actSelectAll = 0;
 
101
KAction *Krusader::actUnselect = 0;
 
102
KAction *Krusader::actUnselectAll = 0;
 
103
KAction *Krusader::actInvert = 0;
 
104
KAction *Krusader::actCompDirs = 0;
 
105
KAction *Krusader::actSync = 0;
 
106
KAction *Krusader::actDiskUsage = 0;
 
107
KAction *Krusader::actHomeTerminal = 0;
 
108
KAction *Krusader::actFTPConnect = 0;
 
109
KAction *Krusader::actFTPNewConnect = 0;
 
110
KAction *Krusader::actFTPDisconnect = 0;
 
111
KAction *Krusader::actProfiles = 0;
 
112
KAction *Krusader::actMultiRename = 0;
 
113
KAction *Krusader::actAllFilter = 0;
 
114
KAction *Krusader::actExecFilter = 0;
 
115
KAction *Krusader::actCustomFilter = 0;
 
116
KAction *Krusader::actMountMan = 0;
 
117
KAction *Krusader::actNewTool = 0;
 
118
KAction *Krusader::actKonfigurator = 0;
 
119
KAction *Krusader::actToolsSetup = 0;
 
120
KAction *Krusader::actSwapPanels = 0;
 
121
KAction *Krusader::actBack = 0;
 
122
KAction *Krusader::actRoot = 0;
 
123
KAction *Krusader::actFind = 0;
 
124
KAction *Krusader::actLocate = 0;
 
125
//KAction *Krusader::actAddBookmark = 0;
 
126
KAction *Krusader::actSavePosition = 0;
 
127
KAction *Krusader::actSelectColorMask = 0;
 
128
KAction *Krusader::actOpenLeftBm = 0;
 
129
KAction *Krusader::actOpenRightBm = 0;
 
130
KAction *Krusader::actDirUp = 0;
 
131
KAction *Krusader::actCmdlinePopup = 0;
 
132
KAction *Krusader::actNewTab = 0;
 
133
KAction *Krusader::actDupTab = 0;
 
134
KAction *Krusader::actCloseTab = 0;
 
135
KAction *Krusader::actNextTab = 0;
 
136
KAction *Krusader::actPreviousTab = 0;
 
137
KAction *Krusader::actSplit = 0;
 
138
KAction *Krusader::actCombine = 0;
 
139
KAction *Krusader::actUserMenu = 0;
 
140
KAction *Krusader::actSyncDirs = 0;
 
141
KAction *Krusader::actF2 = 0;
 
142
KAction *Krusader::actF3 = 0;
 
143
KAction *Krusader::actF4 = 0;
 
144
KAction *Krusader::actF5 = 0;
 
145
KAction *Krusader::actF6 = 0;
 
146
KAction *Krusader::actF7 = 0;
 
147
KAction *Krusader::actF8 = 0;
 
148
KAction *Krusader::actF9 = 0;
 
149
KAction *Krusader::actF10 = 0;
 
150
KToggleAction *Krusader::actToggleTerminal = 0;
 
151
KRadioAction  *Krusader::actMarkNewerAndSingle = 0;
 
152
KRadioAction  *Krusader::actMarkSingle = 0;
 
153
KRadioAction  *Krusader::actMarkNewer = 0;
 
154
KRadioAction  *Krusader::actMarkDifferentAndSingle = 0;
 
155
KRadioAction  *Krusader::actMarkDifferent = 0;
 
156
KRadioAction  **Krusader::compareArray[] = {&actMarkNewerAndSingle, &actMarkNewer, &actMarkSingle, 
 
157
                                            &actMarkDifferentAndSingle, &actMarkDifferent, 0};
 
158
UserAction *Krusader::userAction = 0;
 
159
Expander *Krusader::expander = 0;
 
160
UserMenu *Krusader::userMenu = 0;
 
161
KrBookmarkHandler *Krusader::bookman = 0;
87
162
 
88
163
// construct the views, statusbar and menu bars and prepare Krusader to start
89
 
Krusader::Krusader() : KParts::MainWindow() {
90
 
  // create the "krusader"
91
 
  App=this;
92
 
        slot = new KRslots();
93
 
        setXMLFile("krusaderui.rc"); // kpart-related xml file
94
 
 
95
 
  plzWait = new KRPleaseWaitHandler();
96
 
 
97
 
  bool runKonfig=versionControl();
98
 
 
99
 
  QString message;
100
 
  switch (config->getConfigState()) {
101
 
    case KConfigBase::NoAccess :
102
 
      message="Krusader's configuration file can't be found.\nDefault values will be used.";
103
 
      break;
104
 
    case KConfigBase::ReadOnly :
105
 
      message="Krusader's configuration file is in READ ONLY mode (why is that !?)\nChanged values will not be saved";
106
 
      break;
107
 
    case KConfigBase::ReadWrite :
108
 
      message="";
109
 
     break;
110
 
  }
111
 
  if (message!="") {
112
 
    KMessageBox::error(krApp,message);
113
 
  }
114
 
 
115
 
  // register with the dcop server
116
 
        DCOPClient* client = KApplication::kApplication()->dcopClient();
117
 
        if ( !client->attach() ) exit(0);
118
 
        client->registerAs( KApplication::kApplication()->name() );
119
 
        
120
 
        // create an icon loader
121
 
        iconLoader = KGlobal::iconLoader();
122
 
        
123
 
        // create BookMan
124
 
  bookMan  = new BookMan();
125
 
  
126
 
        // create MountMan
127
 
        mountMan = new MountMan::KMountMan();
128
 
 
129
 
        // setup all the krusader's actions
130
 
        setupActions();
131
 
 
132
 
        // init the permmision handler class
133
 
  KRpermHandler::init();
134
 
 
135
 
  // create the main view and set it
136
 
  mainView=new KrusaderView(this);
137
 
 
138
 
  // setup keyboard accelerators        
139
 
        setupAccels();
140
 
        
141
 
        // create a status bar
142
 
        status=new KrusaderStatus(this);
143
 
 
144
 
        // This enables Krusader to minimize to tray if needed
145
 
        KSystemTray *st=new KSystemTray(this);
146
 
        st->setPixmap(iconLoader->loadIcon("krusader",KIcon::Panel));
147
 
        
148
 
        disableFutureItems();
149
 
 
150
 
  setCentralWidget(mainView);
151
 
  config->setGroup("Look&Feel");
152
 
  if (krConfig->readBoolEntry("Minimize To Tray",_MinimizeToTray))
153
 
    st->show(); else show();
154
 
 
155
 
  setCursor(KCursor::arrowCursor());
156
 
  // first, resize and move to starting point
157
 
  config->setGroup("Private");
158
 
  move(krConfig->readPointEntry("Start Position",_StartPosition));
159
 
  resize(krConfig->readSizeEntry("Start Size",_StartSize));
160
 
 
161
 
  // let the good times rool :)
162
 
  updateGUI(true);
163
 
  if (runKonfig) slot->runKonfigurator(true);
164
 
 
165
 
  // refresh the right and left panels
166
 
        mainView->left->refresh();
167
 
        mainView->right->refresh();
 
164
Krusader::Krusader() : KParts::MainWindow(), sysTray( 0 ), isStarting( true ) {
 
165
   // parse command line arguments
 
166
   KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
 
167
   QString leftPath, rightPath, startProfile;
 
168
 
 
169
   // get command-line arguments
 
170
   if ( args->isSet( "left" ) ) {
 
171
      leftPath = args->getOption( "left" );
 
172
      // make sure left or right are not relative paths
 
173
      if ( !leftPath.startsWith( "/" ) && leftPath.find( ":/" ) < 0 )    // make sure we don't touch things like ftp://
 
174
         leftPath = QDir::currentDirPath() + "/" + leftPath;
 
175
   } else leftPath = QString::null;
 
176
   if ( args->isSet( "right" ) ) {
 
177
      rightPath = args->getOption( "right" );
 
178
      // make sure left or right are not relative paths
 
179
      if ( !rightPath.startsWith( "/" ) && rightPath.find( ":/" ) < 0 )    // make sure we don't touch things like ftp://
 
180
         rightPath = QDir::currentDirPath() + "/" + rightPath;
 
181
   } else rightPath = QString::null;
 
182
   if ( args->isSet( "profile" ) ) {
 
183
      startProfile = args->getOption( "profile" );
 
184
   } else startProfile = QString::null;
 
185
 
 
186
   // create the "krusader"
 
187
   App = this;
 
188
   slot = new KRslots();
 
189
   setXMLFile( "krusaderui.rc" ); // kpart-related xml file
 
190
 
 
191
   plzWait = new KRPleaseWaitHandler();
 
192
 
 
193
   bool runKonfig = versionControl();
 
194
 
 
195
   QString message;
 
196
   switch ( config->getConfigState() ) {
 
197
         case KConfigBase::NoAccess :
 
198
         message = "Krusader's configuration file can't be found. Default values will be used.";
 
199
         break;
 
200
         case KConfigBase::ReadOnly :
 
201
         message = "Krusader's configuration file is in READ ONLY mode (why is that!?) Changed values will not be saved";
 
202
         break;
 
203
         case KConfigBase::ReadWrite :
 
204
         message = "";
 
205
         break;
 
206
   }
 
207
   if ( message != "" ) {
 
208
      KMessageBox::error( krApp, message );
 
209
   }
 
210
 
 
211
 
 
212
   // register with the dcop server
 
213
   DCOPClient* client = KApplication::kApplication() ->dcopClient();
 
214
   if ( !client->attach() )
 
215
      exit( 0 );
 
216
   client->registerAs( KApplication::kApplication() ->name() );
 
217
 
 
218
   // create an icon loader
 
219
   iconLoader = KGlobal::iconLoader();
 
220
 
 
221
   // create MountMan
 
222
   mountMan = new KMountMan();
 
223
 
 
224
   // create bookman
 
225
   bookman = new KrBookmarkHandler();
 
226
 
 
227
   // create the main view
 
228
   mainView = new KrusaderView( this );
 
229
   
 
230
   // setup all the krusader's actions
 
231
   setupActions();
 
232
 
 
233
   // init the permmision handler class
 
234
   KRpermHandler::init();
 
235
 
 
236
   // init the protocol handler
 
237
   KgProtocols::init();
 
238
 
 
239
   // starting the panels
 
240
   mainView->start( leftPath, rightPath );
 
241
 
 
242
   // restore TabBar
 
243
   {
 
244
      KConfigGroupSaver grp( krConfig, "Startup" );
 
245
      QStringList l1( krConfig->readPathListEntry( "Left Tab Bar" ) );
 
246
      QStringList l2( krConfig->readPathListEntry( "Right Tab Bar" ) );
 
247
      QStringList::const_iterator it;
 
248
      
 
249
      if ( krConfig->readEntry( "Left Panel Origin" ) == i18n( "the last place it was" ) )
 
250
         for ( it = ++(l1.begin()); it != l1.end(); ++it )
 
251
           mainView->leftMng->slotNewTab( *it );
 
252
 
 
253
      krConfig->setGroup( "Startup" );             
 
254
      if ( krConfig->readEntry( "Right Panel Origin" ) == i18n( "the last place it was" ) )
 
255
         for ( it = ++(l2.begin()); it != l2.end(); ++it )
 
256
           mainView->rightMng->slotNewTab( *it );
 
257
      
 
258
      krConfig->setGroup( "Startup" );             
 
259
      mainView->leftMng->setActiveTab( krConfig->readNumEntry( "Left Active Tab", 0 ) );
 
260
      krConfig->setGroup( "Startup" );             
 
261
      mainView->rightMng->setActiveTab( krConfig->readNumEntry( "Right Active Tab", 0 ) );
 
262
   }
 
263
   
 
264
   // create the user menu
 
265
   userMenu = new UserMenu( this );
 
266
   userMenu->hide();
 
267
 
 
268
   // setup keyboard accelerators
 
269
   setupAccels();
 
270
 
 
271
   // create a status bar
 
272
   status = new KrusaderStatus( this );
 
273
   QWhatsThis::add( status, i18n( "Status bar will show  basic informations "
 
274
                                     "about file below mouse pointer." ) );
 
275
 
 
276
   // This enables Krusader to show a tray icon
 
277
   sysTray = new KSystemTray( this );
 
278
   sysTray->setPixmap( iconLoader->loadIcon( "krusader", KIcon::Panel, 22 ) );
 
279
   sysTray->hide();
 
280
 
 
281
   setCentralWidget( mainView );
 
282
   config->setGroup( "Look&Feel" );
 
283
 
 
284
   // manage our keyboard short-cuts
 
285
   //KAcceleratorManager::manage(this,true);
 
286
 
 
287
   setCursor( KCursor::arrowCursor() );
 
288
   // first, resize and move to starting point
 
289
   config->setGroup( "Private" );
 
290
   move( oldPos = krConfig->readPointEntry( "Start Position", _StartPosition ) );
 
291
   resize( oldSize = krConfig->readSizeEntry( "Start Size", _StartSize ) );
 
292
 
 
293
   if ( ! startProfile.isEmpty() )
 
294
       mainView->profiles( startProfile );
 
295
   
 
296
   if ( krConfig->readBoolEntry( "Maximized" ) )
 
297
      showMaximized();
 
298
   else
 
299
      show();
 
300
 
 
301
   // let the good times rool :)
 
302
   updateGUI( true );
 
303
   if ( runKonfig )
 
304
      slot->runKonfigurator( true );
 
305
 
 
306
   isStarting = false;
168
307
}
169
308
 
170
 
Krusader::~Krusader(){}
 
309
Krusader::~Krusader() {}
171
310
 
172
311
bool Krusader::versionControl() {
173
 
  bool retval=false;
174
 
  // create config file
175
 
  config=kapp->config();
176
 
  QString oldVerText = config->readEntry("Version","100");
177
 
  oldVerText.truncate(oldVerText.find("-"));
178
 
  float oldVer = oldVerText.toFloat();
179
 
        
180
 
        kdDebug() << QString("version = %1").arg(oldVer) << endl;
181
 
 
182
 
  // older icompatible version
183
 
        if ( oldVer < (9/10) ){
184
 
                KMessageBox::information(krApp,i18n("A configuration older then v0.90,\nwas detected Krusader has to reset your\nconfiguration to default values.\nKrusader will now run Konfigurator."));
185
 
    if (!QDir::home().remove(".kde/share/config/krusaderrc")) {
186
 
      KMessageBox::error(krApp,i18n("Unable to remove your krusaderrc file !\nPlease remove it manually and rerun Krusader."));
187
 
      exit(1);
188
 
    }
189
 
    retval=true;
190
 
    config->reparseConfiguration();
191
 
  }
192
 
  // first installation of krusader
193
 
        if ( oldVer == 100 ){
194
 
                KMessageBox::information(krApp,i18n("Welcome to Krusader,\nas this is your first run,\nKrusader will now run Konfigurator."));
195
 
        retval = true;
196
 
        }
197
 
        config->writeEntry("Version",VERSION);
198
 
  config->sync();
199
 
  return retval;
200
 
}
201
 
 
202
 
void Krusader::statusBarUpdate(QString mess) {
203
 
  // change the message on the statusbar for 2 seconds
204
 
  statusBar()->message(mess,5000);
205
 
}
206
 
 
207
 
void Krusader::disableFutureItems() {
208
 
  //krCompare->setEnabled(false);
209
 
  //krSyncDirs->setEnabled(false);
210
 
  //krNewTool->setEnabled(false);
211
 
  //krToolsSetup->setEnabled(false);
212
 
  //actionCollection()->action("std_print")->setEnabled(false);
 
312
   bool retval = false;
 
313
   // create config file
 
314
   config = kapp->config();
 
315
   QString oldVerText = config->readEntry( "Version", "200" );
 
316
   oldVerText.truncate( oldVerText.find( "-" ) );
 
317
   float oldVer = oldVerText.toFloat();
 
318
 
 
319
   //kdDebug() << QString( "version = %1" ).arg( oldVer ) << endl;
 
320
 
 
321
   // older icompatible version
 
322
   if ( oldVer < ( 9 / 10 ) ) {
 
323
      KMessageBox::information( krApp, i18n( "A configuration older then v0.90 was detected Krusader has to reset your configuration to default values. Krusader will now run Konfigurator." ) );
 
324
      if ( !QDir::home().remove( ".kde/share/config/krusaderrc" ) ) {
 
325
         KMessageBox::error( krApp, i18n( "Unable to remove your krusaderrc file! Please remove it manually and rerun Krusader." ) );
 
326
         exit( 1 );
 
327
      }
 
328
      retval = true;
 
329
      config->reparseConfiguration();
 
330
   }
 
331
   // first installation of krusader
 
332
   if ( oldVer == 100 ) {
 
333
      KMessageBox::information( krApp, i18n( "Welcome to Krusader, as this is your first run, Krusader will now run Konfigurator." ) );
 
334
      retval = true;
 
335
   }
 
336
   config->writeEntry( "Version", VERSION );
 
337
   config->sync();
 
338
   return retval;
 
339
}
 
340
 
 
341
void Krusader::statusBarUpdate( QString& mess ) {
 
342
   // change the message on the statusbar for 2 seconds
 
343
   statusBar() ->message( mess, 5000 );
 
344
}
 
345
 
 
346
void Krusader::showEvent ( QShowEvent * ) {
 
347
   sysTray->hide();
 
348
   show(); // needed to make sure krusader is removed from
 
349
   // the taskbar when minimizing (system tray issue)
 
350
}
 
351
 
 
352
void Krusader::hideEvent ( QHideEvent *e ) {
 
353
   QString lastGroup = config->group();
 
354
   config->setGroup( "Look&Feel" );
 
355
   bool showTrayIcon = krConfig->readBoolEntry( "Minimize To Tray", _MinimizeToTray );
 
356
   config->setGroup ( lastGroup );
 
357
 
 
358
   bool isModalTopWidget = false;
 
359
 
 
360
   QWidget *actWnd = qApp->activeWindow();
 
361
   if ( actWnd )
 
362
      isModalTopWidget = actWnd->isModal();
 
363
 
 
364
   if ( showTrayIcon && !isModalTopWidget && KWin::windowInfo( winId() ).isMinimized() ) {
 
365
      sysTray->show();
 
366
      hide(); // needed to make sure krusader is removed from
 
367
      // the taskbar when minimizing (system tray issue)
 
368
   } else KParts::MainWindow::hideEvent( e );
 
369
}
 
370
 
 
371
void Krusader::moveEvent ( QMoveEvent *e ) {
 
372
   oldPos = e->oldPos();
 
373
   KParts::MainWindow::moveEvent( e );
 
374
}
 
375
 
 
376
void Krusader::resizeEvent ( QResizeEvent *e ) {
 
377
   oldSize = e->oldSize();
 
378
   KParts::MainWindow::resizeEvent( e );
213
379
}
214
380
 
215
381
void Krusader::setupAccels() {
216
 
  accels = new KAccel(this);
217
 
  // F2
218
 
  accels->insertItem("F2 Terminal", "F2_terminal", Key_F2,false);
219
 
  accels->connectItem("F2_terminal",SLOTS, SLOT(terminal()));
220
 
  // F3
221
 
  accels->insertItem("F3 View", "F3_view", Key_F3,false);
222
 
  accels->connectItem("F3_view",SLOTS, SLOT(view()));
223
 
  // F4
224
 
  accels->insertItem("F4 Edit", "F4_edit", Key_F4,false);
225
 
  accels->connectItem("F4_edit",SLOTS, SLOT(edit()));
226
 
  // F5
227
 
  accels->insertItem("F5-Copy", "F5_copy", Key_F5,false);
228
 
  accels->connectItem("F5_copy",SLOTS, SLOT(copyFiles()));
229
 
  // F6
230
 
  accels->insertItem("F6-Move", "F6_move", Key_F6,false);
231
 
  accels->connectItem("F6_move",SLOTS, SLOT(moveFiles()));
232
 
  // F7
233
 
  accels->insertItem("F7-Mkdir", "F7_mkdir", Key_F7,false);
234
 
  accels->connectItem("F7_mkdir",SLOTS, SLOT(mkdir()));
235
 
  // F8
236
 
  accels->insertItem("F8-Delete", "F8_delete", Key_F8,false);
237
 
  accels->connectItem("F8_delete",SLOTS, SLOT(deleteFiles()));
238
 
  // F9
239
 
  accels->insertItem("F9-Rename", "F9_rename", Key_F9,false);
240
 
  accels->connectItem("F9_rename",SLOTS, SLOT(rename()));
241
 
  // F10
242
 
  accels->insertItem("F10-Quit", "F10_quit", Key_F10,false);
243
 
  accels->connectItem("F10_quit",this, SLOT(quitKrusader()));
244
 
  // Tab
245
 
  accels->insertItem("Tab-Switch panel", "tab_switch_panel", Key_Tab,false);
246
 
  accels->connectItem("tab_switch_panel", mainView, SLOT(panelSwitch()));
 
382
         accels = new KAccel( this );
 
383
         // SHIFT+F3
 
384
   accels->insert( "F3_ViewDlg", i18n( "F3 View Dialog" ), QString::null,
 
385
                   SHIFT + Key_F3, SLOTS, SLOT( viewDlg() ) );
 
386
#if 0   
 
387
        // F2
 
388
   accels->insert( "F2_Terminal", i18n( "F2 Terminal" ), QString::null,
 
389
                   Key_F2, SLOTS, SLOT( terminal() ) );
 
390
   // F3
 
391
   accels->insert( "F3_View", i18n( "F3 View" ), QString::null,
 
392
                   Key_F3, SLOTS, SLOT( view() ) );
 
393
   // SHIFT+F3
 
394
   accels->insert( "F3_ViewDlg", i18n( "F3 View Dialog" ), QString::null,
 
395
                   SHIFT + Key_F3, SLOTS, SLOT( viewDlg() ) );
 
396
   // F4
 
397
   accels->insert( "F4_Edit", i18n( "F4 Edit" ), QString::null,
 
398
                   Key_F4, SLOTS, SLOT( edit() ) );
 
399
   // F5
 
400
   accels->insert( "F5_Copy", i18n( "F5 Copy" ), QString::null,
 
401
                   Key_F5, SLOTS, SLOT( copyFiles() ) );
 
402
   // F6
 
403
   accels->insert( "F6_Move", i18n( "F6 Move" ), QString::null,
 
404
                   Key_F6, SLOTS, SLOT( moveFiles() ) );
 
405
   // F7
 
406
   accels->insert( "F7_Mkdir", i18n( "F7 Mkdir" ), QString::null,
 
407
                   Key_F7, SLOTS, SLOT( mkdir() ) );
 
408
   // F8
 
409
   accels->insert( "F8_Delete", i18n( "F8 Delete" ), QString::null,
 
410
                   Key_F8, SLOTS, SLOT( deleteFiles() ) );
 
411
   // F9
 
412
   accels->insert( "F9_Rename", i18n( "F9 Rename" ), QString::null,
 
413
                   Key_F9, SLOTS, SLOT( rename() ) );
 
414
   // F10
 
415
   accels->insert( "F10_Quit", i18n( "F10 Quit" ), QString::null,
 
416
                   Key_F10, this, SLOT( quitKrusader() ) );
 
417
#endif
 
418
   // Tab
 
419
   accels->insert( "Tab-Switch panel", i18n( "Tab: switch panel" ), QString::null,
 
420
                   Key_Tab, mainView, SLOT( panelSwitch() ) );
247
421
 
248
422
}
249
423
 
250
424
// <patch> Moving from Pixmap actions to generic filenames - thanks to Carsten Pfeiffer
251
425
void Krusader::setupActions() {
252
 
  // first come the TODO actions
253
 
  //actSync =       0;//new KAction(i18n("S&yncronize Dirs"),                         0, this, 0, actionCollection(), "sync dirs");
254
 
        //actNewTool =    0;//new KAction(i18n("&Add a new tool"),                          0, this, 0, actionCollection(), "add tool");
255
 
        //actToolsSetup = 0;//new KAction(i18n("&Tools Menu Setup"),                        0, 0, this, 0, actionCollection(), "tools setup");
256
 
  //KStdAction::print(SLOTS, 0,actionCollection(),"std_print");
257
 
 
258
 
 
259
 
        // second, the KDE standard action
260
 
  KStdAction::up(SLOTS,SLOT(dirUp()),actionCollection(),"std_up");
261
 
        KStdAction::home(SLOTS,SLOT(home()),actionCollection(),"std_home");
262
 
  KStdAction::redisplay(SLOTS,SLOT(refresh()),actionCollection(),"std_redisplay");
263
 
  actShowToolBar   = KStdAction::showToolbar(SLOTS, SLOT(toggleToolbar()),actionCollection(),"std_toolbar");    
264
 
  actShowStatusBar = KStdAction::showStatusbar(SLOTS, SLOT(toggleStatusbar()),actionCollection(),"std_statusbar");      
265
 
  KStdAction::quit(this, SLOT(quitKrusader()),actionCollection(),"std_quit");
266
 
  KStdAction::configureToolbars(SLOTS,SLOT(configToolbar()),actionCollection(),"std_config_toolbar");
267
 
  KStdAction::keyBindings(SLOTS,SLOT(configKeys()),actionCollection(),"std_config_keys");
268
 
 
269
 
  // the toggle actions
270
 
  actCompareDirs = new KToggleAction(i18n("Compare Mode"), "kr_comparedirs",
271
 
                           CTRL+Key_Equal, SLOTS, SLOT(compareDirectories()), actionCollection(), "compare mode");
272
 
  actCompareDirs->setChecked(false);
273
 
        actToggleFnkeys =   new KToggleAction(i18n("Show &FN Keys Bar"),0,SLOTS,
274
 
                               SLOT(toggleFnkeys()),actionCollection(),"toggle fn bar");
275
 
        actToggleFnkeys->setChecked(true);
276
 
        actToggleCmdline =  new KToggleAction(i18n("Show &Command Line"),0,SLOTS,
277
 
                               SLOT(toggleCmdline()),actionCollection(),"toggle command line");
278
 
        actToggleCmdline->setChecked(true);
279
 
        actToggleTerminal = new KToggleAction(i18n("Show &Terminal Emulator"),0,SLOTS,
280
 
                               SLOT(toggleTerminal()),actionCollection(),"toggle terminal emulator");
281
 
        actToggleTerminal->setChecked(false);
282
 
        actToggleHidden =   new KToggleAction(i18n("Show H&idden Files"),0,SLOTS,
283
 
                         SLOT(toggleHidden()),actionCollection(),"toggle hidden files");
284
 
        actToggleSortByExt = new KToggleAction(i18n("Sort By E&xtention"),0,SLOTS,
285
 
                         SLOT(toggleSortByExt()),actionCollection(),"toggle sort by extention");
286
 
  krConfig->setGroup("Look&Feel");
287
 
        actToggleHidden->setChecked(krConfig->readBoolEntry("Show Hidden",_ShowHidden));
288
 
        actToggleSortByExt->setChecked(krConfig->readBoolEntry("Sort By Extention",_SortByExt));
289
 
        
290
 
        // and then the DONE actions
291
 
        actSelectColorMask =new KAction(i18n("Configure compare-mode"), 0,
292
 
                              SLOTS,     SLOT(selectCompareMask()),      actionCollection(), "select colormask");
293
 
        actTest =           new KAction(i18n("Test Archi&ve(s)"), "kr_arc_test", CTRL+Key_T,
294
 
                              SLOTS,     SLOT(testArchive()),      actionCollection(), "test archives");
295
 
  actFTPConnect =     new KAction(i18n("&FTP Connect"), "kr_ftp_connect", CTRL+Key_F,
296
 
                                                                                                SLOTS,          SLOT(runRemoteMan()),           actionCollection(), "ftp connect");
297
 
        actFTPNewConnect =  new KAction(i18n("FT&P New Connection"), "kr_ftp_new",    CTRL+Key_N,
298
 
                              SLOTS,     SLOT(newFTPconnection()), actionCollection(), "ftp new connection");
299
 
        actCalculate =      new KAction(i18n("Calculate &Occupied Space"), "kr_calc",  0,
300
 
                        SLOTS,     SLOT(calcSpace()),        actionCollection(), "calculate");
301
 
  actProperties =     new KAction(i18n("&Properties"), "kr_properties", 0,
302
 
                        SLOTS,     SLOT(properties()),       actionCollection(),"properties");
303
 
  actPack =           new KAction(i18n("Pac&k"),            "kr_arc_pack", CTRL+Key_P,
304
 
                        SLOTS,     SLOT(slotPack()),         actionCollection(), "pack");
305
 
  actUnpack =         new KAction(i18n("&Unpack"),          "kr_arc_unpack", CTRL+Key_U,
306
 
                        SLOTS,     SLOT(slotUnpack()),       actionCollection() , "unpack");
307
 
  actSelect =         new KAction(i18n("Select &Group"),    "kr_select",         CTRL+Key_Plus,
308
 
                        SLOTS,     SLOT(markGroup()),        actionCollection(), "select group");
309
 
  actSelectAll =      new KAction(i18n("&Select All"),      "kr_selectall",        ALT+Key_Plus,
310
 
                        SLOTS,     SLOT(markAll()),          actionCollection(), "select all");
311
 
  actUnselectAll =    new KAction(i18n("U&nselect All"),    "kr_unselectall",      ALT+Key_Minus,
312
 
                        SLOTS,     SLOT(unmarkAll()),        actionCollection(), "unselect all");
313
 
        actHomeTerminal =   new KAction(i18n("&Terminal"),        "kr_terminal", 0,
314
 
                        SLOTS,     SLOT(homeTerminal()),     actionCollection(), "terminal@home");
315
 
  actFTPDisconnect =  new KAction(i18n("FTP Disc&onnect"),  "kr_ftp_disconnect",     SHIFT+CTRL+Key_F,
316
 
                              SLOTS,     SLOT(FTPDisconnect()),    actionCollection(), "ftp disconnect");
317
 
        actFullPanel =      new KAction(i18n("&Full Panel"),            "kr_fullview",      ALT+Key_1,
318
 
                              SLOTS,     SLOT(setListView()),      actionCollection(), "full panel");
319
 
        actTreePanel =      new KAction(i18n("&Tree Panel"),            "kr_treeview",      ALT+Key_2,
320
 
                              SLOTS,     SLOT(setTreeView()),      actionCollection(), "tree panel");
321
 
        actMountMan =       new KAction(i18n("&MountMan"),        "kr_mountman",       ALT+Key_Slash,
322
 
                        SLOTS,     SLOT(runMountMan()),      actionCollection(), "mountman");
323
 
        actBookMan =        new KAction(i18n("&BookMan"),         "kr_bookman",  0,
324
 
                              krBookMan,SLOT(showGUI()),          actionCollection(), "bookman");
325
 
        actFind =           new KAction(i18n("&Search"),            "filefind",         CTRL+Key_S,
326
 
                        SLOTS,     SLOT(search()),           actionCollection(), "find");
327
 
  actInvert =         new KAction(i18n("&Invert Selection"),"kr_invert",         ALT+Key_Asterisk,
328
 
                              SLOTS,     SLOT(invert()),           actionCollection(), "invert");
329
 
        actUnselect =       new KAction(i18n("&Unselect &Group"), "kr_unselect",         CTRL+Key_Minus,
330
 
                        SLOTS,     SLOT(unmarkGroup()),      actionCollection(), "unselect group");
331
 
  actAddBookmark =    new KAction(i18n("Add Bookmark"),     "kr_addbookmark",    CTRL+Key_B,
332
 
                        SLOTS,     SLOT(addBookmark()),      actionCollection(), "add bookmark");
333
 
  actKonfigurator =   new KAction(i18n("&Konfigurator"),    "configure", 0,
334
 
                        SLOTS,     SLOT(runKonfigurator()),  actionCollection(), "konfigurator");
335
 
        actBack =           new KAction(i18n("Back"),             "back",         0,
336
 
                        SLOTS,     SLOT(back()),             actionCollection(), "back");
337
 
  actRoot =           new KAction(i18n("Root"),             "top",  CTRL+Key_Backspace,
338
 
                        SLOTS,     SLOT(root()),             actionCollection(), "root");
339
 
  actSysInfo =        new KAction(i18n("&Device Manager"),   "kr_hwinfo",   0,
340
 
                        SLOTS,     SLOT(sysInfo()),          actionCollection(), "sysinfo");
341
 
  actSavePosition =   new KAction(i18n("Save &Position"),                             0,
342
 
                              krApp,     SLOT(savePosition()),     actionCollection(), "save position");
343
 
  actAllFilter =                new KAction(i18n("&All Files"),  SHIFT+Key_F10,
344
 
                                                                                                SLOTS,          SLOT(allFilter()),                               actionCollection(), "all files");
345
 
        actExecFilter = new KAction(i18n("&Executables"),    SHIFT+Key_F11,
346
 
                                                                                                SLOTS,          SLOT(execFilter()),                      actionCollection(), "exec files");
347
 
        actCustomFilter=new KAction(i18n("&Custom"),                                                            SHIFT+Key_F12,
348
 
                                                                                                SLOTS,                  SLOT(customFilter()),           actionCollection(), "custom files");
349
 
  actQuickPanel = new KAction(i18n("&Quickview Panel"), ALT+Key_3,
350
 
                                                                                                SLOTS,                  SLOT(setQuickView()),           actionCollection(), "quickview panel");
351
 
  actCompare = new KAction(i18n("Compare b&y content"), "kr_compare",
352
 
                           0, SLOTS, SLOT(compareContent()), actionCollection(), "compare");
353
 
  new KAction(i18n("Right-click menu"), Key_Menu,
354
 
                                SLOTS,                  SLOT(rightclickMenu()),                 actionCollection(), "rightclick menu");
355
 
                                                                                                                                
356
 
        // and at last we can set the tool-tips
357
 
  actSelect->setToolTip(i18n("Highlight files by using a filter"));
358
 
  actSelectAll->setToolTip(i18n("Highlight all the files in the current directory"));
359
 
  actUnselectAll->setToolTip(i18n("Remove selection from all highlight files"));
360
 
  actMountMan->setToolTip(i18n("Mount.Man: Krusader's mount-manager. Try it!"));
361
 
  actKonfigurator->setToolTip(i18n("Setup Krusader the way you like it"));
362
 
        actBack->setToolTip(i18n("Back to the place you came from"));
363
 
  actRoot->setToolTip(i18n("ROOT (/)"));
364
 
  actFind->setToolTip(i18n("Search for files"));
365
 
  actAddBookmark->setToolTip(i18n("Add the current path to your bookmarks"));
 
426
   // first come the TODO actions
 
427
   //actSync =       0;//new KAction(i18n("S&yncronize Dirs"),                         0, this, 0, actionCollection(), "sync dirs");
 
428
   //actNewTool =    0;//new KAction(i18n("&Add a new tool"),                          0, this, 0, actionCollection(), "add tool");
 
429
   //actToolsSetup = 0;//new KAction(i18n("&Tools Menu Setup"),                        0, 0, this, 0, actionCollection(), "tools setup");
 
430
   //KStdAction::print(SLOTS, 0,actionCollection(),"std_print");
 
431
 
 
432
 
 
433
   // second, the KDE standard action
 
434
   //KStdAction::up( SLOTS, SLOT( dirUp() ), actionCollection(), "std_up" )->setShortcut(Key_Backspace);
 
435
   /* Shortcut disabled because of the Terminal Emulator bug. */
 
436
   krConfig->setGroup( "Private" );
 
437
   int compareMode = krConfig->readNumEntry( "Compare Mode", 0 );
 
438
   
 
439
   KStdAction::home( SLOTS, SLOT( home() ), actionCollection(), "std_home" ); /*->setShortcut(Key_QuoteLeft);*/
 
440
   KAction *actRedisplay = KStdAction::redisplay( SLOTS, SLOT( refresh() ), actionCollection(), "std_redisplay" );
 
441
   actRedisplay->setText( "Reload" );
 
442
   actRedisplay->setShortcut( CTRL + Key_R );
 
443
   actShowToolBar = KStdAction::showToolbar( SLOTS, SLOT( toggleToolbar() ), actionCollection(), "std_toolbar" );
 
444
   actShowStatusBar = KStdAction::showStatusbar( SLOTS, SLOT( toggleStatusbar() ), actionCollection(), "std_statusbar" );
 
445
   KStdAction::quit( this, SLOT( quitKrusader() ), actionCollection(), "std_quit" );
 
446
   KStdAction::configureToolbars( SLOTS, SLOT( configToolbar() ), actionCollection(), "std_config_toolbar" );
 
447
   KStdAction::keyBindings( SLOTS, SLOT( configKeys() ), actionCollection(), "std_config_keys" );
 
448
   
 
449
   KStdAction::cut( SLOTS, SLOT( cut() ), actionCollection(), "std_cut" );
 
450
   KStdAction::copy( SLOTS, SLOT( copy() ), actionCollection(), "std_copy" );
 
451
   KStdAction::paste( SLOTS, SLOT( paste() ), actionCollection(), "std_paste" );
 
452
 
 
453
   // the toggle actions
 
454
   actToggleFnkeys = new KToggleAction( i18n( "Show &FN Keys Bar" ), 0, SLOTS,
 
455
                                        SLOT( toggleFnkeys() ), actionCollection(), "toggle fn bar" );
 
456
   actToggleFnkeys->setChecked( true );
 
457
   actToggleCmdline = new KToggleAction( i18n( "Show &Command Line" ), 0, SLOTS,
 
458
                                         SLOT( toggleCmdline() ), actionCollection(), "toggle command line" );
 
459
   actToggleCmdline->setChecked( true );
 
460
   actToggleTerminal = new KToggleAction( i18n( "Show Terminal &Emulator" ), 0, SLOTS,
 
461
                                          SLOT( toggleTerminal() ), actionCollection(), "toggle terminal emulator" );
 
462
   actToggleTerminal->setChecked( false );
 
463
   actToggleHidden = new KToggleAction( i18n( "Show &Hidden Files" ), CTRL + Key_Period, SLOTS,
 
464
                                        SLOT( toggleHidden() ), actionCollection(), "toggle hidden files" );
 
465
   actSwapPanels = new KAction( i18n( "S&wap Panels" ), CTRL + Key_U, SLOTS,
 
466
                                SLOT( toggleSwapPanels() ), actionCollection(), "toggle swap panels" );
 
467
   krConfig->setGroup( "Look&Feel" );
 
468
   actToggleHidden->setChecked( krConfig->readBoolEntry( "Show Hidden", _ShowHidden ) );
 
469
 
 
470
   // and then the DONE actions
 
471
   actCmdlinePopup = new KAction( i18n( "popup cmdline" ), 0, CTRL + Key_Slash, SLOTS,
 
472
                                  SLOT( cmdlinePopup() ), actionCollection(), "cmdline popup" );
 
473
   /* Shortcut disabled because of the Terminal Emulator bug. */
 
474
   actDirUp = new KAction( i18n( "Up one directory" ), "up", CTRL+Key_PageUp /*Key_Backspace*/, SLOTS, SLOT( dirUp() ), actionCollection(), "dirUp" );
 
475
   new KAction( i18n( "&Edit new file" ), "filenew", SHIFT + Key_F4, SLOTS, SLOT( editDlg() ), actionCollection(), "edit_new_file" );
 
476
   new KAction( i18n( "Start &Root Mode Krusader" ), "krusader_red", ALT + Key_K, SLOTS, SLOT( rootKrusader() ), actionCollection(), "root krusader" );
 
477
 
 
478
   actTest = new KAction( i18n( "T&est Archive(s)" ), "ark", ALT + Key_E,
 
479
                          SLOTS, SLOT( testArchive() ), actionCollection(), "test archives" );
 
480
   actFTPConnect = new KAction( i18n( "&Net Connections" ), "domtreeviewer", 0,
 
481
                                SLOTS, SLOT( runRemoteMan() ), actionCollection(), "ftp connect" );
 
482
   actFTPNewConnect = new KAction( i18n( "New Net &Connection" ), "connect_creating", CTRL + Key_N,
 
483
                                   SLOTS, SLOT( newFTPconnection() ), actionCollection(), "ftp new connection" );
 
484
   actProfiles = new KAction( i18n( "Pro&files" ), "kr_profile", ALT + Key_L,
 
485
                                   MAIN_VIEW, SLOT( profiles() ), actionCollection(), "profile" );
 
486
   actCalculate = new KAction( i18n( "Calculate &Occupied Space" ), "kcalc", 0,
 
487
                               SLOTS, SLOT( calcSpace() ), actionCollection(), "calculate" );
 
488
   actProperties = new KAction( i18n( "&Properties" ), "help", 0,
 
489
                                SLOTS, SLOT( properties() ), actionCollection(), "properties" );
 
490
   actPack = new KAction( i18n( "Pac&k" ), "kr_arc_pack", ALT + Key_P,
 
491
                          SLOTS, SLOT( slotPack() ), actionCollection(), "pack" );
 
492
   actUnpack = new KAction( i18n( "&Unpack" ), "kr_arc_unpack", ALT + Key_U,
 
493
                            SLOTS, SLOT( slotUnpack() ), actionCollection() , "unpack" );
 
494
   actSplit = new KAction( i18n( "Sp&lit file" ), "kr_split", CTRL + Key_P,
 
495
                           SLOTS, SLOT( slotSplit() ), actionCollection(), "split" );
 
496
   actCombine = new KAction( i18n( "Com&bine files" ), "kr_combine", CTRL + Key_B,
 
497
                             SLOTS, SLOT( slotCombine() ), actionCollection() , "combine" );
 
498
   actSelect = new KAction( i18n( "Select &Group" ), "kr_select", CTRL + Key_Plus,
 
499
                            SLOTS, SLOT( markGroup() ), actionCollection(), "select group" );
 
500
   actSelectAll = new KAction( i18n( "&Select All" ), "kr_selectall", ALT + Key_Plus,
 
501
                               SLOTS, SLOT( markAll() ), actionCollection(), "select all" );
 
502
   actUnselectAll = new KAction( i18n( "U&nselect All" ), "kr_unselectall", ALT + Key_Minus,
 
503
                                 SLOTS, SLOT( unmarkAll() ), actionCollection(), "unselect all" );
 
504
   actCompDirs = new KAction( i18n( "&Compare Directories" ), "view_left_right", 0,
 
505
                                 SLOTS, SLOT( compareDirs() ), actionCollection(), "compare dirs" );
 
506
   actMarkNewerAndSingle = new KRadioAction( i18n( "&Mark Newer And Single" ), 0,
 
507
                                 SLOTS, SLOT( compareSetup() ), actionCollection(), "mark_newer_and_single" );
 
508
   actMarkNewer = new KRadioAction( i18n( "Mark &Newer" ), 0,
 
509
                                 SLOTS, SLOT( compareSetup() ), actionCollection(), "mark_newer" );
 
510
   actMarkSingle = new KRadioAction( i18n( "Mark &Single" ), 0,
 
511
                                 SLOTS, SLOT( compareSetup() ), actionCollection(), "mark_single" );
 
512
   actMarkDifferentAndSingle = new KRadioAction( i18n( "Mark Different &And Single" ), 0,
 
513
                                 SLOTS, SLOT( compareSetup() ), actionCollection(), "mark_different_and_single" );
 
514
   actMarkDifferent = new KRadioAction( i18n( "Mark &Different" ), 0,
 
515
                                 SLOTS, SLOT( compareSetup() ), actionCollection(), "mark_different" );
 
516
   actMarkNewerAndSingle->setExclusiveGroup( "mark group" );
 
517
   actMarkNewer->setExclusiveGroup( "mark group" );
 
518
   actMarkSingle->setExclusiveGroup( "mark group" );
 
519
   actMarkDifferentAndSingle->setExclusiveGroup( "mark group" );
 
520
   actMarkDifferent->setExclusiveGroup( "mark group" );
 
521
   if( compareMode < (int)( sizeof( compareArray ) / sizeof( KRadioAction ** ) ) -1 )
 
522
     (*compareArray[ compareMode ])->setChecked( true );
 
523
   actHomeTerminal = new KAction( i18n( "&Terminal" ), "konsole", 0,
 
524
                                  SLOTS, SLOT( homeTerminal() ), actionCollection(), "terminal@home" );
 
525
   actFTPDisconnect = new KAction( i18n( "Disconnect &From Net" ), "kr_ftp_disconnect", SHIFT + CTRL + Key_F,
 
526
                                   SLOTS, SLOT( FTPDisconnect() ), actionCollection(), "ftp disconnect" );
 
527
#if KDE_IS_VERSION(3,2,0)       /* new mountman feature is available in kde 3.2 only! */
 
528
   actMountMan = new KToolBarPopupAction( i18n( "&MountMan" ), "kr_mountman", ALT + Key_Slash,
 
529
                                          SLOTS, SLOT( runMountMan() ), actionCollection(), "mountman" );
 
530
   connect( ( ( KToolBarPopupAction* ) actMountMan ) ->popupMenu(), SIGNAL( aboutToShow() ),
 
531
            mountMan, SLOT( quickList() ) );
 
532
#else
 
533
   actMountMan = new KAction( i18n( "&MountMan" ), "kr_mountman", ALT + Key_Slash,
 
534
                              SLOTS, SLOT( runMountMan() ), actionCollection(), "mountman" );
 
535
#endif /* KDE 3.2 */
 
536
 
 
537
   actFind = new KAction( i18n( "&Search" ), "filefind", CTRL + Key_S,
 
538
                          SLOTS, SLOT( search() ), actionCollection(), "find" );
 
539
   actLocate = new KAction( i18n( "&Locate" ), "find", CTRL + Key_L,
 
540
                            SLOTS, SLOT( locate() ), actionCollection(), "locate" );
 
541
   actSyncDirs = new KAction( i18n( "Synchronize &Directories" ), "kr_syncdirs", CTRL + Key_Y,
 
542
                              SLOTS, SLOT( slotSynchronizeDirs() ), actionCollection(), "sync dirs" );
 
543
   //actDiskUsage = new KAction( i18n( "D&isk Usage" ), "kchart", ALT + Key_D,
 
544
   //                           SLOTS, SLOT( slotDiskUsage() ), actionCollection(), "disk usage" );
 
545
   actInvert = new KAction( i18n( "&Invert Selection" ), "kr_invert", ALT + Key_Asterisk,
 
546
                            SLOTS, SLOT( invert() ), actionCollection(), "invert" );
 
547
   actUnselect = new KAction( i18n( "&Unselect Group" ), "kr_unselect", CTRL + Key_Minus,
 
548
                              SLOTS, SLOT( unmarkGroup() ), actionCollection(), "unselect group" );
 
549
   actKonfigurator = new KAction( i18n( "Configure &Krusader" ), "configure", 0,
 
550
                                  SLOTS, SLOT( startKonfigurator() ), actionCollection(), "konfigurator" );
 
551
   actBack = new KAction( i18n( "Back" ), "back", 0,
 
552
                          SLOTS, SLOT( back() ), actionCollection(), "back" );
 
553
   actRoot = new KAction( i18n( "Root" ), "top", CTRL + Key_Backspace,
 
554
                          SLOTS, SLOT( root() ), actionCollection(), "root" );
 
555
   actSavePosition = new KAction( i18n( "Save &Position" ), 0,
 
556
                                  krApp, SLOT( savePosition() ), actionCollection(), "save position" );
 
557
   actAllFilter = new KAction( i18n( "&All Files" ), SHIFT + Key_F10,
 
558
                               SLOTS, SLOT( allFilter() ), actionCollection(), "all files" );
 
559
   //actExecFilter = new KAction( i18n( "&Executables" ), SHIFT + Key_F11,
 
560
   //                             SLOTS, SLOT( execFilter() ), actionCollection(), "exec files" );
 
561
   actCustomFilter = new KAction( i18n( "&Custom" ), SHIFT + Key_F12,
 
562
                                  SLOTS, SLOT( customFilter() ), actionCollection(), "custom files" );
 
563
   actCompare = new KAction( i18n( "Compare b&y content" ), "kmultiple", 0,
 
564
                             SLOTS, SLOT( compareContent() ), actionCollection(), "compare" );
 
565
   actMultiRename = new KAction( i18n( "Multi &Rename" ), "krename", SHIFT + Key_F9,
 
566
                                 SLOTS, SLOT( multiRename() ), actionCollection(), "multirename" );
 
567
   new KAction( i18n( "Right-click menu" ), Key_Menu,
 
568
                SLOTS, SLOT( rightclickMenu() ), actionCollection(), "rightclick menu" );
 
569
   new KAction( i18n( "Right bookmarks" ), ALT + Key_Right,
 
570
                SLOTS, SLOT( openRightBookmarks() ), actionCollection(), "right bookmarks" );
 
571
   new KAction( i18n( "Left bookmarks" ), ALT + Key_Left,
 
572
                SLOTS, SLOT( openLeftBookmarks() ), actionCollection(), "left bookmarks" );
 
573
        new KAction( i18n( "Bookmarks" ), CTRL + Key_D,
 
574
                SLOTS, SLOT( openBookmarks() ), actionCollection(), "bookmarks" );
 
575
        new KAction( i18n( "Sync Panels" ), ALT + Key_O,
 
576
                                         SLOTS, SLOT( syncPanels() ), actionCollection(), "sync panels");
 
577
   new KAction( i18n( "Left history" ), ALT + CTRL + Key_Left,
 
578
                SLOTS, SLOT( openLeftHistory() ), actionCollection(), "left history" );
 
579
   new KAction( i18n( "Right history" ), ALT + CTRL + Key_Right,
 
580
                SLOTS, SLOT( openRightHistory() ), actionCollection(), "right history" );
 
581
        new KToggleAction( i18n( "Toggle Popup Panel" ), ALT + Key_Down, SLOTS,
 
582
                                          SLOT( togglePopupPanel() ), actionCollection(), "toggle popup panel" );
 
583
        new KToggleAction( i18n( "Vertical Mode" ), ALT + CTRL + Key_R, MAIN_VIEW, 
 
584
                                        SLOT( toggleVerticalMode() ), actionCollection(), "toggle vertical mode" );
 
585
   actNewTab = new KAction( i18n( "New tab" ), ALT + CTRL + Key_N, SLOTS,
 
586
                            SLOT( newTab() ), actionCollection(), "new tab" );
 
587
   actDupTab = new KAction( i18n( "Duplicate tab" ), ALT + CTRL + SHIFT + Key_N, SLOTS,
 
588
                            SLOT( duplicateTab() ), actionCollection(), "duplicate tab" );
 
589
   actCloseTab = new KAction( i18n( "Close tab" ), ALT + CTRL + Key_C, SLOTS,
 
590
                              SLOT( closeTab() ), actionCollection(), "close tab" );
 
591
   actNextTab  = new KAction( i18n( "Next tab" ), SHIFT + Key_Right, SLOTS,
 
592
             SLOT( nextTab() ), actionCollection(), "next tab" );
 
593
   actPreviousTab  = new KAction( i18n( "Previous tab" ), SHIFT + Key_Left, SLOTS,
 
594
             SLOT( previousTab() ), actionCollection(), "previous tab" );                                                                               
 
595
   actUserMenu = new KAction( i18n( "User Menu" ), ALT + Key_QuoteLeft, SLOTS,
 
596
                              SLOT( userMenu() ), actionCollection(), "user menu" );
 
597
 
 
598
        // setup the Fn keys
 
599
        actF2 = new KAction( i18n( "F2 - Open a terminal" ), Key_F2,
 
600
                SLOTS, SLOT( terminal() ) , actionCollection(), "F2_Terminal" );
 
601
        actF3 = new KAction( i18n( "F3 - View a file" ), Key_F3,
 
602
                SLOTS, SLOT( view() ) , actionCollection(), "F3_View" );
 
603
        actF4 = new KAction( i18n( "F4 - Edit a file" ), Key_F4,
 
604
                SLOTS, SLOT( edit() ) , actionCollection(), "F4_Edit" );
 
605
        actF5 = new KAction( i18n( "F5 - Copy" ), Key_F5,
 
606
                SLOTS, SLOT( copyFiles() ) , actionCollection(), "F5_Copy" );
 
607
        actF6 = new KAction( i18n( "F6 - Move" ), Key_F6,
 
608
                SLOTS, SLOT( moveFiles() ) , actionCollection(), "F6_Move" );
 
609
        actF7 = new KAction( i18n( "F7 - Mkdir" ), Key_F7,
 
610
                SLOTS, SLOT( mkdir() ) , actionCollection(), "F7_Mkdir" );
 
611
        actF8 = new KAction( i18n( "F8 - Delete" ), Key_F8,
 
612
                SLOTS, SLOT( deleteFiles() ) , actionCollection(), "F8_Delete" );
 
613
        actF9 = new KAction( i18n( "F9 - Rename" ), Key_F9,
 
614
                SLOTS, SLOT( rename() ) , actionCollection(), "F9_Rename" );
 
615
        actF10 = new KAction( i18n( "F10 - Quit" ), Key_F10,
 
616
                this, SLOT( quitKrusader() ) , actionCollection(), "F10_Quit" );
 
617
                                                                                
 
618
   // and at last we can set the tool-tips
 
619
   actSelect->setToolTip( i18n( "Highlight files by using a filter" ) );
 
620
   actSelectAll->setToolTip( i18n( "Highlight all the files in the current directory" ) );
 
621
   actUnselectAll->setToolTip( i18n( "Remove selection from all highlight files" ) );
 
622
   actKonfigurator->setToolTip( i18n( "Setup Krusader the way you like it" ) );
 
623
   actBack->setToolTip( i18n( "Back to the place you came from" ) );
 
624
   actRoot->setToolTip( i18n( "ROOT (/)" ) );
 
625
   actFind->setToolTip( i18n( "Search for files" ) );
 
626
 
 
627
   // setup all UserActions
 
628
   expander = new Expander();
 
629
   userAction = new UserAction();
366
630
}
367
631
 
368
632
///////////////////////////////////////////////////////////////////////////
369
633
//////////////////// implementation of slots //////////////////////////////
370
634
///////////////////////////////////////////////////////////////////////////
371
 
        
372
 
void Krusader::savePosition(){
373
 
  config->setGroup("Private");
374
 
  config->writeEntry( "Start Position", pos() );
375
 
  config->writeEntry( "Start Size", size() );
376
 
  config->writeEntry( "Panel Size", mainView->vert_splitter->sizes()[0]);
377
 
  config->writeEntry( "Terminal Size", mainView->vert_splitter->sizes()[1]);
378
 
 
379
 
  config->writeEntry( "Left Name Size", mainView->left->fileList->columnWidth(0));
380
 
  config->writeEntry( "Left Size Size", mainView->left->fileList->columnWidth(1));
381
 
  config->writeEntry( "Left Date Size", mainView->left->fileList->columnWidth(2));
382
 
  config->writeEntry( "Right Name Size", mainView->right->fileList->columnWidth(0));
383
 
  config->writeEntry( "Right Size Size", mainView->right->fileList->columnWidth(1));
384
 
  config->writeEntry( "Right Date Size", mainView->right->fileList->columnWidth(2));
385
 
  QValueList<int> lst = mainView->horiz_splitter->sizes();
386
 
  config->writeEntry( "Splitter Sizes", lst);
387
 
 
388
 
  config->sync();
 
635
 
 
636
void Krusader::savePosition() {
 
637
   config->setGroup( "Private" );
 
638
   config->writeEntry( "Start Position", isMaximized() ? oldPos : pos() );
 
639
   config->writeEntry( "Start Size", isMaximized() ? oldSize : size() );
 
640
   config->writeEntry( "Maximized", isMaximized() );
 
641
   config->writeEntry( "Panel Size", mainView->vert_splitter->sizes() [ 0 ] );
 
642
   config->writeEntry( "Terminal Size", mainView->vert_splitter->sizes() [ 1 ] );
 
643
   QValueList<int> lst = mainView->horiz_splitter->sizes();
 
644
   config->writeEntry( "Splitter Sizes", lst );
 
645
   // save view settings ---> fix when we have tabbed-browsing
 
646
   mainView->left->view->saveSettings();
 
647
   mainView->right->view->saveSettings();
 
648
   config->sync();
389
649
}
390
650
 
391
651
void Krusader::saveSettings() {
392
 
  toolBar()->saveSettings(krConfig,"Private");
393
 
  config->setGroup("Startup");
394
 
  if (config->readBoolEntry("Panels Save Settings",_PanelsSave)){
395
 
    // left panel
396
 
    if      (mainView->left->type == "tree")      config->writeEntry("Left Panel Type",i18n("Tree"));
397
 
    else if (mainView->left->type == "quickview") config->writeEntry("Left Panel Type",i18n("Quickview"));
398
 
    else { // list view - save both type and homepage
399
 
      config->writeEntry("Left Panel Type",i18n("List"));
400
 
      config->writeEntry("Left Panel Origin",i18n("the last place it was"));
401
 
    }
402
 
    // right panel
403
 
    if      (mainView->right->type == "tree")      config->writeEntry("Right Panel Type",i18n("Tree"));
404
 
    else if (mainView->right->type == "quickview") config->writeEntry("Right Panel Type",i18n("Quickview"));
405
 
    else { // list view - save both type and homepage
406
 
      config->writeEntry("Right Panel Type",i18n("List"));
407
 
      config->writeEntry("Right Panel Origin",i18n("the last place it was"));
408
 
    }
409
 
  }
410
 
 
411
 
  if( mainView->left->type=="list" )
412
 
    config->writeEntry("lastHomeLeft",mainView->left->realPath);
413
 
 
414
 
  if( mainView->right->type=="list" )
415
 
    config->writeEntry("lastHomeRight",mainView->right->realPath);
416
 
 
417
 
  // save size and position
418
 
  if (config->readBoolEntry("Remember Position",_RememberPos) ||
419
 
      config->readBoolEntry("UI Save Settings",_UiSave) ) {
 
652
   toolBar() ->saveSettings( krConfig, "Private" );
 
653
   config->setGroup( "Startup" );
 
654
   config->writeEntry( "Left Active Tab", mainView->leftMng->activeTab() );
 
655
   config->writeEntry( "Right Active Tab", mainView->rightMng->activeTab() );
 
656
   mainView->leftMng->saveSettings( krConfig, "Left Tab Bar" );
 
657
   mainView->rightMng->saveSettings( krConfig, "Right Tab Bar" );
 
658
   bool panelsavesettings = config->readBoolEntry( "Panels Save Settings", _PanelsSave );
 
659
   bool rememberpos = config->readBoolEntry( "Remember Position", _RememberPos );
 
660
   bool uisavesettings = config->readBoolEntry( "UI Save Settings", _UiSave );
 
661
   if ( panelsavesettings ) {
 
662
      // left panel
 
663
      config->writeEntry( "Left Panel Type", i18n( "List" ) );
 
664
      config->writeEntry( "Left Panel Origin", i18n( "the last place it was" ) );
 
665
      // right panel
 
666
      config->writeEntry( "Right Panel Type", i18n( "List" ) );
 
667
      config->writeEntry( "Right Panel Origin", i18n( "the last place it was" ) );
 
668
   }
 
669
        // save the popup panel's page of the CURRENT tab
 
670
        config->writeEntry( "Left Panel Popup", mainView->left->popup->currentPage() );
 
671
        config->writeEntry( "Right Panel Popup", mainView->right->popup->currentPage() );
 
672
        
 
673
   // save size and position
 
674
   if ( rememberpos || uisavesettings ) {
420
675
      savePosition();
421
 
  }
 
676
   }
422
677
 
423
 
  // save the gui
424
 
  if ( config->readBoolEntry("UI Save Settings",_UiSave ) ){
425
 
    config->writeEntry( "Show status bar",actShowStatusBar->isChecked() );
426
 
    config->writeEntry( "Show tool bar",actShowToolBar->isChecked() );
427
 
    config->writeEntry( "Show FN Keys",actToggleFnkeys->isChecked() );
428
 
    config->writeEntry( "Show Cmd Line",actToggleCmdline->isChecked() );
429
 
    config->writeEntry( "Show Terminal Emulator",actToggleTerminal->isChecked());
430
 
  }
431
 
  config->sync();
432
 
  // delete all vfs records...
433
 
  mainView->left->cleanUp();
434
 
  mainView->right->cleanUp();
 
678
   // save the gui
 
679
   if ( uisavesettings ) {
 
680
      config->setGroup( "Startup" );
 
681
      config->writeEntry( "Show status bar", actShowStatusBar->isChecked() );
 
682
      config->writeEntry( "Show tool bar", actShowToolBar->isChecked() );
 
683
      config->writeEntry( "Show FN Keys", actToggleFnkeys->isChecked() );
 
684
      config->writeEntry( "Show Cmd Line", actToggleCmdline->isChecked() );
 
685
      config->writeEntry( "Show Terminal Emulator", actToggleTerminal->isChecked() );
 
686
   }
 
687
   config->sync();
435
688
}
436
689
 
437
 
void Krusader::refreshView(){
438
 
        delete mainView;
439
 
        mainView=new KrusaderView(this);
440
 
  setCentralWidget(mainView);
441
 
  config->setGroup("Private");
442
 
  resize(krConfig->readSizeEntry("Start Size",_StartSize));
443
 
  move(krConfig->readPointEntry("Start Position",_StartPosition));
444
 
  mainView->show();
445
 
  show();       
 
690
void Krusader::refreshView() {
 
691
   delete mainView;
 
692
   mainView = new KrusaderView( this );
 
693
   setCentralWidget( mainView );
 
694
   config->setGroup( "Private" );
 
695
   resize( krConfig->readSizeEntry( "Start Size", _StartSize ) );
 
696
   move( krConfig->readPointEntry( "Start Position", _StartPosition ) );
 
697
   mainView->show();
 
698
   show();
446
699
}
447
700
 
448
701
bool Krusader::queryClose() {
449
 
  saveSettings();
450
 
  krConfig->setGroup("Look&Feel");
451
 
        if (krConfig->readBoolEntry("Warn On Exit",_WarnOnExit)) {
452
 
    switch ( KMessageBox::warningYesNo( this,
453
 
      i18n("Ok to shutdown Krusader ?")) ) {
454
 
      case KMessageBox::Yes :
455
 
        return true;
456
 
      case KMessageBox::No :
457
 
        return false;
458
 
      default:
459
 
        return false;
460
 
    }
461
 
  } else return true;
 
702
   if( isStarting )
 
703
     return false;
 
704
 
 
705
   bool quit = true;
 
706
   krConfig->setGroup( "Look&Feel" );
 
707
   if ( krConfig->readBoolEntry( "Warn On Exit", _WarnOnExit ) ) {
 
708
      switch ( KMessageBox::warningYesNo( this,
 
709
                                          i18n( "Ok to shutdown Krusader?" ) ) ) {
 
710
            case KMessageBox::Yes :
 
711
            quit = true;
 
712
            break;
 
713
            case KMessageBox::No :
 
714
            quit = false;
 
715
            break;
 
716
            default:
 
717
            quit = false;
 
718
      }
 
719
   }
 
720
   if ( quit ) {
 
721
      // close all open VFS
 
722
      //delete krApp->mainView->left->func;
 
723
      //delete krApp->mainView->right->func;
 
724
      saveSettings();
 
725
      delete MAIN_VIEW;
 
726
      return true;
 
727
   } else return false;
 
728
 
462
729
}
463
730
 
464
731
void Krusader::quitKrusader() {
465
 
  if (queryClose()) kapp->quit();
 
732
   if ( queryClose() ) {
 
733
      kapp->quit();
 
734
   }
466
735
}
467
736
 
468
737
// the please wait dialog functions
469
 
void Krusader::startWaiting( QString msg, int count , bool cancel){
470
 
  plzWait->startWaiting( msg ,count, cancel );
471
 
}
472
 
 
473
 
void Krusader::incProgress(KProcess *,char *buffer,int buflen){
474
 
  int howMuch=0;
475
 
  for (int i=0 ; i<buflen; ++i)
476
 
   if ( buffer[i] == '\n' ) ++howMuch;
477
 
 
478
 
  plzWait->incProgress(howMuch);
479
 
}
480
 
 
481
 
void Krusader::stopWait(){
482
 
  plzWait->stopWait();
483
 
}
484
 
 
485
 
void Krusader::updateGUI(bool enforce) {
486
 
  // now, check if we need to create a konsole_part
487
 
  config->setGroup("Startup");
488
 
  if (config->readBoolEntry("Show Terminal Emulator",_ShowTerminalEmulator)) {
489
 
    if (enforce) {
490
 
      mainView->slotTerminalEmulator(true); // create konsole_part
491
 
      config->setGroup("Private");
492
 
      QValueList<int> lst;
493
 
      lst.append(config->readNumEntry("Panel Size",_PanelSize));
494
 
      lst.append(config->readNumEntry("Terminal Size",_TerminalSize));
495
 
      mainView->vert_splitter->setSizes(lst);
496
 
      config->setGroup("Startup");
497
 
    }
498
 
  }
499
 
 
500
 
  // call the XML GUI function to draw the UI
501
 
  createGUI(mainView->konsole_part);
502
 
  toolBar()->applySettings(krConfig,"Private");
503
 
  if (enforce) {
504
 
    // now, hide what need to be hidden
505
 
    if (!krConfig->readBoolEntry("Show tool bar",_ShowToolBar)){
506
 
      toolBar()->hide();
507
 
      actShowToolBar->setChecked(false);
508
 
    } else {
509
 
      toolBar()->show();
510
 
      actShowToolBar->setChecked(true);
511
 
    }
512
 
    if (!krConfig->readBoolEntry("Show status bar",_ShowStatusBar)){
513
 
      statusBar()->hide();
514
 
      actShowStatusBar->setChecked(false);
515
 
    } else {
516
 
      statusBar()->show();
517
 
      actShowStatusBar->setChecked(true);
518
 
    }
519
 
    if (!krConfig->readBoolEntry("Show Cmd Line",_ShowCmdline)){
520
 
      mainView->cmdLine->hide();
521
 
      actToggleCmdline->setChecked(false);
522
 
    } else {
523
 
      mainView->cmdLine->show();
524
 
      actToggleCmdline->setChecked(true);
525
 
    }
526
 
    if (!krConfig->readBoolEntry("Show FN Keys",_ShowFNkeys)){
527
 
      mainView->fnKeys->hide();
528
 
      actToggleFnkeys->setChecked(false);
529
 
    } else {
530
 
      mainView->fnKeys->show();
531
 
      actToggleFnkeys->setChecked(true);
532
 
    }
533
 
  }
 
738
void Krusader::startWaiting( QString msg, int count , bool cancel ) {
 
739
   plzWait->startWaiting( msg , count, cancel );
 
740
}
 
741
 
 
742
void Krusader::incProgress( KProcess *, char *buffer, int buflen ) {
 
743
   int howMuch = 0;
 
744
   for ( int i = 0 ; i < buflen; ++i )
 
745
      if ( buffer[ i ] == '\n' )
 
746
         ++howMuch;
 
747
 
 
748
   plzWait->incProgress( howMuch );
 
749
}
 
750
 
 
751
void Krusader::stopWait() {
 
752
   plzWait->stopWait();
 
753
}
 
754
 
 
755
void Krusader::updateGUI( bool enforce ) {
 
756
   // now, check if we need to create a konsole_part
 
757
   config->setGroup( "Startup" );
 
758
   if ( config->readBoolEntry( "Show Terminal Emulator", _ShowTerminalEmulator ) ) {
 
759
      if ( enforce ) {
 
760
         mainView->slotTerminalEmulator( true ); // create konsole_part
 
761
         config->setGroup( "Private" );
 
762
         QValueList<int> lst;
 
763
         lst.append( config->readNumEntry( "Panel Size", _PanelSize ) );
 
764
         lst.append( config->readNumEntry( "Terminal Size", _TerminalSize ) );
 
765
         mainView->vert_splitter->setSizes( lst );
 
766
         config->setGroup( "Startup" );
 
767
      }
 
768
   }
 
769
 
 
770
   // call the XML GUI function to draw the UI
 
771
   createGUI( mainView->konsole_part );
 
772
   toolBar() ->applySettings( krConfig, "Private" );
 
773
   if ( enforce ) {
 
774
      // now, hide what need to be hidden
 
775
      if ( !krConfig->readBoolEntry( "Show tool bar", _ShowToolBar ) ) {
 
776
         toolBar() ->hide();
 
777
         actShowToolBar->setChecked( false );
 
778
      } else {
 
779
         toolBar() ->show();
 
780
         actShowToolBar->setChecked( true );
 
781
      }
 
782
      if ( !krConfig->readBoolEntry( "Show status bar", _ShowStatusBar ) ) {
 
783
         statusBar() ->hide();
 
784
         actShowStatusBar->setChecked( false );
 
785
      } else {
 
786
         statusBar() ->show();
 
787
         actShowStatusBar->setChecked( true );
 
788
      }
 
789
      if ( !krConfig->readBoolEntry( "Show Cmd Line", _ShowCmdline ) ) {
 
790
         mainView->cmdLine->hide();
 
791
         actToggleCmdline->setChecked( false );
 
792
      } else {
 
793
         mainView->cmdLine->show();
 
794
         actToggleCmdline->setChecked( true );
 
795
      }
 
796
                // update the Fn bar to the shortcuts selected by the user
 
797
                mainView->fnKeys->updateShortcuts();
 
798
      if ( !krConfig->readBoolEntry( "Show FN Keys", _ShowFNkeys ) ) {
 
799
         mainView->fnKeys->hide();
 
800
         actToggleFnkeys->setChecked( false );
 
801
      } else {
 
802
         mainView->fnKeys->show();
 
803
         actToggleFnkeys->setChecked( true );
 
804
      }
 
805
   }
534
806
}
535
807
 
536
808
// return a list in the format of TOOLS,PATH. for example
537
809
// DIFF,kdiff,TERMINAL,konsole,...
538
810
//
539
 
// currently supported tools: DIFF,
 
811
// currently supported tools: DIFF, MAIL, RENAME
540
812
//
541
813
// to use it: QStringList lst = supportedTools();
542
814
//            int i = lst.findIndex("DIFF");
543
815
//            if (i!=-1) pathToDiff=lst[i+1];
544
816
QStringList Krusader::supportedTools() {
545
 
  QStringList tools;
546
 
  bool skip;
547
 
 
548
 
  KShellProcess proc;
549
 
 
550
 
  // first, a diff program: kdiff
551
 
  skip = false;
552
 
  if (!skip) {
553
 
    proc << "which kdiff >/dev/null 2>&1";
554
 
    if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
555
 
      tools.append("DIFF"); tools.append("kdiff");
556
 
      skip = true;
557
 
    }
558
 
  }
559
 
  if (!skip) {
560
 
    proc.clearArguments();
561
 
    proc << "which xxdiff >/dev/null 2>&1";
562
 
    if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
563
 
      tools.append("DIFF"); tools.append("xxdiff");
564
 
      skip = true;
565
 
    }
566
 
  }
567
 
 
568
 
  // a mailer: kmail
569
 
  skip = false;
570
 
  if (!skip) {
571
 
    proc.clearArguments();
572
 
    proc << "which kmail >/dev/null 2>&1";
573
 
    if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
574
 
      tools.append("MAIL"); tools.append("kmail");
575
 
      skip = true;
576
 
    }
577
 
  }
578
 
 
579
 
  return tools;
580
 
}
581
 
 
582
 
QString Krusader::getTempDir(){
583
 
        // try to make krusader temp dir
584
 
  krConfig->setGroup("General");
585
 
  QString tmpDir =  krConfig->readEntry("Temp Directory",_TempDirectory);
586
 
  for(int i = 1 ; i != -1 ; i=tmpDir.find('/',i+1) )
587
 
    QDir().mkdir( tmpDir.left(i) );
588
 
  QDir().mkdir( tmpDir );
589
 
  chmod( tmpDir.local8Bit(), 0777);
590
 
        // add a secure sub dir under the user UID
591
 
        QString uid;
592
 
        uid.sprintf("%d",getuid());
593
 
        QDir(tmpDir).mkdir(uid);
594
 
        tmpDir=tmpDir+"/"+uid+"/";
595
 
        chmod(tmpDir.local8Bit(),S_IRUSR | S_IWUSR | S_IXUSR );
596
 
        // add a random sub dir to use
597
 
        while (QDir().exists(tmpDir)) tmpDir = tmpDir+kapp->randomString(8);
598
 
        QDir().mkdir(tmpDir);
599
 
 
600
 
  if( !QDir(tmpDir).isReadable() ){
601
 
    KMessageBox::error(krApp,"Could not create a temporary directory.\nHandling of Archives will not be possible until this is fixed.");
602
 
                return QString::null;
603
 
        }
604
 
        return tmpDir;
605
 
}
606
 
 
607
 
QString Krusader::getTempFile(){
608
 
        // try to make krusader temp dir
609
 
  krConfig->setGroup("General");
610
 
  QString tmpDir =  krConfig->readEntry("Temp Directory",_TempDirectory);
611
 
  for(int i = 1 ; i != -1 ; i=tmpDir.find('/',i+1) )
612
 
    QDir().mkdir( tmpDir.left(i) );
613
 
  QDir().mkdir( tmpDir );
614
 
  chmod( tmpDir.local8Bit(), 0777);
615
 
        // add a secure sub dir under the user UID
616
 
        QString uid;
617
 
        uid.sprintf("%d",getuid());
618
 
        QDir(tmpDir).mkdir(uid);
619
 
        tmpDir=tmpDir+"/"+uid+"/";
620
 
        chmod(tmpDir.local8Bit(),S_IRUSR | S_IWUSR | S_IXUSR );
621
 
 
622
 
  while(QDir().exists(tmpDir)) tmpDir = tmpDir+kapp->randomString(8);
623
 
  return tmpDir;
 
817
   QStringList tools;
 
818
 
 
819
   // first, a diff program: kdiff
 
820
   if ( KrServices::cmdExist( "kdiff" ) ) {
 
821
      tools.append( "DIFF" );
 
822
      tools.append( KrServices::fullPathName( "kdiff", "diff utility" ) );
 
823
   } else if ( KrServices::cmdExist( "kompare" ) ) {
 
824
      tools.append( "DIFF" );
 
825
      tools.append( KrServices::fullPathName( "kompare", "diff utility" ) );
 
826
   } else if ( KrServices::cmdExist( "xxdiff" ) ) {
 
827
      tools.append( "DIFF" );
 
828
      tools.append( KrServices::fullPathName( "xxdiff", "diff utility" ) );
 
829
   }
 
830
   // a mailer: kmail
 
831
   if ( KrServices::cmdExist( "kmail" ) ) {
 
832
      tools.append( "MAIL" );
 
833
      tools.append( KrServices::fullPathName( "kmail" ) );
 
834
   }
 
835
   // rename tool: krename
 
836
   if ( KrServices::cmdExist( "krename" ) ) {
 
837
      tools.append( "RENAME" );
 
838
      tools.append( KrServices::fullPathName( "krename" ) );
 
839
   }
 
840
 
 
841
   return tools;
 
842
}
 
843
 
 
844
QString Krusader::getTempDir() {
 
845
   // try to make krusader temp dir
 
846
   krConfig->setGroup( "General" );
 
847
   QString tmpDir = krConfig->readEntry( "Temp Directory", _TempDirectory );
 
848
 
 
849
   if ( ! QDir( tmpDir ).exists() ) {
 
850
      for ( int i = 1 ; i != -1 ; i = tmpDir.find( '/', i + 1 ) )
 
851
         QDir().mkdir( tmpDir.left( i ) );
 
852
      QDir().mkdir( tmpDir );
 
853
      chmod( tmpDir.local8Bit(), 0777 );
 
854
   }
 
855
 
 
856
   // add a secure sub dir under the user UID
 
857
   QString uid;
 
858
   uid.sprintf( "%d", getuid() );
 
859
   QDir( tmpDir ).mkdir( uid );
 
860
   tmpDir = tmpDir + "/" + uid + "/";
 
861
   chmod( tmpDir.local8Bit(), S_IRUSR | S_IWUSR | S_IXUSR );
 
862
   // add a random sub dir to use
 
863
   while ( QDir().exists( tmpDir ) )
 
864
      tmpDir = tmpDir + kapp->randomString( 8 );
 
865
   QDir().mkdir( tmpDir );
 
866
 
 
867
   if ( !QDir( tmpDir ).isReadable() ) {
 
868
      KMessageBox::error( krApp, "Could not create a temporary directory. Handling of Archives will not be possible until this is fixed." );
 
869
      return QString::null;
 
870
   }
 
871
   return tmpDir;
 
872
}
 
873
 
 
874
QString Krusader::getTempFile() {
 
875
   // try to make krusader temp dir
 
876
   krConfig->setGroup( "General" );
 
877
   QString tmpDir = krConfig->readEntry( "Temp Directory", _TempDirectory );
 
878
 
 
879
   if ( ! QDir( tmpDir ).exists() ) {
 
880
      for ( int i = 1 ; i != -1 ; i = tmpDir.find( '/', i + 1 ) )
 
881
         QDir().mkdir( tmpDir.left( i ) );
 
882
      QDir().mkdir( tmpDir );
 
883
      chmod( tmpDir.local8Bit(), 0777 );
 
884
   }
 
885
 
 
886
   // add a secure sub dir under the user UID
 
887
   QString uid;
 
888
   uid.sprintf( "%d", getuid() );
 
889
   QDir( tmpDir ).mkdir( uid );
 
890
   tmpDir = tmpDir + "/" + uid + "/";
 
891
   chmod( tmpDir.local8Bit(), S_IRUSR | S_IWUSR | S_IXUSR );
 
892
 
 
893
   while ( QDir().exists( tmpDir ) )
 
894
      tmpDir = tmpDir + kapp->randomString( 8 );
 
895
   return tmpDir;
624
896
}
625
897
 
626
898