OSDN Git Service

Ver0.21
[gefu/Gefu.git] / global.cpp
1 #include "global.h"
2
3 void appendActionShortcut(QAction *action, const QString &ks)
4 {
5     QList<QKeySequence> shortcuts = action->shortcuts();
6     shortcuts << QKeySequence(ks);
7     action->setShortcuts(shortcuts);
8 }
9
10 QString FileSizeToString(qint64 size)
11 {
12     if (size >= 1024 * 1024 * 1024) {
13         return QString("%1GB").arg(int(10 * size / (1024 * 1024 * 1024)) / 10);
14     }
15     if (size >= 1024 * 1024) {
16         return QString("%1MB").arg(int(10 * size / (1024 * 1024)) / 10);
17     }
18     if (size >= 1024) {
19         return QString("%1KB").arg(int(10 * size / (1024)) / 10);
20     }
21     return QString("%1B").arg(size);
22 }