Subversion Repositories Scribus

Rev

Rev 18611 | Rev 19153 | 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
 
18154 jghali 13
#include "scescapecatcher.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
 
18154 jghali 37
        ScEscapeCatcher* keyCatcher = new ScEscapeCatcher(this);
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()));
43
 
10250 fschmid 44
        QList<QPushButton *> b = findChildren<QPushButton *>();
10245 cbradney 45
        QListIterator<QPushButton *> i(b);
46
        while (i.hasNext())
47
                i.next()->setVisible(false);
10242 subik 48
        setMinimumSize(QSize(480, 310));
49
        setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
50
}
51
 
52
QString ScFileWidget::selectedFile()
53
{
54
        QStringList l(selectedFiles());
55
        if (l.count() == 0)
56
                return QString();
57
        return l.at(0);
58
}
14198 fschmid 59
 
18611 jghali 60
/* Hack to make the previews in our file dialogs useable again
14198 fschmid 61
   needed e.g on OpenSuse patched Qt versions */
62
void ScFileWidget::accept()
63
{
18204 fschmid 64
#ifndef Q_OS_LINUX
14243 jghali 65
        QFileDialog::accept();
66
#endif
14198 fschmid 67
}