mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-20 18:40:57 +00:00
Don't show full path on Data Recover view if the user wants to hide them
This commit is contained in:
parent
93fe19d353
commit
1ac3148f72
@ -30,6 +30,7 @@
|
||||
#include "base/thread.h"
|
||||
#include "base/time.h"
|
||||
#include "doc/cancel_io.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
namespace app {
|
||||
namespace crash {
|
||||
@ -44,16 +45,23 @@ Session::Backup::Backup(const std::string& dir)
|
||||
DocumentInfo info;
|
||||
read_document_info(dir, info);
|
||||
|
||||
std::vector<char> buf(1024);
|
||||
sprintf(&buf[0], "%s Sprite %dx%d, %d %s: %s",
|
||||
info.mode == ColorMode::RGB ? "RGB":
|
||||
info.mode == ColorMode::GRAYSCALE ? "Grayscale":
|
||||
info.mode == ColorMode::INDEXED ? "Indexed":
|
||||
info.mode == ColorMode::BITMAP ? "Bitmap": "Unknown",
|
||||
info.width, info.height, info.frames,
|
||||
info.frames == 1 ? "frame": "frames",
|
||||
info.filename.c_str());
|
||||
m_desc = &buf[0];
|
||||
m_fn = info.filename;
|
||||
m_desc =
|
||||
fmt::format("{} Sprite {}x{}, {} {}",
|
||||
info.mode == ColorMode::RGB ? "RGB":
|
||||
info.mode == ColorMode::GRAYSCALE ? "Grayscale":
|
||||
info.mode == ColorMode::INDEXED ? "Indexed":
|
||||
info.mode == ColorMode::BITMAP ? "Bitmap": "Unknown",
|
||||
info.width, info.height, info.frames,
|
||||
info.frames == 1 ? "frame": "frames");
|
||||
}
|
||||
|
||||
std::string Session::Backup::description(const bool withFullPath) const
|
||||
{
|
||||
return fmt::format("{}: {}",
|
||||
m_desc,
|
||||
withFullPath ? m_fn:
|
||||
base::get_file_name(m_fn));
|
||||
}
|
||||
|
||||
Session::Session(RecoveryConfig* config,
|
||||
|
@ -32,10 +32,11 @@ namespace crash {
|
||||
public:
|
||||
Backup(const std::string& dir);
|
||||
const std::string& dir() const { return m_dir; }
|
||||
const std::string& description() const { return m_desc; }
|
||||
std::string description(const bool withFullPath) const;
|
||||
private:
|
||||
std::string m_dir;
|
||||
std::string m_desc;
|
||||
std::string m_fn;
|
||||
};
|
||||
typedef std::vector<Backup*> Backups;
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "app/crash/session.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/task.h"
|
||||
#include "app/ui/data_recovery_view.h"
|
||||
#include "app/ui/drop_down_button.h"
|
||||
@ -52,11 +53,10 @@ namespace {
|
||||
class Item : public ListItem {
|
||||
public:
|
||||
Item(crash::Session* session, crash::Session::Backup* backup)
|
||||
: ListItem(backup->description())
|
||||
, m_session(session)
|
||||
: m_session(session)
|
||||
, m_backup(backup)
|
||||
, m_task(nullptr)
|
||||
{
|
||||
, m_task(nullptr) {
|
||||
updateText();
|
||||
}
|
||||
|
||||
crash::Session* session() const { return m_session; }
|
||||
@ -122,6 +122,13 @@ public:
|
||||
updateView();
|
||||
}
|
||||
|
||||
void updateText() {
|
||||
if (!m_task)
|
||||
setText(
|
||||
m_backup->description(
|
||||
Preferences::instance().general.showFullPath()));
|
||||
}
|
||||
|
||||
private:
|
||||
void onSizeHint(SizeHintEvent& ev) override {
|
||||
ListItem::onSizeHint(ev);
|
||||
@ -238,6 +245,15 @@ DataRecoveryView::DataRecoveryView(crash::DataRecovery* dataRecovery)
|
||||
m_listBox.Change.connect(base::Bind(&DataRecoveryView::onChangeSelection, this));
|
||||
m_listBox.DoubleClickItem.connect(base::Bind(&DataRecoveryView::onOpen, this));
|
||||
m_waitToEnableRefreshTimer.Tick.connect(base::Bind(&DataRecoveryView::onCheckIfWeCanEnableRefreshButton, this));
|
||||
|
||||
m_conn = Preferences::instance()
|
||||
.general.showFullPath.AfterChange.connect(
|
||||
[this](const bool&){ onShowFullPathPrefChange(); });
|
||||
}
|
||||
|
||||
DataRecoveryView::~DataRecoveryView()
|
||||
{
|
||||
m_conn.disconnect();
|
||||
}
|
||||
|
||||
void DataRecoveryView::refreshListNotification()
|
||||
@ -487,6 +503,16 @@ void DataRecoveryView::onCheckIfWeCanEnableRefreshButton()
|
||||
m_view.updateView();
|
||||
}
|
||||
|
||||
void DataRecoveryView::onShowFullPathPrefChange()
|
||||
{
|
||||
for (auto widget : m_listBox.children()) {
|
||||
if (auto item = dynamic_cast<Item*>(widget)) {
|
||||
if (!item->isTaskRunning())
|
||||
item->updateText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DataRecoveryView::thereAreCrashSessions() const
|
||||
{
|
||||
for (auto widget : m_listBox.children()) {
|
||||
|
@ -28,6 +28,7 @@ namespace app {
|
||||
, public WorkspaceView {
|
||||
public:
|
||||
DataRecoveryView(crash::DataRecovery* dataRecovery);
|
||||
~DataRecoveryView();
|
||||
|
||||
// Called after the "Refresh" button is pressed (onRefresh) and
|
||||
// the crash::DataRecovery::SessionsListIsReady signal is received.
|
||||
@ -60,6 +61,7 @@ namespace app {
|
||||
void onRefresh();
|
||||
void onChangeSelection();
|
||||
void onCheckIfWeCanEnableRefreshButton();
|
||||
void onShowFullPathPrefChange();
|
||||
bool thereAreCrashSessions() const;
|
||||
|
||||
crash::DataRecovery* m_dataRecovery;
|
||||
@ -69,6 +71,10 @@ namespace app {
|
||||
ui::Button m_deleteButton;
|
||||
ui::Button m_refreshButton;
|
||||
ui::Timer m_waitToEnableRefreshTimer;
|
||||
|
||||
// Connection to to showFullPath.AfterChange signal to update the
|
||||
// items text when the setting is changed.
|
||||
obs::connection m_conn;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
Loading…
x
Reference in New Issue
Block a user