summaryrefslogtreecommitdiffstats
path: root/konq-plugins/kuick/kcmkuick/kcmkuick.cpp
blob: d8015ce6e1acfd947d7578ae4dba3052f0c7d4fc (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
/***************************************************************************
                          kcmkuick.cpp - control module for kuick
                             -------------------
    copyright            : (C) 2001 by Holger Freyther <freyther@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; version 2 of the License.        *
 *                                                                         *
 ***************************************************************************/

#include "kcmkuick.h"

#include <tqlayout.h>
#include <tqfile.h>
#include <kglobal.h>
#include <klocale.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kgenericfactory.h>
#include <kstandarddirs.h>
#include <kservice.h>

#include <tqcheckbox.h>
#include <tqgroupbox.h>
#include <tqpushbutton.h>
#include <tqspinbox.h>
#include <tqstring.h>

typedef KGenericFactory<KCMKuick, TQWidget> KuickFactory;
K_EXPORT_COMPONENT_FACTORY ( kcm_kuick, KuickFactory( "kcmkuick" ) )

KCMKuick::KCMKuick(TQWidget *parent, const char *name, const TQStringList &)
:KCModule(parent, name)
{
    TDEAboutData *ab=new TDEAboutData( "kcmkuick", I18N_NOOP("KCM Kuick"),
       "0.2",I18N_NOOP("KControl module for Kuick's configuration"), TDEAboutData::License_GPL,
       "(c) 2001, Holger Freyther", 0, 0, "freyther@kde.org");
    ab->addAuthor("Holger Freyther",0, "freyther@kde.org");
    setAboutData( ab );

    TQVBoxLayout *topLayout = new TQVBoxLayout(this, 0, 0);
    dialog = new KCMKuickDialog(this);
    topLayout->add(dialog);
    topLayout->addStretch();

    connect( dialog->m_sbCopy, TQT_SIGNAL(valueChanged(int) ), TQT_SLOT(configChanged() ) );
    connect( dialog->m_sbMove, TQT_SIGNAL(valueChanged(int) ), TQT_SLOT(configChanged() ) );
    connect( dialog->pbCopyClear, TQT_SIGNAL(pressed() ), TQT_SLOT(slotClearCopyCache() ) );
    connect( dialog->pbMoveClear, TQT_SIGNAL(pressed() ), TQT_SLOT(slotClearMoveCache() ) );
    connect( dialog->m_chkShow, TQT_SIGNAL(clicked() ), TQT_SLOT(slotShowToggled() ) );
    
    load();
}

void KCMKuick::slotShowToggled()
{
    bool showChecked = dialog->m_chkShow->isChecked();
    dialog->m_grpCopy->setEnabled( showChecked );
    dialog->m_grpMove->setEnabled( showChecked );
    configChanged();
}

void KCMKuick::load()
{
    KConfig config( "konquerorrc");
    config.setGroup("kuick-copy");
    dialog->m_sbCopy->setValue(config.readNumEntry("ShowRecent",5) );

    config.setGroup("kuick-move" );
    dialog->m_sbMove->setValue(config.readNumEntry("ShowRecent",5) );
    
    KConfig cfg("kuick_plugin.desktop", true, false, "services");
    cfg.setDesktopGroup();
    bool hidden=cfg.readBoolEntry("Hidden", false);
    dialog->m_chkShow->setChecked(!hidden);
    slotShowToggled();
    
    emit changed(false);
}

KCMKuick::~KCMKuick()
{
}

void KCMKuick::load(const TQString & /*s*/)
{
}

void KCMKuick::configChanged()
{
    emit changed(true);
}

void KCMKuick::save()
{
    KConfig config("konquerorrc" );
    config.setGroup("kuick-copy");

    config.writeEntry("ShowRecent", dialog->m_sbCopy->value() );

    config.setGroup("kuick-move" );
    config.writeEntry("ShowRecent", dialog->m_sbMove->value() );

    config.sync();		//is it necessary ?

    if ( dialog->m_chkShow->isChecked() ) {       
       TQString servicespath = TDEGlobal::dirs()->saveLocation( "services");
       TQFile::remove(servicespath+"/kuick_plugin.desktop");
    }
    else {
       KConfig cfg("kuick_plugin.desktop", false, false, "services");
       cfg.setDesktopGroup();
       cfg.writeEntry("Hidden", true);
    }
    KService::rebuildKSycoca(this);
    
    emit changed(false);
}

void KCMKuick::slotClearCopyCache( ) {
    KConfig config("konquerorrc");
    config.setGroup("kuick-copy" );
    config.writePathEntry("Paths", TQStringList() );
    config.sync();		//is it necessary ?
}

void KCMKuick::slotClearMoveCache() {
    KConfig config("konquerorrc");
    config.setGroup("kuick-move" );
    config.writePathEntry("Paths", TQStringList() );
    config.sync();		//is it necessary ?
}

void KCMKuick::defaults()
{
    dialog->m_sbCopy->setValue(4);
    dialog->m_sbMove->setValue(4);
    
    dialog->m_chkShow->setChecked(true);
    slotShowToggled();
    
    emit changed( true );
}

TQString KCMKuick::quickHelp() const
{
    return i18n("<h1>Kuick</h1> With this module you can configure Kuick, the TDE quick"
		"copy and move plugin for Konqueror.");
}

#include "kcmkuick.moc"