paysages3d/src/interface/desktop/tools.cpp

48 lines
920 B
C++
Raw Normal View History

#include "tools.h"
#include <QEvent>
2013-11-12 22:15:35 +00:00
#include "BasePreview.h"
DialogWithPreview::DialogWithPreview(QWidget* parent) : QDialog(parent)
{
}
bool DialogWithPreview::event(QEvent* event)
{
if (event->type() == QEvent::WindowActivate)
{
BasePreview::reviveAll();
}
return QDialog::event(event);
}
QString getHumanMemory(qint64 memused)
{
if (memused >= 1024)
{
memused /= 1024;
if (memused >= 1024)
{
memused /= 1024;
if (memused >= 1024)
{
memused /= 1024;
return QObject::tr("%1 GB").arg(memused);
}
else
{
return QObject::tr("%1 MB").arg(memused);
}
}
else
{
return QObject::tr("%1 kB").arg(memused);
}
}
else
{
return QObject::tr("%1 B").arg(memused);
}
}