Drop Qt 4 support

This commit is contained in:
Eugene Shalygin
2017-01-19 13:10:09 +01:00
parent 60998a68eb
commit e64bb1de8c
67 changed files with 48 additions and 8809 deletions

View File

@@ -424,9 +424,7 @@ bool ICOHandler::canRead(QIODevice *device)
class ICOPlugin : public QImageIOPlugin
{
#ifdef QBT_USES_QT5
Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin")
#endif
public:
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
@@ -460,8 +458,3 @@ QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format)
handler->setFormat(format);
return handler;
}
#ifndef QBT_USES_QT5
Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
Q_EXPORT_PLUGIN2(ico, ICOPlugin)
#endif

View File

@@ -11,10 +11,6 @@ resources/lineeditimages.qrc
)
add_library(qbt_lineedit STATIC ${QBT_LINEEDIT_SOURCES} ${QBT_LINEEDIT_HEADERS})
if (QT4_FOUND)
target_link_libraries(qbt_lineedit Qt4::QtGui)
else (QT4_FOUND)
target_link_libraries(qbt_lineedit Qt5::Widgets)
endif (QT4_FOUND)
target_link_libraries(qbt_lineedit Qt5::Widgets)
qbt_target_sources(${QBT_LINEEDIT_RESOURCES})

View File

@@ -25,24 +25,8 @@ LineEdit::LineEdit(QWidget *parent)
QSize searchButtonHint = searchButton->sizeHint();
QSize clearButtonHint(0, 0);
#ifndef QBT_USES_QT5
QPixmap pixmap2(":/lineeditimages/clear_left.png");
clearButton = new QToolButton(this);
clearButton->setIcon(QIcon(pixmap2));
clearButton->setIconSize(pixmap2.size());
clearButton->setCursor(Qt::ArrowCursor);
clearButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
clearButton->setToolTip(tr("Clear the text"));
clearButton->hide();
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(updateCloseButton(const QString &)));
clearButtonHint = clearButton->sizeHint();
setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(searchButtonHint.width()).arg(clearButtonHint.width()));
#else
setClearButtonEnabled(true);
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButtonHint.width())); // padding between text and widget borders
#endif
QSize widgetHint = sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
@@ -56,15 +40,5 @@ void LineEdit::resizeEvent(QResizeEvent *e)
QSize sz = searchButton->sizeHint();
searchButton->move(frameWidth, (e->size().height() - sz.height()) / 2);
#ifndef QBT_USES_QT5
QSize cz = clearButton->sizeHint();
clearButton->move((e->size().width() - frameWidth - cz.width()), (e->size().height() - sz.height()) / 2);
#endif
}
#ifndef QBT_USES_QT5
void LineEdit::updateCloseButton(const QString &text)
{
clearButton->setVisible(!text.isEmpty());
}
#endif

View File

@@ -24,16 +24,8 @@ public:
protected:
void resizeEvent(QResizeEvent *e);
#ifndef QBT_USES_QT5
private slots:
void updateCloseButton(const QString &text);
#endif
private:
QToolButton *searchButton;
#ifndef QBT_USES_QT5
QToolButton *clearButton;
#endif
};
#endif // LIENEDIT_H

View File

@@ -122,11 +122,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
}
}
#ifndef QBT_USES_QT5
m_ui->scanFoldersView->header()->setResizeMode(QHeaderView::ResizeToContents);
#else
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
m_ui->scanFoldersView->setItemDelegate(new ScanFoldersDelegate(this, m_ui->scanFoldersView));
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(enableApplyButton()));

View File

@@ -42,12 +42,8 @@
#include "previewselect.h"
#ifdef Q_OS_WIN
#ifndef QBT_USES_QT5
#include <QPlastiqueStyle>
#else
#include <QProxyStyle>
#endif
#endif
class PreviewListDelegate: public QItemDelegate {
Q_OBJECT
@@ -80,11 +76,7 @@ class PreviewListDelegate: public QItemDelegate {
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
#ifndef QBT_USES_QT5
QPlastiqueStyle st;
#else
QProxyStyle st("fusion");
#endif
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;

View File

@@ -32,9 +32,7 @@
#include <QHeaderView>
#include <QMessageBox>
#include <QFile>
#ifdef QBT_USES_QT5
#include <QTableView>
#endif
#include "base/utils/misc.h"
#include "previewlistdelegate.h"
@@ -54,14 +52,12 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(previewList->header());
previewList->header()->setParent(previewList);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
previewList->setModel(previewListModel);
previewList->hideColumn(FILE_INDEX);
listDelegate = new PreviewListDelegate(this);

View File

@@ -44,6 +44,4 @@ speedplotview.cpp
add_library(qbt_properties STATIC ${QBT_PROPERTIES_HEADERS} ${QBT_PROPERTIES_SOURCES})
target_link_libraries(qbt_properties qbt_base)
if (NOT QT4_FOUND)
target_link_libraries(qbt_properties Qt5::Widgets Qt5::Concurrent)
endif (NOT QT4_FOUND)
target_link_libraries(qbt_properties Qt5::Widgets Qt5::Concurrent)

View File

@@ -36,9 +36,7 @@
#include <QClipboard>
#include <QMessageBox>
#include <QWheelEvent>
#ifdef QBT_USES_QT5
#include <QTableView>
#endif
#include "base/net/reverseresolution.h"
#include "base/bittorrent/torrenthandle.h"
@@ -135,14 +133,12 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
handleSortColumnChanged(header()->sortIndicatorSection());
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copySelectedPeers()), 0, Qt::WidgetShortcut);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(this->header());
this->header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
}
PeerListWidget::~PeerListWidget()

