]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Alert_pimpl.C
reverse last change
[lyx.git] / src / frontends / qt2 / Alert_pimpl.C
1 /**
2  * \file qt2/Alert_pimpl.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include <qmessagebox.h>
18 #include <qlabel.h>
19 #include <qlineedit.h>
20 #include "ui/QAskForTextDialog.h"
21 #include "qt_helpers.h"
22 #include "gettext.h"
23
24 #include <algorithm>
25
26 #include "Alert.h"
27 #include "Alert_pimpl.h"
28
29 #include "BoostFormat.h"
30 #include "gettext.h"
31
32 using std::pair;
33 using std::make_pair;
34
35
36 void alert_pimpl(string const & s1, string const & s2, string const & s3)
37 {
38         QMessageBox::warning(0, "LyX",
39                              toqstr(s1 + '\n' + '\n' + s2 + '\n' + s3));
40 }
41
42
43 bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
44 {
45         return !(QMessageBox::information(0, "LyX", toqstr(s1 + '\n' + s2 + '\n' + s3),
46                 qt_("&Yes"), qt_("&No"), 0, 1));
47 }
48
49
50 int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
51 {
52         return (QMessageBox::information(0, "LyX", toqstr(s1 + '\n' + s2 + '\n' + s3),
53                 qt_("&Yes"), qt_("&No"), qt_("&Cancel"), 0, 2)) + 1;
54 }
55
56
57 pair<bool, string> const
58 askForText_pimpl(string const & msg, string const & dflt)
59 {
60 #if USE_BOOST_FORMAT
61         boost::format fmt(_("LyX: %1$s"));
62         fmt % msg;
63         string const title = fmt.str();
64 #else
65         string const title = _("LyX: ") + msg;
66 #endif
67         QAskForTextDialog d(0, toqstr(title), true);
68         // less than ideal !
69         d.askLA->setText(toqstr('&' + msg));
70         d.askLE->setText(toqstr(dflt));
71         d.askLE->setFocus();
72         int ret = d.exec();
73
74         d.hide();
75
76         if (ret)
77                 return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
78         else
79                 return make_pair<bool, string>(false, string());
80 }