summaryrefslogtreecommitdiffstats
path: root/digikam/digikam/main.cpp
blob: 71a9ea7b9677553f186eab2299d81f2b632cc158 (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
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2002-07-28
 * Description : main program from digiKam
 *
 * Copyright (C) 2002-2006 by Renchi Raju <renchi at pooh.tam.uiuc.edu>
 * Copyright (C) 2002-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * 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.
 *
 * ============================================================ */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// TQt includes.

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqfileinfo.h>
#include <tqfile.h>

// KDE includes.

#include <tdecmdlineargs.h>
#include <tdeapplication.h>
#include <tdeaboutdata.h>
#include <klocale.h>
#include <tdeconfig.h>
#include <kglobal.h>
#include <ktip.h>
#include <tdeversion.h>
#include <kmessagebox.h>

// KIPI includes.

#include <libkipi/version.h>
#include <libkipi/interface.h>

// Local includes.

#include "daboutdata.h"
#include "albumdb.h"
#include "digikamapp.h"
#include "digikamfirstrun.h"

static TDECmdLineOptions options[] =
{
    { "detect-camera", I18N_NOOP("Automatically detect and open camera"), 0 },
    { "download-from <path>", I18N_NOOP("Open camera dialog at <path>"), 0 },
    TDECmdLineLastOption
};

int main(int argc, char *argv[])
{
    TQString libInfo     = Digikam::libraryInfo();

    TQString description = Digikam::digiKamDescription();

    TDEAboutData aboutData( "digikam",
                          I18N_NOOP("digiKam"),
                          digikam_version,
                          description.latin1(),
                          TDEAboutData::License_GPL,
                          Digikam::copyright(),
                          0,
                          Digikam::webProjectUrl());

    aboutData.setOtherText(libInfo.latin1());

    Digikam::authorsRegistration(aboutData);

    TDECmdLineArgs::init( argc, argv, &aboutData );
    TDECmdLineArgs::addCmdLineOptions( options );

    TDEApplication app;

    TDEConfig* config = TDEGlobal::config();
    config->setGroup("General Settings");
    TQString version = config->readEntry("Version");

    config->setGroup("Album Settings");
    TQString albumPath = config->readPathEntry("Album Path");
    TQFileInfo dirInfo(albumPath);

    // version 0.6 was the version when the new Albums Library
    // storage was implemented

    if (version.startsWith("0.5") ||
        !dirInfo.exists() ||
        !dirInfo.isDir())
    {
        // Run the first run
        Digikam::DigikamFirstRun *firstRun = new Digikam::DigikamFirstRun(config);
        app.setMainWidget(firstRun);
        firstRun->show();
        return app.exec();
    }

    Digikam::DigikamApp *digikam = new Digikam::DigikamApp();

    app.setMainWidget(digikam);
    digikam->show();

    TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs();
    if (args && args->isSet("detect-camera"))
        digikam->autoDetect();
    else if (args && args->isSet("download-from"))
        digikam->downloadFrom(args->getOption("download-from"));

#if KDE_IS_VERSION(3,2,0)
    TQStringList tipsFiles;
    tipsFiles.append("digikam/tips");
    tipsFiles.append("kipi/tips");

    TDEGlobal::locale()->insertCatalogue("kipiplugins");
    TDEGlobal::locale()->insertCatalogue("libkdcraw");

    KTipDialog::showMultiTip(0, tipsFiles, false);
#else
    KTipDialog::showTip(0, "digikam/tips", false);
#endif

    return app.exec();
}