Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
103 Franz 1
#include "cmddialog.h"
332 Franz 2
#include "cmdutil.h"
418 Franz 3
#include "valuedialog.h"
792 subik 4
 
138 Franz 5
#include <qmessagebox.h>
645 fschmid 6
#include <qcursor.h>
792 subik 7
 
934 subik 8
PyObject *scribus_newdocdia(PyObject */*self*/)
82 Franz 9
{
645 fschmid 10
        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
82 Franz 11
        bool ret = Carrier->slotFileNew();
645 fschmid 12
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
173 Franz 13
//      qApp->processEvents();
82 Franz 14
        return PyInt_FromLong(static_cast<long>(ret));
15
}
16
 
934 subik 17
PyObject *scribus_filedia(PyObject */*self*/, PyObject* args, PyObject* kw)
82 Franz 18
{
934 subik 19
        char *caption = const_cast<char*>("");
20
        char *filter = const_cast<char*>("");
21
        char *defName = const_cast<char*>("");
899 cbradney 22
        int haspreview = 0;
23
        int issave = 0;
934 subik 24
        char* kwargs[] = {const_cast<char*>("caption"), const_cast<char*>("filter"),
25
                                                const_cast<char*>("defaultname"), const_cast<char*>("haspreview"),
951 subik 26
                                                const_cast<char*>("issave"), NULL};
900 cbradney 27
        if (!PyArg_ParseTupleAndKeywords(args, kw, "es|esesii", kwargs,
28
                                                                         "utf-8", &caption, "utf-8", &filter, "utf-8", &defName,
29
                                                                         &haspreview, &issave))
332 Franz 30
                return NULL;
645 fschmid 31
        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
900 cbradney 32
        QString fName = Carrier->CFileDialog(".", QString::fromUtf8(caption), QString::fromUtf8(filter),
33
                                                                                 QString::fromUtf8(defName), static_cast<bool>(haspreview),
34
                                                                                 static_cast<bool>(issave), 0, 0);
645 fschmid 35
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
900 cbradney 36
        // FIXME: filename return unicode OK?
645 fschmid 37
        return PyString_FromString(fName.utf8());
82 Franz 38
}
39
 
934 subik 40
PyObject *scribus_messdia(PyObject */*self*/, PyObject* args, PyObject* kw)
138 Franz 41
{
934 subik 42
        char *caption = const_cast<char*>("");
43
        char *message = const_cast<char*>("");
645 fschmid 44
        uint result;
138 Franz 45
        QMessageBox::Icon ico = QMessageBox::NoIcon;
899 cbradney 46
        int butt1 = QMessageBox::Ok|QMessageBox::Default;
138 Franz 47
        int butt2 = QMessageBox::NoButton;
48
        int butt3 = QMessageBox::NoButton;
934 subik 49
        char* kwargs[] = {const_cast<char*>("caption"), const_cast<char*>("message"),
50
                                                const_cast<char*>("icon"), const_cast<char*>("button1"),
951 subik 51
                                                const_cast<char*>("button2"), const_cast<char*>("button3"), NULL};
900 cbradney 52
        if (!PyArg_ParseTupleAndKeywords(args, kw, "eses|iiii", kwargs, "utf-8", &caption, "utf-8", &message, &ico, &butt1, &butt2, &butt3))
138 Franz 53
                return NULL;
645 fschmid 54
        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
900 cbradney 55
        QMessageBox mb(QString::fromUtf8(caption), QString::fromUtf8(message), ico, butt1, butt2, butt3, Carrier);
645 fschmid 56
        result = mb.exec();
57
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
58
        return PyInt_FromLong(static_cast<long>(result));
138 Franz 59
}
60
 
934 subik 61
PyObject *scribus_valdialog(PyObject */*self*/, PyObject* args)
418 Franz 62
{
934 subik 63
        char *caption = const_cast<char*>("");
64
        char *message = const_cast<char*>("");
418 Franz 65
        char *value = "";
900 cbradney 66
        if (!PyArg_ParseTuple(args, "eses|es", "utf-8", &caption, "utf-8", &message, "utf-8", &value))
418 Franz 67
                return NULL;
645 fschmid 68
        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
418 Franz 69
        ValueDialog *d = new ValueDialog(Carrier, "d", TRUE, 0);
900 cbradney 70
        d->dialogLabel->setText(QString::fromUtf8(message));
71
        d->valueEdit->setText(QString::fromUtf8(value));
72
        d->setCaption(QString::fromUtf8(caption));
418 Franz 73
        d->exec();
645 fschmid 74
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
418 Franz 75
        return PyString_FromString(d->valueEdit->text().utf8());
76
}