Skip to content

Commit

Permalink
Remove support for Qt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Mar 8, 2018
1 parent f76c73d commit 0d28f4b
Show file tree
Hide file tree
Showing 46 changed files with 95 additions and 485 deletions.
31 changes: 4 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.6)
cmake_minimum_required(VERSION 2.8.8)
project(copyq)

# C++11
Expand All @@ -16,7 +16,6 @@ endif()
OPTION(PEDANTIC "Enable all compiler warnings" OFF)

# Options (cmake -LH)
OPTION(WITH_QT5 "Use Qt 5 (disable to use Qt 4 instead)" ON)
OPTION(WITH_TESTS "Run test cases from command line" ${COPYQ_DEBUG})
OPTION(WITH_PLUGINS "Compile plugins" ON)
# Unix-specific options
Expand All @@ -34,26 +33,8 @@ endif()

set(CMAKE_AUTOMOC ON)

if (WITH_QT5)
cmake_minimum_required(VERSION 2.8.8)
list(APPEND copyq_Qt5_Modules Widgets)
find_package(Qt5Widgets)
if (NOT Qt5Widgets_FOUND)
message(FATAL_ERROR "Qt 5 is unavailable. To compile with Qt 4 use -DWITH_QT5=OFF.")
endif()
message(STATUS "Building with Qt 5.")
else()
find_package(Qt4)
if (NOT QT4_FOUND)
# Try different executable name.
set(QT_QMAKE_EXECUTABLE "qmake-qt4")
find_package(Qt4)
if (NOT QT4_FOUND)
message(FATAL_ERROR "Qt 4 is unavailable. To compile with Qt 5 use -DWITH_QT5=ON.")
endif()
endif()
message(STATUS "Building with Qt 4.")
endif()
list(APPEND copyq_Qt5_Modules Widgets)
find_package(Qt5Widgets REQUIRED)

set(copyq_ICON_PREFIX src/images/icon)
set(copyq_ICON_NORMAL src/images/icon.svg)
Expand Down Expand Up @@ -137,11 +118,7 @@ if(WITH_TESTS)

add_definitions( -DHAS_TESTS )

if (WITH_QT5)
list(APPEND copyq_Qt5_Modules Test)
else()
set(QT_USE_QTTEST TRUE)
endif()
list(APPEND copyq_Qt5_Modules Test)
endif()

# Get application version.
Expand Down
41 changes: 0 additions & 41 deletions debian/control-qt4

This file was deleted.

17 changes: 0 additions & 17 deletions debian/rules-qt4

This file was deleted.

6 changes: 3 additions & 3 deletions docs/source-code-overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ CI servers.

- `Travis CI <https://travis-ci.org/hluk/CopyQ>`__
- Builds packages for OS X.
- Builds and runs tests for Linux binaries with Qt 4.
- Builds and runs tests for Linux binaries.

- `GitLab CI <https://gitlab.com/CopyQ/CopyQ/builds>`__
- Builds and runs tests for Ubuntu 16.04 binaries with Qt 5.
- Builds and runs tests for Ubuntu 16.04 binaries.
- Screenshots are taken while GUI tests are running. These are
available if a test fails.

- `AppVeyor <https://ci.appveyor.com/project/hluk/copyq>`__
- Builds installers and portable packages for Windows with Qt 5.
- Builds installers and portable packages for Windows.
- Provides downloads for recent commits.
- Release build are based on gcc-compiled binaries (Visual Studio
builds are also available).
Expand Down
2 changes: 1 addition & 1 deletion docs/text-encoding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ The same goes for other way. CopyQ sends texts back to client or to a
command in system encoding so it needs to convert these texts from
UTF-8.

As for the re-encoding part, Qt 5 does nice job transforming characters
As for the re-encoding part, Qt does nice job transforming characters
from UTF-8 but of course for lot of characters in UTF-8 there is no
alternative in Latin1 and other encodings.
21 changes: 5 additions & 16 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@ macro (copyq_add_plugin)

