ENH:Optimization of File Transfer System Part2

jira: [STUDIO-11777]

Change-Id: I12744db7d2e3b53425454d632533768c54524677
(cherry picked from commit 4358e9ce351c5784e392a75d1ffcf2f54e1916ec)
This commit is contained in:
milk
2025-04-27 15:30:43 +08:00
committed by Noisyfox
parent 32c055ca7a
commit 10428f71c0
7 changed files with 133 additions and 26 deletions

View File

@@ -4,6 +4,8 @@ project(libslic3r_gui)
include(PrecompiledHeader) include(PrecompiledHeader)
set(SLIC3R_GUI_SOURCES set(SLIC3R_GUI_SOURCES
GUI/Widgets/AnimaController.hpp
GUI/Widgets/AnimaController.cpp
Config/Snapshot.cpp Config/Snapshot.cpp
Config/Snapshot.hpp Config/Snapshot.hpp
Config/Version.cpp Config/Version.cpp

View File

@@ -1245,7 +1245,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
while (m_stopped) { while (m_stopped) {
if (m_session.owner == nullptr) if (m_session.owner == nullptr)
return; return;
m_status = Status::Stopped; m_status = Status::Reconnecting;
SendChangedEvent(EVT_STATUS_CHANGED, m_status); SendChangedEvent(EVT_STATUS_CHANGED, m_status);
m_cond.wait(l); m_cond.wait(l);
} }

View File

@@ -170,7 +170,7 @@ public:
ListSyncing, ListSyncing,
ListReady, ListReady,
Failed, Failed,
Stopped, Reconnecting,
}; };
Status GetStatus() const { return m_status; } Status GetStatus() const { return m_status; }

View File

@@ -0,0 +1,77 @@
#include "AnimaController.hpp"
#include <wx/dcclient.h>
#include <wx/dcgraph.h>
#ifdef __APPLE__
#include "libslic3r/MacUtils.hpp"
#endif
AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), m_ivt(ivt)
{
SetBackgroundColour((wxColour(255, 255, 255)));
m_size = 20;
//add ScalableBitmap
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, m_size));
m_image_enable = create_scaled_bitmap(img_enable, this, m_size-8);
// show first wxStaticBitmap
if (!m_images.empty()) m_bitmap = new wxStaticBitmap(this, wxID_ANY, m_images[0], wxDefaultPosition, wxSize(FromDIP(m_size), FromDIP(m_size)));
m_timer = new wxTimer();
m_timer->SetOwner(this);
Bind(wxEVT_TIMER, [this](wxTimerEvent &) {
if (m_timer->IsRunning() && !m_images.empty()) {
m_current_frame = (m_current_frame + 1) % 4;
m_bitmap->SetBitmap(m_images[m_current_frame]);
}
});
m_bitmap->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
wxMouseEvent evt(wxEVT_LEFT_DOWN);
evt.SetEventObject(this);
wxPostEvent(this, evt);
});
m_bitmap->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (!m_timer->IsRunning())
SetCursor(wxCursor(wxCURSOR_HAND));
else
SetCursor(wxCursor(wxCURSOR_ARROW));
e.Skip();
});
m_bitmap->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
SetCursor(wxCursor(wxCURSOR_ARROW));
e.Skip();
});
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
Refresh();
Play();
}
void AnimaIcon::Play()
{
if (true)
m_timer->Start(m_ivt);
}
void AnimaIcon::Stop()
{
m_timer->Stop();
}
void AnimaIcon::Enable()
{
if (m_bitmap) { m_bitmap->SetBitmap(m_image_enable); }
}

View File

@@ -0,0 +1,28 @@
#ifndef slic3r_GUI_AnimaController_hpp_
#define slic3r_GUI_AnimaController_hpp_
#include "../wxExtensions.hpp"
#include "Label.hpp"
class AnimaIcon : public wxPanel
{
public:
AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt = 1000);
void Play();
void Stop();
void Enable();
bool IsRunning() const;
private:
wxBitmap m_image_enable;
wxStaticBitmap * m_bitmap{nullptr};
std::vector<wxBitmap> m_images;
wxTimer * m_timer;
int m_current_frame = 0;
int m_ivt;
int m_size;
};
#endif // !slic3r_GUI_AnimaController_hpp_