diff --git a/examples/ragephoto-gtkviewer/src/PhotoViewer.cpp b/examples/ragephoto-gtkviewer/src/PhotoViewer.cpp index a32fd4e..3a31752 100644 --- a/examples/ragephoto-gtkviewer/src/PhotoViewer.cpp +++ b/examples/ragephoto-gtkviewer/src/PhotoViewer.cpp @@ -29,7 +29,7 @@ PhotoViewer::PhotoViewer(Gtk::Window *win) : p_win(win) { } -void PhotoViewer::open_file(const char *filename) +void PhotoViewer::open_file(const std::string &filename) { if (p_image) p_image.clear(); @@ -39,7 +39,7 @@ void PhotoViewer::open_file(const char *filename) // Read file std::ifstream ifs(filename, std::ios::in | std::ios::binary); if (!ifs.is_open()) { - Gtk::MessageDialog msg(*p_win, "Failed to open file: " + Glib::ustring(filename), false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msg(*p_win, "Failed to open file: " + filename, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); msg.set_title("Open Photo"); msg.run(); return; @@ -52,7 +52,7 @@ void PhotoViewer::open_file(const char *filename) if (!loaded) { const RagePhoto::Error error = ragePhoto.error(); if (error <= RagePhoto::Error::PhotoReadError) { - Gtk::MessageDialog msg(*p_win, "Failed to read photo: " + Glib::ustring(filename), false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msg(*p_win, "Failed to read photo: " + filename, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); msg.set_title("Open Photo"); msg.run(); return; diff --git a/examples/ragephoto-gtkviewer/src/PhotoViewer.h b/examples/ragephoto-gtkviewer/src/PhotoViewer.h index 5c1a122..1b1f5ab 100644 --- a/examples/ragephoto-gtkviewer/src/PhotoViewer.h +++ b/examples/ragephoto-gtkviewer/src/PhotoViewer.h @@ -27,7 +27,7 @@ class PhotoViewer : public Gtk::DrawingArea { public: PhotoViewer(Gtk::Window *win); - void open_file(const char *filename); + void open_file(const std::string &filename); protected: bool on_draw(const Cairo::RefPtr& cr) override; diff --git a/examples/ragephoto-gtkviewer/src/main.cpp b/examples/ragephoto-gtkviewer/src/main.cpp index b727121..a1e4e56 100644 --- a/examples/ragephoto-gtkviewer/src/main.cpp +++ b/examples/ragephoto-gtkviewer/src/main.cpp @@ -96,14 +96,14 @@ int main(int argc, char *argv[]) app->signal_open().connect([&](const Gio::Application::type_vec_files &files, const Glib::ustring &hint) { if (files.size() == 1) { for (const auto &file : files) { - photo_viewer.open_file(file->get_path().c_str()); + photo_viewer.open_file(file->get_path()); } app->add_window(win); - win.show(); + win.present(); } else { app->add_window(win); - win.show(); + win.present(); Gtk::MessageDialog msg(win, "Can't open multiple photos at once!", false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); msg.set_title("RagePhoto GTK Photo Viewer"); msg.run(); @@ -114,6 +114,7 @@ int main(int argc, char *argv[]) vertical_box.show(); win.add(vertical_box); + win.present(); return app->run(win); } diff --git a/examples/ragephoto-qtviewer/src/main.cpp b/examples/ragephoto-qtviewer/src/main.cpp index c26664a..5bf58a6 100644 --- a/examples/ragephoto-qtviewer/src/main.cpp +++ b/examples/ragephoto-qtviewer/src/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) QMainWindow mainWindow; mainWindow.setWindowTitle("RagePhoto Qt Photo Viewer"); - mainWindow.setFixedSize(400, 100); + mainWindow.setFixedSize(400, 0); QWidget centralWidget(&mainWindow); mainWindow.setCentralWidget(¢ralWidget); @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) verticalLayout.setContentsMargins(0, 0, 0, 0); verticalLayout.setSpacing(6); - QLabel photoLabel(&mainWindow); + QLabel photoLabel(¢ralWidget); verticalLayout.addWidget(&photoLabel); QHBoxLayout horizontalLayout; @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) horizontalLayout.setSpacing(6); verticalLayout.addLayout(&horizontalLayout); - QPushButton openButton("Open", &mainWindow); + QPushButton openButton("Open", ¢ralWidget); if (QIcon::hasThemeIcon("document-open")) openButton.setIcon(QIcon::fromTheme("document-open")); QObject::connect(&openButton, &QPushButton::clicked, &mainWindow, [&](){ @@ -98,12 +98,14 @@ int main(int argc, char *argv[]) }); } }); + openButton.setAutoDefault(true); horizontalLayout.addWidget(&openButton); - QPushButton closeButton("Close", &mainWindow); + QPushButton closeButton("Close", ¢ralWidget); if (QIcon::hasThemeIcon("dialog-close")) closeButton.setIcon(QIcon::fromTheme("dialog-close")); QObject::connect(&closeButton, &QPushButton::clicked, &mainWindow, &QMainWindow::close); + closeButton.setAutoDefault(true); horizontalLayout.addWidget(&closeButton); const QStringList args = app.arguments();