gui2/tscreenshot_notification: New GUI2 dialog shown when taking screenshots
It includes the following features: * A cleaner and more structured message display * Buttons to copy the screenshot file path to clipboard or open it with an external application defined by the platform * An additional button to browse to the screenshots folder using an external file manager defined by the platform It also breaks the scons build. This will be addressed by the next commit.
This commit is contained in:
parent
a9298e1d6d
commit
47ffd9ea2d
7 changed files with 392 additions and 3 deletions
221
data/gui/default/window/screenshot_notification.cfg
Normal file
221
data/gui/default/window/screenshot_notification.cfg
Normal file
|
@ -0,0 +1,221 @@
|
|||
#textdomain wesnoth-lib
|
||||
|
||||
#define __GUI_FILENAME_OPTIONS_GRID
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
[text_box]
|
||||
id = "path"
|
||||
definition = "default"
|
||||
label = ""
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
[button]
|
||||
id = "copy"
|
||||
definition = "action_copy"
|
||||
label = _ "filesystem^Copy"
|
||||
tooltip = _ "Copy this path to clipboard"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
[button]
|
||||
id = "open"
|
||||
definition = "action_go"
|
||||
label = _ "filesystem^Open"
|
||||
tooltip = _ "Open this file with an external application"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
#enddef
|
||||
|
||||
[window]
|
||||
id = "screenshot_notification"
|
||||
description = "Notification dialog used after saving a game or map screenshot."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
click_dismiss = "true"
|
||||
maximum_width = 600
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip_large"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "tooltip_large"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
|
||||
label = _ "Screenshot Saved"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Name:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
|
||||
{__GUI_FILENAME_OPTIONS_GRID}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
label = _ "Size:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "filesize"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[button]
|
||||
id = "browse_dir"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Screenshots..."
|
||||
|
||||
tooltip = _ "Browse the screenshots folder using a file manager"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
||||
|
||||
#undef __GUI_FILENAME_OPTIONS_GRID
|
|
@ -779,6 +779,7 @@ set(wesnoth-main_SRC
|
|||
gui/dialogs/network_transmission.cpp
|
||||
gui/dialogs/popup.cpp
|
||||
gui/dialogs/edit_text.cpp
|
||||
gui/dialogs/screenshot_notification.cpp
|
||||
gui/dialogs/simple_item_selector.cpp
|
||||
gui/dialogs/theme_list.cpp
|
||||
gui/dialogs/title_screen.cpp
|
||||
|
|
|
@ -388,6 +388,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/network_transmission.cpp
|
||||
gui/dialogs/popup.cpp
|
||||
gui/dialogs/edit_text.cpp
|
||||
gui/dialogs/screenshot_notification.cpp
|
||||
gui/dialogs/simple_item_selector.cpp
|
||||
gui/dialogs/theme_list.cpp
|
||||
gui/dialogs/tip.cpp
|
||||
|
|
99
src/gui/dialogs/screenshot_notification.cpp
Normal file
99
src/gui/dialogs/screenshot_notification.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
Copyright (C) 2013 - 2014 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/screenshot_notification.hpp"
|
||||
|
||||
#include "clipboard.hpp"
|
||||
#include "desktop_util.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "gui/auxiliary/find_widget.tpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "gettext.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWindowDefinitionWML
|
||||
* @order = 2_screenshot_notification
|
||||
*
|
||||
* == Screenshot notification ==
|
||||
*
|
||||
* Notification dialog used after saving a game or map screenshot to display
|
||||
* information about it for the user.
|
||||
*
|
||||
* @begin{table}{dialog_widgets}
|
||||
*
|
||||
* path & & text_box & m &
|
||||
* Read-only textbox containing the screenshot path. $
|
||||
*
|
||||
* filesize & & label & o &
|
||||
* Optional label to display the file size. $
|
||||
*
|
||||
* copy & & button & m &
|
||||
* Button to copy the path to clipboard. $
|
||||
*
|
||||
* open & & button & m &
|
||||
* Button to open the screnshot using the default application. $
|
||||
*
|
||||
* browse_dir & & button & m &
|
||||
* Button to browse the screenshots directory in the file manager. $
|
||||
*
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
REGISTER_DIALOG(screenshot_notification)
|
||||
|
||||
tscreenshot_notification::tscreenshot_notification(const std::string& path,
|
||||
int filesize)
|
||||
: path_(path)
|
||||
, screenshots_dir_path_(get_screenshot_dir())
|
||||
{
|
||||
register_label("filesize",
|
||||
false,
|
||||
utils::si_string(filesize, true, _("unit_byte^B")),
|
||||
false);
|
||||
}
|
||||
|
||||
void tscreenshot_notification::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
ttext_box& path_box = find_widget<ttext_box>(&window, "path", false);
|
||||
path_box.set_value(file_name(path_));
|
||||
path_box.set_active(false);
|
||||
|
||||
tbutton& copy_b = find_widget<tbutton>(&window, "copy", false);
|
||||
connect_signal_mouse_left_click(copy_b,
|
||||
boost::bind(©_to_clipboard,
|
||||
boost::ref(path_),
|
||||
false));
|
||||
|
||||
tbutton& open_b = find_widget<tbutton>(&window, "open", false);
|
||||
connect_signal_mouse_left_click(open_b,
|
||||
boost::bind(&desktop::open_object,
|
||||
boost::ref(path_)));
|
||||
|
||||
tbutton& bdir_b = find_widget<tbutton>(&window, "browse_dir", false);
|
||||
connect_signal_mouse_left_click(bdir_b,
|
||||
boost::bind(&desktop::open_object,
|
||||
boost::ref(screenshots_dir_path_)));
|
||||
}
|
||||
|
||||
}
|
56
src/gui/dialogs/screenshot_notification.hpp
Normal file
56
src/gui/dialogs/screenshot_notification.hpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
Copyright (C) 2013 - 2014 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_SCREENSHOT_NOTIFICATION_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_SCREENSHOT_NOTIFICATION_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tscreenshot_notification : public tdialog
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param path Path to the screenshot file created,
|
||||
* @param filesize Size of the screenshot file.
|
||||
*/
|
||||
tscreenshot_notification(const std::string& path, int filesize);
|
||||
|
||||
/**
|
||||
* The display function.
|
||||
*
|
||||
* See @ref tdialog for more information.
|
||||
*/
|
||||
static void display(const std::string& path, int filesize, CVideo& video)
|
||||
{
|
||||
tscreenshot_notification(path, filesize).show(video);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string path_;
|
||||
const std::string screenshots_dir_path_;
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ! GUI_DIALOGS_SCREENSHOT_NOTIFICATION_HPP_INCLUDED */
|
|
@ -18,6 +18,7 @@
|
|||
#include "boost/foreach.hpp"
|
||||
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/screenshot_notification.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "wml_separators.hpp"
|
||||
|
@ -627,9 +628,7 @@ void execute_command(display& disp, const hotkey_command& command, command_execu
|
|||
filename = get_next_filename(filename, ".bmp");
|
||||
int size = disp.screenshot(filename, map_screenshot);
|
||||
if (size > 0) {
|
||||
std::stringstream res;
|
||||
res << filename << " ( " << utils::si_string(size, true, _("unit_byte^B")) << " )";
|
||||
gui2::show_message(disp.video(), _("Screenshot Done"), res.str());
|
||||
gui2::tscreenshot_notification::display(filename, size, disp.video());
|
||||
} else {
|
||||
gui2::show_message(disp.video(), _("Screenshot Done"), "");
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "gui/dialogs/mp_login.hpp"
|
||||
#include "gui/dialogs/mp_method_selection.hpp"
|
||||
#include "gui/dialogs/simple_item_selector.hpp"
|
||||
#include "gui/dialogs/screenshot_notification.hpp"
|
||||
#include "gui/dialogs/title_screen.hpp"
|
||||
#include "gui/dialogs/tip.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
|
@ -375,6 +376,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
test<gui2::tlanguage_selection>();
|
||||
test<gui2::tmessage>();
|
||||
test<gui2::tsimple_item_selector>();
|
||||
test<gui2::tscreenshot_notification>();
|
||||
test<gui2::tmp_change_control>();
|
||||
test<gui2::tmp_cmd_wrapper>();
|
||||
test<gui2::tmp_connect>();
|
||||
|
@ -649,6 +651,16 @@ struct twrapper<gui2::tsimple_item_selector>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::tscreenshot_notification>
|
||||
{
|
||||
static gui2::tscreenshot_notification* create()
|
||||
{
|
||||
return new gui2::tscreenshot_notification("path"
|
||||
, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::teditor_generate_map>
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue