void TWLCard::restoreSaveFile(std::string const& filename, void (*cb)(u32, u32)) const { FILE* f = fopen(filename.c_str(), "rb"); if(f == NULL) throw std::runtime_error("cannot open file"); u8* in = new u8[saveSize()]; fread(in, saveSize(), 1, f); fclose(f); try { restoreSaveFile(in, cb); } catch(Error const& e) { delete[] in; throw e; } delete[] in; }
void TWLCard::backupSaveFile(std::string const& filename, void (*cb)(u32, u32)) const { FILE* f = fopen(filename.c_str(), "wb+"); if(f == NULL) throw std::runtime_error("cannot open file"); u8* out = new u8[saveSize()]; try { backupSaveFile(out, cb); } catch(Error const& e) { delete[] out; fclose(f); throw e; } fwrite(out, saveSize(), 1, f); fclose(f); delete[] out; }
void ClockPhotoDialog::slotOk() { // Called when the ok button is pressed. Calculate the time difference // between the photo and the user set datetime information, and store it in // the public variables. // Determine the number of seconds between the dates. int delta = d->photoDateTime->secsTo(d->calendar->dateTime()); // If the photo datetime is newer than the user datetime, it results in // subtraction. if (delta < 0) { deltaNegative = true; delta *= -1; } else { deltaNegative = false; } // Calculate the number of days, hours, minutes and seconds. deltaDays = delta / 86400; delta = delta % 86400; deltaHours = delta / 3600; delta = delta % 3600; deltaMinutes = delta / 60; delta = delta % 60; deltaSeconds = delta; // Accept the dialog. saveSize(); accept(); }
void TWLCard::restoreSaveFile(u8* in, void (*cb)(u32, u32)) const { u32 sz = saveSize(); u32 pageSize = SPIGetPageSize(cardType_); cb(0, sz); for(u32 i = 0; i < sz/pageSize; ++i){ Result res = SPIWriteSaveData(cardType_, pageSize*i, in + pageSize*i, pageSize); if(res != 0) throw Error(res, __FILE__, __LINE__); cb(pageSize*(i+1), sz); } }
void TWLCard::backupSaveFile(u8* out, void (*cb)(u32, u32)) const { u32 sz = saveSize(); u32 sectorSize = (sz < 0x10000) ? sz : 0x10000; cb(0, sz); for(u32 i = 0; i < sz/sectorSize; ++i) { Result res = SPIReadSaveData(cardType_, sectorSize*i, out + sectorSize*i, sectorSize); if(res != 0) throw Error(res, __FILE__, __LINE__); cb(sectorSize*(i+1), sz); } }
void XDialog::closeEvent(QCloseEvent * event) { event->accept(); // we have no reason not to accept and let the script change it if needed _private->callCloseEvent(event); if(event->isAccepted()) { saveSize(); QDialog::closeEvent(event); } }
void PrefInterface::getData(Preferences * pref) { requires_restart = false; language_changed = false; iconset_changed = false; gui_changed = false; style_changed = false; recents_changed = false; if (pref->language != language()) { pref->language = language(); language_changed = true; qDebug("PrefInterface::getData: chosen language: '%s'", pref->language.toUtf8().data()); } if (pref->iconset != iconSet()) { pref->iconset = iconSet(); iconset_changed = true; } if (pref->gui != GUI()) { pref->gui = GUI(); gui_changed = true; } pref->resize_method = resizeMethod(); pref->save_window_size_on_exit = saveSize(); #ifdef SINGLE_INSTANCE pref->use_single_instance = useSingleInstance(); #endif if (pref->history_recents->maxItems() != recentsMaxItems()) { pref->history_recents->setMaxItems( recentsMaxItems() ); recents_changed = true; } pref->seeking1 = seeking1(); pref->seeking2 = seeking2(); pref->seeking3 = seeking3(); pref->seeking4 = seeking4(); pref->update_while_seeking = updateWhileDragging(); pref->relative_seeking= relativeSeeking(); pref->precise_seeking = preciseSeeking(); pref->default_font = defaultFont(); pref->hide_video_window_on_audio_files = hideVideoOnAudioFiles(); #if STYLE_SWITCHING if ( pref->style != style() ) { pref->style = style(); style_changed = true; } #endif pref->floating_control_animated = floatingAnimated(); pref->floating_control_width = floatingWidth(); pref->floating_control_margin = floatingMargin(); pref->floating_display_in_compact_mode = displayFloatingInCompactMode(); #ifndef Q_OS_WIN pref->bypass_window_manager = floatingBypassWindowManager(); #endif }
void ClockPhotoDialog::slotCancel() { /* If the cancel button is clicked, reject the dialog. */ saveSize(); reject(); }