Subversion Repositories Scribus

Rev

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