include_directories(${CMAKE_CURRENT_BINARY_DIR} ../../src)

if (WITH_QT5)
include_directories(${Qt5Widgets_INCLUDES})
add_definitions(${Qt5Widgets_DEFINITIONS})
qt5_wrap_ui(copyq_plugin_FORMS_HEADERS ${copyq_plugin_FORMS})
qt5_add_resources(copyq_plugin_RCC ${copyq_plugin_${copyq_pkg}_RESOURCES})
else()
include_directories(${QT_INCLUDES})
add_definitions(${QT_DEFINITIONS})
qt4_wrap_ui(copyq_plugin_FORMS_HEADERS ${copyq_plugin_FORMS})
qt4_add_resources(copyq_plugin_RCC ${copyq_plugin_${copyq_pkg}_RESOURCES})
endif()
include_directories(${Qt5Widgets_INCLUDES})
add_definitions(${Qt5Widgets_DEFINITIONS})
qt5_wrap_ui(copyq_plugin_FORMS_HEADERS ${copyq_plugin_FORMS})
qt5_add_resources(copyq_plugin_RCC ${copyq_plugin_${copyq_pkg}_RESOURCES})

add_library(${copyq_pkg} MODULE
${copyq_plugin_SOURCES}
Expand All @@ -38,11 +31,7 @@ macro (copyq_add_plugin)
set_target_properties(${copyq_pkg} PROPERTIES
COMPILE_DEFINITIONS "${copyq_plugin_${copyq_pkg}_DEFINITIONS}")

if (WITH_QT5)
qt5_use_modules(${copyq_pkg} Widgets ${copyq_Qt5_Modules} ${copyq_plugin_${copyq_pkg}_Qt5_Modules})
else()
include(${QT_USE_FILE})
endif()
qt5_use_modules(${copyq_pkg} Widgets ${copyq_Qt5_Modules} ${copyq_plugin_${copyq_pkg}_Qt5_Modules})

target_link_libraries(${copyq_pkg} ${QT_LIBRARIES} ${copyq_plugin_${copyq_pkg}_LIBRARIES})

Expand Down
10 changes: 0 additions & 10 deletions plugins/itemimage/itemimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,10 @@ QObject *ItemImage::createExternalEditor(const QModelIndex &index, QWidget *pare
void ItemImage::updateSize(QSize, int)
{
const auto m2 = 2 * margin();
#if QT_VERSION < 0x050000
setFixedSize( m_pixmap.size() + QSize(m2, m2) );
#else
const int ratio = devicePixelRatio();
const int w = (m_pixmap.width() + 1) / ratio + m2;
const int h = (m_pixmap.height() + 1) / ratio + m2;
setFixedSize( QSize(w, h) );
#endif
}

void ItemImage::setCurrent(bool current)
Expand Down Expand Up @@ -172,9 +168,6 @@ void ItemImage::hideEvent(QHideEvent *event)

void ItemImage::paintEvent(QPaintEvent *event)
{
#if QT_VERSION < 0x050000
QLabel::paintEvent(event);
#else
// WORKAROUND: Draw current animation frame with correct DPI.
if (movie()) {
QPainter painter(this);
Expand All @@ -185,7 +178,6 @@ void ItemImage::paintEvent(QPaintEvent *event)
} else {
QLabel::paintEvent(event);
}
#endif
}

void ItemImage::startAnimation()
Expand Down Expand Up @@ -216,9 +208,7 @@ ItemWidget *ItemImageLoader::create(const QVariantMap &data, QWidget *parent, bo
if ( !getPixmapFromData(data, &pix) )
return nullptr;

#if QT_VERSION >= 0x050000
pix.setDevicePixelRatio( parent->devicePixelRatio() );
#endif

// scale pixmap
const int w = preview ? 0 : m_settings.value("max_image_width", 320).toInt();
Expand Down
5 changes: 1 addition & 4 deletions plugins/itemnotes/itemnotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ QWidget *createIconWidget(const QByteArray &icon, QWidget *parent)
if (!icon.isEmpty()) {
QPixmap p;
if (p.loadFromData(icon)) {
#if QT_VERSION < 0x050000
const auto ratio = 1;
#else
const auto ratio = parent->devicePixelRatio();
p.setDevicePixelRatio(ratio);
#endif

const int side = ratio * (iconFontSizePixels() + 2);
p = p.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QLabel *label = new QLabel(parent);
Expand Down
4 changes: 0 additions & 4 deletions plugins/itempinned/itempinned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,7 @@ void ItemPinnedSaver::onDataChanged(const QModelIndex &topLeft, const QModelInde

void ItemPinnedSaver::moveRow(int from, int to)
{
#if QT_VERSION < 0x050000
QMetaObject::invokeMethod(m_model, "moveRow", Q_ARG(int, from), Q_ARG(int, to));
#else
m_model->moveRow(QModelIndex(), from, QModelIndex(), to);
#endif
}

void ItemPinnedSaver::updateLastPinned(int from, int to)
Expand Down
13 changes: 2 additions & 11 deletions plugins/itemsync/itemsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ void writeConfiguration(QIODevice *file, const QStringList &savedFiles)
stream << config;
}

void setHeaderSectionResizeMode(QHeaderView *header, int logicalIndex, QHeaderView::ResizeMode mode)
{
#if QT_VERSION < 0x050000
header->setResizeMode(logicalIndex, mode);
#else
header->setSectionResizeMode(logicalIndex, mode);
#endif
}

QString iconFromId(int id)
{
return id != -1 ? QString(QChar(id)) : QString();
Expand Down Expand Up @@ -338,8 +329,8 @@ void fixUserMimeType(QString *mimeType)
void setNormalStretchFixedColumns(QTableWidget *table, int normalColumn, int stretchColumn, int fixedColumn)
{
QHeaderView *header = table->horizontalHeader();
setHeaderSectionResizeMode(header, stretchColumn, QHeaderView::Stretch);
setHeaderSectionResizeMode(header, fixedColumn, QHeaderView::Fixed);
header->setSectionResizeMode(stretchColumn, QHeaderView::Stretch);
header->setSectionResizeMode(fixedColumn, QHeaderView::Fixed);
header->resizeSection(fixedColumn, table->rowHeight(0));
table->resizeColumnToContents(normalColumn);
}
Expand Down
29 changes: 9 additions & 20 deletions plugins/itemtags/itemtags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,9 @@ void setColorIcon(QPushButton *button, const QColor &color)
button->setProperty(propertyColor, color);
}

void setHeaderSectionResizeMode(QTableWidget *table, int logicalIndex, QHeaderView::ResizeMode mode)
{
#if QT_VERSION < 0x050000
table->horizontalHeader()->setResizeMode(logicalIndex, mode);
#else
table->horizontalHeader()->setSectionResizeMode(logicalIndex, mode);
#endif
}

void setFixedColumnSize(QTableWidget *table, int logicalIndex)
{
setHeaderSectionResizeMode(table, logicalIndex, QHeaderView::Fixed);
table->horizontalHeader()->setSectionResizeMode(logicalIndex, QHeaderView::Fixed);
table->horizontalHeader()->resizeSection(logicalIndex, table->rowHeight(0));
}

Expand Down Expand Up @@ -320,13 +311,11 @@ class TagTableWidgetItem : public QTableWidgetItem
if ( isTagValid(tag) ) {
QWidget tagWidget;
initTagWidget(&tagWidget, tag, smallerFont(QFont()));
#if QT_VERSION < 0x050000
m_pixmap = QPixmap( tagWidget.sizeHint() );
#else

const auto ratio = tagWidget.devicePixelRatio();
m_pixmap = QPixmap( tagWidget.sizeHint() * ratio );
m_pixmap.setDevicePixelRatio(ratio);
#endif

m_pixmap.fill(Qt::transparent);
QPainter painter(&m_pixmap);
tagWidget.render(&painter);
Expand Down Expand Up @@ -680,12 +669,12 @@ QWidget *ItemTagsLoader::createSettingsWidget(QWidget *parent)
for (int i = 0; i < 10; ++i)
addTagToSettingsTable();

QTableWidget *t = ui->tableWidget;
setHeaderSectionResizeMode(t, tagsTableColumns::name, QHeaderView::Stretch);
setHeaderSectionResizeMode(t, tagsTableColumns::styleSheet, QHeaderView::Stretch);
setHeaderSectionResizeMode(t, tagsTableColumns::match, QHeaderView::Stretch);
setFixedColumnSize(t, tagsTableColumns::color);
setFixedColumnSize(t, tagsTableColumns::icon);
auto header = ui->tableWidget->horizontalHeader();
header->setSectionResizeMode(tagsTableColumns::name, QHeaderView::Stretch);
header->setSectionResizeMode(tagsTableColumns::styleSheet, QHeaderView::Stretch);
header->setSectionResizeMode(tagsTableColumns::match, QHeaderView::Stretch);
setFixedColumnSize(ui->tableWidget, tagsTableColumns::color);
setFixedColumnSize(ui->tableWidget, tagsTableColumns::icon);

connect( ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)),
this, SLOT(onTableWidgetItemChanged(QTableWidgetItem*)) );
Expand Down
22 changes: 5 additions & 17 deletions plugins/itemweb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
OPTION(WITH_WEBKIT "WebKit support" ON)

# Qt modules
if (WITH_QT5)
# webkit
if (WITH_WEBKIT)
find_package(Qt5WebKitWidgets QUIET)
set(HAS_WEBKIT ${Qt5WebKitWidgets_FOUND})
endif(WITH_WEBKIT)
else()
# webkit
if (WITH_WEBKIT)
set(HAS_WEBKIT ${QT_QTWEBKIT_FOUND})
endif(WITH_WEBKIT)
endif()
if (WITH_WEBKIT)
find_package(Qt5WebKitWidgets QUIET)
set(HAS_WEBKIT ${Qt5WebKitWidgets_FOUND})
endif(WITH_WEBKIT)

# webkit
if (HAS_WEBKIT)
message(STATUS "Building with ItemWeb plugin.")

if (WITH_QT5)
set(copyq_plugin_itemweb_Qt5_Modules WebKitWidgets)
else()
set(QT_USE_QTWEBKIT ON)
endif()
set(copyq_plugin_itemweb_Qt5_Modules WebKitWidgets)

set(copyq_plugin_itemweb_SOURCES
../../src/common/mimetypes.cpp
Expand Down
11 changes: 2 additions & 9 deletions plugins/itemweb/itemweb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@
#include <QPalette>
#include <QtPlugin>
#include <QtWebKit/QWebHistory>
#if QT_VERSION < 0x050000
# include <QtWebKit/QWebFrame>
# include <QtWebKit/QWebPage>
#else
# include <QtWebKitWidgets/QWebFrame>
# include <QtWebKitWidgets/QWebPage>
#endif
#include <QtWebKitWidgets/QWebFrame>
#include <QtWebKitWidgets/QWebPage>
#include <QVariant>

namespace {
Expand Down Expand Up @@ -197,9 +192,7 @@ void ItemWeb::mouseReleaseEvent(QMouseEvent *e)
{
if (m_copyOnMouseUp) {
m_copyOnMouseUp = false;
#if QT_VERSION >= 0x040800
if ( hasSelection() )
#endif
triggerPageAction(QWebPage::Copy);
} else {
QWebView::mouseReleaseEvent(e);
Expand Down
Loading

0 comments on commit 0d28f4b

Please sign in to comment.