Revision: 6038
Author: ek.kato
Date: Sun Oct 25 11:05:11 2009
Log: * Add KDE4 applet by Muneyuki Noguchi (bug #24620).

* qt4/toolbar/applet-kde4.{h,cpp}
* qt4/toolbar/plasma-applet-uim.desktop.in
* qt4/toolbar/CMakeLists.txt
  - New.
* configure.ac
  - Add check for KDE4 applet.
* qt4/toolbar/Makefile.am
  - Build KDE4 applet with cmake in build directory.

http://code.google.com/p/uim/source/detail?r=6038

Added:
 /trunk/qt4/toolbar/CMakeLists.txt
 /trunk/qt4/toolbar/applet-kde4.cpp
 /trunk/qt4/toolbar/applet-kde4.h
 /trunk/qt4/toolbar/plasma-applet-uim.desktop.in
Modified:
 /trunk/configure.ac
 /trunk/qt4/toolbar/Makefile.am

=======================================
--- /dev/null
+++ /trunk/qt4/toolbar/CMakeLists.txt   Sun Oct 25 11:05:11 2009
@@ -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})
=======================================
--- /dev/null
+++ /trunk/qt4/toolbar/applet-kde4.cpp  Sun Oct 25 11:05:11 2009
@@ -0,0 +1,121 @@
+/*
+ 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 <config.h>
+
+#include "applet-kde4.h"
+
+#include <QtGui/QGraphicsProxyWidget>
+#include <QtGui/QGraphicsLinearLayout>
+
+#include <Plasma/ToolButton>
+
+#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<QAction *> 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;
+}
=======================================
--- /dev/null
+++ /trunk/qt4/toolbar/applet-kde4.h    Sun Oct 25 11:05:11 2009
@@ -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 <Plasma/PopupApplet>
+
+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
=======================================
--- /dev/null
+++ /trunk/qt4/toolbar/plasma-applet-uim.desktop.in     Sun Oct 25 11:05:11 2009
@@ -0,0 +1,18 @@
+[Desktop Entry]
+Name=uim
+Comment=Input Method Indicator (uim)
+Comment[ja]=入力メソッドインジケータ (uim)
+Type=Service
+ServiceTypes=Plasma/Applet
+ic...@uim_pixmapsdir@/uim-icon.png
+
+X-KDE-Library=plasma_applet_uim
+X-KDE-PluginInfo-Author=The uim developers
[email protected]
+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
=======================================
--- /trunk/configure.ac Mon Oct 12 19:22:56 2009
+++ /trunk/configure.ac Sun Oct 25 11:05:11 2009
@@ -1329,6 +1329,38 @@
 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_WARN([no CMake found])
+    use_applet_kde4="no"
+fi
+AC_PATH_PROG(KDE4_CONFIG, [kde4-config], [no])
+if test "x$use_applet_kde4" = "xyes" && test "x$KDE4_CONFIG" = "xno"; then
+    AC_MSG_WARN([no kde4-config found])
+    use_applet_kde4="no"
+fi
+
 if test x$use_qtimmodule = xyes ; then
     AC_MSG_CHECKING(for qt-immodule patch)
     # Check for immodule for Qt patch
@@ -1346,6 +1378,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 +1689,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 +1724,23 @@
                 ${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
+        mkdir -p ${ac_abs_top_builddir}/qt4/toolbar/build
+        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 +1773,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}
=======================================
--- /trunk/qt4/toolbar/Makefile.am      Fri Sep 25 08:52:02 2009
+++ /trunk/qt4/toolbar/Makefile.am      Sun Oct 25 11:05:11 2009
@@ -4,15 +4,20 @@
 if QT4
 all clean mocclean install uninstall:
        $(MAKE) $(AM_MAKEFLAGS) -f Makefile.qmake INSTALL_ROOT=$(DESTDIR) $@
+if APPLET_KDE4
+       ( cd build; $(MAKE) $(AM_MAKEFLAGS) $@ )
+endif

 # *.pro is required to run Makefile.qmake. So distclean-am is deferred.
 distclean:
        $(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 +28,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

Reply via email to