rdm update every 2 seconds
This commit is contained in:
parent
1cd06e3267
commit
4337b65f52
@ -46,6 +46,7 @@
|
|||||||
#include "SysInfoDialog.hpp"
|
#include "SysInfoDialog.hpp"
|
||||||
#include "KBShortcutsDialog.hpp"
|
#include "KBShortcutsDialog.hpp"
|
||||||
#include "UpdateDialogs.hpp"
|
#include "UpdateDialogs.hpp"
|
||||||
|
#include "RemovableDriveManager.hpp"
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
@ -269,6 +270,7 @@ bool GUI_App::on_init_inner()
|
|||||||
|
|
||||||
this->obj_manipul()->update_if_dirty();
|
this->obj_manipul()->update_if_dirty();
|
||||||
|
|
||||||
|
RemovableDriveManager::getInstance().update(wxGetLocalTime());
|
||||||
// Preset updating & Configwizard are done after the above initializations,
|
// Preset updating & Configwizard are done after the above initializations,
|
||||||
// and after MainFrame is created & shown.
|
// and after MainFrame is created & shown.
|
||||||
// The extra CallAfter() is needed because of Mac, where this is the only way
|
// The extra CallAfter() is needed because of Mac, where this is the only way
|
||||||
|
@ -23,6 +23,7 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
std::vector<DriveData> RemovableDriveManager::m_current_drives;
|
std::vector<DriveData> RemovableDriveManager::m_current_drives;
|
||||||
|
long RemovableDriveManager::m_last_update = 0;
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
@ -215,8 +216,20 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool RemovableDriveManager::update()
|
bool RemovableDriveManager::update(long time)
|
||||||
{
|
{
|
||||||
|
if(time != 0) //time = 0 is forced update
|
||||||
|
{
|
||||||
|
long diff = m_last_update - time;
|
||||||
|
if(diff <= -2)
|
||||||
|
{
|
||||||
|
m_last_update = time;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
return false; // return value shouldnt matter if update didnt run
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "RDM update " << m_last_update <<"\n";
|
||||||
search_for_drives();
|
search_for_drives();
|
||||||
return !m_current_drives.empty();
|
return !m_current_drives.empty();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
void operator=(RemovableDriveManager const&) = delete;
|
void operator=(RemovableDriveManager const&) = delete;
|
||||||
|
|
||||||
//update() searches for removable devices, returns false if empty.
|
//update() searches for removable devices, returns false if empty.
|
||||||
static bool update();
|
static bool update(long time = 0); //time = 0 is forced update
|
||||||
static bool is_drive_mounted(const std::string &path);
|
static bool is_drive_mounted(const std::string &path);
|
||||||
static void eject_drive(const std::string &path);
|
static void eject_drive(const std::string &path);
|
||||||
static std::string get_last_drive_path();
|
static std::string get_last_drive_path();
|
||||||
@ -34,6 +34,7 @@ private:
|
|||||||
RemovableDriveManager(){}
|
RemovableDriveManager(){}
|
||||||
static void search_for_drives();
|
static void search_for_drives();
|
||||||
static std::vector<DriveData> m_current_drives;
|
static std::vector<DriveData> m_current_drives;
|
||||||
|
static long m_last_update;
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#else
|
#else
|
||||||
static void search_path(const std::string &path, const dev_t &parentDevID);
|
static void search_path(const std::string &path, const dev_t &parentDevID);
|
||||||
|
Loading…
Reference in New Issue
Block a user