Changeset 124 for smplayer/trunk/src/filechooser.cpp
- Timestamp:
- Mar 16, 2012, 4:02:47 PM (13 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 121-122
- Property svn:mergeinfo changed
-
smplayer/trunk/src/filechooser.cpp
r119 r124 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 1 Ricardo Villalba <rvm@escomposlinux.org>2 Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 18 18 19 19 #include "filechooser.h" 20 #include <QToolButton> 21 #include <QStyle> 20 22 21 23 //#define NO_SMPLAYER_SUPPORT … … 28 30 #endif 29 31 30 FileChooser::FileChooser(QWidget * parent) : QWidget(parent) 32 QString FileChooser::last_dir; 33 34 FileChooser::FileChooser(QWidget * parent) : LineEditWithIcon(parent) 31 35 { 32 setupUi(this);33 34 #ifndef NO_SMPLAYER_SUPPORT35 button->setIcon(Images::icon("find"));36 #else37 button->setIcon(QIcon(":/find"));38 #endif39 40 36 setDialogType(GetFileName); 41 37 setOptions(0); 38 39 setupButton(); 40 button->setCursor( Qt::PointingHandCursor ); 41 42 connect(button, SIGNAL(clicked()), this, SLOT(openFileDialog())); 42 43 } 43 44 … … 45 46 } 46 47 47 QLineEdit * FileChooser::lineEdit() { 48 return line_edit; 48 void FileChooser::setupButton() { 49 #ifdef NO_SMPLAYER_SUPPORT 50 setIcon( QPixmap(":/folder_open") ); 51 #else 52 setIcon( Images::icon("folder_open") ); 53 #endif 54 button->setToolTip( tr("Click to select a file or folder") ); 49 55 } 50 56 51 QToolButton * FileChooser::toolButton() { 52 return button; 53 } 57 void FileChooser::openFileDialog() { 58 qDebug("FileChooser::openFileDialog"); 54 59 55 QString FileChooser::text() const {56 return line_edit->text();57 }58 59 void FileChooser::setText(const QString & text) {60 line_edit->setText(text);61 }62 63 void FileChooser::on_button_clicked() {64 60 QString result; 65 61 QString f; … … 69 65 if (opts == 0) opts = QFileDialog::DontResolveSymlinks; 70 66 67 QString dir = QFileInfo(text()).absolutePath(); 68 if (dir.isEmpty()) dir = last_dir; 69 if (dir.isEmpty()) dir = QDir::homePath(); 70 71 71 #ifndef NO_SMPLAYER_SUPPORT 72 72 result = MyFileDialog::getOpenFileName( … … 75 75 #endif 76 76 this, caption(), 77 line_edit->text(),77 dir, 78 78 filter(), &f, opts ); 79 if (!result.isEmpty()) last_dir = QFileInfo(result).absolutePath(); 79 80 } 80 81 else … … 82 83 QFileDialog::Options opts = options(); 83 84 if (opts == 0) opts = QFileDialog::ShowDirsOnly; 85 86 QString dir = text(); 87 if (dir.isEmpty()) dir = last_dir; 88 if (dir.isEmpty()) dir = QDir::homePath(); 84 89 85 90 #ifndef NO_SMPLAYER_SUPPORT … … 89 94 #endif 90 95 this, caption(), 91 line_edit->text(), opts ); 96 dir, opts ); 97 if (!result.isEmpty()) last_dir = result; 92 98 } 93 99 94 100 if (!result.isEmpty()) { 95 QString old_file = line_edit->text();96 line_edit->setText(result);101 QString old_file = text(); 102 setText(result); 97 103 if (old_file != result) emit fileChanged(result); 98 104 } … … 100 106 101 107 #include "moc_filechooser.cpp" 102
Note:
See TracChangeset
for help on using the changeset viewer.