source: smplayer/trunk/src/clhelp.cpp@ 93

Last change on this file since 93 was 93, checked in by Silvan Scherrer, 15 years ago

smplayer: 0.6.9

File size: 6.1 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
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
24QString 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
57QString 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
83QString 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 "[-sub %5] [-pos x y] [-size %6 %7] "
90 "[-add-to-playlist] [-help|--help|-h|-?] "
91 "[[-playlist] %8] [[-playlist] %8]...")
92 .arg(app_name)
93 .arg(QObject::tr("directory"))
94 .arg(QObject::tr("action_name"))
95 .arg(QObject::tr("action_list"))
96 .arg(QObject::tr("subtitle_file"))
97 .arg(QObject::tr("width")).arg(QObject::tr("height"))
98 .arg(QObject::tr("media"));
99
100 QString s;
101
102 if (html) {
103 s = QObject::tr("Usage:") + " <b>" + options + "</b><br>";
104 s += "<table>";
105 } else {
106 s = formatText(QObject::tr("Usage:") + " " + options, 80);
107 s += "\n\n";
108 }
109
110#ifdef Q_OS_WIN
111 s += formatHelp( "-uninstall", QObject::tr(
112 "Restores the old associations and cleans up the registry."), html );
113#endif
114 s += formatHelp( "-minigui", QObject::tr(
115 "opens the mini gui instead of the default one."), html );
116
117 s += formatHelp( "-mpcgui", QObject::tr(
118 "opens the mpc gui."), html );
119
120 s += formatHelp( "-defaultgui", QObject::tr(
121 "opens the default gui."), html );
122
123 s += formatHelp( "-config-path", QObject::tr(
124 "specifies the directory where smplayer will store its configuration "
125 "files (smplayer.ini, smplayer_files.ini...)"), html );
126
127 s += formatHelp( "-send-action", QObject::tr(
128 "tries to make a connection to another running instance "
129 "and send to it the specified action. Example: -send-action pause "
130 "The rest of options (if any) will be ignored and the "
131 "application will exit. It will return 0 on success or -1 "
132 "on failure."), html );
133
134 s += formatHelp( "-actions", QObject::tr(
135 "action_list is a list of actions separated by spaces. "
136 "The actions will be executed just after loading the file (if any) "
137 "in the same order you entered. For checkable actions you can pass "
138 "true or false as parameter. Example: "
139 "-actions \"fullscreen compact true\". Quotes are necessary in "
140 "case you pass more than one action."), html );
141
142 s += formatHelp( "-close-at-end", QObject::tr(
143 "the main window will be closed when the file/playlist finishes."), html );
144
145 s += formatHelp( "-no-close-at-end", QObject::tr(
146 "the main window won't be closed when the file/playlist finishes."), html );
147
148 s += formatHelp( "-fullscreen", QObject::tr(
149 "the video will be played in fullscreen mode."), html );
150
151 s += formatHelp( "-no-fullscreen", QObject::tr(
152 "the video will be played in window mode."), html );
153
154 s += formatHelp( "-sub", QObject::tr(
155 "specifies the subtitle file to be loaded for the first video."), html );
156
157 s += formatHelp( "-pos", QObject::tr(
158 "specifies the coordinates where the main window will be displayed."), html );
159
160 s += formatHelp( "-size", QObject::tr(
161 "specifies the size of the main window."), html );
162
163 s += formatHelp( "-help", QObject::tr(
164 "will show this message and then will exit."), html );
165
166 s += formatHelp( "-add-to-playlist", QObject::tr(
167 "if there's another instance running, the media will be added "
168 "to that instance's playlist. If there's no other instance, "
169 "this option will be ignored and the "
170 "files will be opened in a new instance."), html );
171
172 s += formatHelp( QObject::tr("media"), QObject::tr(
173 "'media' is any kind of file that SMPlayer can open. It can "
174 "be a local file, a DVD (e.g. dvd://1), an Internet stream "
175 "(e.g. mms://....) or a local playlist in format m3u or pls. "
176 "If the -playlist option is used, that means that SMPlayer "
177 "will pass the -playlist option to MPlayer, so MPlayer will "
178 "handle the playlist, not SMPlayer."), html );
179
180 if (html) s += "</table>";
181
182 return s;
183}
Note: See TracBrowser for help on using the repository browser.