From e8544bc43f964096d95311c85f08d4e56605e78d Mon Sep 17 00:00:00 2001 From: Petr Vanek Date: Wed, 3 Nov 2010 18:41:27 +0100 Subject: [PATCH 1/4] correct lib ID for mac --- lib/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index aa75405..d348090 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -115,6 +115,13 @@ endif (HAVE_UPDWTMPX) #add_library( qtermwidget STATIC ${SRCS} ${MOC_SRCS} ) add_library ( qtermwidget SHARED ${SRCS} ${MOC_SRCS} ) +if (APPLE) + # this is a must to load the lib correctly + set_target_properties( qtermwidget PROPERTIES + INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} ) +endif (APPLE) + + #| Set Build Type if (NOT CMAKE_BUILD_TYPE) set ( CMAKE_BUILD_TYPE From 061c4cc5b838ce5130eca49f2d115dd11b2200ff Mon Sep 17 00:00:00 2001 From: Petr Vanek Date: Fri, 12 Nov 2010 22:51:59 +0100 Subject: [PATCH 2/4] qt designer plugin --- CMakeLists.txt | 2 + lib/CMakeLists.txt | 37 +++++++++++ lib/designer/qtermwidget.png | Bin 0 -> 2268 bytes lib/designer/qtermwidgetplugin.cpp | 102 +++++++++++++++++++++++++++++ lib/designer/qtermwidgetplugin.h | 33 ++++++++++ lib/designer/qtermwidgetplugin.qrc | 6 ++ 6 files changed, 180 insertions(+) create mode 100644 lib/designer/qtermwidget.png create mode 100644 lib/designer/qtermwidgetplugin.cpp create mode 100644 lib/designer/qtermwidgetplugin.h create mode 100644 lib/designer/qtermwidgetplugin.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index df10802..cbab9bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ ###| Cmake qtermwidget |### +option(BUILD_DESIGNER_PLUGIN "Build Qt4 designer plugin" ON) + #| Setting required version cmake_minimum_required( VERSION 2.4 ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d348090..c6196a9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -150,3 +150,40 @@ install(FILES ${HDRS_DISTRIB} DESTINATION include) # keyboard layouts install(DIRECTORY kb-layouts/ DESTINATION ${KB_LAYOUT_DIR} FILES_MATCHING PATTERN "*.keytab" ) + +# +# Qt4 designer plugin +# +if (BUILD_DESIGNER_PLUGIN) + message(STATUS "Building Qt designer plugin") + + include_directories(designer + ${QT_QTDESIGNER_INCLUDE_DIR}) + + set(DESIGNER_SRC designer/qtermwidgetplugin.cpp) + QT4_WRAP_CPP( DESIGNER_MOC designer/qtermwidgetplugin.h) + QT4_ADD_RESOURCES( DESIGNER_QRC designer/qtermwidgetplugin.qrc) + + link_directories(${CMAKE_BINARY_DIR}) + add_library( qtermwidgetplugin SHARED + ${DESIGNER_MOC} + ${DESIGNER_QRC} + ${DESIGNER_SRC} + ) + + target_link_libraries( qtermwidgetplugin + ${QT_QTCORE_LIBRARY} + ${QT_QTDESIGNER_LIBRARY} + ${QT_QTDESIGNERCOMPONENTS_LIBRARY} + qtermwidget + ) + + if (APPLE) + # this is a must to load the lib correctly + set_target_properties( qtermwidgetplugin PROPERTIES + INSTALL_NAME_DIR ${QT_PLUGINS_DIR}/designer ) + endif (APPLE) + + install( TARGETS qtermwidgetplugin DESTINATION ${QT_PLUGINS_DIR}/designer ) + +endif (BUILD_DESIGNER_PLUGIN) diff --git a/lib/designer/qtermwidget.png b/lib/designer/qtermwidget.png new file mode 100644 index 0000000000000000000000000000000000000000..7b9abcc04ebd5adc241e236f3099c026b78feb85 GIT binary patch literal 2268 zcmV<22qX82P)ev7MoSO*xl2n`Tcuo;opJ*Jd%)<^6}5J@+PLtNP{kjaC`hvbd5h0 z1pz7vS7?az%wiG(&}d%JRD=&VVpeh(%oYn&MTX>Thd08GanWO-LdHPHWjxd>!x85| zhfl-)qo?udp(8K&yx!Njq%q+U|0v${#^UjDNf;U)f=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xq5r**~0vgv7~^ z6-rRlXjrWl3=g}}SWi4SdV;`EvNGR385K%$>z`kRmbMlYm(?xf07{B-rJA)BQ7^yr zJ0h7EDJjWFotX-U!$FOXKsBDyvxRybBF5KWx8u;i52LTIAEBY4{BYSXbJJ=@)(d3o zAdAp6vl@#UMOIK#TaNb5c4h%yj3$*9wc^5b6Hwv%@>OEZ=rDR~MlmN7Uu443mXPPxv&J>o$~SSZ(oafA(4 zDYCND5q4kLw>n3oR`FuSz@Bn8;fsGBr2JvS`i-m6+IALCm(*skb@7$uE2NU5yx3P? z{sU+J`~`Cn6FU)SNZYf`tr(=_M2#vBH~psKq7Yw}Ezd?wObqXaR9+F;8jS;BQ>_X#q%gAs^;Z5v9i2?5>Zjq<`>`KCbE#fST%H0X=a7U%u=uZ zon1BcD>7nZ9b|zqfx~GZYw1`6JG#e2{YBs9t3+^>hip|%8G5et5P+(D2H=6G3v#3l z>sH_Q;-=TQ8C4R(F4h<5w>UWX@_T(ee*`Lra3du7J+R+GnlmEG1g@&40$mq6h=g^O zY(-jO!4uN@s%Na5f3uxhsN0NZ+})cCbJLotGF<5HM9IqMtC@^hPnDI9T9)CPU1Fs7rZ?~AccpE2Bzkl*M{_|zS@=?Pqr147{VKl~qztQnwHtvEkL}QFzOu7=}3*8tR zS05mMLJs + +#include "qtermwidget.h" + + +QTermWidgetPlugin::QTermWidgetPlugin(QObject *parent) + : QObject(parent), initialized(false) +{ + Q_INIT_RESOURCE(qtermwidgetplugin); +} + + +QTermWidgetPlugin::~QTermWidgetPlugin() +{ +} + + +void QTermWidgetPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + initialized = true; +} + + +bool QTermWidgetPlugin::isInitialized() const +{ + return initialized; +} + + +QWidget *QTermWidgetPlugin::createWidget(QWidget *parent) +{ + return new QTermWidget(0, parent); +} + + +QString QTermWidgetPlugin::name() const +{ + return "QTermWidget"; +} + + +QString QTermWidgetPlugin::group() const +{ + return "Input Widgets"; +} + + +QIcon QTermWidgetPlugin::icon() const +{ + return QIcon(":qtermwidget.png"); +} + + +QString QTermWidgetPlugin::toolTip() const +{ + return "QTermWidget component/widget"; +} + + +QString QTermWidgetPlugin::whatsThis() const +{ + return "Qt based terminal emulator"; +} + + +bool QTermWidgetPlugin::isContainer() const +{ + return false; +} + + +QString QTermWidgetPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " 0\n" + " 0\n" + " 400\n" + " 200\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; +} + + +QString QTermWidgetPlugin::includeFile() const +{ + return "qtermwidget.h"; +} + + +Q_EXPORT_PLUGIN2(QTermWidgetPlugin, QTermWidgetPlugin) diff --git a/lib/designer/qtermwidgetplugin.h b/lib/designer/qtermwidgetplugin.h new file mode 100644 index 0000000..8a216de --- /dev/null +++ b/lib/designer/qtermwidgetplugin.h @@ -0,0 +1,33 @@ + +#ifndef QTERMWIDGETPLUGIN_H +#define QTERMWIDGETPLUGIN_H + +#include + + +class QTermWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + QTermWidgetPlugin(QObject *parent = 0); + virtual ~QTermWidgetPlugin(); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; + +#endif diff --git a/lib/designer/qtermwidgetplugin.qrc b/lib/designer/qtermwidgetplugin.qrc new file mode 100644 index 0000000..fbf222c --- /dev/null +++ b/lib/designer/qtermwidgetplugin.qrc @@ -0,0 +1,6 @@ + + + + qtermwidget.png + + From 8787a21b676dcbc4caaef6aa61ba75fa3ccced33 Mon Sep 17 00:00:00 2001 From: Petr Vanek Date: Sat, 13 Nov 2010 13:55:08 +0100 Subject: [PATCH 3/4] font display fix on mac (widths in int) --- lib/TerminalDisplay.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 1b8805c..8299c44 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -232,6 +232,14 @@ void TerminalDisplay::setVTFont(const QFont& f) { QFont font = f; +#ifdef Q_WS_MAC +#if QT_VERSION >= 0x040700 + font.setStyleStrategy(QFont::ForceIntegerMetrics); +#else +#warning "Correct handling of the QFont metrics requited Qt>=4.7" +#endif +#endif + QFontMetrics metrics(font); if ( !QFontInfo(font).fixedPitch() ) { From 0facab4a5ad59ec3ca30e4927c4ae010b9bdc127 Mon Sep 17 00:00:00 2001 From: Petr Vanek Date: Wed, 24 Nov 2010 11:26:43 +0100 Subject: [PATCH 4/4] transparency support --- lib/TerminalDisplay.cpp | 6 ++++-- lib/qtermwidget.cpp | 7 +++++++ lib/qtermwidget.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 8299c44..cd1b2ea 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -234,6 +234,8 @@ void TerminalDisplay::setVTFont(const QFont& f) #ifdef Q_WS_MAC #if QT_VERSION >= 0x040700 + // mac uses floats for font width specification. + // this ensures the same handling for all platforms font.setStyleStrategy(QFont::ForceIntegerMetrics); #else #warning "Correct handling of the QFont metrics requited Qt>=4.7" @@ -557,14 +559,14 @@ void TerminalDisplay::setOpacity(qreal opacity) // enable automatic background filling to prevent the display // flickering if there is no transparency - /*if ( color.alpha() == 255 ) + if ( color.alpha() == 255 ) { setAutoFillBackground(true); } else { setAutoFillBackground(false); - }*/ + } _blendColor = color.rgba(); } diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index 8220fb8..dc329a7 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -196,6 +196,13 @@ void QTermWidget::setTerminalFont(QFont &font) m_impl->m_terminalDisplay->setVTFont(font); } +void QTermWidget::setTerminalOpacity(qreal level) +{ + if (!m_impl->m_terminalDisplay) + return; + m_impl->m_terminalDisplay->setOpacity(level); +} + void QTermWidget::setShellProgram(const QString &progname) { if (!m_impl->m_session) diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index b24ba41..f389e6a 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -66,6 +66,8 @@ public: // otherwise symbols' position could be incorrect void setTerminalFont(QFont & font); + void setTerminalOpacity(qreal level); + //environment void setEnvironment(const QStringList & environment);