Move utilities to core/utils folder.

Also move the names to Utils namespace.
This commit is contained in:
Vladimir Golovnev (Glassez)
2015-05-06 14:53:27 +03:00
parent 427688cb34
commit 191cdc2849
67 changed files with 1172 additions and 1135 deletions

View File

@@ -60,7 +60,7 @@
#include "application.h"
#include "core/logger.h"
#include "core/preferences.h"
#include "core/misc.h"
#include "core/utils/misc.h"
#include "core/iconprovider.h"
#include "core/scanfoldersmodel.h"
#include "core/net/smtp.h"
@@ -74,7 +74,7 @@ Application::Application(const QString &id, int &argc, char **argv)
: BaseApplication(id, argc, argv)
, m_running(false)
#ifndef DISABLE_GUI
, m_shutdownAct(NO_SHUTDOWN)
, m_shutdownAct(ShutdownAction::None)
#endif
{
Logger::initInstance();
@@ -118,11 +118,11 @@ void Application::sendNotificationEmail(BitTorrent::TorrentHandle *const torrent
{
// Prepare mail content
QString content = QObject::tr("Torrent name: %1").arg(torrent->name()) + "\n";
content += QObject::tr("Torrent size: %1").arg(misc::friendlyUnit(torrent->wantedSize())) + "\n";
content += QObject::tr("Torrent size: %1").arg(Utils::Misc::friendlyUnit(torrent->wantedSize())) + "\n";
content += QObject::tr("Save path: %1").arg(torrent->savePath()) + "\n\n";
content += QObject::tr("The torrent was downloaded in %1.",
"The torrent was downloaded in 1 hour and 20 seconds")
.arg(misc::userFriendlyDuration(torrent->activeTime())) + "\n\n\n";
.arg(Utils::Misc::userFriendlyDuration(torrent->activeTime())) + "\n\n\n";
content += QObject::tr("Thank you for using qBittorrent.") + "\n";
// Send the notification email
@@ -169,13 +169,13 @@ void Application::allTorrentsFinished()
bool shutdown = pref->shutdownWhenDownloadsComplete();
// Confirm shutdown
ShutDownAction action = NO_SHUTDOWN;
ShutdownAction action = ShutdownAction::None;
if (suspend)
action = SUSPEND_COMPUTER;
action = ShutdownAction::Suspend;
else if (hibernate)
action = HIBERNATE_COMPUTER;
action = ShutdownAction::Hibernate;
else if (shutdown)
action = SHUTDOWN_COMPUTER;
action = ShutdownAction::Shutdown;
if (!ShutdownConfirmDlg::askForConfirmation(action)) return;
@@ -458,9 +458,9 @@ void Application::cleanup()
shutdownBRDestroy((HWND)m_window->effectiveWinId());
#endif // Q_OS_WIN
delete m_window;
if (m_shutdownAct != NO_SHUTDOWN) {
if (m_shutdownAct != ShutdownAction::None) {
qDebug() << "Sending computer shutdown/suspend/hibernate signal...";
misc::shutdownComputer(m_shutdownAct);
Utils::Misc::shutdownComputer(m_shutdownAct);
}
#endif
}

View File

@@ -50,7 +50,7 @@ QT_END_NAMESPACE
typedef QtSingleCoreApplication BaseApplication;
#endif
#include "core/misc.h"
#include "core/utils/misc.h"
#ifndef DISABLE_WEBUI
class WebUI;
@@ -96,7 +96,7 @@ private:
#ifndef DISABLE_GUI
QPointer<MainWindow> m_window;
ShutDownAction m_shutdownAct;
ShutdownAction m_shutdownAct;
#endif
#ifndef DISABLE_WEBUI

View File

@@ -66,7 +66,7 @@ Q_IMPORT_PLUGIN(qico)
#include <cstdlib>
#include <iostream>
#include "application.h"
#include "core/misc.h"
#include "core/utils/misc.h"
#include "core/preferences.h"
// Signal handlers
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
bool isOneArg = (argc == 2);
// Create Application
QString appId = QLatin1String("qBittorrent-") + misc::getUserIDString();
QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
QScopedPointer<Application> app(new Application(appId, argc, argv));
const QBtCommandLineParameters params = parseCommandLine();
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
#endif
qDebug("qBittorrent is already running for this user.");
misc::msleep(300);
Utils::Misc::msleep(300);
app->sendParams(params.torrents);
return EXIT_SUCCESS;
@@ -395,7 +395,7 @@ void displayUsage(const QString& prg_name)
#else
QMessageBox msgBox(QMessageBox::Information, QObject::tr("Help"), makeUsage(prg_name), QMessageBox::Ok);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(misc::screenCenter(&msgBox));
msgBox.move(Utils::Misc::screenCenter(&msgBox));
msgBox.exec();
#endif
}
@@ -407,7 +407,7 @@ void displayBadArgMessage(const QString& message)
QMessageBox msgBox(QMessageBox::Critical, QObject::tr("Bad command line"),
message + QLatin1Char('\n') + help, QMessageBox::Ok);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(misc::screenCenter(&msgBox));
msgBox.move(Utils::Misc::screenCenter(&msgBox));
msgBox.exec();
#else
std::cerr << qPrintable(QObject::tr("Bad command line: "));
@@ -439,7 +439,7 @@ bool userAgreesWithLegalNotice()
msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(misc::screenCenter(&msgBox));
msgBox.move(Utils::Misc::screenCenter(&msgBox));
msgBox.exec();
if (msgBox.clickedButton() == agree_button) {
// Save the answer