1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2011 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 "inputurl.h"
|
---|
20 | #include "images.h"
|
---|
21 |
|
---|
22 | InputURL::InputURL( QWidget* parent, Qt::WindowFlags f )
|
---|
23 | : QDialog(parent, f)
|
---|
24 | {
|
---|
25 | setupUi(this);
|
---|
26 |
|
---|
27 | url_icon->setPixmap( Images::icon("url_big") );
|
---|
28 | url_edit->setFocus();
|
---|
29 |
|
---|
30 | playlist_check->setWhatsThis(
|
---|
31 | tr("If this option is checked, the URL will be treated as a playlist: "
|
---|
32 | "it will be opened as text and will play the URLs in it.") );
|
---|
33 |
|
---|
34 | connect(url_edit, SIGNAL(editTextChanged(const QString &)), this, SLOT(textChanged(const QString &)));
|
---|
35 | connect(url_edit, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
|
---|
36 | connect(playlist_check, SIGNAL(stateChanged(int)), this, SLOT(playlistChanged(int)));
|
---|
37 | }
|
---|
38 |
|
---|
39 | InputURL::~InputURL() {
|
---|
40 | }
|
---|
41 |
|
---|
42 | void InputURL::setURL(QString url, bool is_playlist) {
|
---|
43 | url_edit->addItem(url, is_playlist);
|
---|
44 | }
|
---|
45 |
|
---|
46 | QString InputURL::url() {
|
---|
47 | return url_edit->currentText().trimmed();
|
---|
48 | }
|
---|
49 |
|
---|
50 | void InputURL::setPlaylist(bool b) {
|
---|
51 | playlist_check->setChecked(b);
|
---|
52 | /*
|
---|
53 | int pos = url_edit->currentIndex();
|
---|
54 | url_edit->setItemData(pos, b);
|
---|
55 | */
|
---|
56 | }
|
---|
57 |
|
---|
58 | bool InputURL::isPlaylist() {
|
---|
59 | return playlist_check->isChecked();
|
---|
60 | }
|
---|
61 |
|
---|
62 | void InputURL::indexChanged(int) {
|
---|
63 | qDebug("InputURL::indexChanged");
|
---|
64 | int pos = url_edit->currentIndex();
|
---|
65 | if (url_edit->itemText(pos) == url_edit->currentText()) {
|
---|
66 | playlist_check->setChecked( url_edit->itemData(pos).toBool() );
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | void InputURL::textChanged(const QString & new_text) {
|
---|
71 | qDebug("InputURL::textChanged");
|
---|
72 | QString s = new_text.trimmed();
|
---|
73 | /*
|
---|
74 | if (s != new_text) {
|
---|
75 | url_edit->setEditText(s);
|
---|
76 | return;
|
---|
77 | }
|
---|
78 | */
|
---|
79 | QRegExp rx("\\.ram$|\\.asx$|\\.m3u$|\\.pls$", Qt::CaseInsensitive);
|
---|
80 | setPlaylist( (rx.indexIn(s) != -1) );
|
---|
81 | }
|
---|
82 |
|
---|
83 | void InputURL::playlistChanged(int state) {
|
---|
84 | /*
|
---|
85 | int pos = url_edit->currentIndex();
|
---|
86 | if (url_edit->itemText(pos) == url_edit->currentText()) {
|
---|
87 | bool is_playlist = (state == Qt::Checked);
|
---|
88 | url_edit->setItemIcon( pos, is_playlist ? Images::icon("playlist") : QIcon() );
|
---|
89 | }
|
---|
90 | */
|
---|
91 | }
|
---|
92 |
|
---|
93 | #include "moc_inputurl.cpp"
|
---|