diff --git a/share/katarakt.ini b/share/katarakt.ini index 00685e9285c94eccf43fb0689641ba41f120210a..2c33eeb01a551ce6f8a71ea24b721e255207bd68 100644 --- a/share/katarakt.ini +++ b/share/katarakt.ini @@ -2,7 +2,7 @@ default_layout=single background_color=0xDF202020 background_color_fullscreen=0xFF000000 -unrendered_page_color=0x80808080 +unrendered_page_color=0x40FFFFFF click_link_button=1 drag_view_button=2 select_text_button=1 diff --git a/src/config.cpp b/src/config.cpp index 1facb064d849e5da3a6f9789054c8ca48dd2306d..98d01b9ba8bd1c2e36877f701287fcc43a9ab5f9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -172,7 +172,12 @@ QVariant CFG::get_most_current_value(const char *key) const { if (tmp_values.contains(key)) { return tmp_values[key]; } else { - return settings.value(QString("Settings/") + key, defaults[key]); +#ifdef DEBUG + if (defaults.find(key) == defaults.end()) { + cout << "missing key " << key << endl; + } +#endif + return settings.value(key, defaults[key]); } } diff --git a/src/dbus/dbus.cpp b/src/dbus/dbus.cpp index ff8a43f03eae0a2e124d9a682728ff0cab2859ff..901d49aa57564f7df23ad03099b843527ece8846 100644 --- a/src/dbus/dbus.cpp +++ b/src/dbus/dbus.cpp @@ -41,6 +41,11 @@ void dbus_init(Viewer *viewer) { } bool activate_katarakt_with_file(QString file) { + if (file.isNull()) { + // always start a new instance if no argument was given + return false; + } + QString filepath = QFileInfo(file).absoluteFilePath(); QDBusConnection bus = QDBusConnection::sessionBus(); QStringList services = bus.interface()->registeredServiceNames().value(); diff --git a/src/main.cpp b/src/main.cpp index 18971e4bfa44023e1cbf3052c61319711ff132cc..7af3b07c52768f7e63754a5b7832c24b5e872ed3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { CFG::get_instance()->set_tmp_value("fullscreen", true); break; case 'q': - CFG::get_instance()->set_tmp_value("Viewer/quit_on_init_fail", optarg); + CFG::get_instance()->set_tmp_value("Settings/quit_on_init_fail", optarg); break; case 'h': print_help(argv[0]); @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { case 's': // (according to QVariant) any string can be converted to // bool, so no type check needed here - CFG::get_instance()->set_tmp_value("single_instance_per_file", optarg); + CFG::get_instance()->set_tmp_value("Settings/single_instance_per_file", optarg); break; case 'c': CFG::write_defaults(optarg); @@ -106,10 +106,13 @@ int main(int argc, char *argv[]) { if (file.isNull()) { return 1; } + } else if (CFG::get_instance()->get_most_current_value("Settings/quit_on_init_fail").toBool()) { + print_help(argv[0]); + return 1; } - // else no argument given, "open" empty string + // else: opens empty window without file - if (CFG::get_instance()->get_most_current_value("single_instance_per_file").toBool()) { + if (CFG::get_instance()->get_most_current_value("Settings/single_instance_per_file").toBool()) { if (activate_katarakt_with_file(file)) { return 0; } diff --git a/src/resourcemanager.cpp b/src/resourcemanager.cpp index b85515f73a331fdf9fcd9cbd5b792cbd14049cbb..bf4009a89463e9daa10b20dd7c9d7c4ce2d13b35 100644 --- a/src/resourcemanager.cpp +++ b/src/resourcemanager.cpp @@ -44,7 +44,10 @@ void ResourceManager::initialize(const QString &file, const QByteArray &password page_count = 0; k_page = NULL; - doc = Poppler::Document::load(file, QByteArray(), password); + doc = NULL; + if (!file.isNull()) { + doc = Poppler::Document::load(file, QByteArray(), password); + } worker = new Worker(this); if (viewer->get_canvas() != NULL) { diff --git a/src/search.cpp b/src/search.cpp index 78e8387a015b6b1ea288149271e97df78a77ddab..7bfaad2274e3a188116ae29f8501ee4226f8ee35 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -164,7 +164,11 @@ SearchBar::SearchBar(const QString &file, Viewer *v, QWidget *parent) : void SearchBar::initialize(const QString &file, const QByteArray &password) { worker = NULL; - doc = Poppler::Document::load(file, QByteArray(), password); + doc = NULL; +// if (!file.isNull()) { // don't print the poppler error message for the second time + if (!file.isEmpty()) { + doc = Poppler::Document::load(file, QByteArray(), password); + } if (doc == NULL) { // poppler already prints a debug message diff --git a/src/viewer.cpp b/src/viewer.cpp index 9f0b45f3fffb52b00e62b0a2a60633bb84630fe1..328e1c5326cf04f957b8a3602652ddab67942c5e 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -35,7 +35,7 @@ Viewer::Viewer(const QString &file, QWidget *parent) : valid(true) { res = new ResourceManager(file, this); if (!res->is_valid()) { - if (CFG::get_instance()->get_most_current_value("Viewer/quit_on_init_fail").toBool()) { + if (CFG::get_instance()->get_most_current_value("Settings/quit_on_init_fail").toBool()) { valid = false; return; } @@ -43,7 +43,7 @@ Viewer::Viewer(const QString &file, QWidget *parent) : search_bar = new SearchBar(file, this, this); if (!search_bar->is_valid()) { - if (CFG::get_instance()->get_most_current_value("Viewer/quit_on_init_fail").toBool()) { + if (CFG::get_instance()->get_most_current_value("Settings/quit_on_init_fail").toBool()) { valid = false; return; }