source: smplayer/trunk/src/filechooser.cpp@ 121

Last change on this file since 121 was 119, checked in by Silvan Scherrer, 14 years ago

SMPlayer: latest svn update

  • Property svn:eol-style set to LF
File size: 2.5 KB
Line 
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 "filechooser.h"
20
21//#define NO_SMPLAYER_SUPPORT
22
23#ifndef NO_SMPLAYER_SUPPORT
24#include "filedialog.h"
25#include "images.h"
26#else
27#include <QFileDialog>
28#endif
29
30FileChooser::FileChooser(QWidget * parent) : QWidget(parent)
31{
32 setupUi(this);
33
34#ifndef NO_SMPLAYER_SUPPORT
35 button->setIcon(Images::icon("find"));
36#else
37 button->setIcon(QIcon(":/find"));
38#endif
39
40 setDialogType(GetFileName);
41 setOptions(0);
42}
43
44FileChooser::~FileChooser() {
45}
46
47QLineEdit * FileChooser::lineEdit() {
48 return line_edit;
49}
50
51QToolButton * FileChooser::toolButton() {
52 return button;
53}
54
55QString FileChooser::text() const {
56 return line_edit->text();
57}
58
59void FileChooser::setText(const QString & text) {
60 line_edit->setText(text);
61}
62
63void FileChooser::on_button_clicked() {
64 QString result;
65 QString f;
66
67 if (dialogType() == GetFileName) {
68 QFileDialog::Options opts = options();
69 if (opts == 0) opts = QFileDialog::DontResolveSymlinks;
70
71#ifndef NO_SMPLAYER_SUPPORT
72 result = MyFileDialog::getOpenFileName(
73#else
74 result = QFileDialog::getOpenFileName(
75#endif
76 this, caption(),
77 line_edit->text(),
78 filter(), &f, opts );
79 }
80 else
81 if (dialogType() == GetDirectory) {
82 QFileDialog::Options opts = options();
83 if (opts == 0) opts = QFileDialog::ShowDirsOnly;
84
85#ifndef NO_SMPLAYER_SUPPORT
86 result = MyFileDialog::getExistingDirectory(
87#else
88 result = QFileDialog::getExistingDirectory(
89#endif
90 this, caption(),
91 line_edit->text(), opts );
92 }
93
94 if (!result.isEmpty()) {
95 QString old_file = line_edit->text();
96 line_edit->setText(result);
97 if (old_file != result) emit fileChanged(result);
98 }
99}
100
101#include "moc_filechooser.cpp"
102
Note: See TracBrowser for help on using the repository browser.