summaryrefslogtreecommitdiffstats
path: root/kiosktool/kioskgui.cpp
blob: afdc190809802ec38903d04a473d2e15358e0cdc (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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
/*
 * kioskgui.cpp
 *
 *   Copyright (C) 2003,2004 Waldo Bastian <bastian@kde.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License versin 2 as
 *   published by the Free Software Foundation.
 *
 *   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.
 */
#include "kioskgui.h"

#include <tqdir.h>
#include <tqlineedit.h>
#include <tqobjectlist.h>
#include <tqwidgetstack.h>
#include <tqpushbutton.h>

#include <kapplication.h>
#include <kaction.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kfiledialog.h>
#include <kglobal.h>
#include <kiconloader.h>
#include <kiconview.h>
#include <klocale.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <kstdaccel.h>
#include <kstdaction.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>

#include "mainview.h"
#include "profileSelectionPage_ui.h"
#include "profilePropsPage.h"
#include "componentSelectionPage.h"
#include "desktopComponent.h"
#include "menueditComponent.h"
#include "screensaverComponent.h"
#include "panelComponent.h"
#include "filetypeeditComponent.h"
#include "componentPage.h"
#include "pageWidget.h"
#include "userManagement.h"
#include "kioskConfigDialog.h"
#include "kioskdata.h"
#include "kioskrun.h"
#include "kiosksync.h"

KioskGui::KioskGui()
    : KMainWindow( 0, "kioskgui" ), m_profileSelectionPage(0),
    m_componentSelectionPage(0), m_componentPage(0), m_profileAssignPage(0),
    m_profilePropsPage(0), m_data(0),
    m_activePage(0), m_profile(0), m_componentData(0)
{
    m_run = new KioskRun;

    m_view = new MainView(this);

    setupActions();

    updateBackground();

    // tell the KMainWindow that this is indeed the main widget
    setCentralWidget(m_view);

    setWidgetBackground(m_view);
    m_view->setBackgroundOrigin(WindowOrigin);


    createGUI();

    // apply the saved mainwindow settings, if any, and ask the mainwindow
    // to automatically save settings if changed: window size, toolbar
    // position, icon size, etc.
    setAutoSaveSettings();

    m_view->pbHelp->hide(); // TODO, write help :)

    connect(m_view->pbDiscard, TQT_SIGNAL(clicked()), this, TQT_SLOT(discardPage()));
    connect(m_view->pbFinished, TQT_SIGNAL(clicked()), this, TQT_SLOT(finishedPage()));

    KConfig *config = kapp->config();
    config->setGroup("General");
    m_profile = config->readEntry("CurrentProfile", "default");
    m_component = config->readEntry("CurrentComponent");

    selectPage(PAGE_PROFILE_SELECTION, true);
    
    TQTimer::singleShot(0, this, TQT_SLOT(slotCheckEtcSkel()));
}

KioskGui::~KioskGui()
{
    delete m_data;
    delete m_run;
}

void KioskGui::slotCheckEtcSkel()
{
    TQString etcSkel = "/etc/skel/.kde";
    KioskSync skelDir;
    skelDir.addDir(etcSkel, KURL());
    TQStringList skelFiles = skelDir.listFiles();
    if (!skelFiles.isEmpty())
    {
        KMessageBox::informationList(this,
            i18n("<qt>Your system contains KDE configuration settings in the "
                 "skeleton directory <b>%1</b>. These files are copied to the "
                 "personal KDE settings directory of newly created users.<p>"
                 "This may interfere with the correct operation of user profiles.<p>"
                 "Unless a setting has been locked down, settings that have been copied "
                 "to the personal KDE settings directory of a user will override "
                 "a default setting configured in a profile.<p>"
                 "<b>If this is not the intended behavior, please remove the offending "
                 "files from the skeleton folder on all systems that you want to "
                 "administer with user profiles.</b><p>"
                 "The following files were found under <b>%2</b>:").arg(etcSkel).arg(etcSkel),
            skelFiles,
            TQString(),
            "etc_skel_warning");
    }
}

void KioskGui::setWidgetBackground(TQWidget *w)
{
    TQObjectList *l = w->queryList( TQWIDGET_OBJECT_NAME_STRING );
    TQObjectListIt it( *l );
    for(TQWidget *wid=0; (wid = (TQWidget*)it.current()); ++it)
    {
        wid->setBackgroundOrigin(WindowOrigin);
        if (::tqqt_cast<TQPushButton*>(wid))
           wid->setAutoMask(true);
    }
    w->setBackgroundOrigin(WindowOrigin);
    delete l;
}

void KioskGui::setSubCaption(const TQString &subCaption)
{
    m_view->subCaptionLabel->setText("<h1>"+subCaption+"</h1>");
}

void KioskGui::setupActions()
{
//    KStdAction::open(this, TQT_SLOT(fileOpen()), actionCollection());
//    KStdAction::save(this, TQT_SLOT(fileSave()), actionCollection());
//    KStdAction::saveAs(this, TQT_SLOT(fileSaveAs()), actionCollection());
    KStdAction::quit(this, TQT_SLOT(close()), actionCollection());
//    KStdAction::back(this, TQT_SLOT(previousPage()), actionCollection(), "previousPage");
//    KStdAction::forward(this, TQT_SLOT(nextPage()), actionCollection(), "nextPage");

//    createStandardStatusBarAction();
//    setStandardToolBarMenuEnabled(true);

//    KStdAction::keyBindings(this, TQT_SLOT(optionsConfigureKeys()), actionCollection());
//    KStdAction::configureToolbars(this, TQT_SLOT(optionsConfigureToolbars()), actionCollection());
    KStdAction::preferences(this, TQT_SLOT(slotConfig()), actionCollection());
    m_uploadAction = new KAction(i18n("Upload &All Profiles"), TQString(), 0, this, TQT_SLOT(uploadAllProfiles()), actionCollection(), "upload_all");
    m_backgroundAction = new KToggleAction(i18n("Background Graphics"), TQString(), 0, this, TQT_SLOT(slotUpdateBackground()), actionCollection(), "show_background");

    updateActions();
}

void KioskGui::updateActions()
{
   KConfig *config = kapp->config();
   config->setGroup("General");
   
   bool uploadEnabled = !config->readEntry("uploadURL").isEmpty();
   
   m_uploadAction->setEnabled(uploadEnabled);
   m_backgroundAction->setChecked(config->readBoolEntry("FancyBackground", true));
}

void KioskGui::saveProperties(KConfig * /*config*/ )
{
    // the 'config' object points to the session managed
    // config file.  anything you write here will be available
    // later when this app is restored
}

void KioskGui::readProperties(KConfig * /*config*/ )
{
    // the 'config' object points to the session managed
    // config file.  this function is automatically called whenever
    // the app is being restored.  read in here whatever you wrote
    // in 'saveProperties'
}

void KioskGui::slotAddProfile()
{
    selectPage(PAGE_PROFILE_NEW, true);
}

void KioskGui::slotProfileProperties()
{
    selectPage(PAGE_PROFILE_PROPS, true);
#if 0
    savePage(PAGE_PROFILE_SELECTION);
    ProfileConfigDialog dlg(this, m_profile);
    if (dlg.exec())
    {
       loadPage(PAGE_PROFILE_SELECTION);
       updateActions();
    }
#endif
}

void KioskGui::slotProfileSetup()
{
    selectPage(PAGE_COMPONENT_SELECTION, true);
}

void KioskGui::slotDeleteProfile(TQListViewItem *item)
{
    if (!m_profileSelectionPage)
       return;
    if (!item)
       item = m_profileSelectionPage->listProfile->selectedItem();
    if (!item)
       return;
    TQString profile = item->text(0);
    int result = KMessageBox::warningContinueCancel(this,
               i18n("<qt>You are about to delete the profile <b>%1</b>.<p>"
                    "Are you sure you want to do this?").arg(profile),
               TQString(), KGuiItem(i18n("Delete"),"editdelete"));
    if (result == KMessageBox::Continue)
    {
       if (KioskRun::self()->deleteProfile(profile))
       {
          delete item;

          item = m_profileSelectionPage->listProfile->currentItem();
          if (item)
             m_profileSelectionPage->listProfile->setSelected(item, true);
       }
    }
}

void KioskGui::slotManageUsers()
{
    selectPage(PAGE_PROFILE_ASSIGN, true);
}

void KioskGui::slotProfileContextMenu(TQListViewItem *item, const TQPoint &p)
{
    if (!item) return; // No item selected

    TQPopupMenu menu(this);
    menu.insertItem(i18n("&Delete Profile"), 1);

    int result = menu.exec( p );
    if (result == 1)
       slotDeleteProfile(item);
}

void KioskGui::selectPage(int page, bool save)
{
    if (save && !savePage(m_activePage))
       return;
    m_activePage = page;
    if ((m_activePage == PAGE_PROFILE_SELECTION) && !m_profileSelectionPage)
    {
       m_profileSelectionPage = new ProfileSelectionPageUI(this);
       setWidgetBackground(m_profileSelectionPage);

       connect(m_profileSelectionPage->listProfile,
               TQT_SIGNAL(contextMenuRequested(TQListViewItem *, const TQPoint &, int)),
               this, TQT_SLOT(slotProfileContextMenu(TQListViewItem *, const TQPoint &)));
       connect(m_profileSelectionPage->listProfile,
               TQT_SIGNAL(doubleClicked (TQListViewItem *, const TQPoint &, int )),
               this, TQT_SLOT(nextPage()));
       connect(m_profileSelectionPage->buttonDelete, TQT_SIGNAL(clicked()),
               this, TQT_SLOT(slotDeleteProfile()));
       connect(m_profileSelectionPage->buttonAdd, TQT_SIGNAL(clicked()),
               this, TQT_SLOT(slotAddProfile()));
       connect(m_profileSelectionPage->buttonProperty, TQT_SIGNAL(clicked()),
               this, TQT_SLOT(slotProfileProperties()));
       connect(m_profileSelectionPage->buttonSetup, TQT_SIGNAL(clicked()),
               this, TQT_SLOT(slotProfileSetup()));
       connect(m_profileSelectionPage->buttonUsers, TQT_SIGNAL(clicked()),
               this, TQT_SLOT(slotManageUsers()));

       m_view->widgetStack->addWidget(m_profileSelectionPage, PAGE_PROFILE_SELECTION);
       m_profileSelectionPage->listProfile->setFocus();
    }
    if ((m_activePage == PAGE_COMPONENT_SELECTION) && !m_componentSelectionPage)
    {
       m_data = new KioskData;
       if (!m_data->load())
       {
          KMessageBox::error(this, m_data->errorMsg(), i18n("Error accessing Kiosk data"));
       }

       m_componentSelectionPage = new ComponentSelectionPage(m_data, this);
       connect(m_componentSelectionPage, TQT_SIGNAL(componentActivated()), this, TQT_SLOT(nextPage()));
       m_componentSelectionPage->setCurrentComponent(m_component);
       setWidgetBackground(m_componentSelectionPage);

       m_view->widgetStack->addWidget(m_componentSelectionPage, PAGE_COMPONENT_SELECTION);
       m_componentSelectionPage->listComponent->setFocus();
    }
    if (m_activePage == PAGE_PROFILE_NEW)
    {
       delete m_profilePropsPage;
       m_profilePropsPage = new ProfilePropsPage(this, TQString());
       setWidgetBackground(m_profilePropsPage->widget());

       m_view->widgetStack->addWidget(m_profilePropsPage->widget(), PAGE_PROFILE_NEW);
       m_profilePropsPage->setFocus();
    }
    if (m_activePage == PAGE_PROFILE_PROPS)
    {
       delete m_profilePropsPage;
       m_profilePropsPage = new ProfilePropsPage(this, m_profile);
       setWidgetBackground(m_profilePropsPage->widget());

       m_view->widgetStack->addWidget(m_profilePropsPage->widget(), PAGE_PROFILE_PROPS);
       m_profilePropsPage->setFocus();
    }
    if ((m_activePage == PAGE_PROFILE_ASSIGN) && !m_profileAssignPage)
    {
       m_profileAssignPage = new UserManagementPage(this);
       setWidgetBackground(m_profileAssignPage->widget());

       m_view->widgetStack->addWidget(m_profileAssignPage->widget(), PAGE_PROFILE_ASSIGN);
       m_profileAssignPage->setFocus();
    }
    if (m_activePage == PAGE_COMPONENT)
    {
       delete m_componentPage;

       Component *component = 0;
       if (m_component == "kdesktop")
          component = new DesktopComponent;
       else if (m_component == "kdemenu")
          component = new MenuEditComponent;
       else if (m_component == "screensaver")
          component = new ScreenSaverComponent;
       else if (m_component == "kicker")
          component = new PanelComponent;
       else if (m_component == "filetypes")
          component = new FileTypeEditComponent;

       m_componentPage = new ComponentPage(m_componentData, component, m_view->widgetStack);
       setWidgetBackground(m_componentPage->widget());
       m_view->widgetStack->addWidget(m_componentPage->widget(), PAGE_COMPONENT);
       m_componentPage->setFocus();
    }
    m_view->widgetStack->raiseWidget(m_activePage);

    switch (m_activePage)
    {
      case PAGE_PROFILE_SELECTION:
       setSubCaption(i18n("Main Menu"));
       setCaption(i18n("Main Menu"));
       break;
      case PAGE_PROFILE_NEW:
       setSubCaption(i18n("Add New Profile"));
       setCaption(i18n("Add New Profile"));
       break;
      case PAGE_PROFILE_PROPS:
       setSubCaption(i18n("Profile Properties"));
       setCaption(i18n("Profile Properties"));
       break;
      case PAGE_COMPONENT_SELECTION:
       setSubCaption(i18n("Setup Profile \"%1\"").arg(m_profile));
       setCaption(m_profile);
       break;
      case PAGE_COMPONENT:
       setSubCaption(m_componentPage->subCaption());
       break;
      case PAGE_PROFILE_ASSIGN:
       setSubCaption(i18n("Assign Profiles"));
       break;
    }
    
    loadPage(m_activePage);

    updateButtons();
}

void KioskGui::updateButtons()
{
    switch(m_activePage)
    {
      case PAGE_PROFILE_SELECTION:
      {
         m_view->pbDiscard->hide();
         m_view->pbFinished->hide();
         break;
      }

      case PAGE_COMPONENT_SELECTION:
      {
         m_view->pbDiscard->hide();
         m_view->pbFinished->show();
         break;
      }

      case PAGE_COMPONENT:
      {
         m_view->pbDiscard->hide();
         m_view->pbFinished->show();
         break;
      }

      case PAGE_PROFILE_NEW:
      {
         m_view->pbDiscard->show();
         m_view->pbFinished->show();
         break;
      }

      case PAGE_PROFILE_PROPS:
      {
         m_view->pbDiscard->show();
         m_view->pbFinished->show();
         break;
      }

      case PAGE_PROFILE_ASSIGN:
      {
         m_view->pbDiscard->show();
         m_view->pbFinished->show();
         break;
      }
    }

    if (m_activePage == PAGE_PROFILE_NEW)
    {
      m_view->pbDiscard->setText(i18n("&Cancel"));
      m_view->pbFinished->setText(i18n("&Add"));
    }
    else
    {
      m_view->pbDiscard->setText(i18n("&Discard Changes"));
      m_view->pbFinished->setText(i18n("&Finished"));
    }

}

void KioskGui::loadProfiles()
{
   m_profileSelectionPage->listProfile->clear();

   TQStringList profiles = KioskRun::self()->allProfiles();

   for(TQStringList::ConstIterator it = profiles.begin();
       it != profiles.end(); ++it)
   {
      TQString profile = *it;
      TQString description;
      TQString installUser;
      TQString installDir;

      KioskRun::self()->getProfileInfo(profile, description, installDir, installUser);

      TQListViewItem *item = new TQListViewItem(m_profileSelectionPage->listProfile, profile, description);
      if (m_profile == profile)
         m_profileSelectionPage->listProfile->setSelected(item, true);
   }
   if (!m_profileSelectionPage->listProfile->selectedItem())
      m_profileSelectionPage->listProfile->setSelected(m_profileSelectionPage->listProfile->firstChild(), true);
}

void KioskGui::loadPage(int page)
{
    switch(page)
    {
      case PAGE_PROFILE_SELECTION:
      {
        loadProfiles();
        break;
      }

      case PAGE_COMPONENT:
      {
        m_componentPage->load();
        break;
      }

      case PAGE_PROFILE_NEW:
      {
        m_profilePropsPage->load();
        break;
      }

      case PAGE_PROFILE_PROPS:
      {
        m_profilePropsPage->load();
        break;
      }

      case PAGE_PROFILE_ASSIGN:
      {
        m_profileAssignPage->load();
        break;
      }
    }
}

bool KioskGui::savePage(int page)
{
    switch(page)
    {
      case PAGE_PROFILE_SELECTION:
      {
        m_profile = m_profileSelectionPage->listProfile->selectedItem() ?
                    m_profileSelectionPage->listProfile->selectedItem()->text(0) : TQString();

        KConfig *config = kapp->config();
        config->setGroup("General");
        config->writeEntry("CurrentProfile", m_profile);
        config->sync();

        TQString description;
        TQString installDir;
        TQString installUser;

        KioskRun::self()->getProfileInfo(m_profile, description, installDir, installUser);

        TQStringList kdeDirs;
        kdeDirs << installDir;
        m_run->setKdeDirs(kdeDirs);
        m_run->setUser(installUser);

        break;
      }

      case PAGE_COMPONENT_SELECTION:
      {
        m_component = m_componentSelectionPage->currentComponent();
        m_componentData = m_data->m_componentData.find(m_component);
        if (!m_componentData)
           return false;

        return m_componentSelectionPage->save();
      }

      case PAGE_COMPONENT:
      {
        if (m_componentPage)
           return m_componentPage->save();
      }

      case PAGE_PROFILE_NEW:
      {
        if (m_profilePropsPage)
        {
           m_profile = m_profilePropsPage->profile();
           return m_profilePropsPage->save();
        }
      }

      case PAGE_PROFILE_PROPS:
      {
        if (m_profilePropsPage)
        {
           m_profile = m_profilePropsPage->profile();
           return m_profilePropsPage->save();
        }
      }

      case PAGE_PROFILE_ASSIGN:
      {
        if (m_profileAssignPage)
           return m_profileAssignPage->save();
      }
    }
    return true;
}

void KioskGui::finishedPage(bool save)
{
    if (m_activePage == PAGE_PROFILE_NEW)
       selectPage(PAGE_PROFILE_SELECTION, save);
    else if (m_activePage == PAGE_PROFILE_PROPS)
       selectPage(PAGE_PROFILE_SELECTION, save);
    else if (m_activePage == PAGE_PROFILE_ASSIGN)
       selectPage(PAGE_PROFILE_SELECTION, save);
    else if (m_activePage > 1)
       selectPage(m_activePage - 1, save);
}

void KioskGui::discardPage()
{
   finishedPage(false);
}

void KioskGui::nextPage()
{
    if (m_activePage < PAGE_LAST)
       selectPage(m_activePage + 1, true);
}

void KioskGui::slotConfig()
{
    KioskConfigDialog dlg(this);
    if (dlg.exec())
    {
       dlg.save();
       updateActions();
    }
}

bool KioskGui::queryClose()
{
    if (!savePage(m_activePage))
    {
       int result = KMessageBox::warningContinueCancel(this,
       		i18n("Your changes could not be saved, do you want to quit anyway?"),
       		TQString(),
       		KStdGuiItem::quit());
       if (result == KMessageBox::Continue)
          return true;
       return false;
    }
    if (m_uploadAction->isEnabled())
    {
       KConfig *config = kapp->config();
       config->setGroup("General");
   
       KURL uploadUrl = config->readEntry("uploadURL");
       int result = KMessageBox::questionYesNo(this,
                    i18n("<qt>Do you want to upload the profiles to <b>%1</b> ?</qt>").arg(uploadUrl.prettyURL()));
       if (result == KMessageBox::Yes)
       {
          uploadAllProfiles();
       }
    }
    
    return true;
}

void KioskGui::uploadAllProfiles()
{
   KConfig *config = kapp->config();
   config->setGroup("General");
   TQString uploadPrefix = config->readEntry("uploadPrefix");
   TQString uploadURL = config->readEntry("uploadURL");

   KioskSync sync(this);
   
   TQStringList profiles = KioskRun::self()->allProfiles();

   for(TQStringList::ConstIterator it = profiles.begin();
       it != profiles.end(); ++it)
   {
      TQString profile = *it;
      TQString description;
      TQString installUser;
      TQString installDir;

      KioskRun::self()->getProfileInfo(profile, description, installDir, installUser);

//      sync.addDir(installDir, KURL("ftp://localhost/kde/profiles"));

      TQString dir = installDir;
      if (dir.startsWith(uploadPrefix))
         dir = dir.mid(uploadPrefix.length());
      if (dir.startsWith("/"))
         dir = dir.mid(1);

      KURL url(uploadURL);
      url.setPath(url.path(1)+dir);
      sync.addDir(installDir, url);
   }

   if (sync.sync())
   {
      KMessageBox::information(this, i18n("<qt>All profiles have been successfully uploaded to <b>%1</b>").arg(uploadURL));
   }
}

void KioskGui::uploadCurrentProfile()
{
}

void KioskGui::slotUpdateBackground()
{
  KConfig *config = kapp->config();
  config->setGroup("General");
  config->writeEntry("FancyBackground", m_backgroundAction->isChecked());
  config->sync();
  updateBackground();
}

void KioskGui::updateBackground()
{
  if (m_backgroundAction->isChecked())
  {
    m_view->setPaletteBackgroundPixmap(locate("appdata", "background.png"));
    m_view->logoLabel->setPixmap(locate("appdata", "logo.png"));
    m_view->logoLabel->setMinimumSize(TQSize(160,170));
    TQString language = KGlobal::locale()->language();
    TQString caption = locate("appdata", "caption-"+language+".png");
    if (caption.isEmpty())
       caption = locate("appdata", "caption.png");
    TQPixmap pm(caption);
    m_view->captionLabel->setPixmap(pm);
    m_view->captionLabel->setMinimumHeight(pm.height());
  }
  else
  {
    m_view->unsetPalette();
    m_view->logoLabel->setPixmap(TQPixmap());
    m_view->logoLabel->setMinimumSize(0,0);
    m_view->captionLabel->setPixmap(TQPixmap());
    m_view->captionLabel->setMinimumHeight(0);
  }
}


#include "kioskgui.moc"