mirror of
https://github.com/transmission/transmission.git
synced 2025-12-21 10:58:50 +00:00
Remove supporting code for Qt < 5.2
This commit is contained in:
@@ -97,10 +97,6 @@ Application::Application (int& argc, char ** argv):
|
|||||||
|
|
||||||
Formatter::initUnits ();
|
Formatter::initUnits ();
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
setAttribute (Qt::AA_UseHighDpiPixmaps);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (_WIN32) || defined (__APPLE__)
|
#if defined (_WIN32) || defined (__APPLE__)
|
||||||
if (QIcon::themeName ().isEmpty ())
|
if (QIcon::themeName ().isEmpty ())
|
||||||
QIcon::setThemeName (QLatin1String ("Faenza"));
|
QIcon::setThemeName (QLatin1String ("Faenza"));
|
||||||
@@ -310,12 +306,7 @@ Application::loadTranslations ()
|
|||||||
#endif
|
#endif
|
||||||
(applicationDirPath () + QLatin1String ("/translations"));
|
(applicationDirPath () + QLatin1String ("/translations"));
|
||||||
|
|
||||||
const QString qtFileName =
|
const QString qtFileName = QLatin1String ("qtbase");
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
QLatin1String ("qt");
|
|
||||||
#else
|
|
||||||
QLatin1String ("qtbase");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const QLocale locale;
|
const QLocale locale;
|
||||||
const QLocale englishLocale (QLocale::English, QLocale::UnitedStates);
|
const QLocale englishLocale (QLocale::English, QLocale::UnitedStates);
|
||||||
@@ -589,7 +580,10 @@ tr_main (int argc,
|
|||||||
{
|
{
|
||||||
InteropHelper::initialize ();
|
InteropHelper::initialize ();
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
Application::setAttribute (Qt::AA_EnableHighDpiScaling);
|
Application::setAttribute (Qt::AA_EnableHighDpiScaling);
|
||||||
|
#endif
|
||||||
|
|
||||||
Application::setAttribute (Qt::AA_UseHighDpiPixmaps);
|
Application::setAttribute (Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
Application app (argc, argv);
|
Application app (argc, argv);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ set(${PROJECT_NAME}_SOURCES
|
|||||||
FilterBar.cc
|
FilterBar.cc
|
||||||
FilterBarComboBox.cc
|
FilterBarComboBox.cc
|
||||||
FilterBarComboBoxDelegate.cc
|
FilterBarComboBoxDelegate.cc
|
||||||
FilterBarLineEdit.cc
|
|
||||||
Filters.cc
|
Filters.cc
|
||||||
Formatter.cc
|
Formatter.cc
|
||||||
FreeSpaceLabel.cc
|
FreeSpaceLabel.cc
|
||||||
@@ -76,7 +75,6 @@ set(${PROJECT_NAME}_HEADERS
|
|||||||
FilterBar.h
|
FilterBar.h
|
||||||
FilterBarComboBox.h
|
FilterBarComboBox.h
|
||||||
FilterBarComboBoxDelegate.h
|
FilterBarComboBoxDelegate.h
|
||||||
FilterBarLineEdit.h
|
|
||||||
Filters.h
|
Filters.h
|
||||||
Formatter.h
|
Formatter.h
|
||||||
FreeSpaceLabel.h
|
FreeSpaceLabel.h
|
||||||
|
|||||||
@@ -10,12 +10,7 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#else
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FaviconCache.h"
|
#include "FaviconCache.h"
|
||||||
|
|
||||||
@@ -41,12 +36,7 @@ FaviconCache::~FaviconCache ()
|
|||||||
QString
|
QString
|
||||||
FaviconCache::getCacheDir ()
|
FaviconCache::getCacheDir ()
|
||||||
{
|
{
|
||||||
const QString base =
|
const QString base = QStandardPaths::writableLocation (QStandardPaths::CacheLocation);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
QDesktopServices::storageLocation (QDesktopServices::CacheLocation);
|
|
||||||
#else
|
|
||||||
QStandardPaths::writableLocation (QStandardPaths::CacheLocation);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return QDir(base).absoluteFilePath (QLatin1String ("favicons"));
|
return QDir(base).absoluteFilePath (QLatin1String ("favicons"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
@@ -16,7 +17,6 @@
|
|||||||
#include "FilterBar.h"
|
#include "FilterBar.h"
|
||||||
#include "FilterBarComboBox.h"
|
#include "FilterBarComboBox.h"
|
||||||
#include "FilterBarComboBoxDelegate.h"
|
#include "FilterBarComboBoxDelegate.h"
|
||||||
#include "FilterBarLineEdit.h"
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
#include "Torrent.h"
|
#include "Torrent.h"
|
||||||
#include "TorrentFilter.h"
|
#include "TorrentFilter.h"
|
||||||
@@ -241,7 +241,9 @@ FilterBar::FilterBar (Prefs& prefs, const TorrentModel& torrents, const TorrentF
|
|||||||
|
|
||||||
h->addStretch ();
|
h->addStretch ();
|
||||||
|
|
||||||
myLineEdit = new FilterBarLineEdit (this);
|
myLineEdit = new QLineEdit (this);
|
||||||
|
myLineEdit->setClearButtonEnabled (true);
|
||||||
|
myLineEdit->setPlaceholderText (tr ("Search..."));
|
||||||
myLineEdit->setMaximumWidth (250);
|
myLineEdit->setMaximumWidth (250);
|
||||||
h->addWidget (myLineEdit, 1);
|
h->addWidget (myLineEdit, 1);
|
||||||
connect (myLineEdit, SIGNAL (textChanged (QString)), this, SLOT (onTextChanged (QString)));
|
connect (myLineEdit, SIGNAL (textChanged (QString)), this, SLOT (onTextChanged (QString)));
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
class FilterBarComboBox;
|
class FilterBarComboBox;
|
||||||
class FilterBarLineEdit;
|
|
||||||
class Prefs;
|
class Prefs;
|
||||||
class TorrentFilter;
|
class TorrentFilter;
|
||||||
class TorrentModel;
|
class TorrentModel;
|
||||||
@@ -56,6 +56,6 @@ class FilterBar: public QWidget
|
|||||||
QStandardItemModel * myTrackerModel;
|
QStandardItemModel * myTrackerModel;
|
||||||
QTimer * myRecountTimer;
|
QTimer * myRecountTimer;
|
||||||
bool myIsBootstrapping;
|
bool myIsBootstrapping;
|
||||||
FilterBarLineEdit * myLineEdit;
|
QLineEdit * myLineEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file Copyright (C) 2012-2015 Mnemosyne LLC
|
|
||||||
*
|
|
||||||
* It may be used under the GNU GPL versions 2 or 3
|
|
||||||
* or any future license endorsed by Mnemosyne LLC.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QStyle>
|
|
||||||
|
|
||||||
#include "FilterBarLineEdit.h"
|
|
||||||
|
|
||||||
FilterBarLineEdit::FilterBarLineEdit (QWidget * parent):
|
|
||||||
QLineEdit (parent),
|
|
||||||
myClearButton (nullptr)
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
||||||
const QIcon icon = QIcon::fromTheme (QLatin1String ("edit-clear"), style ()->standardIcon (QStyle::SP_DialogCloseButton));
|
|
||||||
const int iconSize = style ()->pixelMetric (QStyle::PM_SmallIconSize);
|
|
||||||
|
|
||||||
myClearButton = new QToolButton (this);
|
|
||||||
myClearButton->setStyleSheet (QLatin1String ("QToolButton{border:0;padding:0;margin:0}"));
|
|
||||||
myClearButton->setToolButtonStyle (Qt::ToolButtonIconOnly);
|
|
||||||
myClearButton->setFocusPolicy (Qt::NoFocus);
|
|
||||||
myClearButton->setCursor (Qt::ArrowCursor);
|
|
||||||
myClearButton->setIconSize (QSize (iconSize, iconSize));
|
|
||||||
myClearButton->setIcon (icon);
|
|
||||||
myClearButton->setFixedSize (myClearButton->iconSize () + QSize (2, 2));
|
|
||||||
myClearButton->hide ();
|
|
||||||
|
|
||||||
const int frameWidth = style ()->pixelMetric (QStyle::PM_DefaultFrameWidth);
|
|
||||||
const QSize minSizeHint = minimumSizeHint ();
|
|
||||||
const QSize buttonSize = myClearButton->size ();
|
|
||||||
|
|
||||||
setStyleSheet (QString::fromLatin1 ("QLineEdit{padding-right:%1px}").arg (buttonSize.width () + frameWidth + 1));
|
|
||||||
setMinimumSize (qMax (minSizeHint.width (), buttonSize.width () + frameWidth * 2 + 2),
|
|
||||||
qMax (minSizeHint.height (), buttonSize.height () + frameWidth * 2 + 2));
|
|
||||||
|
|
||||||
connect (this, SIGNAL (textChanged (QString)), this, SLOT (updateClearButtonVisibility ()));
|
|
||||||
connect (myClearButton, SIGNAL (clicked ()), this, SLOT (clear ()));
|
|
||||||
#else
|
|
||||||
setClearButtonEnabled (true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
|
||||||
setPlaceholderText (tr ("Search..."));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FilterBarLineEdit::resizeEvent (QResizeEvent * event)
|
|
||||||
{
|
|
||||||
QLineEdit::resizeEvent (event);
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
||||||
const int frameWidth = style ()->pixelMetric (QStyle::PM_DefaultFrameWidth);
|
|
||||||
const QRect editRect = rect();
|
|
||||||
const QSize buttonSize = myClearButton->size ();
|
|
||||||
|
|
||||||
myClearButton->move (editRect.right () - frameWidth - buttonSize.width (),
|
|
||||||
editRect.top () + (editRect.height () - buttonSize.height ()) / 2);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FilterBarLineEdit::updateClearButtonVisibility ()
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
||||||
myClearButton->setVisible (!text ().isEmpty ());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file Copyright (C) 2010-2015 Mnemosyne LLC
|
|
||||||
*
|
|
||||||
* It may be used under the GNU GPL versions 2 or 3
|
|
||||||
* or any future license endorsed by Mnemosyne LLC.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
class QToolButton;
|
|
||||||
|
|
||||||
class FilterBarLineEdit: public QLineEdit
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
FilterBarLineEdit (QWidget * parent = nullptr);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// QWidget
|
|
||||||
virtual void resizeEvent (QResizeEvent * event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateClearButtonVisibility ();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QToolButton * myClearButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -86,14 +86,8 @@ RpcClient::isLocal () const
|
|||||||
if (mySession != 0)
|
if (mySession != 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
if (myUrl.host () == QLatin1String ("127.0.0.1") ||
|
|
||||||
myUrl.host ().compare (QLatin1String ("localhost"), Qt::CaseInsensitive) == 0)
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
if (QHostAddress (myUrl.host ()).isLoopback ())
|
if (QHostAddress (myUrl.host ()).isLoopback ())
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
71
qt/Utils.cc
71
qt/Utils.cc
@@ -21,16 +21,13 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
#include <QMimeType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
#include <QMimeDatabase>
|
|
||||||
#include <QMimeType>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h> // tr_formatter
|
#include <libtransmission/utils.h> // tr_formatter
|
||||||
|
|
||||||
@@ -40,7 +37,7 @@
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#if defined(_WIN32)
|
||||||
// Should be in QtWinExtras soon, but for now let's import it manually
|
// Should be in QtWinExtras soon, but for now let's import it manually
|
||||||
extern QPixmap qt_pixmapFromWinHICON(HICON icon);
|
extern QPixmap qt_pixmapFromWinHICON(HICON icon);
|
||||||
#endif
|
#endif
|
||||||
@@ -68,11 +65,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (shellFileInfo.hIcon != NULL)
|
if (shellFileInfo.hIcon != NULL)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
pixmap = qt_pixmapFromWinHICON (shellFileInfo.hIcon);
|
pixmap = qt_pixmapFromWinHICON (shellFileInfo.hIcon);
|
||||||
#else
|
|
||||||
pixmap = QPixmap::fromWinHICON (shellFileInfo.hIcon);
|
|
||||||
#endif
|
|
||||||
::DestroyIcon (shellFileInfo.hIcon);
|
::DestroyIcon (shellFileInfo.hIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,69 +106,13 @@ Utils::guessMimeIcon (const QString& filename)
|
|||||||
if (!icon.isNull ())
|
if (!icon.isNull ())
|
||||||
return icon;
|
return icon;
|
||||||
|
|
||||||
#elif QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#else
|
||||||
|
|
||||||
QMimeDatabase mimeDb;
|
QMimeDatabase mimeDb;
|
||||||
QMimeType mimeType = mimeDb.mimeTypeForFile (filename, QMimeDatabase::MatchExtension);
|
QMimeType mimeType = mimeDb.mimeTypeForFile (filename, QMimeDatabase::MatchExtension);
|
||||||
if (mimeType.isValid ())
|
if (mimeType.isValid ())
|
||||||
return QIcon::fromTheme (mimeType.iconName (), QIcon::fromTheme (mimeType.genericIconName (), fallback));
|
return QIcon::fromTheme (mimeType.iconName (), QIcon::fromTheme (mimeType.genericIconName (), fallback));
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
enum { DISK, DOCUMENT, PICTURE, VIDEO, ARCHIVE, AUDIO, APP, TYPE_COUNT };
|
|
||||||
static QIcon fileIcons[TYPE_COUNT];
|
|
||||||
static QSet<QString> suffixes[TYPE_COUNT];
|
|
||||||
|
|
||||||
if (fileIcons[0].isNull ())
|
|
||||||
{
|
|
||||||
suffixes[DISK] << QString::fromLatin1("iso");
|
|
||||||
fileIcons[DISK]= QIcon::fromTheme (QString::fromLatin1("media-optical"), fallback);
|
|
||||||
|
|
||||||
const char * doc_types[] = {
|
|
||||||
"abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp",
|
|
||||||
"ods", "odt", "pdf", "ppt", "ps", "rtf", "tex", "txt", "xml" };
|
|
||||||
for (const char * t: doc_types)
|
|
||||||
suffixes[DOCUMENT] << QString::fromLatin1(t);
|
|
||||||
fileIcons[DOCUMENT] = QIcon::fromTheme (QString::fromLatin1("text-x-generic"), fallback);
|
|
||||||
|
|
||||||
const char * pic_types[] = {
|
|
||||||
"bmp", "gif", "jpg", "jpeg", "pcx", "png", "psd", "ras", "tga", "tiff" };
|
|
||||||
for (const char * t: pic_types)
|
|
||||||
suffixes[PICTURE] << QString::fromLatin1(t);
|
|
||||||
fileIcons[PICTURE] = QIcon::fromTheme (QString::fromLatin1("image-x-generic"), fallback);
|
|
||||||
|
|
||||||
const char * vid_types[] = {
|
|
||||||
"3gp", "asf", "avi", "mkv", "mov", "mpeg", "mpg", "mp4",
|
|
||||||
"ogm", "ogv", "qt", "rm", "wmv" };
|
|
||||||
for (const char * t: vid_types)
|
|
||||||
suffixes[VIDEO] << QString::fromLatin1(t);
|
|
||||||
fileIcons[VIDEO] = QIcon::fromTheme (QString::fromLatin1("video-x-generic"), fallback);
|
|
||||||
|
|
||||||
const char * arc_types[] = {
|
|
||||||
"7z", "ace", "bz2", "cbz", "gz", "gzip", "lzma", "rar", "sft", "tar", "zip" };
|
|
||||||
for (const char * t: arc_types)
|
|
||||||
suffixes[ARCHIVE] << QString::fromLatin1(t);
|
|
||||||
fileIcons[ARCHIVE] = QIcon::fromTheme (QString::fromLatin1("package-x-generic"), fallback);
|
|
||||||
|
|
||||||
const char * aud_types[] = {
|
|
||||||
"aac", "ac3", "aiff", "ape", "au", "flac", "m3u", "m4a", "mid", "midi", "mp2",
|
|
||||||
"mp3", "mpc", "nsf", "oga", "ogg", "ra", "ram", "shn", "voc", "wav", "wma" };
|
|
||||||
for (const char * t: aud_types)
|
|
||||||
suffixes[AUDIO] << QString::fromLatin1(t);
|
|
||||||
fileIcons[AUDIO] = QIcon::fromTheme (QString::fromLatin1("audio-x-generic"), fallback);
|
|
||||||
|
|
||||||
const char * exe_types[] = { "bat", "cmd", "com", "exe" };
|
|
||||||
for (const char * t: exe_types)
|
|
||||||
suffixes[APP] << QString::fromLatin1(t);
|
|
||||||
fileIcons[APP] = QIcon::fromTheme (QString::fromLatin1("application-x-executable"), fallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString suffix (QFileInfo (filename).suffix ().toLower ());
|
|
||||||
|
|
||||||
for (int i=0; i<TYPE_COUNT; ++i)
|
|
||||||
if (suffixes[i].contains (suffix))
|
|
||||||
return fileIcons[i];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ SOURCES += AboutDialog.cc \
|
|||||||
FilterBar.cc \
|
FilterBar.cc \
|
||||||
FilterBarComboBox.cc \
|
FilterBarComboBox.cc \
|
||||||
FilterBarComboBoxDelegate.cc \
|
FilterBarComboBoxDelegate.cc \
|
||||||
FilterBarLineEdit.cc \
|
|
||||||
Filters.cc \
|
Filters.cc \
|
||||||
Formatter.cc \
|
Formatter.cc \
|
||||||
FreeSpaceLabel.cc \
|
FreeSpaceLabel.cc \
|
||||||
|
|||||||
Reference in New Issue
Block a user