41,11 → 41,21 |
#include "config.h" |
#endif |
|
// jjsa 28-03-2004 added define for choosing of option type |
// if USE_LONG_OPT is 1 old options will be compiled |
// else use option with single '-' |
#define USE_LONG_OPT 0 |
#define ARG_VERSION "--version" |
#define ARG_HELP "--help" |
#define ARG_LANG "--lang" |
#define ARG_NOSPLASH "--no-splash" |
#define ARG_NOGUI "--no-gui" |
#define ARG_DISPLAY "--display" |
|
#define ARG_VERSION_SHORT "-v" |
#define ARG_HELP_SHORT "-h" |
#define ARG_LANG_SHORT "-l" |
#define ARG_NOSPLASH_SHORT "-s" |
#define ARG_NOGUI_SHORT "-g" |
#define ARG_DISPLAY_SHORT "-d" |
|
|
QString lang = ""; |
bool showSplash = true; |
bool useGui = true; |
62,48 → 72,36 |
QString arg = ""; |
|
arg = argv[1]; |
#if USE_LONG_OPT // jjsa 28-03-2004 begin |
if (arg == "--version") { |
if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { |
std::cout << "Scribus Version " << VERSION << std::endl; |
return 0; |
} else if (arg == "--help") { |
} else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { |
std::cout << std::endl; |
std::cout << "Scribus, a DTP-Program" << std::endl; |
std::cout << "Scribus, Open Source Desktop Publishing" << std::endl; |
std::cout << "---------------------------------------" << std::endl; |
std::cout << "Homepage: http://www.scribus.net " << std::endl; |
std::cout << "Documentation: http://docs.scribus.net" << std::endl; |
std::cout << "Issues: http://bugs.scribus.net" << std::endl; |
showUsage(); |
return 0; |
} |
#else |
if (arg == "-version") { |
std::cout << "Scribus Version " << VERSION << std::endl; |
return 0; |
} else if (arg == "-help") { |
std::cout << std::endl; |
std::cout << "Scribus, a DTP-Program" << std::endl; |
showUsage(); |
return 0; |
} |
#endif // jjsa 28-03-2004end |
|
#if USE_LONG_OPT // jjsa 28-03-2004 begin |
for(int i = 1; i < argc; i++) { |
arg = argv[i]; |
if ((arg == "--lang") && (++i < argc)) { |
if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc)) { |
lang = argv[i]; |
} else if (arg == "--no-splash") { |
} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { |
showSplash = false; |
} else if (arg == "--no-gui") { |
} else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { |
useGui = false; |
// jjsa 28-03-2004 begin |
} else if (arg == "-display" && i < argc) { |
} else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT) && ++i < argc) { |
// allow setting of display, QT expect the |
// option -display <display_name> |
i++; |
// jjsa 28-03-2004 end |
} else { |
file = QFile::decodeName(argv[i]); |
if (!QFileInfo(file).exists()) { |
std::cout << std::endl; |
if (file.left(2) == "--") { |
if (file.left(1) == "-" || file.left(2) == "--") { |
std::cout << "Invalid argument: " << file << std::endl; |
} else { |
std::cout << "File " << file << "does not exist, aborting." << std::endl; |
113,61 → 111,7 |
} |
} |
} |
#else |
for(int i = 1; i < argc; i++) { |
arg = argv[i]; |
if ((arg == "-lang") && (++i < argc)) { |
lang = argv[i]; |
} else if (arg == "-no-splash") { |
showSplash = false; |
} else if (arg == "-no-gui") { |
useGui = false; |
} else if (arg.left(2) == "--" || arg == "-file" || arg.left(1) != "-") { |
if ( arg.left(1) == "-" ) { |
i++; |
} |
file = QFile::decodeName(argv[i]); |
if (!QFileInfo(file).exists()) { |
std::cout << std::endl; |
std::cout << "File " << file << "does not exist, aborting." << std::endl; |
showUsage(); |
return 0; |
} |
} else if (arg.left(1) == "-" && i+1 < argc ) { |
i++; |
} |
} |
#endif |
|
/* if (useGui) |
{ |
// Please Test this carefully and report problems. |
// if this works we can add it to the CVS |
// Currently disabled because of trouble with accented Filenames. |
// jjsa added on 8-mar-2004 |
if ( lang == "" ) |
{ |
// if we have .UTF-8 we will have problems |
// with compose key, at least for european |
// languages |
lang = getenv("LANG"); |
lang = lang.left(5); |
QString nlang = "LANG="+lang.left(5); |
putenv((char*)nlang.ascii()); |
} |
else |
{ |
// in order to install the language correctly |
// we must put this to the environment |
// sp the LC_... variabls will also be set |
// correctly |
QString nlang = "LANG="+lang; |
putenv((char*)nlang.ascii()); |
} |
// jjsa end off add |
return mainGui(argc, argv); |
} */ |
|
if (useGui) |
return mainGui(argc, argv); |
} |
181,7 → 125,6 |
\param lang QString a two letter string describing the lang environement |
\retval QString A string describing the language environement |
*/ |
#if USE_LONG_OPT // jjsa 28-03-2004 begin |
|
void showUsage() |
{ |
188,26 → 131,16 |
std::cout << std::endl; |
std::cout << "Usage: scribus [option ... ] [file]" << std::endl; |
std::cout << "Options:" << std::endl; |
std::cout << "--lang xx Uses xx as shortcut for a language" << std::endl; |
std::cout << "--help Print help (this message) and exit" << std::endl; |
std::cout << "--version Output version information and exit" << std::endl; |
std::cout << std::endl; |
} |
#else |
void showUsage() |
{ |
std::cout << std::endl; |
std::cout << "Usage: scribus [option ... ] [file]" << std::endl; |
std::cout << "Options:" << std::endl; |
std::cout << "-lang xx Uses xx as shortcut for a language" << std::endl; |
std::cout << "-help Print help (this message) and exit" << std::endl; |
std::cout << "-version Output version information and exit" << std::endl; |
std::cout << "-l, --lang xx Uses xx as shortcut for a language" << std::endl; |
std::cout << "-h, --help Print help (this message) and exit" << std::endl; |
std::cout << "-v, --version Output version information and exit" << std::endl; |
/* |
std::cout << "-file|-- name Open file 'name'" << std::endl; |
std::cout << "name Open file 'name', the file name must not begin with '-'" << std::endl; |
std::cout << "QT specific options as -display ..." << std::endl; |
*/ |
std::cout << std::endl; |
} |
#endif // jjsa 28-03-2004 end |
|
/*! |
\fn int mainGui(int argc, char **argv) |
279,15 → 212,11 |
#endif |
langs.push_back(QString(QTextCodec::locale())); |
|
// remove duplicate entries... how can i remove the empty entries? |
// remove duplicate entries... |
for (QStringList::Iterator it = langs.fromLast(); it != langs.begin(); --it) |
// if (langs.contains(*it) > 1 || (*it == "") || (*it).isEmpty()) |
if (langs.contains(*it) > 1) |
it = langs.remove(it); |
|
// debugging code |
// for (QStringList::Iterator it = langs.begin(); it != langs.end(); ++it) |
// std::cout << "**" << *it << "**" << std::endl; |
|
return langs; |
} |
310,8 → 239,6 |
QString path = SCRIBUS_LIB; |
path += BASE_QM; |
|
// QString lang = ""; |
|
bool loaded = false; |
for (QStringList::Iterator it = langs.begin(); it != langs.end() && !loaded; ++it) { |
if ((*it).left(5) == "en_GB") |
329,7 → 256,6 |
app->installTranslator(trans); |
|
|
/* ! the en_GB localisations cannot be loaded... ! */ |
path = SCRIBUS_PLUGIN; |
QDir dir(path , "*.*", QDir::Name, QDir::Files | QDir::NoSymLinks); |
if (dir.exists() && (dir.count() != 0)) { |