Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
qt-gui: make it possible to build the plugin with Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
erijo committed Oct 6, 2014
1 parent de72289 commit cdff6e0
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 23 deletions.
32 changes: 24 additions & 8 deletions qt-gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
project(Qt-GUI)
cmake_minimum_required(VERSION 2.4.2)
cmake_minimum_required(VERSION 2.8.11)
include(CheckIncludeFile)
include(TestCXXAcceptsFlag)
include(CheckLibraryExists)
include(CMakeDependentOption)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

# Use KDE support
option(WITH_KDE "Compile with KDE support" OFF)

cmake_dependent_option(WITH_QT5 "Compile with Qt5 support" OFF
"NOT WITH_KDE" OFF)

# Licq
find_package(Licq REQUIRED)
include_directories(${Licq_INCLUDE_DIRS})
Expand All @@ -29,6 +33,10 @@ set(LIBRARIES)
if (NOT APPLE)
find_package(X11 REQUIRED)

if (WITH_QT5)
set(X11_Xscreensaver_FOUND false)
endif (WITH_QT5)

if (X11_Xscreensaver_FOUND)
set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xscreensaver_LIB})
set(USE_SCRNSAVER 1)
Expand All @@ -38,13 +46,19 @@ if (NOT APPLE)
set(LIBRARIES ${LIBRARIES} ${X11_LIBRARIES})
endif (NOT APPLE)


# Check for Qt4
set(QT_MIN_VERSION "4.3.0")
# Check for Qt
if (NOT WITH_QT5)
set(QT_MIN_VERSION "4.3.0")
endif (NOT WITH_QT5)

# Check for Qt unless WITH_KDE is requested
if (NOT WITH_KDE)
find_package(Qt4 REQUIRED)
if (WITH_QT5)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
else (WITH_QT5)
find_package(Qt4 REQUIRED)
endif (WITH_QT5)

# Check for HunSpell
find_package(Hunspell)
Expand Down Expand Up @@ -94,9 +108,11 @@ else (NOT WITH_KDE)
${KDE4_KIO_LIBS})
endif (NOT WITH_KDE)

