1
/* This file is part of the KDE project
2
Copyright (C) 2004-2015 Jarosław Staniek <staniek@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "kexistartupdata.h"
22
#include "KexiCommandLineOptions.h"
23
#include "config-kexi.h"
26
#include <KDbDriverManager>
30
#include <QCommandLineParser>
32
class KexiStartupData::Private
38
QCommandLineParser parser;
39
KexiCommandLineOptions options;
40
KexiProjectData *projectData;
42
KexiStartupData::Import importActionData;
44
bool forcedDesignMode;
45
bool isProjectNavigatorVisible;
46
bool isMainMenuVisible;
50
bool forcedFullScreen;
53
KexiStartupData::Private::Private()
55
, projectData(0), action(KexiStartupData::DoNothing), forcedUserMode(false)
56
, forcedDesignMode(false), isProjectNavigatorVisible(false), forcedFullScreen(false)
60
KexiStartupData::Private::~Private()
65
KexiStartupData::KexiStartupData() : d(new Private)
69
KexiStartupData::~KexiStartupData()
74
KexiProjectData *KexiStartupData::projectData()
76
return d->projectData;
79
void KexiStartupData::setProjectData(KexiProjectData *data)
81
if (data != d->projectData) {
82
delete d->projectData;
84
d->projectData = data;
87
KexiStartupData::Action KexiStartupData::action() const
92
void KexiStartupData::setAction(KexiStartupData::Action action)
97
bool KexiStartupData::forcedUserMode() const
99
return d->forcedUserMode;
102
void KexiStartupData::setForcedUserMode(bool set)
104
d->forcedUserMode = set;
107
bool KexiStartupData::forcedDesignMode() const
109
return d->forcedDesignMode;
112
void KexiStartupData::setForcedDesignMode(bool set)
114
d->forcedDesignMode = set;
117
bool KexiStartupData::isProjectNavigatorVisible() const
119
if (d->forcedUserMode && !d->forcedDesignMode)
120
return d->isProjectNavigatorVisible;
124
void KexiStartupData::setProjectNavigatorVisible(bool set)
126
d->isProjectNavigatorVisible = set;
129
bool KexiStartupData::isMainMenuVisible() const
131
return d->isMainMenuVisible;
134
void KexiStartupData::setMainMenuVisible(bool set)
136
d->isMainMenuVisible = set;
139
KexiStartupData::Import KexiStartupData::importActionData() const
141
return d->importActionData;
144
void KexiStartupData::setImportActionData(KexiStartupData::Import import)
146
d->importActionData = import;
149
KexiStartupData::Import::Import()
153
KexiStartupData::Import::operator bool() const
155
return !fileName.isEmpty() && !mimeType.isEmpty();
158
bool KexiStartupData::forcedFullScreen() const
160
return d->forcedFullScreen;
163
void KexiStartupData::setForcedFullScreen(bool set)
165
d->forcedFullScreen = set;
168
//! Command line options
169
KexiCommandLineOptions KexiStartupData::options() const
174
tristate KexiStartupData::parseOptions()
176
d->parser.setApplicationDescription(KAboutData::applicationData().shortDescription());
177
KAboutData::applicationData().setupCommandLine(&d->parser); // adds -h and -v too
179
#define ADD_OPTION(o) \
180
if (!d->parser.addOption(d->options.o)) { \
181
qWarning() << "Could not add option" << d->options.o.names(); \
185
ADD_OPTION(createAndOpenDb)
189
ADD_OPTION(connectionShortcut)
192
ADD_OPTION(designMode)
193
ADD_OPTION(showNavigator)
199
ADD_OPTION(newObject)
200
#ifdef KEXI_QUICK_PRINTING_SUPPORT
202
ADD_OPTION(printPreview)
207
ADD_OPTION(localSocket)
208
ADD_OPTION(skipConnDialog)
209
ADD_OPTION(fullScreen)
210
ADD_OPTION(listPlugins)
213
d->parser.addPositionalArgument("file",
214
xi18nc("<file> argument description for the command line",
215
"Kexi database project filename, Kexi shortcut filename, or name of a Kexi "
216
"database project on a server to open."));
218
//qDebug() << QCoreApplication::instance()->arguments();
219
d->parser.process(*qApp);
220
KAboutData::applicationData().processCommandLine(&d->parser);
224
bool KexiStartupData::isSet(const QCommandLineOption & option) const
226
return d->parser.isSet(option);
229
QString KexiStartupData::value(const QCommandLineOption & option) const
231
return d->parser.value(option);
234
QStringList KexiStartupData::positionalArguments() const
236
return d->parser.positionalArguments();
239
QString KexiStartupData::helpText() const
241
return d->parser.helpText();