Subversion Repositories Scribus

Rev

Rev 18771 | Rev 19168 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10242 subik 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
15422 craig 7
 
8
#include <QDesktopServices>
18154 jghali 9
#include <QListView>
10242 subik 10
#include <QPushButton>
15422 craig 11
#include <QUrl>
10242 subik 12
 
19153 craig 13
#include "filedialogeventcatcher.h"
10242 subik 14
#include "scfilewidget.h"
15
 
16
 
15422 craig 17
ScFileWidget::ScFileWidget(QWidget * parent) : QFileDialog(parent, Qt::Widget)
10242 subik 18
{
18771 jghali 19
        setOption(QFileDialog::DontUseNativeDialog);
10242 subik 20
        setSizeGripEnabled(false);
21
        setModal(false);
22
        setViewMode(QFileDialog::List);
23
        setWindowFlags(Qt::Widget);
15422 craig 24
 
25
#ifdef Q_OS_MAC
26
        QList<QUrl> urls;
27
        QUrl computer(QUrl::fromLocalFile(QLatin1String("")));
28
        if (!urls.contains(computer))
29
                urls << computer;
30
        QUrl volumes(QUrl::fromLocalFile("/Volumes"));
31
        if (!urls.contains(volumes))
32
                urls << volumes;
33
        //desktop too?  QUrl computer(QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)));
34
        setSidebarUrls(urls);
35
#endif
36
 
19153 craig 37
        FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this);
18154 jghali 38
        QList<QListView *> lv = findChildren<QListView *>();
39
        QListIterator<QListView *> lvi(lv);
40
        while (lvi.hasNext())
41
                lvi.next()->installEventFilter(keyCatcher);
42
        connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject()));
19153 craig 43
        connect(keyCatcher, SIGNAL(dropLocation(QString)), this, SLOT(locationDropped(QString)));
18154 jghali 44
 
10250 fschmid 45
        QList<QPushButton *> b = findChildren<QPushButton *>();
10245 cbradney 46
        QListIterator<QPushButton *> i(b);
47
        while (i.hasNext())
48
                i.next()->setVisible(false);
10242 subik 49
        setMinimumSize(QSize(480, 310));
50
        setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
51
}
52
 
53
QString ScFileWidget::selectedFile()
54
{
55
        QStringList l(selectedFiles());
56
        if (l.count() == 0)
57
                return QString();
58
        return l.at(0);
59
}
14198 fschmid 60
 
18611 jghali 61
/* Hack to make the previews in our file dialogs useable again
14198 fschmid 62
   needed e.g on OpenSuse patched Qt versions */
63
void ScFileWidget::accept()
64
{
18204 fschmid 65
#ifndef Q_OS_LINUX
14243 jghali 66
        QFileDialog::accept();
67
#endif
14198 fschmid 68
}
19153 craig 69
 
70
void ScFileWidget::locationDropped(QString dl)
71
{
72
        setDirectory(dl);
73
}