2010-04-13 00:44:29 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-04-13 00:44:29 +02:00
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMANDLINEOPTIONS_H
|
|
|
|
#define COMMANDLINEOPTIONS_H
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QDataStream>
|
|
|
|
|
|
|
|
class CommandlineOptions {
|
|
|
|
friend QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a);
|
|
|
|
friend QDataStream& operator>>(QDataStream& s, CommandlineOptions& a);
|
|
|
|
|
|
|
|
public:
|
|
|
|
CommandlineOptions(int argc = 0, char** argv = NULL);
|
|
|
|
|
|
|
|
static const char* kHelpText;
|
2011-05-16 21:21:46 +02:00
|
|
|
static const char* kVersionText;
|
2010-04-13 00:44:29 +02:00
|
|
|
|
|
|
|
// Don't change the values or order, these get serialised and sent to
|
|
|
|
// possibly a different version of Clementine
|
|
|
|
enum UrlListAction {
|
|
|
|
UrlList_Append = 0,
|
|
|
|
UrlList_Load = 1,
|
|
|
|
};
|
|
|
|
enum PlayerAction {
|
|
|
|
Player_None = 0,
|
|
|
|
Player_Play = 1,
|
|
|
|
Player_PlayPause = 2,
|
|
|
|
Player_Pause = 3,
|
|
|
|
Player_Stop = 4,
|
|
|
|
Player_Previous = 5,
|
|
|
|
Player_Next = 6,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool Parse();
|
|
|
|
|
2010-04-13 01:35:47 +02:00
|
|
|
bool is_empty() const;
|
|
|
|
|
2010-04-13 00:44:29 +02:00
|
|
|
UrlListAction url_list_action() const { return url_list_action_; }
|
|
|
|
PlayerAction player_action() const { return player_action_; }
|
2010-04-13 01:35:47 +02:00
|
|
|
int set_volume() const { return set_volume_; }
|
|
|
|
int volume_modifier() const { return volume_modifier_; }
|
|
|
|
int seek_to() const { return seek_to_; }
|
2010-04-13 22:22:29 +02:00
|
|
|
int seek_by() const { return seek_by_; }
|
2010-04-13 01:35:47 +02:00
|
|
|
int play_track_at() const { return play_track_at_; }
|
|
|
|
bool show_osd() const { return show_osd_; }
|
2011-06-05 10:21:17 +02:00
|
|
|
bool toggle_pretty_osd() const { return toggle_pretty_osd_; }
|
2010-04-13 00:44:29 +02:00
|
|
|
QList<QUrl> urls() const { return urls_; }
|
2010-08-02 21:02:21 +02:00
|
|
|
QString language() const { return language_; }
|
2011-04-22 18:50:29 +02:00
|
|
|
QString log_levels() const { return log_levels_; }
|
2010-04-13 00:44:29 +02:00
|
|
|
|
|
|
|
QByteArray Serialize() const;
|
|
|
|
void Load(const QByteArray& serialized);
|
|
|
|
|
|
|
|
private:
|
2010-04-13 22:22:29 +02:00
|
|
|
// These are "invalid" characters to pass to getopt_long for options that
|
|
|
|
// shouldn't have a short (single character) option.
|
2010-04-13 01:35:47 +02:00
|
|
|
enum LongOptions {
|
|
|
|
VolumeUp = 256,
|
|
|
|
VolumeDown,
|
|
|
|
SeekTo,
|
2010-04-13 22:22:29 +02:00
|
|
|
SeekBy,
|
2011-04-22 18:50:29 +02:00
|
|
|
Quiet,
|
|
|
|
Verbose,
|
|
|
|
LogLevels,
|
2011-09-16 16:19:52 +02:00
|
|
|
Version,
|
2010-04-13 01:35:47 +02:00
|
|
|
};
|
|
|
|
|
2010-04-13 00:44:29 +02:00
|
|
|
QString tr(const char* source_text);
|
2010-12-11 11:04:17 +01:00
|
|
|
void RemoveArg(const QString& starts_with, int count);
|
2010-04-13 00:44:29 +02:00
|
|
|
|
|
|
|
private:
|
2011-05-16 21:21:46 +02:00
|
|
|
|
2010-04-13 00:44:29 +02:00
|
|
|
int argc_;
|
|
|
|
char** argv_;
|
|
|
|
|
|
|
|
UrlListAction url_list_action_;
|
|
|
|
PlayerAction player_action_;
|
|
|
|
|
2010-04-13 01:35:47 +02:00
|
|
|
// Don't change the type of these.
|
|
|
|
int set_volume_;
|
|
|
|
int volume_modifier_;
|
|
|
|
int seek_to_;
|
2010-04-13 22:22:29 +02:00
|
|
|
int seek_by_;
|
2010-04-13 01:35:47 +02:00
|
|
|
int play_track_at_;
|
|
|
|
bool show_osd_;
|
2011-06-05 10:21:17 +02:00
|
|
|
bool toggle_pretty_osd_;
|
2010-08-02 21:02:21 +02:00
|
|
|
QString language_;
|
2011-04-22 18:50:29 +02:00
|
|
|
QString log_levels_;
|
2010-04-13 01:35:47 +02:00
|
|
|
|
2010-04-13 00:44:29 +02:00
|
|
|
QList<QUrl> urls_;
|
|
|
|
};
|
|
|
|
|
|
|
|
QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a);
|
|
|
|
QDataStream& operator>>(QDataStream& s, CommandlineOptions& a);
|
|
|
|
|
|
|
|
#endif // COMMANDLINEOPTIONS_H
|