/** * Copyright (c) 2011-2013 by Andrew Mustun. All rights reserved. * * This file is part of the QCAD project. * * QCAD 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 3 of the License, or * (at your option) any later version. * * QCAD 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 QCAD. */ include("library.js"); include("AddOn.js"); include("scripts/Edit/AppPreferences/StylePreferences/StylePreferences.js"); include("scripts/File/OpenFile/OpenFile.js"); include("scripts/File/AutoSave/AutoSave.js"); /** * Prints version information. */ function version() { print(); print("Version: " + RSettings.getVersionString()); print("Qt Version: " + RSettings.getQtVersion()); print("Release Date: " + RSettings.getReleaseDate()); print(); } /** * Prints command line usage information on stdout. */ function usage() { var styleNames = StylePreferences.getStyleNames(); print("\nUsage: " + QCoreApplication.arguments()[0] + " [Options] [Files to open]\n" + "\n" + "-allow-multiple-instances Don't try to avoid multiple instances from running\n" + " simultaneously.\n" + "-always-load-scripts Forces reloading of scripts when they are used.\n" + " This is mainly useful during script development,\n" + " to apply changes without restarting QCAD.\n" + "-app-id [ID] Set application ID. Multiple instances of the\n" + " same application (same ID) cannot run\n" + " simultaneously unless -allow-multiple-instances\n" + " is used.\n" + "-autostart [script file] Starts the given script file instead of the default\n" + " scripts/autostart.js. Note that with this option,\n" + " QCAD is not started but rather the application \n" + " implemented in the given script.\n" + "-config [path] Reads and stores settings to QCAD3.ini at the given\n" + " location instead of the default location.\n" + "-enable-script-debugger Enables the script debugger.\n" + " NOT recommended as this may cause unexpected \n" + " behavior when using QCAD.\n" + "-exec [script file] [options] Executes the given script file directly\n" + " after staring QCAD. Options after the script\n" + " file are passed on to the script.\n" + "-gui-css-file [CSS file] Loads the specified CSS file.\n" + "-gui-style [StyleName] Loads a predefined style. Available styles are:\n" + " " + styleNames.join(", ") + "\n" + "-help Displays this help.\n" + "-locale [locale] Sets the locale to be used (overrides\n" + " the language set in the preferences).\n" + " E.g. '-locale de' starts QCAD in German.\n" + "-no-gui Don't use GUI. X11: don't connect to X11 server.\n" + "-no-show Use but don't display GUI.\n" + "-filter [filter] Opens the subsequent file(s) with the explicitly \n" + " given import filter.\n" + "-rescan Rescan scripts folder for new add-ons\n" + "-version Displays the application version.\n" + "-enable-xdata Enables XData (custom properties) support.\n" + "-quit Quits QCAD, for example after executing the\n" + " given script(s).\n" ); // Mac OS X only: if (RS.getSystemId()==="osx") { print("\nMac OS X specific options:\n"); print("-no-dock-icon Don't show icon in dock. This should only be used\n" + " in combination with -no-gui." ); } print("\n"); } /** * Open files given as arguments args or creates a new document if * no files are given and createNew is true. */ function openFiles(args, createNew) { var appWin = RMainWindowQt.getMainWindow(); if (isNull(appWin)) { // application is shutting down.. return; } var mdiArea = appWin.getMdiArea(); var mdiChildren = mdiArea.subWindowList(); var foundFile = false; var filter = undefined; for (var i = 0; i < args.length; ++i) { // arguments with one parameter: if (args[i] === "-gui-style" || args[i] === "-gui-css-file" || args[i] === "-locale" || args[i] === "-autostart" || args[i] === "-app-id" || args[i] === "-ignore" || args[i] === "-config") { // skip 2 arguments if (++i>=args.length) { break; } continue; } // all arguments after -exec are script files or script arguments: if (args[i] === "-exec") { break; } if (args[i] === "-filter") { if (++i>=args.length) { break; } filter = args[i]; continue; } // skip other arguments without parameter: if (args[i][0] === "-") { continue; } foundFile = true; // if the file is already open, activate that appropriate sub window instead // of opening the file again: var document = undefined; var fileName = undefined; var fileInfo = undefined; var argFileInfo = undefined; var foundExisting = false; for (var k=0; k-1) { qDebug("Loading Style Sheets..."); if (idx+1-1) { if (idx+1