summaryrefslogtreecommitdiffstats
path: root/kmrml/kmrml/kcontrol/kcmkmrml.cpp
blob: 2a79cd5d747b71e0216cc23088ffb3240e83c866 (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
/* This file is part of the KDE project
   Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@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.

   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; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include <tqlabel.h>
#include <tqlayout.h>

#include <kaboutdata.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kdialog.h>
#include <kglobal.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kgenericfactory.h>
#include <kstandarddirs.h>
#include <kurllabel.h>

#include "kcmkmrml.h"
#include <dcopclient.h>

#include "mainpage.h"
#include <version.h>

using namespace KMrmlConfig;

static const int COL_FILENAME = 1;

typedef KGenericFactory<KCMKMrml, TQWidget> MrmlFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_kmrml, MrmlFactory("kmrml") )

KCMKMrml::KCMKMrml(TQWidget *parent, const char *name, const TQStringList & ):
    KCModule(MrmlFactory::instance(), parent, name)
{
    TDEAboutData* ab = new TDEAboutData(
        "kcmkmrml",
        I18N_NOOP("KCMKMrml"),
        KMRML_VERSION,
        I18N_NOOP("Advanced Search Control Module"),
            TDEAboutData::License_GPL,
        I18N_NOOP( "Copyright 2002, Carsten Pfeiffer" ),
        0,
        "http://devel-home.kde.org/~pfeiffer/kmrml/" );
    ab->addAuthor( "Carsten Pfeiffer", 0, "pfeiffer@kde.org" );
    setAboutData( ab );

    TQVBoxLayout *layout = new TQVBoxLayout( this );
    layout->setSpacing( KDialog::spacingHint() );
    m_mainPage = new MainPage( this, "main page" );

    layout->addWidget( m_mainPage );

    connect( m_mainPage, TQT_SIGNAL( changed( bool ) ), TQT_SIGNAL( changed( bool )));

    checkGiftInstallation();
}

KCMKMrml::~KCMKMrml()
{
}

void KCMKMrml::checkGiftInstallation()
{
    TQString giftExe = TDEGlobal::dirs()->findExe( "gift" );
    TQString giftAddCollectionExe = TDEGlobal::dirs()->findExe( "gift-add-collection.pl" );

    if ( giftExe.isEmpty() || giftAddCollectionExe.isEmpty() )
    {
        TQString errorMessage = 
            i18n("Cannot find executables \"gift\" and/or \"gift-add-collection.pl\" in the PATH.\n"
                 "Please install the \"GNU Image Finding Tool\".");
        KMessageBox::error( this, errorMessage );
        m_mainPage->hide();
        TQLabel *errorLabel = new TQLabel( errorMessage, this );
        errorLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Fixed ) );
        KURLLabel *urlLabel = new KURLLabel( "http://www.gnu.org/software/gift", TQString(), this ); 
        urlLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ) );
        connect( urlLabel, TQT_SIGNAL( leftClickedURL( const TQString& )), kapp, TQT_SLOT( invokeBrowser( const TQString& )) );
        TQLayout *l = layout();
        l->addItem( new TQSpacerItem( 0, 10, TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
        l->add( errorLabel );
        l->add( urlLabel );
        l->addItem( new TQSpacerItem( 0, 10, TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
        errorLabel->show();
    }
    else
        load();
}

void KCMKMrml::defaults()
{
    if (KMessageBox::warningContinueCancel(this,
         i18n("Do you really want the configuration to be reset "
              "to the defaults?"), i18n("Reset Configuration"), KStdGuiItem::cont())
        != KMessageBox::Continue)
        return;

    m_mainPage->resetDefaults();

    emit changed( true );
}

void KCMKMrml::load()
{
    m_mainPage->load();

    emit changed( true );
}

void KCMKMrml::save()
{
    m_mainPage->save();

    emit changed( false );
}

TQString KCMKMrml::quickHelp() const
{
    return i18n("<h1>Image Index</h1>"
                "TDE can make use of the GNU Image Finding Tool (GIFT) to "
                "perform queries based not just on filenames, but on "
                "file content."
                "<p>For example, you can search for an image by giving an example "
                "image that looks similar to the one you are looking for.</p>"
                "<p>For this to work, your image directories need to be "
                "indexed by, for example, the GIFT server.</p>"
                "<p>Here you can configure the servers (you can also query "
                "remote servers) and the directories to index.</p>"
        );
}

#include "kcmkmrml.moc"