Add global.h file

This commit is contained in:
Chocobo1 2016-04-29 17:25:15 +08:00
parent 2e8c01d88c
commit d277696acc
5 changed files with 40 additions and 7 deletions

View file

@ -52,6 +52,7 @@ utils/string.h
utils/version.h
asyncfilestorage.h
filesystemwatcher.h
global.h
iconprovider.h
indexrange.h
logger.h

View file

@ -63,7 +63,8 @@ HEADERS += \
$$PWD/torrentfileguard.h \
$$PWD/torrentfilter.h \
$$PWD/scanfoldersmodel.h \
$$PWD/searchengine.h
$$PWD/searchengine.h \
$$PWD/global.h
SOURCES += \
$$PWD/asyncfilestorage.cpp \

30
src/base/global.h Normal file
View file

@ -0,0 +1,30 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Mike Tzou
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";

View file

@ -64,6 +64,7 @@
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/global.h"
#include "base/rss/rss_folder.h"
#include "base/rss/rss_session.h"
@ -1152,7 +1153,7 @@ void MainWindow::dropEvent(QDropEvent *event)
// differentiate ".torrent" files and others
QStringList torrentFiles, otherFiles;
foreach (const QString &file, files) {
if (file.endsWith(".torrent", Qt::CaseInsensitive))
if (file.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive))
torrentFiles << file;
else
otherFiles << file;
@ -1203,7 +1204,7 @@ void MainWindow::on_actionOpen_triggered()
// Note: it is possible to select more than one file
const QStringList pathsList =
QFileDialog::getOpenFileNames(this, tr("Open Torrent Files"), pref->getMainLastDir(),
tr("Torrent Files") + " (*.torrent)");
tr("Torrent Files") + " (*" + C_TORRENT_FILE_EXTENSION + ')');
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
if (!pathsList.isEmpty()) {

View file

@ -38,11 +38,11 @@
#include <QUrl>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/torrentcreatorthread.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/global.h"
#include "base/settingsstorage.h"
#include "base/utils/fs.h"
#include "guiiconprovider.h"
#include "ui_torrentcreatordlg.h"
@ -161,8 +161,8 @@ void TorrentCreatorDlg::onCreateButtonClicked()
QString destination = QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), lastPath, tr("Torrent Files (*.torrent)"));
if (destination.isEmpty())
return;
if (!destination.endsWith(".torrent", Qt::CaseInsensitive))
destination += ".torrent";
if (!destination.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive))
destination += C_TORRENT_FILE_EXTENSION;
storeLastSavePath = Utils::Fs::branchPath(destination);
// Disable dialog & set busy cursor