mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Load cloud image without active view only once.
This commit is contained in:
@@ -99,13 +99,19 @@ bool CloudImage::failed() const {
|
|||||||
return (_file.flags & CloudFile::Flag::Failed);
|
return (_file.flags & CloudFile::Flag::Failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CloudImage::loadedOnce() const {
|
||||||
|
return (_file.flags & CloudFile::Flag::Loaded);
|
||||||
|
}
|
||||||
|
|
||||||
void CloudImage::load(not_null<Main::Session*> session, FileOrigin origin) {
|
void CloudImage::load(not_null<Main::Session*> session, FileOrigin origin) {
|
||||||
const auto autoLoading = false;
|
const auto autoLoading = false;
|
||||||
const auto finalCheck = [=] {
|
const auto finalCheck = [=] {
|
||||||
if (const auto active = activeView()) {
|
if (const auto active = activeView()) {
|
||||||
return !active->image();
|
return !active->image();
|
||||||
|
} else if (_file.flags & CloudFile::Flag::Loaded) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return !(_file.flags & CloudFile::Flag::Loaded);
|
||||||
};
|
};
|
||||||
const auto done = [=](QImage result) {
|
const auto done = [=](QImage result) {
|
||||||
if (const auto active = activeView()) {
|
if (const auto active = activeView()) {
|
||||||
@@ -247,6 +253,7 @@ void LoadCloudFile(
|
|||||||
if (!file.loader || file.loader->cancelled()) {
|
if (!file.loader || file.loader->cancelled()) {
|
||||||
file.flags |= CloudFile::Flag::Cancelled;
|
file.flags |= CloudFile::Flag::Cancelled;
|
||||||
} else {
|
} else {
|
||||||
|
file.flags |= CloudFile::Flag::Loaded;
|
||||||
done(file);
|
done(file);
|
||||||
}
|
}
|
||||||
// NB! file.loader may be in ~FileLoader() already.
|
// NB! file.loader may be in ~FileLoader() already.
|
||||||
|
@@ -31,6 +31,7 @@ struct CloudFile final {
|
|||||||
enum class Flag : uchar {
|
enum class Flag : uchar {
|
||||||
Cancelled = 0x01,
|
Cancelled = 0x01,
|
||||||
Failed = 0x02,
|
Failed = 0x02,
|
||||||
|
Loaded = 0x04,
|
||||||
};
|
};
|
||||||
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ public:
|
|||||||
[[nodiscard]] bool empty() const;
|
[[nodiscard]] bool empty() const;
|
||||||
[[nodiscard]] bool loading() const;
|
[[nodiscard]] bool loading() const;
|
||||||
[[nodiscard]] bool failed() const;
|
[[nodiscard]] bool failed() const;
|
||||||
|
[[nodiscard]] bool loadedOnce() const;
|
||||||
void load(not_null<Main::Session*> session, FileOrigin origin);
|
void load(not_null<Main::Session*> session, FileOrigin origin);
|
||||||
[[nodiscard]] const ImageLocation &location() const;
|
[[nodiscard]] const ImageLocation &location() const;
|
||||||
[[nodiscard]] int byteSize() const;
|
[[nodiscard]] int byteSize() const;
|
||||||
|
Reference in New Issue
Block a user