Skip to content

Commit

Permalink
feat: support qt module
Browse files Browse the repository at this point in the history
Change-Id: Iffa23b1971e6e2f49b9a43a34804e3eb0139070e
  • Loading branch information
Iceyer committed Feb 12, 2018
1 parent 48e23bc commit 1525c2c
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 152 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ build*/
src/DtkWidgets
src/dtkwidget_config.h
cmake/DtkWidget/DtkWidgetConfig.cmake
src/qt_lib_dtk*.pri
1 change: 1 addition & 0 deletions debian/libdtkwidget-dev.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ usr/lib/*/lib*.so
usr/include
usr/lib/*/pkgconfig/*.pc
usr/lib/*/cmake/*/*.cmake
usr/lib/*/qt5/*
15 changes: 5 additions & 10 deletions examples/dwidget-examples/collections/collections.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QT += core gui multimedia multimediawidgets svg

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += dtkcore

TARGET = collections
TEMPLATE = app
Expand All @@ -10,8 +10,10 @@ DEFINES += QT_MESSAGELOGCONTEXT

unix {
QT += dbus
CONFIG += link_pkgconfig
PKGCONFIG += dtkcore
}

!isEmpty(DTK_STATIC_LIB){
DEFINES += DTK_STATIC_LIB
}

SOURCES += main.cpp\
Expand Down Expand Up @@ -60,15 +62,8 @@ RESOURCES += \
FORMS += \
cameraform.ui

include($$PWD/../../../src/config.pri)

win32* {
CONFIG += no_lflags_merge
DEFINES += STATIC_LIB

#DEPENDS dtkcore
INCLUDEPATH += $$INCLUDE_INSTALL_DIR\libdtk-$$VERSION\DCore
LIBS += -L$$LIB_INSTALL_DIR -ldtkcore
}

win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../src/release -ldtkwidget
Expand Down
3 changes: 1 addition & 2 deletions examples/dwidget-examples/collections/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ DWIDGET_USE_NAMESPACE

int main(int argc, char *argv[])
{

#if defined(STATIC_LIB)
#if defined(DTK_STATIC_LIB)
DWIDGET_INIT_RESOURCE();
#endif

Expand Down
8 changes: 4 additions & 4 deletions examples/dwidget-examples/collections/multilistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ DWIDGET_USE_NAMESPACE
class MultiListView : public DSimpleListView
{
Q_OBJECT

public:
MultiListView(DSimpleListView *parent=0);
public slots:

public Q_SLOTS:
void popupMenu(QPoint pos, QList<DSimpleListItem*> items);
};
};

#endif
32 changes: 0 additions & 32 deletions src/config.pri
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
CONFIG += c++11
DEFINES += QT_MESSAGELOGCONTEXT

isEmpty(PREFIX){
PREFIX = /usr
}

win32* {
DEFINES += STATIC_LIB
}

isEmpty(VERSION) {
PKG_CONFIG_EXE = $$first($$list($$pkgConfigExecutable()))
isEmpty(LIB_INSTALL_DIR) {
Expand All @@ -24,24 +13,3 @@ isEmpty(VERSION) {

isEmpty(VERSION): error(VERSION is empty)
}

ver_list = $$split(VERSION, .)

isEmpty(VER_MAJ) {
VER_MAJ = $$first(ver_list)
}

isEmpty(VER_MIN) {
VER_MIN = $$member(ver_list, 1, 1)
isEmpty(VER_MIN):VER_MIN = 0
}

isEmpty(VER_PAT) {
VER_PAT = $$member(ver_list, 2, 2)
isEmpty(VER_PAT):VER_PAT = 0
}

isEmpty(VER_BUI) {
VER_BUI = $$member(ver_list, 3, 3)
isEmpty(VER_BUI):VER_BUI = 0
}
4 changes: 2 additions & 2 deletions src/dtkwidget_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Dtk
namespace Widget
{

#if defined(STATIC_LIB)
#if defined(DTK_STATIC_LIB)
#define DWIDGET_INIT_RESOURCE() \
do { \
Q_INIT_RESOURCE(icons); \
Expand All @@ -45,7 +45,7 @@ namespace Widget
}
}

#if defined(STATIC_LIB)
#if defined(DTK_STATIC_LIB)
# define LIBDTKWIDGETSHARED_EXPORT
#else
#if defined(LIBDTKWIDGET_LIBRARY)
Expand Down
62 changes: 33 additions & 29 deletions src/src.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
include($$PWD/lib.pri)

TEMPLATE = lib
CONFIG += qt
TARGET = dtkwidget

DEFINES += LIBDTKWIDGET_LIBRARY
include($$PWD/config.pri)
# TODO: replace config.pri with dtk_build
load(dtk_build)

QT += multimedia multimediawidgets concurrent
greaterThan(QT_MAJOR_VERSION, 4) {
Expand All @@ -13,26 +9,29 @@ greaterThan(QT_MAJOR_VERSION, 4) {
greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 7): QT += gui-private
else: QT += platformsupport-private
}

QT += dtkcore

linux* {
QT += x11extras dbus
CONFIG += link_pkgconfig
PKGCONFIG += x11 xext dtkcore
}

mac* {
QT += svg
DEFINES += DTK_TITLE_DRAG_WINDOW
CONFIG += link_pkgconfig
PKGCONFIG += dtkcore
}

win* {
QT += svg
DEFINES += DTK_TITLE_DRAG_WINDOW
}

#DEPENDS dtkcore
INCLUDEPATH += $$INCLUDE_INSTALL_DIR\libdtk-$$VERSION\DCore
LIBS += -L$$LIB_INSTALL_DIR -ldtkcore
TEMPLATE = lib
TARGET = dtkwidget

!isEmpty(DTK_STATIC_LIB){
DEFINES += DTK_STATIC_LIB
CONFIG += staticlib
}

HEADERS += dtkwidget_global.h
Expand All @@ -53,28 +52,14 @@ win32* {
includes.files += $$PWD/platforms/windows/*.h
}

QMAKE_PKGCONFIG_NAME = DTK_WIDGET
QMAKE_PKGCONFIG_DESCRIPTION = Deepin Tool Kit Widget Module
QMAKE_PKGCONFIG_INCDIR = $$includes.path
QMAKE_PKGCONFIG_REQUIRES += dtkcore

# CMake configure
INC_DIR = $$replace(includes.path, "/", "\/")
CMD = sed -E \'s/DTKWIDGET_INCLUDE_DIR \".*\"\\)$/DTKWIDGET_INCLUDE_DIR \"$${INC_DIR}\"\\)/\' ../cmake/DtkWidget/DtkWidgetConfig.cmake.in > ../cmake/DtkWidget/DtkWidgetConfig.cmake
message($$CMD)
system($$CMD)

cmake_config.path = $$LIB_INSTALL_DIR
cmake_config.files = $$PWD/../cmake

# add translations
TRANSLATIONS += $$PWD/../translations/$${TARGET}2.ts \
$$PWD/../translations/$${TARGET}2_zh_CN.ts

translations.path = $$PREFIX/share/$${TARGET}/translations
translations.files = $$PWD/../translations/*.qm

INSTALLS += translations cmake_config
INSTALLS += translations

# create DtkWidgets file
defineTest(containIncludeFiles) {
Expand Down Expand Up @@ -126,3 +111,22 @@ defineTest(updateDtkWidgetConfigFile) {
}

!updateDtkWidgetConfigFile():warning(Cannot create "dtkwidget_config.h" header file)

INSTALLS += includes target

# CMake configure
INC_DIR = $$replace(includes.path, "/", "\/")
CMD = sed -E \'s/DTKWIDGET_INCLUDE_DIR \".*\"\\)$/DTKWIDGET_INCLUDE_DIR \"$${INC_DIR}\"\\)/\' ../cmake/DtkWidget/DtkWidgetConfig.cmake.in > ../cmake/DtkWidget/DtkWidgetConfig.cmake
message($$CMD)
system($$CMD)

cmake_config.path = $$LIB_INSTALL_DIR
cmake_config.files = $$PWD/../cmake
INSTALLS += cmake_config

#TODO: use dtkcmake
#CMAKE_MODULE=DtkWidget
#load(dtk_cmake)

QMAKE_PKGCONFIG_REQUIRES += dtkcore
load(dtk_module)
10 changes: 5 additions & 5 deletions src/util/dregionmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void DRegionMonitorPrivate::_q_ButtonPress(const int flag, const int x, const in

D_Q(DRegionMonitor);

emit q->buttonPress(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag);
Q_EMIT q->buttonPress(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag);
}

void DRegionMonitorPrivate::_q_ButtonRelease(const int flag, const int x, const int y, const QString &key)
Expand All @@ -136,7 +136,7 @@ void DRegionMonitorPrivate::_q_ButtonRelease(const int flag, const int x, const

D_Q(DRegionMonitor);

emit q->buttonRelease(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag);
Q_EMIT q->buttonRelease(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag);
}

void DRegionMonitorPrivate::_q_CursorMove(const int x, const int y, const QString &key)
Expand All @@ -146,7 +146,7 @@ void DRegionMonitorPrivate::_q_CursorMove(const int x, const int y, const QStrin

D_Q(DRegionMonitor);

emit q->cursorMove(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()));
Q_EMIT q->cursorMove(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()));
}

void DRegionMonitorPrivate::_q_KeyPress(const QString &keyname, const int x, const int y, const QString &key)
Expand All @@ -159,7 +159,7 @@ void DRegionMonitorPrivate::_q_KeyPress(const QString &keyname, const int x, con

D_Q(DRegionMonitor);

emit q->keyPress(keyname);
Q_EMIT q->keyPress(keyname);
}

void DRegionMonitorPrivate::_q_KeyRelease(const QString &keyname, const int x, const int y, const QString &key)
Expand All @@ -172,7 +172,7 @@ void DRegionMonitorPrivate::_q_KeyRelease(const QString &keyname, const int x, c

D_Q(DRegionMonitor);

emit q->keyRelease(keyname);
Q_EMIT q->keyRelease(keyname);
}

const QPoint DRegionMonitorPrivate::deviceScaledCoordinate(const QPoint &p, const double ratio) const
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dcrumbedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate
}
}

foreach (const DCrumbTextFormat &f, formats) {
Q_FOREACH(const DCrumbTextFormat &f, formats) {
if (!crumbList.contains(f.text())) {
formats.remove(f.text());
formatsChanged = true;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dimagebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void DImageButton::setChecked(bool flag)
d->setState(Normal);
}

emit checkedChanged(d->m_isChecked);
Q_EMIT checkedChanged(d->m_isChecked);
}

/*!
Expand Down
Loading

0 comments on commit 1525c2c

Please sign in to comment.