]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Alert_pimpl.C
the qtclean-2 patch with some very small changes
[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
22 #include <algorithm>
23
24 #include <gettext.h>
25
26 #include "Alert.h"
27 #include "Alert_pimpl.h"
28
29 using std::pair;
30 using std::make_pair;
31
32
33 void alert_pimpl(string const & s1, string const & s2, string const & s3)
34 {
35         QMessageBox::warning(0, "LyX",
36                              (s1 + "\n" + "\n" + s2 + "\n" + s3).c_str());
37 }
38
39
40 bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
41 {
42         return !(QMessageBox::information(0, "LyX", (s1 + "\n" + s2 + "\n" + s3).c_str(),
43                 _("&Yes"), _("&No"), 0, 1));
44 }
45
46
47 int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
48 {
49         return (QMessageBox::information(0, "LyX", (s1 + "\n" + s2 + "\n" + s3).c_str(),
50                 _("&Yes"), _("&No"), _("&Cancel"), 0, 2)) + 1;
51 }
52
53
54 pair<bool, string> const
55 askForText_pimpl(string const & msg, string const & dflt)
56 {
57         string title = _("LyX: ");
58         title += msg;
59
60         QAskForTextDialog d(0, title.c_str(), true);
61         // less than ideal !
62         d.askLA->setText((string("&") + msg).c_str());
63         d.askLE->setText(dflt.c_str());
64         d.askLE->setFocus();
65         int ret = d.exec();
66
67         d.hide();
68
69         if (ret)
70                 return make_pair<bool, string>(true, d.askLE->text().latin1());
71         else
72                 return make_pair<bool, string>(false, string());
73 }