Qt: add open file location to screenshot preview

Remove duplicate slash from screenshot path
This commit is contained in:
Megamouse 2020-03-24 21:10:03 +01:00
parent bd49ad358c
commit f27de28ee9
4 changed files with 5 additions and 4 deletions

View File

@ -301,7 +301,7 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot
std::thread(
[sshot_width, sshot_height](const std::vector<u8> sshot_data)
{
std::string screen_path = fs::get_config_dir() + "/screenshots/";
std::string screen_path = fs::get_config_dir() + "screenshots/";
if (!fs::create_dir(screen_path) && fs::g_tls_error != fs::error::exist)
{

View File

@ -21,7 +21,7 @@ screenshot_manager_dialog::screenshot_manager_dialog(QWidget* parent) : QDialog(
m_grid->setIconSize(QSize(160, 90));
m_grid->setGridSize(m_grid->iconSize() + QSize(10, 10));
const std::string screen_path = fs::get_config_dir() + "/screenshots/";
const std::string screen_path = fs::get_config_dir() + "screenshots/";
const QStringList filter{ QStringLiteral("*.png") };
QDirIterator dir_iter(QString::fromStdString(screen_path), filter, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);

View File

@ -27,13 +27,14 @@ screenshot_preview::screenshot_preview(const QString& filepath, QWidget* parent)
connect(this, &screenshot_preview::customContextMenuRequested, this, &screenshot_preview::show_context_menu);
}
#include <QDebug>
void screenshot_preview::show_context_menu(const QPoint & pos)
{
QMenu* menu = new QMenu();
menu->addAction(tr("&Copy"), [this]() { QGuiApplication::clipboard()->setImage(m_image); });
menu->addSeparator();
menu->addAction(tr("&Open file location"), [this]() { gui::utils::open_dir(m_filepath); });
menu->addSeparator();
QAction* reset_act = menu->addAction(tr("To &Normal Size"), [this]() { scale(m_image.size()); });
reset_act->setEnabled(pixmap()->size() != m_image.size());

View File

@ -11,7 +11,7 @@ public:
screenshot_preview(const QString& filepath, QWidget* parent = nullptr);
protected:
void resizeEvent(QResizeEvent* event);
void resizeEvent(QResizeEvent* event) override;
private Q_SLOTS:
void show_context_menu(const QPoint& pos);