Skip to content

Commit

Permalink
Add tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrm committed Jul 19, 2021
1 parent 09d423e commit 5528ab4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pdf_viewer/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern float MOVE_SCREEN_PERCENTAGE;
extern float BACKGROUND_COLOR[3];
extern bool FLAT_TABLE_OF_CONTENTS;
extern bool SHOULD_USE_MULTIPLE_MONITORS;
extern bool SHOULD_LOAD_TUTORIAL_WHEN_NO_OTHER_FILE;
extern std::wstring LIBGEN_ADDRESS;
extern std::wstring GOOGLE_SCHOLAR_ADDRESS;

Expand Down Expand Up @@ -108,6 +109,8 @@ ConfigManager::ConfigManager(const std::filesystem::path& default_path, const st
configs.push_back({ L"move_screen_percentage", &MOVE_SCREEN_PERCENTAGE, float_serializer, float_deserializer });
configs.push_back({ L"flat_toc", &FLAT_TABLE_OF_CONTENTS, bool_serializer, bool_deserializer });
configs.push_back({ L"should_use_multiple_monitors", &SHOULD_USE_MULTIPLE_MONITORS, bool_serializer, bool_deserializer });
configs.push_back({ L"should_load_tutorial_when_no_other_file", &SHOULD_LOAD_TUTORIAL_WHEN_NO_OTHER_FILE, bool_serializer, bool_deserializer });
//extern bool should_load_tutorial_when_no_other_file = false;

std::wifstream default_infile(default_path);
std::wifstream user_infile(user_path);
Expand Down
9 changes: 7 additions & 2 deletions pdf_viewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//todo: autocomplete in command window
//todo: simplify word selection logic (also avoid inefficient extra insertions followed by clears in selected_characters)
//todo: make it so that all commands that change document state (for example goto_offset_withing_page, goto_link, etc.) do not change the document
// state, instead they return a DocumentViewState object that is then applied using push_state and chnage_state functions
// state, instead they return a DocumentViewState object that is then applied using push_state and change_state functions
// (chnage state should be a function that just applies the state without pushing it to history)
//todo: pdf live reload has some weird bugs. probably caused by inappropriate use of mupdf.
//todo: make tutorial file smaller

#include <iostream>
#include <vector>
Expand Down Expand Up @@ -94,6 +94,7 @@ extern bool FLAT_TABLE_OF_CONTENTS = false;
extern bool SHOULD_USE_MULTIPLE_MONITORS = false;
extern std::wstring LIBGEN_ADDRESS = L"";
extern std::wstring GOOGLE_SCHOLAR_ADDRESS = L"";
extern bool SHOULD_LOAD_TUTORIAL_WHEN_NO_OTHER_FILE = false;

extern std::filesystem::path last_path_file_absolute_location = "";
extern std::filesystem::path parent_path = "";
Expand Down Expand Up @@ -188,6 +189,10 @@ int main(int argc, char* args[]) {
LAUNCHED_FROM_FILE_ICON = true;
}

if ((file_path.size() == 0) && SHOULD_LOAD_TUTORIAL_WHEN_NO_OTHER_FILE) {
file_path = parent_path / "tutorial.pdf";
}

DocumentManager document_manager(mupdf_context, db);

QFileSystemWatcher pref_file_watcher;
Expand Down
3 changes: 3 additions & 0 deletions pdf_viewer/prefs.config
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ status_label_stylesheet background-color: black; color: white; borde
flat_toc 0
# If it is 1, when launching the application if we detect multiple monitors, we automatically launch the helper window in second monitor
should_use_multiple_monitors 0

# if the last opened document is empty, load the tutorial pdf instead
should_load_tutorial_when_no_other_file 1

0 comments on commit 5528ab4

Please sign in to comment.