Subversion Repositories Scribus

Rev

Rev 15422 | Rev 18611 | 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
{
19
        setSizeGripEnabled(false);
20
        setModal(false);
21
        setViewMode(QFileDialog::List);
22
        setWindowFlags(Qt::Widget);
15422 craig 23
 
24
#ifdef Q_OS_MAC
25
        QList<QUrl> urls;
26
        QUrl computer(QUrl::fromLocalFile(QLatin1String("")));
27
        if (!urls.contains(computer))
28
                urls << computer;
29
        QUrl volumes(QUrl::fromLocalFile("/Volumes"));
30
        if (!urls.contains(volumes))
31
                urls << volumes;
32
        //desktop too?  QUrl computer(QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)));
33
        setSidebarUrls(urls);
34
#endif
35
 
18154 jghali 36
        ScEscapeCatcher* keyCatcher = new ScEscapeCatcher(this);
37
        QList<QListView *> lv = findChildren<QListView *>();
38
        QListIterator<QListView *> lvi(lv);
39
        while (lvi.hasNext())
40
                lvi.next()->installEventFilter(keyCatcher);
41
        connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject()));
42
 
10250 fschmid 43
        QList<QPushButton *> b = findChildren<QPushButton *>();
10245 cbradney 44
        QListIterator<QPushButton *> i(b);
45
        while (i.hasNext())
46
                i.next()->setVisible(false);
10242 subik 47
        setMinimumSize(QSize(480, 310));
48
        setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
49
}
50
 
51
QString ScFileWidget::selectedFile()
52
{
53
        QStringList l(selectedFiles());
54
        if (l.count() == 0)
55
                return QString();
56
        return l.at(0);
57
}
14198 fschmid 58
 
59
/* Hack to make the previews in our Fildialogs useable again
60
   needed e.g on OpenSuse patched Qt versions */
61
void ScFileWidget::accept()
62
{
14243 jghali 63
#ifndef Q_WS_X11
64
        QFileDialog::accept();
65
#endif
14198 fschmid 66
}