mac fixes
This commit is contained in:
parent
4438674730
commit
0d61fda4d7
@ -16,7 +16,8 @@
|
||||
LibraryWatcher::LibraryWatcher(QObject* parent)
|
||||
: QObject(parent),
|
||||
fs_watcher_(new QFileSystemWatcher(this)),
|
||||
rescan_timer_(new QTimer(this))
|
||||
rescan_timer_(new QTimer(this)),
|
||||
total_watches_(0)
|
||||
{
|
||||
rescan_timer_->setInterval(1000);
|
||||
rescan_timer_->setSingleShot(true);
|
||||
@ -35,6 +36,7 @@ void LibraryWatcher::AddDirectories(const DirectoryList& directories) {
|
||||
|
||||
// Start monitoring this directory for more changes
|
||||
fs_watcher_->addPath(dir.path);
|
||||
++total_watches_;
|
||||
|
||||
// And all the subdirectories
|
||||
QDirIterator it(dir.path,
|
||||
@ -44,6 +46,12 @@ void LibraryWatcher::AddDirectories(const DirectoryList& directories) {
|
||||
QString subdir(it.next());
|
||||
fs_watcher_->addPath(subdir);
|
||||
paths_watched_[subdir] = dir;
|
||||
#ifdef Q_OS_DARWIN
|
||||
if (++total_watches_ > kMaxWatches) {
|
||||
qWarning() << "Trying to watch more files than we can manage";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,12 @@ class LibraryWatcher : public QObject {
|
||||
|
||||
QMap<QString, Directory> paths_watched_;
|
||||
QStringList paths_needing_rescan_;
|
||||
|
||||
int total_watches_;
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
static const int kMaxWatches = 200;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // LIBRARYWATCHER_H
|
||||
|
@ -12,6 +12,8 @@ SystemTrayIcon::SystemTrayIcon(QObject* parent)
|
||||
{
|
||||
}
|
||||
|
||||
SystemTrayIcon::~SystemTrayIcon() {}
|
||||
|
||||
bool SystemTrayIcon::event(QEvent* event) {
|
||||
if (event->type() == QEvent::Wheel) {
|
||||
emit WheelEvent(static_cast<QWheelEvent*>(event)->delta());
|
||||
|
@ -8,8 +8,9 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||
|
||||
public:
|
||||
SystemTrayIcon(QObject* parent = 0);
|
||||
virtual ~SystemTrayIcon();
|
||||
|
||||
bool event(QEvent* event);
|
||||
virtual bool event(QEvent* event);
|
||||
|
||||
public slots:
|
||||
void SetProgress(int percentage);
|
||||
|
Loading…
x
Reference in New Issue
Block a user