set(QT_USE_QTXML 1)
include(${QT_USE_FILE})
set(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
if (NOT WITH_QT5)
set(QT_USE_QTXML 1)
include(${QT_USE_FILE})
set(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
endif (NOT WITH_QT5)

# Local includes
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down
16 changes: 12 additions & 4 deletions qt-gui/po/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,29 @@ find_program(QT_LRELEASE
DOC "Path to the lrelease program"
)

if (WITH_QT5)
set(qt_version "-qt=5")
else (WITH_QT5)
set(qt_version "-qt=4")
endif (WITH_QT5)


# Update translations (note that [clean-]merge targets write to source directory)
if (QT_LUPDATE)
# merge: update all translations
add_custom_target(${licq_target_prefix}merge
${QT_LUPDATE} ${translate_files} -ts ${po_SRCS}
${QT_LUPDATE} ${qt_version} ${translate_files} -ts ${po_SRCS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

# clean-merge: update all translations and remove obsolete strings
add_custom_target(${licq_target_prefix}clean-merge
${QT_LUPDATE} -noobsolete ${translate_files} -ts ${po_SRCS}
${QT_LUPDATE} ${qt_version} -noobsolete ${translate_files} -ts ${po_SRCS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

# Create template.ts to be used for new translations
add_custom_command(OUTPUT template.ts
COMMAND ${QT_LUPDATE} -noobsolete ${translate_files} -ts template.ts
COMMAND ${QT_LUPDATE} ${qt_version} -noobsolete ${translate_files}
-ts template.ts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${translate_files})

Expand All @@ -72,7 +80,7 @@ if (QT_LRELEASE)
set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
set(po "${CMAKE_CURRENT_SOURCE_DIR}/${po}")
add_custom_command(OUTPUT ${qm}
COMMAND ${QT_LRELEASE} -silent ${po} -qm ${qm}
COMMAND ${QT_LRELEASE} ${qt_version} -silent ${po} -qm ${qm}
DEPENDS ${po})
set(qms ${qms} ${qm})
endforeach(po)
Expand Down
10 changes: 9 additions & 1 deletion qt-gui/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ foreach (dir ${SOURCE_DIRS})
# Add targets for creating moc files
foreach (file ${${dir}_MOC_HDRS})
set(outfile "${dir}/moc_${file}.cpp")
qt4_generate_moc("${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${file}" ${outfile})
if (WITH_QT5)
qt5_generate_moc("${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${file}" ${outfile})
else (WITH_QT5)
qt4_generate_moc("${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${file}" ${outfile})
endif (WITH_QT5)
list(APPEND mocs ${outfile})
endforeach (file)
endforeach (dir)
Expand All @@ -43,3 +47,7 @@ endif (WITH_KDE)

licq_add_plugin(${target} ${sources} ${mocs})
target_link_libraries(${target} ${LIBRARIES})
if (WITH_QT5)
target_link_libraries(${target} Qt5::Widgets)
target_link_libraries(${target} Qt5::Xml)
endif (WITH_QT5)
6 changes: 5 additions & 1 deletion qt-gui/src/config/emoticons.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of Licq, an instant messaging client for UNIX.
* Copyright (C) 2003-2011 Licq developers
* Copyright (C) 2003-2014 Licq developers <licq-dev@googlegroups.com>
*
* Licq is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -281,7 +281,11 @@ static bool parseXml(const QString& dir, QMap<QChar, QLinkedList<Emoticon> >* em
{
Emoticon emo;
emo.smiley = string.text();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
emo.escapedSmiley = emo.smiley.toHtmlEscaped();
#else
emo.escapedSmiley = Qt::escape(emo.smiley);
#endif
emo.file = file;

if (first)
Expand Down
8 changes: 4 additions & 4 deletions qt-gui/src/contactlist/singlecontactproxy.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of Licq, an instant messaging client for UNIX.
* Copyright (C) 2007-2012 Licq developers <licq-dev@googlegroups.com>
* Copyright (C) 2007-2014 Licq developers <licq-dev@googlegroups.com>
*
* Licq is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -55,14 +55,14 @@ void SingleContactProxy::slot_dataChanged(const QModelIndex& topLeft, const QMod
int groupId = topLeft.data(ContactListModel::GroupIdRole).toInt();
if (groupId == ContactListModel::AllUsersGroupId)
if (topLeft.row() <= mySourceIndex[0].row() && bottomRight.row() >= mySourceIndex[0].row())
emit dataChanged(createIndex(0, 0, 0), createIndex(0, myContactList->columnCount() - 1, 0));
emit dataChanged(createIndex(0, 0), createIndex(0, myContactList->columnCount() - 1));
}

QModelIndex SingleContactProxy::index(int row, int column, const QModelIndex& parent) const
{
// Only one top level item so return invalid for anything else
if (!parent.isValid() && row == 0 && column >= 0 && column < MAX_COLUMNCOUNT)
return createIndex(0, column, 0);
return createIndex(0, column);

return QModelIndex();
}
Expand Down Expand Up @@ -114,7 +114,7 @@ QVariant SingleContactProxy::headerData(int section, Qt::Orientation orientation
QModelIndex SingleContactProxy::mapFromSource(const QModelIndex& sourceIndex) const
{
if (sourceIndex.column() < MAX_COLUMNCOUNT && sourceIndex == mySourceIndex[sourceIndex.column()])
return createIndex(0, sourceIndex.column(), 0);
return createIndex(0, sourceIndex.column());

return QModelIndex();
}
Expand Down
4 changes: 4 additions & 0 deletions qt-gui/src/dialogs/gpgkeyselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ KeyView::KeyView(const Licq::UserId& userId, QWidget* parent)
: QTreeWidget(parent),
myUserId(userId)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
header()->setSectionsClickable(false);
#else
header()->setClickable(false);
#endif
QStringList headers;
headers << tr("Name") << tr("EMail") << tr("ID");
setHeaderLabels(headers);
Expand Down
4 changes: 2 additions & 2 deletions qt-gui/src/userevents/usersendevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,11 @@ void UserSendEvent::convoLeave(const Licq::UserId& userId)
}
}

void UserSendEvent::windowActivationChange(bool oldActive)
void UserSendEvent::changeEvent(QEvent* event)
{
if (isActiveWindow())
QTimer::singleShot(clearDelay, this, SLOT(clearNewEvents()));
QWidget::windowActivationChange(oldActive);
QWidget::changeEvent(event);
}

void UserSendEvent::changeEventType(int type)
Expand Down
4 changes: 2 additions & 2 deletions qt-gui/src/userevents/usersendevent.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of Licq, an instant messaging client for UNIX.
* Copyright (C) 2000-2012 Licq developers <licq-dev@googlegroups.com>
* Copyright (C) 2000-2014 Licq developers <licq-dev@googlegroups.com>
*
* Licq is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -78,7 +78,7 @@ class UserSendEvent : public UserEventCommon
*/
void convoLeave(const Licq::UserId& userId);

virtual void windowActivationChange(bool oldActive);
virtual void changeEvent(QEvent* event);
int clearDelay;

signals:
Expand Down
3 changes: 2 additions & 1 deletion qt-gui/src/views/contactdelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of Licq, an instant messaging client for UNIX.
* Copyright (C) 1999-2012 Licq developers <licq-dev@googlegroups.com>
* Copyright (C) 1999-2014 Licq developers <licq-dev@googlegroups.com>
*
* Licq is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,6 +25,7 @@
#include <QKeyEvent>
#include <QLineEdit>
#include <QPainter>
#include <qdrawutil.h>

#include <licq/contactlist/user.h>

Expand Down
5 changes: 5 additions & 0 deletions qt-gui/src/views/userview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ UserView::UserView(ContactListModel* contactList, QWidget* parent)
myIsMainView = true;

// Sorting
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
header()->setSectionsClickable(true);
header()->setSectionsMovable(false);
#else
header()->setClickable(true);
header()->setMovable(false);
#endif
resort();
connect(header(), SIGNAL(sectionClicked(int)), SLOT(slotHeaderClicked(int)));

Expand Down
2 changes: 2 additions & 0 deletions qt-gui/src/views/userviewbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <licq/contactlist/usermanager.h>

#include <QMimeData>

#include "contactlist/contactlist.h"

#include "config/contactlist.h"
Expand Down
4 changes: 4 additions & 0 deletions qt-gui/src/widgets/mlview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ QString MLView::toRichText(const QString& s, bool highlightURLs, bool useHTML, Q

// Get next block of text that can be copied from input
QString rawtext = s.mid(lastpos, newpos - lastpos);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
text.append(useHTML ? rawtext : rawtext.toHtmlEscaped());
#else
text.append(useHTML ? rawtext : Qt::escape(rawtext));
#endif

// Add tags applicable for this position in the string
if (breakhl && hlEnd > 0)
Expand Down

0 comments on commit cdff6e0

Please sign in to comment.