]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Alert_pimpl.C
xforms ? what xforms ?
[lyx.git] / src / frontends / qt2 / Alert_pimpl.C
1 /**
2  * \file qt2/Alert_pimpl.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10
11 #include <qmessagebox.h>
12 #include <qlabel.h>
13 #include <qlineedit.h>
14 #include "ui/QAskForTextDialog.h"
15
16 #include FORMS_H_LOCATION
17
18 #include <algorithm>
19
20 #include <gettext.h>
21
22 #include "Alert.h"
23 #include "Alert_pimpl.h"
24
25 using std::pair;
26 using std::make_pair;
27
28 void alert_pimpl(string const & s1, string const & s2, string const & s3)
29 {
30         QMessageBox::warning(0, "LyX", (s1 + "\n" + "\n" + s2 + "\n" + s3).c_str());
31 }
32
33
34 bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
35 {
36         return !(QMessageBox::information(0, "LyX", (s1 + "\n" + s2 + "\n" + s3).c_str(),
37                 _("&Yes"), _("&No"), 0, 1));
38 }
39
40
41 int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
42 {
43         return (QMessageBox::information(0, "LyX", (s1 + "\n" + s2 + "\n" + s3).c_str(),
44                 _("&Yes"), _("&No"), _("&Cancel"), 0, 2)) + 1;
45 }
46
47
48 pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
49 {
50         string title = _("LyX: ");
51         title += msg;
52
53         QAskForTextDialog d(0, msg.c_str(), true);
54         // less than ideal !
55         d.askLA->setText((string("&") + msg).c_str());
56         d.askLE->setText(dflt.c_str());
57         int ret = d.exec();
58
59         d.hide();
60
61         if (ret)
62                 return make_pair<bool, string>(true, d.askLE->text().latin1());
63         else
64                 return make_pair<bool, string>(false, string());
65 }