71 } else { |
71 } else { |
72 setlocale (LC_ALL, "C"); |
72 setlocale (LC_ALL, "C"); |
73 |
73 |
74 // Tell the user the save failed, and give the option for saving as with it. |
74 // Tell the user the save failed, and give the option for saving as with it. |
75 QMessageBox dlg (QMessageBox::Critical, "Save Failure", |
75 QMessageBox dlg (QMessageBox::Critical, "Save Failure", |
76 format ("Failed to save to %s\nReason: %s", path.chars(), strerror (g_curfile->lastError)), |
76 fmt ("Failed to save to %s\nReason: %s", path.chars(), strerror (g_curfile->lastError)), |
77 QMessageBox::Close, g_win); |
77 QMessageBox::Close, g_win); |
78 |
78 |
79 QPushButton* saveAsBtn = new QPushButton ("Save As"); |
79 QPushButton* saveAsBtn = new QPushButton ("Save As"); |
80 saveAsBtn->setIcon (getIcon ("file-save-as")); |
80 saveAsBtn->setIcon (getIcon ("file-save-as")); |
81 dlg.addButton (saveAsBtn, QMessageBox::ActionRole); |
81 dlg.addButton (saveAsBtn, QMessageBox::ActionRole); |
102 } |
102 } |
103 |
103 |
104 // ============================================================================= |
104 // ============================================================================= |
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
106 // ============================================================================= |
106 // ============================================================================= |
107 MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME_DISPLAY ".", (0)) { |
107 MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME ".", (0)) { |
108 ConfigDialog::staticDialog (); |
108 ConfigDialog::staticDialog (); |
109 } |
109 } |
110 |
110 |
111 // ============================================================================= |
111 // ============================================================================= |
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
113 // ============================================================================= |
113 // ============================================================================= |
114 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".", CTRL (Q)) { |
114 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME ".", CTRL (Q)) { |
115 exit (0); |
115 exit (0); |
116 } |
116 } |
117 |
117 |
118 // ============================================================================= |
118 // ============================================================================= |
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
160 |
160 |
161 LDObject* obj = g_win->sel ()[0]; |
161 LDObject* obj = g_win->sel ()[0]; |
162 AddObjectDialog::staticDialog (obj->getType (), obj); |
162 AddObjectDialog::staticDialog (obj->getType (), obj); |
163 } |
163 } |
164 |
164 |
165 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.", KEY (F1)) { |
165 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME " help manual.", KEY (F1)) { |
166 |
166 |
167 } |
167 } |
168 |
168 |
169 // ============================================================================= |
169 // ============================================================================= |
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
171 // ============================================================================= |
171 // ============================================================================= |
172 MAKE_ACTION (about, "About " APPNAME_DISPLAY, "ldforge", |
172 MAKE_ACTION (about, "About " APPNAME, "ldforge", |
173 "Shows information about " APPNAME_DISPLAY ".", CTRL (F1)) |
173 "Shows information about " APPNAME ".", CTRL (F1)) |
174 { |
174 { |
175 AboutDialog dlg; |
175 AboutDialog dlg; |
176 dlg.exec (); |
176 dlg.exec (); |
177 } |
177 } |
178 |
178 |
283 if (!~fname) |
283 if (!~fname) |
284 return; |
284 return; |
285 |
285 |
286 FILE* fp = fopen (fname, "r"); |
286 FILE* fp = fopen (fname, "r"); |
287 if (!fp) { |
287 if (!fp) { |
288 critical (format ("Couldn't open %s\n%s", fname.chars(), strerror (errno))); |
288 critical (fmt ("Couldn't open %s\n%s", fname.chars(), strerror (errno))); |
289 return; |
289 return; |
290 } |
290 } |
291 |
291 |
292 std::vector<LDObject*> historyCopies; |
292 std::vector<LDObject*> historyCopies; |
293 std::vector<ulong> historyIndices; |
293 std::vector<ulong> historyIndices; |
325 std::vector<ulong> historyIndices; |
325 std::vector<ulong> historyIndices; |
326 |
326 |
327 layout->addWidget (te_edit); |
327 layout->addWidget (te_edit); |
328 layout->addWidget (bbx_buttons); |
328 layout->addWidget (bbx_buttons); |
329 dlg->setLayout (layout); |
329 dlg->setLayout (layout); |
330 dlg->setWindowTitle (APPNAME_DISPLAY ": Insert Raw"); |
330 dlg->setWindowTitle (APPNAME ": Insert Raw"); |
331 dlg->connect (bbx_buttons, SIGNAL (accepted ()), dlg, SLOT (accept ())); |
331 dlg->connect (bbx_buttons, SIGNAL (accepted ()), dlg, SLOT (accept ())); |
332 dlg->connect (bbx_buttons, SIGNAL (rejected ()), dlg, SLOT (reject ())); |
332 dlg->connect (bbx_buttons, SIGNAL (rejected ()), dlg, SLOT (reject ())); |
333 |
333 |
334 if (dlg->exec () == false) |
334 if (dlg->exec () == false) |
335 return; |
335 return; |
367 |
367 |
368 str root = basename (g_curfile->m_filename.chars ()); |
368 str root = basename (g_curfile->m_filename.chars ()); |
369 if (root.substr (~root - 4, -1) == ".dat") |
369 if (root.substr (~root - 4, -1) == ".dat") |
370 root -= 4; |
370 root -= 4; |
371 |
371 |
372 str defaultname = (~root > 0) ? format ("%s.png", root.chars ()) : ""; |
372 str defaultname = (~root > 0) ? fmt ("%s.png", root.chars ()) : ""; |
373 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
373 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
374 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
374 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
375 |
375 |
376 if (~fname > 0 && !img.save (fname)) |
376 if (~fname > 0 && !img.save (fname)) |
377 critical (format ("Couldn't open %s for writing to save screencap: %s", fname.chars(), strerror (errno))); |
377 critical (fmt ("Couldn't open %s for writing to save screencap: %s", fname.chars(), strerror (errno))); |
378 |
378 |
379 delete[] imagedata; |
379 delete[] imagedata; |
380 } |
380 } |
381 |
381 |
382 // ============================================================================= |
382 // ============================================================================= |