Ignore:
Timestamp:
Mar 16, 2012, 4:02:47 PM (13 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: 0.7.1 trunk update

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/filechooser.cpp

    r119 r124  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org>
     2    Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    1818
    1919#include "filechooser.h"
     20#include <QToolButton>
     21#include <QStyle>
    2022
    2123//#define NO_SMPLAYER_SUPPORT
     
    2830#endif
    2931
    30 FileChooser::FileChooser(QWidget * parent) : QWidget(parent)
     32QString FileChooser::last_dir;
     33
     34FileChooser::FileChooser(QWidget * parent) : LineEditWithIcon(parent)
    3135{
    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 
    4036        setDialogType(GetFileName);
    4137        setOptions(0);
     38
     39        setupButton();
     40        button->setCursor( Qt::PointingHandCursor );
     41
     42        connect(button, SIGNAL(clicked()), this, SLOT(openFileDialog()));
    4243}
    4344
     
    4546}
    4647
    47 QLineEdit * FileChooser::lineEdit() {
    48         return line_edit;
     48void 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") );
    4955}
    5056
    51 QToolButton * FileChooser::toolButton() {
    52         return button;
    53 }
     57void FileChooser::openFileDialog() {
     58        qDebug("FileChooser::openFileDialog");
    5459
    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() {
    6460        QString result;
    6561        QString f;
     
    6965                if (opts == 0) opts = QFileDialog::DontResolveSymlinks;
    7066
     67                QString dir = QFileInfo(text()).absolutePath();
     68                if (dir.isEmpty()) dir = last_dir;
     69                if (dir.isEmpty()) dir = QDir::homePath();
     70
    7171#ifndef NO_SMPLAYER_SUPPORT
    7272                result = MyFileDialog::getOpenFileName(
     
    7575#endif
    7676                        this, caption(),
    77                         line_edit->text(),
     77                        dir,
    7878                        filter(), &f, opts );
     79                if (!result.isEmpty()) last_dir = QFileInfo(result).absolutePath();
    7980        }
    8081        else
     
    8283                QFileDialog::Options opts = options();
    8384                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();
    8489
    8590#ifndef NO_SMPLAYER_SUPPORT
     
    8994#endif
    9095                    this, caption(),
    91                     line_edit->text(), opts );
     96                    dir, opts );
     97                if (!result.isEmpty()) last_dir = result;
    9298        }
    9399
    94100        if (!result.isEmpty()) {
    95                 QString old_file = line_edit->text();
    96                 line_edit->setText(result);
     101                QString old_file = text();
     102                setText(result);
    97103                if (old_file != result) emit fileChanged(result);
    98104        }
     
    100106
    101107#include "moc_filechooser.cpp"
    102 
Note: See TracChangeset for help on using the changeset viewer.