View File

@@ -39,10 +39,8 @@ PeersAdditionDlg::PeersAdditionDlg(QWidget *parent)
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
#ifdef QBT_USES_QT5
label_format->hide();
peers_txt->setPlaceholderText("Format: IPv4:port / [IPv6]:port");
#endif
}
QList<BitTorrent::PeerAddress> PeersAdditionDlg::askForPeers()

View File

@@ -102,15 +102,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
connect(filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
connect(filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
#ifdef QBT_USES_QT5
// set bar height relative to screen dpi
int barHeight = devicePixelRatio() * 18;
#else
// set bar height relative to font height
QFont defFont;
QFontMetrics fMetrics(defFont, 0); // need to be device-dependent
int barHeight = fMetrics.height() * 5 / 4;
#endif
// Downloaded pieces progress bar
tempProgressBarArea->setVisible(false);

View File

@@ -36,12 +36,8 @@
#include <QStyleOptionProgressBar>
#ifdef Q_OS_WIN
#ifndef QBT_USES_QT5
#include <QPlastiqueStyle>
#else
#include <QProxyStyle>
#endif
#endif
#include "base/utils/misc.h"
#include "base/utils/string.h"
@@ -106,11 +102,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
#ifndef QBT_USES_QT5
QPlastiqueStyle st;
#else
QProxyStyle st("fusion");
#endif
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
}

View File

@@ -37,10 +37,8 @@
#include <QDebug>
#include <QUrl>
#include <QMessageBox>
#ifdef QBT_USES_QT5
#include <QTableView>
#include <QHeaderView>
#endif
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
@@ -88,14 +86,12 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(this->header());
this->header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
loadSettings();
}

View File

@@ -24,8 +24,4 @@ rsssettingsdlg.ui
add_library(qbt_rss STATIC ${QBT_RSS_HEADERS} ${QBT_RSS_SOURCE} ${QBT_RSS_FORMS})
target_link_libraries(qbt_rss qbt_base)
if (QT4_FOUND)
target_link_libraries(qbt_rss Qt4::QtGui Qt4::QtNetwork)
else (QT4_FOUND)
target_link_libraries(qbt_rss Qt5::Gui Qt5::Widgets Qt5::Network)
endif (QT4_FOUND)
target_link_libraries(qbt_rss Qt5::Gui Qt5::Widgets Qt5::Network)

View File

@@ -36,9 +36,7 @@
#include <QDropEvent>
#include <QMimeData>
#include <QClipboard>
#ifdef QBT_USES_QT5
#include <QTableView>
#endif
#include "base/utils/fs.h"
#include "base/utils/misc.h"
@@ -69,14 +67,13 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(pluginsTree->header());
pluginsTree->header()->setParent(pluginsTree);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
pluginsTree->setRootIsDecorated(false);
pluginsTree->header()->resizeSection(0, 160);
pluginsTree->header()->resizeSection(1, 80);

View File

@@ -39,9 +39,7 @@
#include <QLabel>
#include <QPalette>
#include <QVBoxLayout>
#ifdef QBT_USES_QT5
#include <QTableView>
#endif
#include "base/utils/misc.h"
#include "base/preferences.h"
@@ -67,14 +65,13 @@ SearchTab::SearchTab(SearchWidget *parent)
{
m_ui->setupUi(this);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->resultsBrowser->header());
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
loadSettings();
m_ui->resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
header()->setStretchLastSection(false);

View File

@@ -32,24 +32,20 @@
#include <QKeyEvent>
#include <QModelIndexList>
#ifdef QBT_USES_QT5
#include <QTableView>
#include <QHeaderView>
#endif
#include "torrentcontentmodelitem.h"
TorrentContentTreeView::TorrentContentTreeView(QWidget* parent)
: QTreeView(parent)
{
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
}
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) {

View File

@@ -44,12 +44,8 @@
#include "base/unicodestrings.h"
#ifdef Q_OS_WIN
#ifndef QBT_USES_QT5
#include <QPlastiqueStyle>
#else
#include <QProxyStyle>
#endif
#endif
TransferListDelegate::TransferListDelegate(QObject *parent)
: QItemDelegate(parent)
@@ -175,11 +171,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
#ifndef QBT_USES_QT5
QPlastiqueStyle st;
#else
QProxyStyle st("fusion");
#endif
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;

View File

@@ -41,9 +41,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QWheelEvent>
#ifdef QBT_USES_QT5
#include <QTableView>
#endif
#include "transferlistwidget.h"
#include "base/bittorrent/session.h"
@@ -161,14 +159,12 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window)
doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut);
recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
}
TransferListWidget::~TransferListWidget()