1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program 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
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "clhelp.h"
|
---|
20 | #include <QObject>
|
---|
21 | #include <QApplication>
|
---|
22 | #include <QFileInfo>
|
---|
23 |
|
---|
24 | QString CLHelp::formatText(QString s, int col) {
|
---|
25 | QString res = "";
|
---|
26 |
|
---|
27 | int last = 0;
|
---|
28 | int pos;
|
---|
29 |
|
---|
30 | pos = s.indexOf(" ");
|
---|
31 | while (pos != -1) {
|
---|
32 |
|
---|
33 | if (s.count() < col) {
|
---|
34 | res = res + s;
|
---|
35 | s = "";
|
---|
36 | break;
|
---|
37 | }
|
---|
38 |
|
---|
39 | while ((pos < col) && (pos != -1)) {
|
---|
40 | last = pos;
|
---|
41 | pos = s.indexOf(" ", pos+1);
|
---|
42 | }
|
---|
43 |
|
---|
44 | res = res + s.left(last) + "\n";
|
---|
45 | s = s.mid(last+1);
|
---|
46 |
|
---|
47 | last = 0;
|
---|
48 | pos = s.indexOf(" ");
|
---|
49 |
|
---|
50 | }
|
---|
51 |
|
---|
52 | if (!s.isEmpty()) res = res + s;
|
---|
53 |
|
---|
54 | return res;
|
---|
55 | }
|
---|
56 |
|
---|
57 | QString CLHelp::formatHelp(QString parameter, QString help, bool html) {
|
---|
58 | if (html) {
|
---|
59 | return "<tr><td><b>"+parameter+"</b></td><td>"+help+"</td></tr>";
|
---|
60 | } else {
|
---|
61 | int par_width = 20;
|
---|
62 | int help_width = 80 - par_width;
|
---|
63 |
|
---|
64 | QString s;
|
---|
65 | s = s.fill( ' ', par_width - (parameter.count()+2) );
|
---|
66 | s = s + parameter + ": ";
|
---|
67 |
|
---|
68 | QString f;
|
---|
69 | f = f.fill(' ', par_width);
|
---|
70 |
|
---|
71 | QString s2 = formatText(help, help_width);
|
---|
72 | int pos = s2.indexOf('\n');
|
---|
73 | while (pos != -1) {
|
---|
74 | s2 = s2.insert(pos+1, f);
|
---|
75 | pos = s2.indexOf('\n', pos+1);
|
---|
76 | }
|
---|
77 |
|
---|
78 | return s + s2 + "\n";
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | QString CLHelp::help(bool html) {
|
---|
84 | QString app_name = QFileInfo(qApp->applicationFilePath()).baseName();
|
---|
85 |
|
---|
86 | QString options = QString("%1 [-minigui] [-defaultgui] [-mpcgui] [-config-path %2] "
|
---|
87 | "[-send-action %3] [-actions %4] "
|
---|
88 | "[-close-at-end] [-no-close-at-end] [-fullscreen] [-no-fullscreen] "
|
---|
89 | "[-ontop] [-no-ontop] "
|
---|
90 | "[-sub %5] [-pos x y] [-size %6 %7] "
|
---|
91 | "[-add-to-playlist] [-help|--help|-h|-?] "
|
---|
92 | "[%8] [%8]...")
|
---|
93 | .arg(app_name)
|
---|
94 | .arg(QObject::tr("directory"))
|
---|
95 | .arg(QObject::tr("action_name"))
|
---|
96 | .arg(QObject::tr("action_list"))
|
---|
97 | .arg(QObject::tr("subtitle_file"))
|
---|
98 | .arg(QObject::tr("width")).arg(QObject::tr("height"))
|
---|
99 | .arg(QObject::tr("media"));
|
---|
100 |
|
---|
101 | QString s;
|
---|
102 |
|
---|
103 | if (html) {
|
---|
104 | s = QObject::tr("Usage:") + " <b>" + options + "</b><br>";
|
---|
105 | s += "<table>";
|
---|
106 | } else {
|
---|
107 | s = formatText(QObject::tr("Usage:") + " " + options, 80);
|
---|
108 | s += "\n\n";
|
---|
109 | }
|
---|
110 |
|
---|
111 | #ifdef Q_OS_WIN
|
---|
112 | s += formatHelp( "-uninstall", QObject::tr(
|
---|
113 | "Restores the old associations and cleans up the registry."), html );
|
---|
114 | #endif
|
---|
115 | s += formatHelp( "-minigui", QObject::tr(
|
---|
116 | "opens the mini gui instead of the default one."), html );
|
---|
117 |
|
---|
118 | s += formatHelp( "-mpcgui", QObject::tr(
|
---|
119 | "opens the mpc gui."), html );
|
---|
120 |
|
---|
121 | s += formatHelp( "-defaultgui", QObject::tr(
|
---|
122 | "opens the default gui."), html );
|
---|
123 |
|
---|
124 | #ifdef SKINS
|
---|
125 | s += formatHelp( "-skingui", QObject::tr(
|
---|
126 | "opens the gui with support for skins."), html );
|
---|
127 | #endif
|
---|
128 |
|
---|
129 | s += formatHelp( "-config-path", QObject::tr(
|
---|
130 | "specifies the directory where smplayer will store its configuration "
|
---|
131 | "files (smplayer.ini, smplayer_files.ini...)"), html );
|
---|
132 |
|
---|
133 | s += formatHelp( "-send-action", QObject::tr(
|
---|
134 | "tries to make a connection to another running instance "
|
---|
135 | "and send to it the specified action. Example: -send-action pause "
|
---|
136 | "The rest of options (if any) will be ignored and the "
|
---|
137 | "application will exit. It will return 0 on success or -1 "
|
---|
138 | "on failure."), html );
|
---|
139 |
|
---|
140 | s += formatHelp( "-actions", QObject::tr(
|
---|
141 | "action_list is a list of actions separated by spaces. "
|
---|
142 | "The actions will be executed just after loading the file (if any) "
|
---|
143 | "in the same order you entered. For checkable actions you can pass "
|
---|
144 | "true or false as parameter. Example: "
|
---|
145 | "-actions \"fullscreen compact true\". Quotes are necessary in "
|
---|
146 | "case you pass more than one action."), html );
|
---|
147 |
|
---|
148 | s += formatHelp( "-close-at-end", QObject::tr(
|
---|
149 | "the main window will be closed when the file/playlist finishes."), html );
|
---|
150 |
|
---|
151 | s += formatHelp( "-no-close-at-end", QObject::tr(
|
---|
152 | "the main window won't be closed when the file/playlist finishes."), html );
|
---|
153 |
|
---|
154 | s += formatHelp( "-fullscreen", QObject::tr(
|
---|
155 | "the video will be played in fullscreen mode."), html );
|
---|
156 |
|
---|
157 | s += formatHelp( "-no-fullscreen", QObject::tr(
|
---|
158 | "the video will be played in window mode."), html );
|
---|
159 |
|
---|
160 | s += formatHelp( "-ontop", QObject::tr(
|
---|
161 | "sets the stay on top option to always."), html );
|
---|
162 |
|
---|
163 | s += formatHelp( "-no-ontop", QObject::tr(
|
---|
164 | "sets the stay on top option to never."), html );
|
---|
165 |
|
---|
166 | s += formatHelp( "-sub", QObject::tr(
|
---|
167 | "specifies the subtitle file to be loaded for the first video."), html );
|
---|
168 |
|
---|
169 | s += formatHelp( "-media-title", QObject::tr(
|
---|
170 | "sets the media title for the first video."), html );
|
---|
171 |
|
---|
172 | s += formatHelp( "-pos", QObject::tr(
|
---|
173 | "specifies the coordinates where the main window will be displayed."), html );
|
---|
174 |
|
---|
175 | s += formatHelp( "-size", QObject::tr(
|
---|
176 | "specifies the size of the main window."), html );
|
---|
177 |
|
---|
178 | s += formatHelp( "-help", QObject::tr(
|
---|
179 | "will show this message and then will exit."), html );
|
---|
180 |
|
---|
181 | s += formatHelp( "-add-to-playlist", QObject::tr(
|
---|
182 | "if there's another instance running, the media will be added "
|
---|
183 | "to that instance's playlist. If there's no other instance, "
|
---|
184 | "this option will be ignored and the "
|
---|
185 | "files will be opened in a new instance."), html );
|
---|
186 |
|
---|
187 | s += formatHelp( QObject::tr("media"), QObject::tr(
|
---|
188 | "'media' is any kind of file that SMPlayer can open. It can "
|
---|
189 | "be a local file, a DVD (e.g. dvd://1), an Internet stream "
|
---|
190 | "(e.g. mms://....) or a local playlist in format m3u or pls."), html );
|
---|
191 |
|
---|
192 | if (html) s += "</table>";
|
---|
193 |
|
---|
194 | return s;
|
---|
195 | }
|
---|