~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/libs/utils/reloadpromptutils.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
using namespace Utils;
38
38
 
39
 
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
40
 
    Utils::reloadPrompt(const QString &fileName, bool modified, QWidget *parent)
 
39
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer Utils::reloadPrompt(const QString &fileName,
 
40
                                                                     bool modified,
 
41
                                                                     QWidget *parent)
41
42
{
42
43
 
43
44
    const QString title = QCoreApplication::translate("Utils::reloadPrompt", "File Changed");
44
45
    QString msg;
45
46
 
46
 
    if (modified)
47
 
        msg = QCoreApplication::translate("Utils::reloadPrompt",
48
 
                                          "The unsaved file <i>%1</i> has been changed outside Qt Creator. Do you want to reload it and discard your changes?");
49
 
    else
50
 
        msg = QCoreApplication::translate("Utils::reloadPrompt",
51
 
                                          "The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
 
47
    if (modified) {
 
48
        msg = QCoreApplication::translate("Utils::reloadPrompt",
 
49
                "The unsaved file <i>%1</i> has changed outside Qt Creator. "
 
50
                "Do you want to reload it and discard your changes?");
 
51
    } else {
 
52
        msg = QCoreApplication::translate("Utils::reloadPrompt",
 
53
                "The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
 
54
    }
52
55
    msg = msg.arg(QFileInfo(fileName).fileName());
53
56
    return reloadPrompt(title, msg, QDir::toNativeSeparators(fileName), parent);
54
57
}
55
58
 
56
 
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
57
 
    Utils::reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent)
 
59
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer Utils::reloadPrompt(const QString &title,
 
60
                                                                     const QString &prompt,
 
61
                                                                     const QString &details,
 
62
                                                                     QWidget *parent)
58
63
{
59
64
    QMessageBox msg(parent);
60
 
    msg.setStandardButtons(QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::Close|QMessageBox::No|QMessageBox::NoToAll);
 
65
    msg.setStandardButtons(QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::Close
 
66
                           | QMessageBox::No | QMessageBox::NoToAll);
61
67
    msg.setDefaultButton(QMessageBox::YesToAll);
62
68
    msg.setWindowTitle(title);
63
69
    msg.setText(prompt);
81
87
QTCREATOR_UTILS_EXPORT Utils::FileDeletedPromptAnswer
82
88
        Utils::fileDeletedPrompt(const QString &fileName, bool triggerExternally, QWidget *parent)
83
89
{
84
 
    const QString title = QCoreApplication::translate("Utils::fileDeletedPrompt", "File has been removed");
 
90
    const QString title = QCoreApplication::translate("Utils::fileDeletedPrompt",
 
91
                                                      "File has been removed");
85
92
    QString msg;
86
 
    if (triggerExternally)
87
 
        msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
88
 
                                          "The file %1 has been removed outside Qt Creator. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName));
89
 
    else
90
 
        msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
91
 
                                          "The file %1 was removed. Do you want to save it under a different name, or close the editor?").arg(QDir::toNativeSeparators(fileName));
 
93
    if (triggerExternally) {
 
94
        msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
 
95
                                          "The file %1 has been removed outside Qt Creator. "
 
96
                                          "Do you want to save it under a different name, or close "
 
97
                                          "the editor?").arg(QDir::toNativeSeparators(fileName));
 
98
    } else {
 
99
        msg = QCoreApplication::translate("Utils::fileDeletedPrompt",
 
100
                                          "The file %1 was removed. "
 
101
                                          "Do you want to save it under a different name, or close "
 
102
                                          "the editor?").arg(QDir::toNativeSeparators(fileName));
 
103
    }
92
104
    QMessageBox box(QMessageBox::Question, title, msg, QMessageBox::NoButton, parent);
93
 
    QPushButton *close = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"), QMessageBox::RejectRole);
94
 
    QPushButton *saveas = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."), QMessageBox::ActionRole);
95
 
    QPushButton *save = box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"), QMessageBox::AcceptRole);
 
105
    QPushButton *close =
 
106
            box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Close"),
 
107
                          QMessageBox::RejectRole);
 
108
    QPushButton *closeAll =
 
109
            box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "C&lose All"),
 
110
                          QMessageBox::RejectRole);
 
111
    QPushButton *saveas =
 
112
            box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "Save &as..."),
 
113
                          QMessageBox::ActionRole);
 
114
    QPushButton *save =
 
115
            box.addButton(QCoreApplication::translate("Utils::fileDeletedPrompt", "&Save"),
 
116
                          QMessageBox::AcceptRole);
96
117
    box.setDefaultButton(saveas);
97
118
    box.exec();
98
119
    QAbstractButton *clickedbutton = box.clickedButton();
99
120
    if (clickedbutton == close)
100
121
        return FileDeletedClose;
 
122
    else if (clickedbutton == closeAll)
 
123
        return FileDeletedCloseAll;
101
124
    else if (clickedbutton == saveas)
102
125
        return FileDeletedSaveAs;
103
126
    else if (clickedbutton == save)