source: smplayer/trunk/src/inputurl.cpp@ 104

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

smplayer: 0.6.9

File size: 2.8 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 "inputurl.h"
20#include "images.h"
21
22InputURL::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
39InputURL::~InputURL() {
40}
41
42void InputURL::setURL(QString url, bool is_playlist) {
43 url_edit->addItem(url, is_playlist);
44}
45
46QString InputURL::url() {
47 return url_edit->currentText().trimmed();
48}
49
50void 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
58bool InputURL::isPlaylist() {
59 return playlist_check->isChecked();
60}
61
62void 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
70void 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
83void 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"
Note: See TracBrowser for help on using the repository browser.