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
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2006-04-04
 * Description : a tool to generate jAlbum image galleries
 *
 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

#include "jalbumsettings.h"

// KDE includes

#include <kconfiggroup.h>

namespace DigikamGenericJAlbumPlugin
{

JAlbumSettings::JAlbumSettings(DInfoInterface* const iface)
{
    m_iface     = iface;
    m_getOption = IMAGES;

    QString dfltAlbumPath;

#ifdef Q_OS_WIN
    dfltAlbumPath = QLatin1String(qgetenv("HOMEDRIVE").constData());
    dfltAlbumPath.append(QLatin1String(qgetenv("HOMEPATH").constData()));
    dfltAlbumPath.append(QLatin1String("\\Documents\\My Albums"));
#else
    dfltAlbumPath = QLatin1String(qgetenv("HOME").constData());
    dfltAlbumPath.append(QLatin1String("/Documents/My Albums"));
#endif

    m_destPath = dfltAlbumPath;
}

JAlbumSettings::~JAlbumSettings()
{
}

void JAlbumSettings::readSettings(KConfigGroup& group)<--- Parameter 'group' can be declared as reference to const
{
    m_destPath            = group.readEntry("destPath",                 QString());
    m_jalbumPath          = group.readEntry("jalbumPath",               QString());
    m_javaPath            = group.readEntry("javaPath",                 QString());
    m_imageSelectionTitle = group.readEntry("imageSelectionTitle",     QString());
    m_getOption           = (ImageGetOption)group.readEntry("SelMode", (int)IMAGES);
}

void JAlbumSettings::writeSettings(KConfigGroup& group)
{
    group.writeEntry("destPath",            m_destPath);
    group.writeEntry("jalbumPath",          m_jalbumPath);
    group.writeEntry("javaPath",            m_javaPath);
    group.writeEntry("imageSelectionTitle", m_imageSelectionTitle);
    group.writeEntry("SelMode",             (int)m_getOption);
}

QDebug operator<<(QDebug dbg, const JAlbumSettings& t)
{
    dbg.nospace() << "JAlbumSettings::Items: "
                  << t.m_imageList << ", ";
    dbg.nospace() << "JAlbumSettings::DestPath: "
                  << t.m_destPath;
    dbg.nospace() << "JAlbumSettings::JalbumPath: "
                  << t.m_jalbumPath;
    dbg.nospace() << "JAlbumSettings::JavaPath: "
                  << t.m_javaPath;
    dbg.nospace() << "JAlbumSettings::ImageSelectionTitle: "
                  << t.m_imageSelectionTitle;
    return dbg.space();
}

} // namespace DigikamGenericJAlbumPlugin