void MainWindow::on_actionCloudstorageopen_triggered() { if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file."))) return; QString filename; if (getCloudURL(filename)) { getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error); return; } qDebug() << filename; closeCurrentFile(); int error; QByteArray fileNamePtr = QFile::encodeName(filename); error = parse_file(fileNamePtr.data()); if (!error) { set_filename(fileNamePtr.data(), true); setTitle(MWTF_FILENAME); } getNotificationWidget()->hideNotification(); process_dives(false, false); refreshDisplay(); ui.actionAutoGroup->setChecked(autogroup); }
// indicate to save the unsaved and untitiled void PicEditWindow::closeEvent(QCloseEvent *event){ if(okToClose()){ event->accept(); }else{ event->ignore(); } }
void MainWindow::quitProgram() { if (!okToClose()) return; writeSettings(); disconnectFromServer(); qApp->quit(); }
/*--------------------------------------- Protect events -----------------------------------------*/ void MainWindow::closeEvent(QCloseEvent *event){ // if the whole program is ok to close if(okToClose()){ // close all the subwindow first, and this will encounter the save action of those documents mdiArea->closeAllSubWindows(); // if successfully closed all the subwindow, event will be accept if(!mdiArea->subWindowList().isEmpty()){ event->ignore(); }else{ writeSettings(); event->accept(); } } }
void MainWindow::closeEvent(QCloseEvent *event) { if (settings.trayicon && settings.minimizeonclose) { hide(); ui->actionShowHide->setText(tr("Show")); event->ignore(); return; } if (okToClose()) { writeSettings(); disconnectFromServer(); qApp->quit(); return; } event->ignore(); }
void MainWindow::on_actionOpen_triggered() { if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file."))) return; // yes, this look wrong to use getSaveFileName() for the open dialog, but we need to be able // to enter file names that don't exist in order to use our git syntax /path/to/dir[branch] // with is a potentially valid input, but of course won't exist. So getOpenFileName() wouldn't work QFileDialog dialog(this, tr("Open file"), lastUsedDir(), filter()); dialog.setFileMode(QFileDialog::AnyFile); dialog.setViewMode(QFileDialog::Detail); dialog.setLabelText(QFileDialog::Accept, tr("Open")); dialog.setLabelText(QFileDialog::Reject, tr("Cancel")); QStringList filenames; if (dialog.exec()) filenames = dialog.selectedFiles(); if (filenames.isEmpty()) return; updateLastUsedDir(QFileInfo(filenames.first()).dir().path()); closeCurrentFile(); loadFiles(filenames); }
void MainWindow::on_actionClose_triggered() { if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) closeCurrentFile(); }