Subversion Repositories Scribus

Rev

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