From 3839200fec448a4839842c0064ba54e9aa46ac5d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 27 Nov 2018 00:35:29 +0100 Subject: [PATCH] Add a progress bar on startup. --- main.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 8f95304..cf03900 100644 --- a/main.cpp +++ b/main.cpp @@ -39,6 +39,7 @@ extern "C" { #include #include #include +#include #include #include @@ -239,6 +240,8 @@ int main(int argc, char **argv) // TODO: Delete the surface, too. } + load_existing_frames(); + MainWindow main_window; main_window.show(); @@ -247,7 +250,6 @@ int main(int argc, char **argv) init_jpeg_vaapi(); - load_existing_frames(); thread record_thread(record_thread_func); int ret = app.exec(); @@ -361,7 +363,12 @@ void load_frame_file(const char *filename, unsigned filename_idx, DB *db) void load_existing_frames() { - DB db(global_flags.working_directory + "/futatabi.db"); + QProgressDialog progress("Scanning frame directory...", "Abort", 0, 1); + progress.setWindowTitle("Futatabi"); + progress.setWindowModality(Qt::WindowModal); + progress.setMinimumDuration(1000); + progress.setMaximum(1); + progress.setValue(0); string frame_dir = global_flags.working_directory + "/frames"; DIR *dir = opendir(frame_dir.c_str()); @@ -384,13 +391,32 @@ void load_existing_frames() if (de->d_type == DT_REG) { string filename = frame_dir + "/" + de->d_name; - load_frame_file(filename.c_str(), frame_filenames.size(), &db); frame_filenames.push_back(filename); } - } + if (progress.wasCanceled()) { + exit(1); + } + } closedir(dir); + progress.setMaximum(frame_filenames.size() + 2); + progress.setValue(1); + + progress.setLabelText("Opening database..."); + DB db(global_flags.working_directory + "/futatabi.db"); + + progress.setLabelText("Reading frame files..."); + progress.setValue(2); + + for (size_t i = 0; i < frame_filenames.size(); ++i) { + load_frame_file(frame_filenames[i].c_str(), i, &db); + progress.setValue(i + 3); + if (progress.wasCanceled()) { + exit(1); + } + } + if (start_pts == -1) { start_pts = 0; } else { -- 2.39.2