Index: configure.ac =================================================================== --- configure.ac (revision 6033) +++ configure.ac (working copy) @@ -1329,6 +1329,36 @@ AC_SUBST(KDE_DATA_DIR) AC_SUBST(KDE_INCLUDE_DIR) +dnl **************************** +dnl *** test for KDE4 applet *** +dnl **************************** +AC_ARG_ENABLE(kde4-applet, + AC_HELP_STRING([--enable-kde4-applet], + [build uim applet for KDE4 panel (experimental) + @<:@default=yes@:>@]), + enable_kde4_applet=$enableval, + enable_kde4_applet=yes) +case "$enable_kde_applet" in + no) + use_applet_kde4="no" + ;; + yes|*) + if test "x$use_qt4" = "xyes"; then + use_applet_kde4="yes" + else + use_applet_kde4="no" + fi + ;; +esac +AC_PATH_PROG(CMAKE, [cmake], [no]) +if test "x$use_applet_kde4" = "xyes" && test "x$CMAKE" = "xno"; then + AC_MSG_ERROR([no CMake found]) +fi +AC_PATH_PROG(KDE4_CONFIG, [kde4-config], [no]) +if test "x$use_applet_kde4" = "xyes" && test "x$KDE4_CONFIG" = "xno"; then + AC_MSG_ERROR([no kde4-config found]) +fi + if test x$use_qtimmodule = xyes ; then AC_MSG_CHECKING(for qt-immodule patch) # Check for immodule for Qt patch @@ -1346,6 +1376,7 @@ AM_CONDITIONAL(APPLET_KDE, test x$use_applet_kde = xyes) AM_CONDITIONAL(QT4, test x$use_qt4 = xyes) AM_CONDITIONAL(QT4_IMMODULE, test x$use_qt4_immodule = xyes) +AM_CONDITIONAL(APPLET_KDE4, test x$use_applet_kde4 = xyes) AC_ARG_ENABLE(pref, AC_HELP_STRING([--enable-pref], @@ -1656,6 +1687,7 @@ qt4/pref/Makefile qt4/switcher/uim-im-switcher-qt4.pro qt4/switcher/Makefile + qt4/toolbar/plasma-applet-uim.desktop qt4/toolbar/uim-toolbar-qt4.pro qt4/toolbar/Makefile xim/Makefile @@ -1690,6 +1722,22 @@ ${ac_abs_top_srcdir}/qt4/switcher/uim-im-switcher-qt4.pro ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/toolbar/Makefile.qmake \ ${ac_abs_top_srcdir}/qt4/toolbar/uim-toolbar-qt4.pro + + # Generate a Makefile for KDE4 applet by cmake + if test x$use_applet_kde4 = xyes; then + if test "x$enable_debug" = xyes; then + cmake_build_type=Debug + else + cmake_build_type=Release + fi + cd ${ac_abs_top_builddir}/qt4/toolbar/build + ${CMAKE} \ + -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \ + -DCMAKE_BUILD_TYPE=${cmake_build_type} \ + -DCMAKE_INSTALL_PREFIX=`$KDE4_CONFIG --prefix` \ + ${ac_abs_top_builddir}/qt4/toolbar + cd - + fi fi if test x$use_qt4_immodule = xyes; then ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/immodule/Makefile.qmake \ @@ -1722,6 +1770,7 @@ Qt4 : ${use_qt4} Qt4 immodule : ${use_qt4_immodule} KDE3 Applet : ${use_applet_kde} + KDE4 Applet : ${use_applet_kde4} FEP : ${use_uim_fep} Emacs : ${use_uim_el} XIM : ${use_xim} Index: qt4/toolbar/build/.svnignore =================================================================== Index: qt4/toolbar/applet-kde4.h =================================================================== --- qt4/toolbar/applet-kde4.h (revision 0) +++ qt4/toolbar/applet-kde4.h (revision 0) @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2006-2009 uim Project http://code.google.com/p/uim/ + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of authors nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +*/ +#ifndef UIM_QT_TOOLBAR_APPLET_KDE4_H +#define UIM_QT_TOOLBAR_APPLET_KDE4_H + +#include + +class QGraphicsLinearLayout; +class QGraphicsProxyWidget; + +class QUimHelperToolbar; + +class UimApplet : public Plasma::PopupApplet +{ + Q_OBJECT + public: + UimApplet(QObject *parent, const QVariantList &args); + + void init(); + + private slots: + void slotToolbarResized(); + + private: + void initPopup(); + QGraphicsWidget *graphicsWidget(); + + QUimHelperToolbar *m_toolbar; + QGraphicsProxyWidget *m_proxy; + QGraphicsLinearLayout *m_layout; + QGraphicsWidget *m_widget; +}; + +#endif Index: qt4/toolbar/plasma-applet-uim.desktop.in =================================================================== --- qt4/toolbar/plasma-applet-uim.desktop.in (revision 0) +++ qt4/toolbar/plasma-applet-uim.desktop.in (revision 0) @@ -0,0 +1,18 @@ +[Desktop Entry] +Name=uim +Comment=Input Method Indicator (uim) +Comment[ja]=入力メソッドインジケータ (uim) +Type=Service +ServiceTypes=Plasma/Applet +Icon=@uim_pixmapsdir@/uim-icon.png + +X-KDE-Library=plasma_applet_uim +X-KDE-PluginInfo-Author=The uim developers +X-KDE-PluginInfo-Email=uim-en@googlegroups.com +X-KDE-PluginInfo-Name=plasma_applet_uim +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://code.google.com/p/uim/ +X-KDE-PluginInfo-Category=Utilities +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=BSD +X-KDE-PluginInfo-EnabledByDefault=true Index: qt4/toolbar/Makefile.am =================================================================== --- qt4/toolbar/Makefile.am (revision 6033) +++ qt4/toolbar/Makefile.am (working copy) @@ -1,3 +1,7 @@ +if APPLET_KDE4 +SUBDIRS = build +endif + .PHONY: mocclean FORCE # Makefile.qmake is only exist when --enable-qt4 @@ -10,9 +14,11 @@ $(MAKE) $(AM_MAKEFLAGS) -f Makefile.qmake $@ $(MAKE) $(AM_MAKEFLAGS) distclean-am -rm -f Makefile uim-toolbar-qt4.pro + -rm -rf build/* else distclean: -rm -f Makefile uim-toolbar-qt4.pro + -rm -rf build/* endif FORCE: @@ -23,4 +29,9 @@ common-uimstateindicator.cpp \ common-uimstateindicator.h \ standalone-qt4.cpp \ - standalone-qt4.h + standalone-qt4.h \ + standalone-qt4.cpp \ + CMakeLists.txt \ + plasma-applet-uim.desktop.in \ + applet-kde4.cpp \ + applet-kde4.h Index: qt4/toolbar/applet-kde4.cpp =================================================================== --- qt4/toolbar/applet-kde4.cpp (revision 0) +++ qt4/toolbar/applet-kde4.cpp (revision 0) @@ -0,0 +1,119 @@ +/* + Copyright (c) 2006-2009 uim Project http://code.google.com/p/uim/ + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of authors nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +*/ +#include "applet-kde4.h" + +#include +#include + +#include + +#include "qtgettext.h" +#include "uim.h" + +#include "common-quimhelpertoolbar.h" +#include "common-uimstateindicator.h" + +K_EXPORT_PLASMA_APPLET(uim, UimApplet) + +UimApplet::UimApplet(QObject *parent, const QVariantList &args) +: Plasma::PopupApplet(parent, args) +{ + bindtextdomain(PACKAGE, LOCALEDIR); + bind_textdomain_codeset(PACKAGE, "UTF-8"); +} + +void UimApplet::init() +{ + uim_init(); + m_toolbar = new QUimHelperToolbar(0, true); + m_toolbar->setMargin(0); + m_toolbar->setAttribute(Qt::WA_NoSystemBackground); + connect(m_toolbar, SIGNAL(toolbarResized()), + this, SLOT(slotToolbarResized())); + + m_proxy = new QGraphicsProxyWidget; + m_proxy->setWidget(m_toolbar); + + m_layout = new QGraphicsLinearLayout; + m_layout->addItem(m_proxy); + + setLayout(m_layout); + + initPopup(); + slotToolbarResized(); +} + +void UimApplet::initPopup() +{ + QList list = m_toolbar->contextMenu()->actions(); + + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + QAction *act; + foreach (act, list) { + Plasma::ToolButton *button = new Plasma::ToolButton; + button->setText(act->text()); + connect(button, SIGNAL(clicked()), act, SLOT(trigger())); + + QToolButton *nativeWidget = button->nativeWidget(); + nativeWidget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + nativeWidget->setIcon(act->icon()); + + layout->addItem(button); + } + + m_widget = new QGraphicsWidget(this); + m_widget->setLayout(layout); +} + +void UimApplet::slotToolbarResized() +{ + m_toolbar->adjustSize(); + qreal lr = 0, tb = 0; + qreal left, top, right, bottom; + m_proxy->getContentsMargins(&left, &top, &right, &bottom); + lr += (left + right); + tb += (top + bottom); + + m_layout->getContentsMargins(&left, &top, &right, &bottom); + lr += (left + right); + tb += (top + bottom); + + getContentsMargins(&left, &top, &right, &bottom); + lr += (left + right); + tb += (top + bottom); + resize(m_toolbar->width() + lr, m_toolbar->height() + tb); +} + +QGraphicsWidget *UimApplet::graphicsWidget() +{ + return m_widget; +} Index: qt4/toolbar/CMakeLists.txt =================================================================== --- qt4/toolbar/CMakeLists.txt (revision 0) +++ qt4/toolbar/CMakeLists.txt (revision 0) @@ -0,0 +1,23 @@ +project(plasma-uim) + +find_package(KDE4 REQUIRED) +include(KDE4Defaults) + +add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) +include_directories(${KDE4_INCLUDES} + ${CMAKE_SOURCE_DIR}/../.. ${CMAKE_SOURCE_DIR}/../../uim + ${CMAKE_SOURCE_DIR}/../../replace ${CMAKE_SOURCE_DIR}/..) + +set(uim_SRCS + common-quimhelpertoolbar.cpp + common-uimstateindicator.cpp + applet-kde4.cpp) + +kde4_add_plugin(plasma_applet_uim ${uim_SRCS}) +target_link_libraries(plasma_applet_uim ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} + ${CMAKE_SOURCE_DIR}/../../uim/.libs/libuim.so + ${CMAKE_SOURCE_DIR}/../../uim/.libs/libuim-scm.so + -luim -luim-scm) + +install(TARGETS plasma_applet_uim DESTINATION ${PLUGIN_INSTALL_DIR}) +install(FILES plasma-applet-uim.desktop DESTINATION ${SERVICES_INSTALL_DIR})