src/lddocument.cpp

changeset 1156
c20ee66b6705
parent 1145
02264bf0108d
child 1159
6ad8cdcd88d9
equal deleted inserted replaced
1155:b0e004c8e3a4 1156:c20ee66b6705
149 // 149 //
150 // Performs safety checks. Do this before closing any files! 150 // Performs safety checks. Do this before closing any files!
151 // 151 //
152 bool LDDocument::isSafeToClose() 152 bool LDDocument::isSafeToClose()
153 { 153 {
154 using msgbox = QMessageBox;
155 setlocale (LC_ALL, "C"); 154 setlocale (LC_ALL, "C");
156 155
157 // If we have unsaved changes, warn and give the option of saving. 156 // If we have unsaved changes, warn and give the option of saving.
158 if (hasUnsavedChanges()) 157 if (hasUnsavedChanges())
159 { 158 {
160 QString message = format (tr ("There are unsaved changes to %1. Should it be saved?"), getDisplayName()); 159 QString message = format(tr("There are unsaved changes to %1. Should it be saved?"), getDisplayName());
161 160
162 int button = msgbox::question (m_window, QObject::tr ("Unsaved Changes"), message, 161 int button = QMessageBox::question (m_window, tr("Unsaved Changes"), message,
163 (msgbox::Yes | msgbox::No | msgbox::Cancel), msgbox::Cancel); 162 (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel), QMessageBox::Cancel);
164 163
165 switch (button) 164 switch (button)
166 { 165 {
167 case msgbox::Yes: 166 case QMessageBox::Yes:
168 { 167 {
169 // If we don't have a file path yet, we have to ask the user for one. 168 // If we don't have a file path yet, we have to ask the user for one.
170 if (name().isEmpty()) 169 if (name().isEmpty())
171 { 170 {
172 QString newpath = QFileDialog::getSaveFileName (m_window, QObject::tr ("Save As"), 171 QString newpath = QFileDialog::getSaveFileName (m_window, QObject::tr ("Save As"),
181 if (not save()) 180 if (not save())
182 { 181 {
183 message = format (QObject::tr ("Failed to save %1 (%2)\nDo you still want to close?"), 182 message = format (QObject::tr ("Failed to save %1 (%2)\nDo you still want to close?"),
184 name(), strerror (errno)); 183 name(), strerror (errno));
185 184
186 if (msgbox::critical (m_window, QObject::tr ("Save Failure"), message, 185 if (QMessageBox::critical (m_window, tr("Save Failure"), message,
187 (msgbox::Yes | msgbox::No), msgbox::No) == msgbox::No) 186 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::No)
188 { 187 {
189 return false; 188 return false;
190 } 189 }
191 } 190 }
192 break; 191 break;
193 } 192 }
194 193
195 case msgbox::Cancel: 194 case QMessageBox::Cancel:
196 return false; 195 return false;
197 196
198 default: 197 default:
199 break; 198 break;
200 } 199 }

mercurial