* Added Kickoff menu
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171422 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
@ -0,0 +1,78 @@
|
||||
dnl Check for pkg-config
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
|
||||
if test "$PKG_CONFIG" = "no"; then
|
||||
AC_MSG_ERROR([
|
||||
This package requires pkg-config.
|
||||
])
|
||||
fi
|
||||
|
||||
dnl Check for Glib-2.0
|
||||
# GLIB_CFLAGS: cflags for compiling glib dependant sources
|
||||
# GLIB_LIBADD: glib libraries (-l options)
|
||||
# GLIB_LDFLAGS: flags containing path to glib libraries (-L options)
|
||||
|
||||
GLIB_PACKAGES="gmodule-2.0 gthread-2.0"
|
||||
GLIB_VERSION="1.3.3"
|
||||
AC_MSG_CHECKING(for GLib-2.0 (at least $GLIB_VERSION))
|
||||
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.15 ; then
|
||||
if $PKG_CONFIG --atleast-version $GLIB_VERSION $GLIB_PACKAGES >/dev/null 2>&1 ; then
|
||||
GLIB_CFLAGS="`$PKG_CONFIG --cflags $GLIB_PACKAGES`"
|
||||
GLIB_LIBADD="`$PKG_CONFIG --libs-only-l --libs-only-other $GLIB_PACKAGES`"
|
||||
GLIB_LDFLAGS="`$PKG_CONFIG --libs-only-L $GLIB_PACKAGES`"
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
else
|
||||
if $PKG_CONFIG --atleast-version $GLIB_VERSION $GLIB_PACKAGES >/dev/null 2>&1 ; then
|
||||
GLIB_CFLAGS="`$PKG_CONFIG --cflags $GLIB_PACKAGES`"
|
||||
GLIB_LIBADD="`$PKG_CONFIG --libs-only-l $GLIB_PACKAGES`"
|
||||
GLIB_LDFLAGS="`$PKG_CONFIG --libs-only-L $GLIB_PACKAGES`"
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_MSG_WARN([you may need to run make LDFLAGS=-pthread to compile arts])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$GLIB_LIBADD"; then
|
||||
AC_MSG_RESULT(not installed)
|
||||
DO_NOT_COMPILE="$DO_NOT_COMPILE kerry gmcop"
|
||||
fi
|
||||
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBADD)
|
||||
AC_SUBST(GLIB_LDFLAGS)
|
||||
|
||||
dnl Check for libbeagle 0.2.0
|
||||
# LIBBEAGLE_CFLAGS: cflags for compiling libbeagle dependant sources
|
||||
# LIBBEAGLE_LIBADD: libbeagle libraries (-l options)
|
||||
# LIBBEAGLE_LDFLAGS: flags containing path to libbeagle libraries (-L options)
|
||||
|
||||
LIBBEAGLE_PACKAGES="libbeagle-0.0"
|
||||
LIBBEAGLE_VERSION="0.2.4"
|
||||
AC_MSG_CHECKING(for libbeagle-0.2.4 (at least $LIBBEAGLE_VERSION))
|
||||
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.15 ; then
|
||||
if $PKG_CONFIG --atleast-version $LIBBEAGLE_VERSION $LIBBEAGLE_PACKAGES >/dev/null 2>&1 ; then
|
||||
LIBBEAGLE_CFLAGS="`$PKG_CONFIG --cflags $LIBBEAGLE_PACKAGES`"
|
||||
LIBBEAGLE_LIBADD="`$PKG_CONFIG --libs-only-l --libs-only-other $LIBBEAGLE_PACKAGES`"
|
||||
LIBBEAGLE_LDFLAGS="`$PKG_CONFIG --libs-only-L $LIBBEAGLE_PACKAGES`"
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
else
|
||||
if $PKG_CONFIG --atleast-version $LIBBEAGLE_VERSION $LIBBEAGLE_PACKAGES >/dev/null 2>&1 ; then
|
||||
LIBBEAGLE_CFLAGS="`$PKG_CONFIG --cflags $LIBBEAGLE_PACKAGES`"
|
||||
LIBBEAGLE_LIBADD="`$PKG_CONFIG --libs-only-l $LIBBEAGLE_PACKAGES`"
|
||||
LIBBEAGLE_LDFLAGS="`$PKG_CONFIG --libs-only-L $LIBBEAGLE_PACKAGES`"
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_MSG_WARN([you may need to run make LDFLAGS=-pthread to compile arts])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$LIBBEAGLE_LIBADD"; then
|
||||
AC_MSG_RESULT(not installed)
|
||||
DO_NOT_COMPILE="$DO_NOT_COMPILE kerry gmcop"
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBBEAGLE_CFLAGS)
|
||||
AC_SUBST(LIBBEAGLE_LIBADD)
|
||||
AC_SUBST(LIBBEAGLE_LDFLAGS)
|
@ -1 +1 @@
|
||||
SUBDIRS = icons tiles app_start_anim wallpaper kmenu_side
|
||||
SUBDIRS = icons tiles app_start_anim wallpaper kmenu_side kickoff
|
||||
|
@ -0,0 +1,14 @@
|
||||
kicker_kmenuside_pics_data_DATA = resize_handle.png \
|
||||
main_corner_tl.png main_corner_tr.png search-gradient.png \
|
||||
menu_separator.png search-tab-center.png search-tab-left.png \
|
||||
search-tab-right.png search-tab-top-center.png search-tab-top-left.png \
|
||||
left_triangle.png right_triangle.png \
|
||||
kmenu_basic.mng kmenu_flipped.mng kmenu_vertical.mng \
|
||||
search-tab-top-right.png search-gradient-topdown.png search-running.mng
|
||||
|
||||
kicker_kmenuside_pics_datadir = $(kde_datadir)/kicker/pics
|
||||
|
||||
EXTRA_DIST = $(kicker_kmenuside_pics_data_DATA)
|
||||
|
||||
kickerdir = $(kde_datadir)/kicker/icons
|
||||
kicker_ICON = leave recently_used suspend2disk suspend2ram
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 4.0 KiB |
@ -1,6 +1,5 @@
|
||||
kicker_kmenuside_pics_data_DATA = kside.png kside_tile.png
|
||||
|
||||
kicker_kmenuside_pics_datadir = $(kde_datadir)/kicker/pics/
|
||||
kicker_kmenuside_pics_data_DATA = kside.png kside_tile.png
|
||||
kicker_kmenuside_pics_datadir = $(kde_datadir)/kicker/pics
|
||||
|
||||
EXTRA_DIST = $(kicker_kmenuside_pics_data_DATA)
|
||||
|
||||
|
@ -0,0 +1,455 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Binner <binner@kde.org>
|
||||
Stephan Kulow <coolo@kde.org>
|
||||
Dirk Mueller <mueller@kde.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include <tqtooltip.h>
|
||||
#include <tqpainter.h>
|
||||
#include <tqcursor.h>
|
||||
#include <private/qeffects_p.h>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kapplication.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "kickerSettings.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "menumanager.h"
|
||||
#include "k_mnu_stub.h"
|
||||
#include "k_new_mnu.h"
|
||||
|
||||
#include "knewbutton.h"
|
||||
#include "knewbutton.moc"
|
||||
|
||||
KNewButton *KNewButton::m_self = 0;
|
||||
|
||||
KNewButton::KNewButton( TQWidget* parent )
|
||||
: KButton( parent ),
|
||||
m_oldPos(0,0)
|
||||
{
|
||||
Q_ASSERT( !m_self );
|
||||
m_self = this;
|
||||
m_hoverTimer = -1;
|
||||
m_openTimer = -1;
|
||||
m_active = false;
|
||||
m_mouseInside = false;
|
||||
m_drag = false;
|
||||
|
||||
setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignRight));
|
||||
setAcceptDrops(true);
|
||||
setIcon("kmenu-suse");
|
||||
setDrawArrow(false);
|
||||
|
||||
m_movie = new TQMovie(locate("data", "kicker/pics/kmenu_basic.mng"));
|
||||
m_movie->connectUpdate(this, TQT_SLOT(updateMovie()));
|
||||
m_movie->connectStatus(this, TQT_SLOT(slotStatus(int)));
|
||||
m_movie->connectResize(this, TQT_SLOT(slotSetSize(const TQSize&)));
|
||||
|
||||
TQApplication::desktop()->screen()->installEventFilter(this);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
KNewButton::~KNewButton()
|
||||
{
|
||||
if ( m_self == this )
|
||||
m_self = 0;
|
||||
setMouseTracking(false);
|
||||
delete m_movie;
|
||||
}
|
||||
|
||||
void KNewButton::slotStatus(int status)
|
||||
{
|
||||
if(status == TQMovie::EndOfLoop)
|
||||
slotStopAnimation();
|
||||
}
|
||||
|
||||
TQColor KNewButton::borderColor() const
|
||||
{
|
||||
TQImage img = m_active_pixmap.convertToImage();
|
||||
|
||||
for (int i = 0; i < img.width(); ++i) {
|
||||
QRgb rgb = img.pixel(orientation() == Qt::Horizontal ? img.width() - i - 1 :
|
||||
i, 2);
|
||||
|
||||
if (qGreen(rgb) > 0x50)
|
||||
return rgb;
|
||||
}
|
||||
|
||||
return img.pixel( orientation() == Qt::Horizontal ? img.width() - 2 : 2, 2);
|
||||
}
|
||||
|
||||
void KNewButton::show()
|
||||
{
|
||||
KButton::show();
|
||||
|
||||
if (KickerSettings::firstRun()) {
|
||||
TQTimer::singleShot(500,this,TQT_SLOT(slotExecMenu()));
|
||||
KickerSettings::setFirstRun(false);
|
||||
KickerSettings::writeConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void KNewButton::updateMovie()
|
||||
{
|
||||
m_oldPos = TQPoint( -1, -1 );
|
||||
drawEye();
|
||||
|
||||
if (!m_active && m_movie->running())
|
||||
m_movie->pause();
|
||||
}
|
||||
|
||||
void KNewButton::setPopupDirection(KPanelApplet::Direction d)
|
||||
{
|
||||
KButton::setPopupDirection(d);
|
||||
|
||||
delete m_movie;
|
||||
|
||||
switch (d) {
|
||||
case KPanelApplet::Left:
|
||||
setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignLeft));
|
||||
m_movie = new TQMovie(locate("data", "kicker/pics/kmenu_vertical.mng"));
|
||||
break;
|
||||
case KPanelApplet::Right:
|
||||
setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignRight));
|
||||
m_movie = new TQMovie(locate("data", "kicker/pics/kmenu_vertical.mng"));
|
||||
break;
|
||||
case KPanelApplet::Up:
|
||||
setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignHCenter));
|
||||
m_movie = new TQMovie(locate("data", "kicker/pics/kmenu_basic.mng"));
|
||||
break;
|
||||
case KPanelApplet::Down:
|
||||
setIconAlignment((Qt::AlignmentFlags)(AlignBottom|AlignHCenter));
|
||||
m_movie = new TQMovie(locate("data", "kicker/pics/kmenu_flipped.mng"));
|
||||
}
|
||||
|
||||
m_movie->connectUpdate(this, TQT_SLOT(updateMovie()));
|
||||
m_movie->connectStatus(this, TQT_SLOT(slotStatus(int)));
|
||||
m_movie->connectResize(this, TQT_SLOT(slotSetSize(const TQSize&)));
|
||||
}
|
||||
|
||||
void KNewButton::slotSetSize(const TQSize& s)
|
||||
{
|
||||
m_iconSize = s;
|
||||
}
|
||||
|
||||
double KNewButton::buttonScaleFactor(const TQSize& s) const
|
||||
{
|
||||
double sf = 1.0;
|
||||
|
||||
switch (popupDirection()) {
|
||||
case KPanelApplet::Left:
|
||||
case KPanelApplet::Right:
|
||||
// sf = kMin(double(s.width()) / m_iconSize.height(), double(s.height()) / m_iconSize.width());
|
||||
// break;
|
||||
case KPanelApplet::Up:
|
||||
case KPanelApplet::Down:
|
||||
sf = kMin(double(s.width()) / m_iconSize.width(), double(s.height()) / m_iconSize.height());
|
||||
break;
|
||||
}
|
||||
|
||||
if (sf > 0.8) sf = 1.0;
|
||||
return sf;
|
||||
}
|
||||
|
||||
int KNewButton::widthForHeight(int height) const
|
||||
{
|
||||
int r = m_iconSize.width() * buttonScaleFactor(TQSize(m_iconSize.width(), height));
|
||||
|
||||
if (!m_movie->running() && height != m_active_pixmap.height())
|
||||
{
|
||||
KNewButton* that = const_cast<KNewButton*>(this);
|
||||
TQTimer::singleShot(0, that, TQT_SLOT(slotStopAnimation()));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int KNewButton::preferredDimension(int panelDim) const
|
||||
{
|
||||
return kMax(m_icon.width(), m_icon.height());
|
||||
}
|
||||
|
||||
int KNewButton::heightForWidth(int width) const
|
||||
{
|
||||
int r = m_iconSize.width() * buttonScaleFactor(TQSize(width, m_iconSize.height()));
|
||||
if (!m_movie->running() && width != m_active_pixmap.width())
|
||||
{
|
||||
KNewButton* that = const_cast<KNewButton*>(this);
|
||||
TQTimer::singleShot(0, that, TQT_SLOT(slotStopAnimation()));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool KNewButton::eventFilter(TQObject *o, TQEvent *e)
|
||||
{
|
||||
if (e->type() == TQEvent::MouseButtonRelease ||
|
||||
e->type() == TQEvent::MouseButtonPress ||
|
||||
e->type() == TQEvent::MouseButtonDblClick )
|
||||
{
|
||||
TQMouseEvent *me = static_cast<TQMouseEvent *>(e);
|
||||
if (rect().contains(mapFromGlobal(me->globalPos())))
|
||||
{
|
||||
if (m_pressedDuringPopup && m_popup && m_openTimer != -1
|
||||
&& (me->button() & Qt::LeftButton) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (KickerSettings::kickoffDrawGeekoEye() && e->type() == TQEvent::MouseMove)
|
||||
{
|
||||
TQMouseEvent *me = static_cast<TQMouseEvent *>(e);
|
||||
if ((me->state() & MouseButtonMask) == NoButton)
|
||||
drawEye();
|
||||
}
|
||||
|
||||
return KButton::eventFilter(o, e);
|
||||
}
|
||||
|
||||
void KNewButton::drawEye()
|
||||
{
|
||||
#define eye_x 62
|
||||
#define eye_y 13
|
||||
TQPoint mouse = TQCursor::pos();
|
||||
TQPoint me = mapToGlobal(TQPoint(eye_x, eye_y));
|
||||
double a = atan2(mouse.y() - me.y(), mouse.x() - me.x());
|
||||
int dx = int(2.1 * cos(a));
|
||||
int dy = int(2.1 * sin(a));
|
||||
|
||||
TQPoint newpos(eye_x+dx,eye_y+dy);
|
||||
if (newpos!=m_oldPos) {
|
||||
m_oldPos = newpos;
|
||||
TQPixmap pixmap = m_active_pixmap;
|
||||
|
||||
double sf = 1.0;
|
||||
|
||||
if(!m_movie->framePixmap().isNull())
|
||||
{
|
||||
pixmap = m_movie->framePixmap();
|
||||
pixmap.detach();
|
||||
m_iconSize = pixmap.size();
|
||||
sf = buttonScaleFactor(size());
|
||||
|
||||
if (KickerSettings::kickoffDrawGeekoEye()) {
|
||||
TQPainter p(&pixmap);
|
||||
p.setPen(white);
|
||||
p.setBrush(white);
|
||||
// p.setPen(TQColor(110,185,55));
|
||||
p.drawRect(eye_x+dx, eye_y+dy, 2, 2);
|
||||
p. end();
|
||||
}
|
||||
}
|
||||
|
||||
TQWMatrix matrix;
|
||||
switch (popupDirection()) {
|
||||
case KPanelApplet::Left:
|
||||
matrix.scale(sf, -sf);
|
||||
matrix.rotate(90);
|
||||
break;
|
||||
case KPanelApplet::Up:
|
||||
matrix.scale(sf, sf);
|
||||
break;
|
||||
case KPanelApplet::Right:
|
||||
matrix.scale(sf, -sf);
|
||||
matrix.rotate(90);
|
||||
break;
|
||||
case KPanelApplet::Down:
|
||||
matrix.scale(sf, sf);
|
||||
break;
|
||||
}
|
||||
m_active_pixmap = pixmap.xForm(matrix);
|
||||
|
||||
repaint(false);
|
||||
}
|
||||
#undef eye_x
|
||||
#undef eye_y
|
||||
}
|
||||
|
||||
void KNewButton::enterEvent(TQEvent* e)
|
||||
{
|
||||
KButton::enterEvent(e);
|
||||
|
||||
TQSize s(size());
|
||||
s *= 0.25;
|
||||
s = s.expandedTo(TQSize(6,6));
|
||||
|
||||
switch (popupDirection()) {
|
||||
case KPanelApplet::Left:
|
||||
m_sloppyRegion = TQRect(rect().topRight() - TQPoint(s.width()-1, 0), s);
|
||||
break;
|
||||
case KPanelApplet::Right:
|
||||
m_sloppyRegion = TQRect(rect().topLeft(), s);
|
||||
break;
|
||||
case KPanelApplet::Up:
|
||||
m_sloppyRegion = TQRect(rect().bottomLeft() - TQPoint(0, s.height()-1), s);
|
||||
break;
|
||||
case KPanelApplet::Down:
|
||||
m_sloppyRegion = TQRect(rect().topLeft(), s);
|
||||
}
|
||||
|
||||
m_active = true;
|
||||
m_movie->unpause();
|
||||
m_movie->restart();
|
||||
}
|
||||
|
||||
void KNewButton::rewindMovie()
|
||||
{
|
||||
m_oldPos = TQPoint( -1, -1 );
|
||||
m_movie->unpause();
|
||||
}
|
||||
|
||||
void KNewButton::dragEnterEvent(TQDragEnterEvent* /*e*/)
|
||||
{
|
||||
if (m_hoverTimer != -1)
|
||||
killTimer(m_hoverTimer);
|
||||
|
||||
m_hoverTimer = startTimer(TQApplication::startDragTime());
|
||||
m_mouseInside = true;
|
||||
m_drag = true;
|
||||
}
|
||||
|
||||
void KNewButton::dragLeaveEvent(TQDragLeaveEvent* /*e*/)
|
||||
{
|
||||
m_mouseInside = false;
|
||||
m_drag = false;
|
||||
}
|
||||
|
||||
void KNewButton::leaveEvent(TQEvent* e)
|
||||
{
|
||||
m_mouseInside = false;
|
||||
if (m_hoverTimer != -1)
|
||||
killTimer(m_hoverTimer);
|
||||
m_hoverTimer = -1;
|
||||
|
||||
KButton::leaveEvent(e);
|
||||
}
|
||||
|
||||
void KNewButton::mouseMoveEvent(TQMouseEvent* e)
|
||||
{
|
||||
KButton::mouseMoveEvent(e);
|
||||
|
||||
m_mouseInside = m_sloppyRegion.contains(e->pos());
|
||||
|
||||
if ( m_sloppyRegion.contains(e->pos()))
|
||||
{
|
||||
if (m_hoverTimer == -1 && KickerSettings::openOnHover())
|
||||
m_hoverTimer = startTimer(kMax(200,TQApplication::doubleClickInterval()/2));
|
||||
}
|
||||
else if (m_hoverTimer != -1)
|
||||
{
|
||||
killTimer(m_hoverTimer);
|
||||
m_hoverTimer = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void KNewButton::slotStopAnimation()
|
||||
{
|
||||
m_active = false;
|
||||
m_movie->pause();
|
||||
m_movie->restart();
|
||||
TQTimer::singleShot(200, this, TQT_SLOT(rewindMovie()));
|
||||
}
|
||||
|
||||
const TQPixmap& KNewButton::labelIcon() const
|
||||
{
|
||||
return m_active_pixmap;
|
||||
}
|
||||
|
||||
void KNewButton::slotExecMenu()
|
||||
{
|
||||
if (m_openTimer != -1)
|
||||
killTimer(m_openTimer);
|
||||
|
||||
m_openTimer = startTimer(TQApplication::doubleClickInterval() * 3);
|
||||
|
||||
if (m_active)
|
||||
{
|
||||
m_active = false;
|
||||
m_movie->pause();
|
||||
m_movie->restart();
|
||||
}
|
||||
|
||||
KButton::slotExecMenu();
|
||||
|
||||
assert(!KickerTip::tippingEnabled());
|
||||
assert(dynamic_cast<KMenu*>(m_popup));
|
||||
|
||||
disconnect(dynamic_cast<KMenu*>(m_popup), TQT_SIGNAL(aboutToHide()), this,
|
||||
TQT_SLOT(slotStopAnimation()));
|
||||
connect(dynamic_cast<KMenu*>(m_popup), TQT_SIGNAL(aboutToHide()),
|
||||
TQT_SLOT(slotStopAnimation()));
|
||||
|
||||
m_popup->move(KickerLib::popupPosition(popupDirection(), m_popup, this));
|
||||
// I wish KMenu would properly done itself when it closes. But it doesn't.
|
||||
|
||||
bool useEffect = true; // could be TQApplication::isEffectEnabled()
|
||||
useEffect = false; // too many TQt bugs to be useful
|
||||
if (m_drag)
|
||||
useEffect = false;
|
||||
|
||||
m_drag = false; // once is enough
|
||||
|
||||
if (useEffect)
|
||||
{
|
||||
switch (popupDirection()) {
|
||||
case KPanelApplet::Left:
|
||||
qScrollEffect(m_popup, QEffects::LeftScroll);
|
||||
break;
|
||||
case KPanelApplet::Up:
|
||||
qScrollEffect(m_popup, QEffects::UpScroll);
|
||||
break;
|
||||
case KPanelApplet::Right:
|
||||
qScrollEffect(m_popup, QEffects::RightScroll);
|
||||
break;
|
||||
case KPanelApplet::Down:
|
||||
qScrollEffect(m_popup, QEffects::DownScroll);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
static_cast<KMenu*>(m_popup)->show();
|
||||
}
|
||||
|
||||
void KNewButton::timerEvent(TQTimerEvent* e)
|
||||
{
|
||||
if (e->timerId() == m_hoverTimer)
|
||||
{
|
||||
if (m_mouseInside && !isDown())
|
||||
showMenu();
|
||||
|
||||
killTimer(m_hoverTimer);
|
||||
m_hoverTimer = -1;
|
||||
}
|
||||
if (e->timerId() == m_openTimer)
|
||||
{
|
||||
killTimer(m_openTimer);
|
||||
m_openTimer = -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Binner <binner@kde.org>
|
||||
Stephan Kulow <coolo@kde.org>
|
||||
Dirk Mueller <mueller@kde.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __knewbutton_h__
|
||||
#define __knewbutton_h__
|
||||
|
||||
#include "kbutton.h"
|
||||
|
||||
#include <tqmovie.h>
|
||||
#include <tqpoint.h>
|
||||
|
||||
/**
|
||||
* Button that contains the PanelKMenu and client menu manager.
|
||||
*/
|
||||
class KNewButton : public KButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KNewButton( TQWidget *parent );
|
||||
~KNewButton();
|
||||
|
||||
static KNewButton *self() { return m_self; }
|
||||
|
||||
void loadConfig( const KConfigGroup& config );
|
||||
|
||||
virtual const TQPixmap& labelIcon() const;
|
||||
|
||||
virtual int widthForHeight(int height) const;
|
||||
virtual int preferredDimension(int panelDim) const;
|
||||
virtual int heightForWidth(int width) const;
|
||||
|
||||
TQColor borderColor() const;
|
||||
|
||||
virtual void setPopupDirection(KPanelApplet::Direction d);
|
||||
|
||||
private slots:
|
||||
void slotStatus(int);
|
||||
void slotSetSize(const TQSize&);
|
||||
void slotStopAnimation();
|
||||
void rewindMovie();
|
||||
void updateMovie();
|
||||
|
||||
protected:
|
||||
virtual void show();
|
||||
virtual void slotExecMenu();
|
||||
virtual TQString tileName() { return "KMenu"; }
|
||||
virtual TQString defaultIcon() const { return "go"; }
|
||||
|
||||
virtual void enterEvent(TQEvent* e);
|
||||
virtual void leaveEvent(TQEvent* e);
|
||||
virtual void mouseMoveEvent(TQMouseEvent* e);
|
||||
virtual void dragEnterEvent(TQDragEnterEvent*);
|
||||
virtual void dragLeaveEvent(TQDragLeaveEvent*);
|
||||
virtual bool eventFilter(TQObject *, TQEvent *);
|
||||
void timerEvent(TQTimerEvent*);
|
||||
|
||||
private:
|
||||
void drawEye();
|
||||
double buttonScaleFactor(const TQSize& s) const;
|
||||
|
||||
TQMovie* m_movie;
|
||||
TQPixmap m_active_pixmap;
|
||||
TQPoint m_oldPos;
|
||||
TQSize m_iconSize;
|
||||
TQRect m_sloppyRegion;
|
||||
int m_hoverTimer;
|
||||
int m_openTimer;
|
||||
bool m_active;
|
||||
bool m_mouseInside;
|
||||
bool m_drag;
|
||||
|
||||
static KNewButton *m_self;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,300 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>KMenuBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
<cstring>KMenu</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>723</width>
|
||||
<height>580</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>KMenu</string>
|
||||
</property>
|
||||
<property name="frameShadow" stdset="0">
|
||||
<string>MShadow</string>
|
||||
</property>
|
||||
<property name="frameShape" stdset="0">
|
||||
<string>MShape</string>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>m_search</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>190</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QFrame">
|
||||
<property name="name">
|
||||
<cstring>m_searchFrame</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>52</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>52</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout18</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>m_searchLabel</cstring>
|
||||
</property>
|
||||
<property name="backgroundOrigin">
|
||||
<enum>ParentOrigin</enum>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KHistoryCombo">
|
||||
<property name="name">
|
||||
<cstring>m_kcommand</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>m_searchPixmap</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="backgroundMode">
|
||||
<enum>PaletteBackground</enum>
|
||||
</property>
|
||||
<property name="backgroundOrigin">
|
||||
<enum>ParentOrigin</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer5_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>m_footer</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>110</y>
|
||||
<width>407</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>m_userInfo</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User&nbsp;<b>user</b>&nbsp;on&nbsp;<b>host</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer13_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QToolButton">
|
||||
<property name="name">
|
||||
<cstring>m_branding</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>4</hsizetype>
|
||||
<vsizetype>4</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="iconSet">
|
||||
<iconset>image0</iconset>
|
||||
</property>
|
||||
<property name="usesBigPixmap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer13</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
</customwidgets>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="PNG" length="347">89504e470d0a1a0a0000000d494844520000005a0000001808060000007a38ea6500000122494441546881ed98610e83200c85c7e2a93c0087e6005c0b7f754152ea43a532ec972c512cf5f96c28d3c5183f467fbe4f0b780b66b41266b41266b412cbd302b4594348d2f5e8bd93e2e83a9a93e2ada21b397a51355e57d1794592695c954af16b08899b23e5f955f41a42a25fbbfcbe709a9ed0c9998eb25b3aa2f72e7aef4634fbdf395c3a72d3f346811c73f390b172fcac36eefc2a522172e3746fd1e8b3a2a579523e3ae7c6b9fbf434f46e764623cda18ce78cc973213950b108b99e1ee6235b398e050d44e2f2f1abb966e3f43eba5c0e466ba03df4d4fa0982b8469706b65469f9a0b57d271787beb89ab63b970da9c1b5c4ba59bf4723464b3de9eebfe0531a3de20e64ba6f1da3f50a62ca8a1e91e92a7a54cc6825cc6825cc682536f10e058bc1bcdf310000000049454e44ae426082</data>
|
||||
</image>
|
||||
</images>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">kmenubase.ui.h</include>
|
||||
</includes>
|
||||
<functions>
|
||||
<function access="private" specifier="non virtual">init()</function>
|
||||
</functions>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kcombobox.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
@ -0,0 +1,9 @@
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
void KMenuBase::init()
|
||||
{
|
||||
XSetWindowAttributes attrs;
|
||||
attrs.override_redirect = True;
|
||||
XChangeWindowAttributes( qt_xdisplay(), winId(), CWOverrideRedirect, &attrs );
|
||||
setWFlags( Qt::WType_Popup );
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
METASOURCES = AUTO
|
||||
INCLUDES= -I$(top_srcdir)/src $(all_includes)
|
||||
|
||||
# The library containing the plugin base class
|
||||
lib_LTLIBRARIES = libkickoffsearch_interfaces.la
|
||||
libkickoffsearch_interfaces_la_SOURCES = kickoff-search-plugin.cpp kickoffsearchinterface.cpp
|
||||
libkickoffsearch_interfaces_la_LDFLAGS = $(all_libraries) -version-info 0:0:0
|
||||
|
||||
kickoffsearchincludedir = $(includedir)
|
||||
kickoffsearchinclude_HEADERS = kickoff-search-plugin.h kickoffsearchinterface.h
|
||||
|
||||
kde_servicetypes_DATA = kickoffsearchplugin.desktop
|
@ -0,0 +1,37 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kickoff-search-plugin.h"
|
||||
#include <tqobjectlist.h>
|
||||
|
||||
KickoffSearch::Plugin::Plugin(TQObject *parent, const char* name )
|
||||
:TQObject( parent, name )
|
||||
{
|
||||
}
|
||||
|
||||
KickoffSearch::Plugin::~Plugin()
|
||||
{
|
||||
}
|
||||
|
||||
KickoffSearch::KickoffSearchInterface* KickoffSearch::Plugin::kickoffSearchInterface()
|
||||
{
|
||||
return static_cast<KickoffSearchInterface*>( parent()->child( 0, "KickoffSearch::KickoffSearchInterface" ) );
|
||||
}
|
||||
|
||||
#include "kickoff-search-plugin.moc"
|
@ -0,0 +1,106 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef KICKOFF_SEARCH_PLUGIN_H
|
||||
#define KICKOFF_SEARCH_PLUGIN_H
|
||||
|
||||
#include "kickoffsearchinterface.h"
|
||||
|
||||
#include <tqobject.h>
|
||||
#include <kurl.h>
|
||||
#include <kservice.h>
|
||||
|
||||
typedef enum {
|
||||
ACTIONS = 0,
|
||||
APPS,
|
||||
BOOKMARKS,
|
||||
NOTES,
|
||||
MAILS,
|
||||
FILES,
|
||||
MUSIC,
|
||||
WEBHIST,
|
||||
CHATS,
|
||||
FEEDS,
|
||||
PICS,
|
||||
VIDEOS,
|
||||
DOCS,
|
||||
OTHER,
|
||||
num_categories
|
||||
} CATEGORY;
|
||||
|
||||
class HitMenuItem
|
||||
{
|
||||
public:
|
||||
HitMenuItem (int id, int category)
|
||||
: id (id), category (category),score(0) { } /* dummy */
|
||||
HitMenuItem (TQString name, TQString info, KURL uri, TQString mimetype, int id, int category, TQString icon=TQString::null, int score = 0)
|
||||
: display_name (name)
|
||||
, display_info (info)
|
||||
, uri (uri)
|
||||
, mimetype (mimetype)
|
||||
, id (id)
|
||||
, category (category)
|
||||
, icon (icon)
|
||||
, score (score)
|
||||
, service (NULL) { }
|
||||
|
||||
~HitMenuItem () { }
|
||||
|
||||
bool operator< (HitMenuItem item)
|
||||
{
|
||||
return ((category == item.category && score > item.score) || (category == item.category && id < item.id) ||
|
||||
(category < item.category));
|
||||
}
|
||||
|
||||
// FIXME: We dont really need to store display_name and display_info
|
||||
TQString display_name; // name to display
|
||||
TQString display_info; // other information to display
|
||||
KURL uri; // uri to open when clicked
|
||||
TQString mimetype;
|
||||
int id; // id of the item in the menu
|
||||
int category;
|
||||
TQString icon;
|
||||
int score;
|
||||
KService::Ptr service;
|
||||
|
||||
TQString quotedPath () const
|
||||
{
|
||||
return uri.path ().replace ('"', "\\\"");
|
||||
}
|
||||
};
|
||||
|
||||
namespace KickoffSearch {
|
||||
|
||||
class Plugin : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plugin(TQObject *parent, const char* name=0);
|
||||
virtual ~Plugin();
|
||||
|
||||
virtual bool daemonRunning()=0;
|
||||
virtual void query(TQString,bool)=0;
|
||||
|
||||
KickoffSearchInterface * kickoffSearchInterface();
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* KICKOFF_SEARCH_PLUGIN_H */
|
@ -0,0 +1,27 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kickoffsearchinterface.h"
|
||||
|
||||
KickoffSearch::KickoffSearchInterface::KickoffSearchInterface( TQObject* parent, const char* name )
|
||||
:TQObject( parent, name )
|
||||
{
|
||||
}
|
||||
|
||||
#include "kickoffsearchinterface.moc"
|
@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef KICKOFFSEARCHINTERFACE_H
|
||||
#define KICKOFFSEARCHINTERFACE_H
|
||||
|
||||
#include <tqobject.h>
|
||||
|
||||
class HitMenuItem;
|
||||
|
||||
namespace KickoffSearch
|
||||
{
|
||||
class KickoffSearchInterface :public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KickoffSearchInterface( TQObject* parent, const char* name = 0);
|
||||
|
||||
public:
|
||||
virtual bool anotherHitMenuItemAllowed(int cat) = 0;
|
||||
virtual void addHitMenuItem(HitMenuItem* item) = 0;
|
||||
virtual void searchOver() = 0;
|
||||
virtual void initCategoryTitlesUpdate() = 0;
|
||||
virtual void updateCategoryTitles() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SELECTIONINTERFACE_H */
|
||||
|
@ -0,0 +1,4 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
X-KDE-ServiceType=KickoffSearch/Plugin
|
||||
Comment=A search plugin for Kickoff
|
@ -0,0 +1,24 @@
|
||||
INCLUDES = -I$(top_srcdir)/interfaces $(all_includes) $(LIBBEAGLE_CFLAGS) $(GLIB_CFLAGS)
|
||||
METASOURCES = AUTO
|
||||
|
||||
# Install this plugin in the KDE modules directory
|
||||
kde_module_LTLIBRARIES = kickoffsearch_beagle.la
|
||||
|
||||
# Srcs for the plugin
|
||||
kickoffsearch_beagle_la_SOURCES = kickoff-beagle-plugin.cpp beaglesearch.cpp
|
||||
|
||||
# Libs needed by the plugin
|
||||
kickoffsearch_beagle_la_LIBADD = $(LIB_KPARTS) ../interfaces/libkickoffsearch_interfaces.la \
|
||||
$(LIBBEAGLE_LIBADD) $(GLIB_LIBADD)
|
||||
|
||||
# LD flags for the plugin
|
||||
# -module says: this is a module, i.e. something you're going to dlopen
|
||||
# so e.g. it has no version number like a normal shared lib would have.
|
||||
kickoffsearch_beagle_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
|
||||
|
||||
# Install the desktop file needed to detect the plugin
|
||||
kde_services_DATA = kickoffsearch_beagle.desktop
|
||||
|
||||
# i18n translation messages
|
||||
messages: rc.cpp
|
||||
$(XGETTEXT) *.cpp *.h -o $(podir)/kickoffsearch_beagle.pot
|
@ -0,0 +1,362 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "beaglesearch.h"
|
||||
|
||||
#include <tqdatetime.h>
|
||||
#include <tqmutex.h>
|
||||
#include <tqstringlist.h>
|
||||
#include <tqapplication.h>
|
||||
#include <time.h>
|
||||
|
||||
void beagle_init ()
|
||||
{
|
||||
g_type_init ();
|
||||
}
|
||||
|
||||
// ---------------- Hit ---------------------------
|
||||
|
||||
Hit::Hit (BeagleHit *_hit) : processed (false)
|
||||
{
|
||||
hit = beagle_hit_ref (_hit);
|
||||
}
|
||||
|
||||
Hit::~Hit ()
|
||||
{
|
||||
beagle_hit_unref (hit);
|
||||
if (! processed)
|
||||
return;
|
||||
TQDictIterator<TQStringList> it (property_map);
|
||||
for( ; it.current(); ++it )
|
||||
((TQStringList *)it.current())->clear ();
|
||||
|
||||
}
|
||||
|
||||
void Hit::processProperties ()
|
||||
{
|
||||
processed = true;
|
||||
GSList *prop_list = beagle_hit_get_all_properties (hit);
|
||||
GSList *it;
|
||||
property_map.setAutoDelete (true);
|
||||
for (it = prop_list; it; it = it->next) {
|
||||
BeagleProperty *property = (BeagleProperty *) it->data;
|
||||
TQString key = TQString::fromUtf8 (beagle_property_get_key (property));
|
||||
if (! property_map [key])
|
||||
property_map.insert (key, new TQStringList ());
|
||||
property_map [key]->append (TQString::fromUtf8 (beagle_property_get_value (property)));
|
||||
}
|
||||
g_slist_free (prop_list);
|
||||
}
|
||||
|
||||
const TQString Hit::operator[] (TQString prop_name)
|
||||
{
|
||||
if (! processed)
|
||||
processProperties ();
|
||||
|
||||
TQStringList *prop_list = property_map [prop_name];
|
||||
if (! prop_list)
|
||||
return TQString::null;
|
||||
if (prop_list->count () != 1)
|
||||
return TQString::null;
|
||||
return (TQString)prop_list->first ();
|
||||
}
|
||||
|
||||
// ---------------- BeagleSearch ------------------
|
||||
|
||||
BeagleSearchResult::BeagleSearchResult(int client_id)
|
||||
: client_id (client_id), total (0)
|
||||
{
|
||||
hitlist = new TQPtrList<Hit>;
|
||||
hitlist->setAutoDelete (true);
|
||||
}
|
||||
|
||||
|
||||
BeagleSearchResult::~BeagleSearchResult()
|
||||
{
|
||||
// everything is set to autodelete
|
||||
}
|
||||
|
||||
void BeagleSearchResult::addHit(BeagleHit *_hit)
|
||||
{
|
||||
Hit *hit = new Hit (_hit);
|
||||
hitlist->prepend (hit);
|
||||
}
|
||||
|
||||
const TQPtrList<Hit> *BeagleSearchResult::getHits () const
|
||||
{
|
||||
return hitlist;
|
||||
}
|
||||
|
||||
|
||||
static int total_hits;
|
||||
|
||||
static void print_feed_item_hit (BeagleHit *hit)
|
||||
{
|
||||
const char *text;
|
||||
|
||||
if (beagle_hit_get_one_property (hit, "dc:title", &text))
|
||||
g_print ("Blog: %s\n", text);
|
||||
}
|
||||
|
||||
static void print_file_hit (BeagleHit *hit)
|
||||
{
|
||||
g_print ("File: %s, (%s)\n", beagle_hit_get_uri (hit), beagle_hit_get_mime_type (hit));
|
||||
}
|
||||
|
||||
static void print_other_hit (BeagleHit *hit)
|
||||
{
|
||||
const char *text;
|
||||
|
||||
g_print ("%s (%s)", beagle_hit_get_uri (hit),
|
||||
beagle_hit_get_source (hit));
|
||||
if (beagle_hit_get_one_property (hit, "dc:title", &text))
|
||||
g_print ("title = %s\n", text);
|
||||
}
|
||||
|
||||
static void print_hit (BeagleHit *hit)
|
||||
{
|
||||
if (strcmp (beagle_hit_get_type (hit), "FeedItem") == 0) {
|
||||
print_feed_item_hit (hit);
|
||||
}
|
||||
else if (strcmp (beagle_hit_get_type (hit), "File") == 0) {
|
||||
print_file_hit (hit);
|
||||
} else {
|
||||
print_other_hit (hit);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- BeagleSearchClient ------------------
|
||||
|
||||
void BeagleSearchClient::run ()
|
||||
{
|
||||
kdDebug () << "Starting query ..." << endl;
|
||||
|
||||
TQTime query_timer;
|
||||
query_timer.start ();
|
||||
|
||||
g_signal_connect (query, "hits-added",
|
||||
G_CALLBACK (hitsAddedSlot),
|
||||
this);
|
||||
g_signal_connect (query, "finished",
|
||||
G_CALLBACK (finishedSlot),
|
||||
this);
|
||||
beagle_client_send_request_async (client,
|
||||
BEAGLE_REQUEST (query),
|
||||
NULL);
|
||||
g_main_loop_run (main_loop);
|
||||
kdDebug () << "Finished query ..." << endl;
|
||||
|
||||
TQCustomEvent *ev;
|
||||
if (collate_results) {
|
||||
result->query_msec = query_timer.elapsed ();
|
||||
|
||||
ev = new TQCustomEvent (RESULTFOUND, result);
|
||||
TQApplication::postEvent (object, ev);
|
||||
}
|
||||
|
||||
ev = new TQCustomEvent (KILLME, this);
|
||||
TQApplication::postEvent (object, ev);
|
||||
|
||||
}
|
||||
|
||||
void BeagleSearchClient::stopClient ()
|
||||
{
|
||||
if (finished ())
|
||||
return; // duh!
|
||||
kdDebug () << "Query thread " << id << " not yet finished ..." << endl;
|
||||
// get ready for suicide
|
||||
client_mutex->lock ();
|
||||
kill_me = true;
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
query,
|
||||
(void *)hitsAddedSlot,
|
||||
this);
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
query,
|
||||
(void *)finishedSlot,
|
||||
this);
|
||||
g_main_loop_quit (main_loop);
|
||||
client_mutex->unlock ();
|
||||
}
|
||||
|
||||
void BeagleSearchClient::hitsAddedSlot (BeagleQuery *query,
|
||||
BeagleHitsAddedResponse *response,
|
||||
BeagleSearchClient *bsclient)
|
||||
{
|
||||
GSList *hits, *l;
|
||||
gint i;
|
||||
gint nr_hits;
|
||||
|
||||
// check if we are supposed to be killed
|
||||
bsclient->client_mutex->lock ();
|
||||
if (bsclient->kill_me) {
|
||||
kdDebug () << "Suicide time before processing" << endl;
|
||||
bsclient->client_mutex->unlock ();
|
||||
return;
|
||||
}
|
||||
bsclient->client_mutex->unlock ();
|
||||
|
||||
hits = beagle_hits_added_response_get_hits (response);
|
||||
|
||||
nr_hits = g_slist_length (hits);
|
||||
total_hits += nr_hits;
|
||||
g_print ("Found hits (%d) at %ld:\n", nr_hits, time (NULL));
|
||||
|
||||
BeagleSearchResult *search_result;
|
||||
if (! bsclient->collate_results)
|
||||
search_result = new BeagleSearchResult (bsclient->id);
|
||||
else
|
||||
search_result = bsclient->result;
|
||||
search_result->total += nr_hits;
|
||||
|
||||
for (l = hits, i = 1; l; l = l->next, ++i) {
|
||||
//g_print ("[%d] ", i);
|
||||
//print_hit (BEAGLE_HIT (l->data));
|
||||
//g_print ("\n");
|
||||
|
||||
search_result->addHit(BEAGLE_HIT (l->data));//hit);
|
||||
}
|
||||
g_print ("[%ld] hits adding finished \n", time (NULL));
|
||||
|
||||
// check if we are supposed to be killed
|
||||
bsclient->client_mutex->lock ();
|
||||
if (bsclient->kill_me) {
|
||||
kdDebug () << "Suicide time before sending ..." << endl;
|
||||
bsclient->client_mutex->unlock ();
|
||||
if (! bsclient->collate_results)
|
||||
delete search_result;
|
||||
return;
|
||||
}
|
||||
bsclient->client_mutex->unlock ();
|
||||
|
||||
// time to send back results, if user asked so
|
||||
if (bsclient->collate_results)
|
||||
return;
|
||||
TQCustomEvent *ev = new TQCustomEvent (RESULTFOUND, search_result);
|
||||
g_print ("[%ld] event notified \n", time (NULL));
|
||||
TQApplication::postEvent (bsclient->object, ev);
|
||||
}
|
||||
|
||||
void BeagleSearchClient::finishedSlot (BeagleQuery *query,
|
||||
BeagleFinishedResponse *response,
|
||||
BeagleSearchClient *bsclient)
|
||||
{
|
||||
// check if we are supposed to be killed
|
||||
bsclient->client_mutex->lock ();
|
||||
bool should_kill = bsclient->kill_me;
|
||||
TQObject* receiver = bsclient->object;
|
||||
bsclient->client_mutex->unlock ();
|
||||
|
||||
if (should_kill)
|
||||
return;
|
||||
|
||||
g_main_loop_quit (bsclient->main_loop);
|
||||
|
||||
if (bsclient->collate_results)
|
||||
return; // if we are collating, everything will be send from a central place
|
||||
if (receiver) {
|
||||
TQCustomEvent *ev = new TQCustomEvent (SEARCHOVER, bsclient);
|
||||
g_print ("[%ld] query finish notified \n", time (NULL));
|
||||
TQApplication::postEvent (receiver, ev);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------- BeagleUtil -------------------
|
||||
|
||||
BeagleQuery *
|
||||
BeagleUtil::createQueryFromString (TQString query_str,
|
||||
TQStringList &sources_menu,
|
||||
TQStringList &types_menu,
|
||||
int max_hits_per_source)
|
||||
{
|
||||
BeagleQuery *beagle_query = beagle_query_new ();
|
||||
beagle_query_set_max_hits (beagle_query, max_hits_per_source); // this is per source!
|
||||
|
||||
kdDebug () << "Creating query from \"" << query_str << "\"" << endl;
|
||||
for ( TQStringList::Iterator it = sources_menu.begin(); it != sources_menu.end(); ++it )
|
||||
beagle_query_add_source (beagle_query, g_strdup ((*it).utf8 ()));
|
||||
|
||||
for ( TQStringList::Iterator it = types_menu.begin(); it != types_menu.end(); ++it )
|
||||
beagle_query_add_hit_type (beagle_query, g_strdup ((*it).utf8 ()));
|
||||
|
||||
TQStringList query_terms;
|
||||
TQString start_date, end_date;
|
||||
TQStringList words = TQStringList::split (' ', query_str, false);
|
||||
for ( TQStringList::Iterator it = words.begin(); it != words.end(); ++it ) {
|
||||
TQStringList key_value_pair = TQStringList::split ('=', *it, false);
|
||||
if (key_value_pair.count () == 1)
|
||||
query_terms += *it;
|
||||
else if (key_value_pair.count () == 2) {
|
||||
TQString key = key_value_pair [0].lower ();
|
||||
TQString value = key_value_pair [1];
|
||||
if (key == "mime")
|
||||
beagle_query_add_mime_type (beagle_query, g_strdup (value.utf8 ()));
|
||||
else if (key == "type")
|
||||
beagle_query_add_hit_type (beagle_query, g_strdup (value.utf8 ()));
|
||||
else if (key == "source")
|
||||
beagle_query_add_source (beagle_query, g_strdup (value.utf8 ()));
|
||||
else if (key == "start")
|
||||
start_date = value;
|
||||
else if (key == "end")
|
||||
end_date = value;
|
||||
else
|
||||
query_terms += *it;
|
||||
} else
|
||||
query_terms += *it;
|
||||
}
|
||||
|
||||
beagle_query_add_text (beagle_query, g_strdup (query_terms.join (" ").utf8 ()));
|
||||
kdDebug () << "Adding query text:" << query_terms.join (" ").utf8 () << endl;
|
||||
|
||||
if (start_date.isNull () && end_date.isNull ())
|
||||
return beagle_query;
|
||||
|
||||
//kdDebug () << "Handling dates ..." << endl;
|
||||
BeagleQueryPartDate * date_part = beagle_query_part_date_new ();
|
||||
if (! start_date.isNull ())
|
||||
beagle_query_part_date_set_start_date (date_part, timestringToBeagleTimestamp (start_date));
|
||||
if (! end_date.isNull ())
|
||||
beagle_query_part_date_set_end_date (date_part, timestringToBeagleTimestamp (end_date));
|
||||
beagle_query_add_part (beagle_query, BEAGLE_QUERY_PART (date_part));
|
||||
|
||||
return beagle_query;
|
||||
}
|
||||
|
||||
// timestring format allowed YYYYmmDD
|
||||
BeagleTimestamp *
|
||||
BeagleUtil::timestringToBeagleTimestamp(TQString timestring)
|
||||
{
|
||||
//kdDebug () << "datetime string:" << timestring << endl;
|
||||
// FIXME: error check timestring format
|
||||
if (timestring.isNull () || timestring.stripWhiteSpace () == "" || timestring.length() != 8 )
|
||||
return beagle_timestamp_new_from_unix_time (TQDateTime::currentDateTime ().toTime_t ());
|
||||
//TQDateTime dt = TQDateTime::fromString (timestring, Qt::ISODate);
|
||||
struct tm tm_time;
|
||||
time_t timet_time;
|
||||
time (&timet_time);
|
||||
localtime_r (&timet_time, &tm_time);
|
||||
strptime (timestring.ascii(), "%Y%m%d", &tm_time);
|
||||
tm_time.tm_sec = tm_time.tm_min = tm_time.tm_hour = 0;
|
||||
//kdDebug() << asctime (&tm_time) << endl;
|
||||
timet_time = mktime (&tm_time);
|
||||
return beagle_timestamp_new_from_unix_time (timet_time);
|
||||
}
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef BEAGLESEARCH_H
|
||||
#define BEAGLESEARCH_H
|
||||
|
||||
#include <tqdict.h>
|
||||
#include <tqptrlist.h>
|
||||
#include <tqthread.h>
|
||||
#include <tqevent.h>
|
||||
#include <tqmutex.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kurl.h>
|
||||
|
||||
extern "C" {
|
||||
#include <glib.h>
|
||||
#include <beagle/beagle.h>
|
||||
}
|
||||
|
||||
// BeagleSearchClient sends 3 types of events
|
||||
// when results are to be sent as they arrive,
|
||||
// - RESULTFOUND : when result is found
|
||||
// - SEARCHOVER : when search is over
|
||||
// - KILLME : just before thread finishes - used to cleanup the thread object
|
||||
// when results are to be sent after receiving all of them
|
||||
// - RESULTFOUND : when all results are obtained
|
||||
// - KILLME : just before thread finishes - used to cleanup the thread object
|
||||
#define RESULTFOUND (TQEvent::Type)1001 /* TQEvent::User + 1 */
|
||||
#define SEARCHOVER (TQEvent::Type)1002 /* TQEvent::User + 2 */
|
||||
#define KILLME (TQEvent::Type)1003 /* TQEvent::User + 3 */
|
||||
|
||||
class TQStringList;
|
||||
|
||||
// IMPORTANT: Call this before any beagle calls
|
||||
void beagle_init ();
|
||||
|
||||
class Hit {
|
||||
public:
|
||||
Hit (BeagleHit *_hit);
|
||||
~Hit ();
|
||||
|
||||
// convenience wrappers
|
||||
// remember that the hit values are utf8 strings
|
||||
const KURL getUri () const { return KURL (TQString::fromUtf8 (beagle_hit_get_uri (hit)));}
|
||||
const TQString getType () const { return TQString::fromUtf8 (beagle_hit_get_type (hit));}
|
||||
const TQString getMimeType () const { return TQString::fromUtf8 (beagle_hit_get_mime_type (hit));}
|
||||
const TQString getSource () const { return TQString::fromUtf8 (beagle_hit_get_source (hit));}
|
||||
const KURL getParentUri () const { return KURL (TQString::fromUtf8 (beagle_hit_get_parent_uri (hit)));}
|
||||
const TQDict<TQStringList>& getAllProperties ()
|
||||
{
|
||||
if (! processed)
|
||||
processProperties ();
|
||||
return property_map;
|
||||
}
|
||||
const TQStringList* getProperties (TQString prop_name)
|
||||
{
|
||||
if (! processed)
|
||||
processProperties ();
|
||||
return property_map [prop_name];
|
||||
}
|
||||
const TQString operator[] (TQString prop_name);
|
||||
|
||||
private:
|
||||
BeagleHit *hit;
|
||||
TQDict<TQStringList> property_map;
|
||||
// not every hit may be used. so, do a lazy processing of property_map
|
||||
bool processed;
|
||||
void processProperties ();
|
||||
};
|
||||
|
||||
class BeagleSearchResult{
|
||||
public:
|
||||
BeagleSearchResult(int client_id);
|
||||
~BeagleSearchResult();
|
||||
void addHit (BeagleHit *hit);
|
||||
TQString getHitCategory (Hit *hit);
|
||||
|
||||
// id of the bsclient
|
||||
int client_id;
|
||||
// time taken to finish query
|
||||
int query_msec;
|
||||
// total number of results in this query
|
||||
int total;
|
||||
|
||||
const TQPtrList<Hit> *getHits () const;
|
||||
|
||||
private:
|
||||
// lists of hits
|
||||
TQPtrList<Hit> *hitlist;
|
||||
};
|
||||
|
||||
// caller should delete bsclient->result and bsclient
|
||||
class BeagleSearchClient : public TQThread {
|
||||
public:
|
||||
// passing NULL for client makes bsclient create client itself and
|
||||
// delete it later
|
||||
BeagleSearchClient (int id,
|
||||
TQObject *y,
|
||||
BeagleClient *client,
|
||||
BeagleQuery *query,
|
||||
bool collate_results)
|
||||
: id (id), kill_me (false), object (y), client (client),
|
||||
query (query), destroy_client (false), collate_results (collate_results)
|
||||
{
|
||||
if (client == NULL) {
|
||||
client = beagle_client_new (NULL);
|
||||
destroy_client = true;
|
||||
}
|
||||
|
||||
// if (client == NULL)
|
||||
// throw -1;
|
||||
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
if (collate_results)
|
||||
result = new BeagleSearchResult (id);
|
||||
|
||||
client_mutex = new TQMutex ();
|
||||
}
|
||||
|
||||
// It is never safe to delete BeagleSearchClient directly, the thread might still be running
|
||||
~BeagleSearchClient ()
|
||||
{
|
||||
if (! finished ()) {
|
||||
kdDebug () << "Thread " << id << " still running. Waiting.........." << endl;
|
||||
wait ();
|
||||
}
|
||||
|
||||
if (destroy_client)
|
||||
g_object_unref (client);
|
||||
g_main_loop_unref (main_loop);
|
||||
g_object_unref (query);
|
||||
kdDebug() << "Deleting client ..." << id << endl;
|
||||
delete client_mutex;
|
||||
}
|
||||
|
||||
private:
|
||||
static void hitsAddedSlot (BeagleQuery *query,
|
||||
BeagleHitsAddedResponse *response,
|
||||
BeagleSearchClient *bsclient);
|
||||
|
||||
static void finishedSlot (BeagleQuery *query,
|
||||
BeagleFinishedResponse *response,
|
||||
BeagleSearchClient *bsclient);
|
||||
|
||||
public:
|
||||
// run() starts the query and sends the result as follows:
|
||||
// - either wait till get back all results and send it as RESULTFOUND
|
||||
// - or, send results as it gets them as RESULTFOUND and
|
||||
// send SEARCHOVER when finished
|
||||
// collate_results controls the behaviour
|
||||
virtual void run ( );
|
||||
|
||||
// after stopClient() is called, application can safely go and remove previous menu entries
|
||||
// - i.e. after stopClient is called, app doesnt except the eventhandler to receive any results
|
||||
// - use client_id to determine which is the current client, set it right after stopclient
|
||||
// - Eventhandler checks client id, if it is current, it adds stuff to the menu
|
||||
// else, it discards everything
|
||||
// Once eventhandler is being processed, doQuery() wont be called and vice versa
|
||||
// so no need to serialize eventhandler and doquery
|
||||
//
|
||||
// stopClient needs to make sure that once it is called, the thread is finished asap. Use a mutex
|
||||
// to serialize actions. callbacks need to use mutex too.
|
||||
// stopclient has to remove signal handlers to prevent further signal calls, set kill_me flag
|
||||
// and quite main loop
|
||||
// stopClient can be called at the following times:
|
||||
// - Waiting for the first result:
|
||||
// nothing extra
|
||||
// - in hitsAddedSlot, processing results
|
||||
// in callback, before processing, if killme is set, just return.
|
||||
// - in hitsAddedSlot, after sending results
|
||||
// before sending, if killme is set, dont send results
|
||||
// (doing it twice in hitsAdded because forming BeagleSearchResult can take time)
|
||||
// - Waiting for more results
|
||||
// nothing extra
|
||||
// - in finishedSlot, before sending finishedMsg
|
||||
// if killme is set, just return
|
||||
// - in finishedSlot, after sending finishedMsg
|
||||
// if killme is set, just return
|
||||
// in Run(), when return from mainloop, if killme is set, dont do anything more but call delete this
|
||||
void stopClient ();
|
||||
|
||||
// id of the client
|
||||
// this is required in case applications fires many clients in rapid succession
|
||||
int id;
|
||||
|
||||
GMainLoop * main_loop;
|
||||
BeagleSearchResult *result;
|
||||
|
||||
// this is set if the client is obsolete now i.e.
|
||||
// the application doesnt need the results from the client anymore
|
||||
bool kill_me;
|
||||
private:
|
||||
// the application; need this to send events to the application
|
||||
TQObject *object;
|
||||
// mutex to control setting the kill_me shared variable
|
||||
TQMutex *client_mutex;
|
||||
BeagleClient *client;
|
||||
BeagleQuery *query;
|
||||
// should the client be destroyed by the client
|
||||
// if the client created it, then most probably it should
|
||||
bool destroy_client;
|
||||
bool collate_results;
|
||||
};
|
||||
|
||||
class BeagleUtil {
|
||||
public:
|
||||
|
||||
static BeagleQuery *createQueryFromString (TQString query_str,
|
||||
TQStringList &sources,
|
||||
TQStringList &types,
|
||||
int max_hits_per_source = 100);
|
||||
static BeagleTimestamp *timestringToBeagleTimestamp (TQString timestring);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,499 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kickoff-beagle-plugin.h"
|
||||
|
||||
#include <tqregexp.h>
|
||||
#include <tqtimer.h>
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kdesktopfile.h>
|
||||
#include <kgenericfactory.h>
|
||||
#include <kservice.h>
|
||||
|
||||
TQString dc_identifier = "dc:identifier";
|
||||
TQString dc_title = "dc:title";
|
||||
TQString parent_dc_title = "parent:dc:title";
|
||||
TQString exactfilename = "beagle:ExactFilename";
|
||||
TQString fixme_name = "fixme:Name";
|
||||
TQString beagle_filename = "beagle:Filename";
|
||||
TQString fixme_attachment_title = "fixme:attachment_title";
|
||||
TQString fixme_hasattachments = "fixme:hasAttachments";
|
||||
TQString parent_prefix = "parent:";
|
||||
TQString fixme_folder = "fixme:folder";
|
||||
TQString fixme_categories = "fixme:Categories";
|
||||
TQString fixme_comment = "fixme:Comment";
|
||||
TQString fixme_width = "fixme:width";
|
||||
TQString fixme_height = "fixme:height";
|
||||
TQString fixme_from_address = "fixme:from_address";
|
||||
TQString fixme_artist = "fixme:artist";
|
||||
TQString fixme_album = "fixme:album";
|
||||
TQString dc_source = "dc:source";
|
||||
TQString dc_publisher = "dc:publisher";
|
||||
TQString digikam_tag = "digikam:Tag";
|
||||
TQString fixme_speakingto = "fixme:speakingto";
|
||||
TQString fixme_starttime = "fixme:starttime";
|
||||
TQString comma_string = ",";
|
||||
TQString vCard_FN = "vCard:FN";
|
||||
TQString vCard_PREFEMAIL = "vCard:PREFEMAIL";
|
||||
TQString fixme_uid = "fixme:uid";
|
||||
|
||||
static CATEGORY getHitCategory (Hit *hit)
|
||||
{
|
||||
TQString hittype = hit->getType();
|
||||
TQString hitsource = hit->getSource();
|
||||
|
||||
// if hit source is None, dont handle it. Might be anthrax-envelope :)
|
||||
if (hitsource.isNull())
|
||||
return OTHER;
|
||||
|
||||
if (hitsource == "documentation")
|
||||
return DOCS;
|
||||
|
||||
if (hittype == "IMLog")
|
||||
return CHATS;
|
||||
|
||||
// sure shots
|
||||
if (hittype == "FeedItem")
|
||||
return FEEDS;
|
||||
if (hittype == "WebHistory")
|
||||
return WEBHIST;
|
||||
if (hittype == "MailMessage")
|
||||
return MAILS;
|
||||
if (hittype == "Note")
|
||||
return NOTES;
|
||||
|
||||
// check for applications
|
||||
if (hittype == "File" && (*hit) ["beagle:FilenameExtension"] == ".desktop")
|
||||
return APPS;
|
||||
|
||||
// check for music
|
||||
TQString hitmimetype = hit->getMimeType();
|
||||
if (hitsource == "Amarok"
|
||||
|| hitmimetype.startsWith ("audio")
|
||||
|| hitmimetype == "application/ogg")
|
||||
return MUSIC; // not an exhaustive search
|
||||
|
||||
// check for images from files
|
||||
if (hitsource == "Files" && hitmimetype.startsWith ("image"))
|
||||
return PICS;
|
||||
|
||||
if (hitsource == "Files" && hitmimetype.startsWith ("video"))
|
||||
return VIDEOS;
|
||||
|
||||
if (hitsource == "Files")
|
||||
return FILES;
|
||||
|
||||
if (hitsource == "KAddressBook")
|
||||
return ACTIONS;
|
||||
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
K_EXPORT_COMPONENT_FACTORY( kickoffsearch_beagle,
|
||||
KGenericFactory<KickoffBeaglePlugin>( "kickoffsearch_beagle" ) )
|
||||
|
||||
KickoffBeaglePlugin::KickoffBeaglePlugin(TQObject *parent, const char* name, const TQStringList&)
|
||||
: KickoffSearch::Plugin(parent, name ), genericTitle( true )
|
||||
{
|
||||
g_type_init ();
|
||||
current_beagle_client = NULL;
|
||||
}
|
||||
|
||||
bool KickoffBeaglePlugin::daemonRunning()
|
||||
{
|
||||
return beagle_util_daemon_is_running();
|
||||
}
|
||||
|
||||
void KickoffBeaglePlugin::query(TQString term, bool _genericTitle)
|
||||
{
|
||||
genericTitle = _genericTitle;
|
||||
current_query_str = term;
|
||||
|
||||
// Beagle search
|
||||
if (current_beagle_client != NULL) {
|
||||
kdDebug () << "Previous client w/id " << current_beagle_client->id << " still running ... ignoring it." << endl;
|
||||
current_beagle_client->stopClient ();
|
||||
}
|
||||
current_beagle_client_id = KApplication::random ();
|
||||
kdDebug () << "Creating client with id:" << current_beagle_client_id << endl;
|
||||
|
||||
BeagleClient *beagle_client = beagle_client_new (NULL);
|
||||
if (beagle_client == NULL) {
|
||||
kdDebug() << "beagle service not running ..." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
TQStringList sources, types;
|
||||
BeagleQuery *beagle_query = BeagleUtil::createQueryFromString (term, sources, types, 99); // maximum 99 results, if this doesnt work, blame the stars
|
||||
|
||||
current_beagle_client = new BeagleSearchClient (
|
||||
current_beagle_client_id,
|
||||
this,
|
||||
beagle_client,
|
||||
beagle_query,
|
||||
false);
|
||||
current_beagle_client->start();
|
||||
// kdDebug () << "Query dispatched at " << time (NULL) << endl;
|
||||
}
|
||||
|
||||
void KickoffBeaglePlugin::cleanClientList ()
|
||||
{
|
||||
toclean_list_mutex.lock ();
|
||||
BeagleSearchClient *old_client = toclean_client_list.take (0);
|
||||
if (old_client != NULL) { // failsafe
|
||||
kdDebug () << "Cleanup old client " << old_client->id << endl;
|
||||
delete old_client;
|
||||
}
|
||||
toclean_list_mutex.unlock ();
|
||||
}
|
||||
|
||||
void KickoffBeaglePlugin::customEvent (TQCustomEvent *e)
|
||||
{
|
||||
if (e->type () == RESULTFOUND) {
|
||||
// kdDebug () << "Quick query thread at " << time (NULL) << " with current_id=" << current_beagle_client_id << " finished ..." << endl;
|
||||
BeagleSearchResult *result = (BeagleSearchResult *) e->data ();
|
||||
if (current_beagle_client_id != result->client_id) {
|
||||
kdDebug () << "Stale result from " << result->client_id << endl;
|
||||
delete result;
|
||||
// FIXME: Should I also free e ?
|
||||
} else {
|
||||
kdDebug () << "Good results ...total=" << result->total << endl;
|
||||
showResults (result);
|
||||
}
|
||||
//KPassivePopup::message( "This is the message", this );
|
||||
} else if (e->type () == SEARCHOVER) {
|
||||
BeagleSearchClient *client = (BeagleSearchClient *) e->data ();
|
||||
if (client == NULL) {
|
||||
// kdDebug () << "Query finished event at " << time (NULL) << " but client is already deleted" << endl;
|
||||
return;
|
||||
}
|
||||
// kdDebug () << "Query finished event at " << time (NULL) << " for id=" << client->id << endl;
|
||||
if (current_beagle_client_id == client->id) {
|
||||
kickoffSearchInterface()->searchOver();
|
||||
current_beagle_client = NULL; // important !
|
||||
}
|
||||
} else if (e->type () == KILLME) {
|
||||
BeagleSearchClient *client = (BeagleSearchClient *) e->data ();
|
||||
if (client->finished ())
|
||||
delete client;
|
||||
else {
|
||||
// add client to cleanup list
|
||||
toclean_list_mutex.lock ();
|
||||
toclean_client_list.append (client);
|
||||
kdDebug () << "Scheduling client to be deleted in 500ms" << endl;
|
||||
toclean_list_mutex.unlock ();
|
||||
TQTimer::singleShot (500, this, TQT_SLOT (cleanClientList ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this method decides what to display in the result list
|
||||
HitMenuItem *KickoffBeaglePlugin::hitToHitMenuItem (int category, Hit *hit)
|
||||
{
|
||||
TQString title, info, mimetype, icon;
|
||||
int score = 0;
|
||||
KURL uri;
|
||||
|
||||
#if 0
|
||||
kdDebug() << "*** " << hit->getUri() << endl;
|
||||
TQDict<TQStringList> all = hit->getAllProperties();
|
||||
TQDictIterator<TQStringList> it( all );
|
||||
for( ; it.current(); ++it )
|
||||
kdDebug() << it.currentKey() << ": " << *(it.current()) << endl;
|
||||
#endif
|
||||
|
||||
switch (category) {
|
||||
case FILES:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
TQString uristr = uri.path ();
|
||||
title = (*hit) [exactfilename];
|
||||
int last_slash = uristr.findRev ('/', -1);
|
||||
info = i18n("Folder: %1").arg(last_slash == 0 ? "/"
|
||||
: uristr.section ('/', -2, -2));
|
||||
}
|
||||
break;
|
||||
case ACTIONS:
|
||||
{
|
||||
if (hit->getSource()=="KAddressBook"){
|
||||
title = i18n("Send Email to %1").arg((*hit)[vCard_FN]);
|
||||
info = (*hit)[vCard_PREFEMAIL];
|
||||
uri = "mailto:"+(*hit)[vCard_PREFEMAIL];
|
||||
mimetype = hit->getMimeType ();
|
||||
icon = "mail_new";
|
||||
|
||||
HitMenuItem * first_item=new HitMenuItem (title, info, uri, mimetype, 0, category, icon, score);
|
||||
kickoffSearchInterface()->addHitMenuItem(first_item);
|
||||
|
||||
title =i18n("Open Addressbook at %1").arg((*hit)[vCard_FN]);
|
||||
uri = "kaddressbook:/"+(*hit)[fixme_uid];
|
||||
icon = "kaddressbook";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MAILS:
|
||||
{
|
||||
TQString prefix = TQString::null;
|
||||
bool is_attachment = ((*hit) [parent_prefix + fixme_hasattachments] == "true");
|
||||
bool has_parent = (! hit->getParentUri ().isEmpty ());
|
||||
bool parent_mbox_file = false;
|
||||
if (has_parent)
|
||||
parent_mbox_file = ((*hit) [parent_prefix + fixme_folder] == TQString::null);
|
||||
|
||||
// Logic:
|
||||
// If has_parent == false, everything is normal
|
||||
// If has_parent == true, parent_mbox_file == false, everything is normal, use uri
|
||||
// FIXME: If has_parent == true, parent_mbox_file == true, ???
|
||||
// If has_parent == true, is_attachment == true, hit is attach and access with prefix "parent:", use parenturi
|
||||
// Else, not attachment (multipart), access with prefix "parent:", use parenturi
|
||||
|
||||
if (has_parent && !parent_mbox_file) {
|
||||
uri = hit->getParentUri ();
|
||||
prefix = parent_prefix;
|
||||
if (is_attachment)
|
||||
title = (*hit) [fixme_attachment_title];
|
||||
if (title.isEmpty ())
|
||||
title = (*hit) [prefix + dc_title];
|
||||
if (title.isEmpty ())
|
||||
title = i18n("No subject");
|
||||
if (is_attachment)
|
||||
title = title.prepend (i18n("(Attachment) "));
|
||||
info = (i18n("From %1").arg((*hit) [prefix + fixme_from_address]));
|
||||
} else {
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [dc_title];
|
||||
info = (i18n("From %1").arg((*hit) [fixme_from_address]));
|
||||
}
|
||||
}
|
||||
mimetype = "message/rfc822"; // to handle attachment results
|
||||
break;
|
||||
case MUSIC:
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [exactfilename];
|
||||
{
|
||||
TQString artist = (*hit) [fixme_artist];
|
||||
TQString album = (*hit) [fixme_album];
|
||||
if (! artist.isEmpty ())
|
||||
info = (i18n("By %1").arg(artist));
|
||||
else if (! album.isEmpty ())
|
||||
info = (i18n("From Album %1").arg(album));
|
||||
else {
|
||||
TQString uristr = uri.path ();
|
||||
int last_slash = uristr.findRev ('/', -1);
|
||||
info = i18n("Folder: %1")
|
||||
.arg(last_slash == 0 ? "/" : uristr.section ('/', -2, -2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VIDEOS:
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [exactfilename];
|
||||
{
|
||||
TQString uristr = uri.path ();
|
||||
int last_slash = uristr.findRev ('/', -1);
|
||||
info = i18n("Folder: %1").arg(last_slash == 0 ? "/" : uristr.section ('/', -2, -2));
|
||||
}
|
||||
break;
|
||||
case WEBHIST:
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [dc_title];
|
||||
title = title.replace(TQRegExp("\n")," ");
|
||||
mimetype = "text/html";
|
||||
if (title.isEmpty () || title.stripWhiteSpace ().isEmpty ()) {
|
||||
title = uri.prettyURL ();
|
||||
} else {
|
||||
info = uri.host () + uri.path ();
|
||||
}
|
||||
break;
|
||||
case FEEDS:
|
||||
{
|
||||
uri = KURL ((*hit) [dc_identifier]);
|
||||
title = (*hit) [dc_title];
|
||||
mimetype = "text/html";
|
||||
TQString publisher = (*hit) [dc_publisher];
|
||||
TQString source = (*hit) [dc_source];
|
||||
if (! publisher.isEmpty ())
|
||||
info = publisher;
|
||||
else if (! source.isEmpty ())
|
||||
info = source;
|
||||
}
|
||||
break;
|
||||
case PICS:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [exactfilename];
|
||||
TQString width = (*hit) [fixme_width];
|
||||
TQString height = (*hit) [fixme_height];
|
||||
if (width.isEmpty () || height.isEmpty ()) {
|
||||
TQString uristr = uri.path ();
|
||||
int last_slash = uristr.findRev ('/', -1);
|
||||
info = i18n("Folder: %1")
|
||||
.arg(last_slash == 0 ? "/" : uristr.section ('/', -2, -2));
|
||||
break;
|
||||
}
|
||||
info = (TQString (" (%1x%2)").arg (width).arg (height));
|
||||
const TQStringList *tags = hit->getProperties (digikam_tag);
|
||||
if (tags == NULL)
|
||||
break;
|
||||
TQString tags_string = tags->join (comma_string);
|
||||
info += (" " + tags_string);
|
||||
}
|
||||
break;
|
||||
case APPS:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [dc_title];
|
||||
KDesktopFile desktopfile(uri.path(),true);
|
||||
if (genericTitle && !desktopfile.readGenericName().isEmpty()) {
|
||||
title = desktopfile.readGenericName();
|
||||
info = desktopfile.readName();
|
||||
}
|
||||
else {
|
||||
title = desktopfile.readName();
|
||||
info = desktopfile.readGenericName();
|
||||
}
|
||||
icon = desktopfile.readIcon();
|
||||
TQString input = current_query_str.lower();
|
||||
TQString command = desktopfile.readEntry("Exec");
|
||||
if (command==input)
|
||||
score = 100;
|
||||
else if (command.find(input)==0)
|
||||
score = 50;
|
||||
else if (command.find(input)!=-1)
|
||||
score = 10;
|
||||
else if (title==input)
|
||||
score = 100;
|
||||
else if (title.find(input)==0)
|
||||
score = 50;
|
||||
else if (title.find(input)!=-1)
|
||||
score = 10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NOTES:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [dc_title];
|
||||
title = i18n("Title: %1").arg(title.isEmpty() ? i18n("Untitled") : title);
|
||||
|
||||
if (hit->getSource()=="KNotes")
|
||||
icon="knotes";
|
||||
else
|
||||
icon="contents2";
|
||||
}
|
||||
break;
|
||||
case CHATS:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [fixme_speakingto];
|
||||
title = i18n("Conversation With %1").arg(title.isEmpty() ? i18n("Unknown Person") : title);
|
||||
TQDateTime datetime;
|
||||
datetime = datetimeFromString((*hit) [fixme_starttime]);
|
||||
info=i18n("Date: %1").arg(KGlobal::locale()->formatDateTime(datetime,false));
|
||||
if (hit->getMimeType()=="beagle/x-kopete-log")
|
||||
icon="kopete";
|
||||
else
|
||||
icon="gaim";
|
||||
}
|
||||
break;
|
||||
case DOCS:
|
||||
{
|
||||
uri = hit->getUri ();
|
||||
title = (*hit) [dc_title];
|
||||
if (title.isEmpty () || title.stripWhiteSpace ().isEmpty ())
|
||||
title = uri.prettyURL ();
|
||||
else {
|
||||
TQString uristr = uri.path ();
|
||||
int last_slash = uristr.findRev ('/', -1);
|
||||
info = i18n("Folder: %1").arg(last_slash == 0 ? "/" : uristr.section ('/',
|
||||
-2, -2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
if (mimetype.isEmpty ())
|
||||
mimetype = hit->getMimeType ();
|
||||
return new HitMenuItem (title, info, uri, mimetype, 0, category, icon, score);
|
||||
}
|
||||
|
||||
void KickoffBeaglePlugin::showResults(BeagleSearchResult *result)
|
||||
{
|
||||
if (result->total == 0 ) {
|
||||
// Dont report error from here ...
|
||||
kdDebug() << "No matches found" << endl;
|
||||
delete result;
|
||||
return;
|
||||
}
|
||||
|
||||
const TQPtrList<Hit> *hits = result->getHits();
|
||||
if (hits == NULL) {
|
||||
kdDebug () << "Hmm... null" << endl;
|
||||
delete result;
|
||||
return;
|
||||
}
|
||||
kickoffSearchInterface()->initCategoryTitlesUpdate();
|
||||
|
||||
TQPtrListIterator<Hit> it (*hits);
|
||||
Hit *hit;
|
||||
for (; (hit = it.current ()) != NULL; ++it) {
|
||||
CATEGORY category = getHitCategory (hit);
|
||||
|
||||
// if category is not handled, continue
|
||||
if (category == OTHER)
|
||||
continue;
|
||||
|
||||
if ( category == APPS ) {
|
||||
// we need to check if this is useful
|
||||
KService cs( hit->getUri().path() );
|
||||
if ( cs.noDisplay() )
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!kickoffSearchInterface()->anotherHitMenuItemAllowed(category))
|
||||
continue;
|
||||
|
||||
HitMenuItem *hit_item = hitToHitMenuItem (category, hit);
|
||||
|
||||
if (!hit_item)
|
||||
continue;
|
||||
|
||||
kickoffSearchInterface()->addHitMenuItem(hit_item);
|
||||
}
|
||||
|
||||
kickoffSearchInterface()->updateCategoryTitles();
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
TQDateTime KickoffBeaglePlugin::datetimeFromString( const TQString& s)
|
||||
{
|
||||
int year( s.mid( 0, 4 ).toInt() );
|
||||
int month( s.mid( 4, 2 ).toInt() );
|
||||
int day( s.mid( 6, 2 ).toInt() );
|
||||
int hour( s.mid( 8, 2 ).toInt() );
|
||||
int min( s.mid( 10, 2 ).toInt() );
|
||||
int sec( s.mid( 12, 2 ).toInt() );
|
||||
return TQDateTime(TQDate(year,month,day),TQTime(hour,min,sec));
|
||||
}
|
||||
|
||||
#include "kickoff-beagle-plugin.moc"
|
@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CAPITALIZEPLUGIN_H
|
||||
#define CAPITALIZEPLUGIN_H
|
||||
|
||||
#include "../interfaces/kickoff-search-plugin.h"
|
||||
#include "beaglesearch.h"
|
||||
|
||||
class KickoffBeaglePlugin :public KickoffSearch::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KickoffBeaglePlugin(TQObject *parent, const char* name, const TQStringList&);
|
||||
|
||||
void query(TQString, bool);
|
||||
bool daemonRunning();
|
||||
|
||||
protected slots:
|
||||
// to clean beaglesearchclients
|
||||
void cleanClientList ();
|
||||
|
||||
private:
|
||||
TQString current_query_str;
|
||||
|
||||
// all beagle activity is done through the BSC object
|
||||
BeagleSearchClient *current_beagle_client;
|
||||
|
||||
// used to send notification from the beagle thread to the main event loop
|
||||
virtual void customEvent (TQCustomEvent *e);
|
||||
|
||||
TQPtrList<BeagleSearchClient> toclean_client_list;
|
||||
TQMutex toclean_list_mutex;
|
||||
|
||||
// show the results
|
||||
void showResults (BeagleSearchResult *);
|
||||
HitMenuItem *hitToHitMenuItem (int category, Hit *hit);
|
||||
|
||||
// use a different id for each bsc client, and use that to separate stale responses from current ones
|
||||
int current_beagle_client_id;
|
||||
|
||||
bool genericTitle;
|
||||
TQDateTime datetimeFromString( const TQString& );
|
||||
};
|
||||
|
||||
#endif /* CAPITALIZEPLUGIN_H */
|
@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Name=Beagle Search
|
||||
Comment=Beagle search plugin for Kickoff search
|
||||
ServiceTypes=KickoffSearch/Plugin
|
||||
Type=Service
|
||||
X-KDE-Library=kickoffsearch_beagle
|
@ -0,0 +1,9 @@
|
||||
MozillaFirefox.desktop
|
||||
kde-Kontact.desktop
|
||||
writer.desktop
|
||||
kde-amarok.desktop
|
||||
kde-digikam.desktop
|
||||
kde-Home.desktop
|
||||
kde-KControl.desktop
|
||||
kde-Help.desktop
|
||||
kde-konsole.desktop
|
@ -0,0 +1,324 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Will Stephenson <wstephenson@novell.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include <tqapplication.h>
|
||||
#include <tqhbox.h>
|
||||
#include <tqheader.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "itemview.h"
|
||||
#include "flipscrollview.h"
|
||||
#include "kickerSettings.h"
|
||||
|
||||
/* Flip scroll steps, as percentage of itemview width to scroll per
|
||||
* step. Assumes the itemview is scrolled in ten steps */
|
||||
|
||||
/* slow start, then fast */
|
||||
//static const double scrollSteps[] = { 0.05, 0.05, 0.1125, 0.1125, 0.1125, 0.1125, 0.1125, 0.1125, 0.1125, 0.1125 };
|
||||
|
||||
/* slow fast slow */
|
||||
//static const double scrollSteps[] = { 0.05, 0.05, 0.13, 0.13, 0.15, 0.13, 0.13, 0.13, 0.05, 0.05 };
|
||||
|
||||
/* slow veryfast slow */
|
||||
static const double scrollSteps[] = { 0.03, 0.03, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.03, 0.028 };
|
||||
;
|
||||
|
||||
BackFrame::BackFrame( TQWidget *parent )
|
||||
: TQFrame( parent ), mouse_inside( false )
|
||||
{
|
||||
setFrameStyle( TQFrame::NoFrame );
|
||||
if ( TQApplication::reverseLayout() )
|
||||
left_triangle.load( locate( "data", "kicker/pics/right_triangle.png" ) );
|
||||
else
|
||||
left_triangle.load( locate( "data", "kicker/pics/left_triangle.png" ) );
|
||||
}
|
||||
|
||||
void BackFrame::drawContents( TQPainter *p )
|
||||
{
|
||||
TQColor gray( 230, 230, 230 );
|
||||
if ( mouse_inside )
|
||||
p->fillRect( 3, 3, width() - 6, height() - 6, colorGroup().color( TQColorGroup::Highlight ) );
|
||||
else
|
||||
p->fillRect( 3, 3, width() - 6, height() - 6, gray );
|
||||
p->setPen( gray.dark(110) );
|
||||
p->drawRect( 3, 3, width() - 6, height() - 6 );
|
||||
|
||||
int pixsize = ( width() - 6 ) * 3 / 5;
|
||||
TQImage i = left_triangle.convertToImage().smoothScale( pixsize, pixsize );
|
||||
TQPixmap tri;
|
||||
tri.convertFromImage( i );
|
||||
|
||||
p->drawPixmap( ( width() - tri.width() ) / 2, ( height() - tri.height() ) / 2, tri );
|
||||
}
|
||||
|
||||
void BackFrame::enterEvent( TQEvent *e )
|
||||
{
|
||||
mouse_inside = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void BackFrame::leaveEvent( TQEvent *e )
|
||||
{
|
||||
mouse_inside = false;
|
||||
update();
|
||||
}
|
||||
|
||||
void BackFrame::mousePressEvent ( TQMouseEvent * e )
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
FlipScrollView::FlipScrollView( TQWidget * parent, const char * name )
|
||||
: TQScrollView( parent, name ), mState( StoppedLeft ), mScrollDirection( 1 ), mShowBack( false )
|
||||
{
|
||||
setVScrollBarMode( TQScrollView::AlwaysOff );
|
||||
setHScrollBarMode( TQScrollView::AlwaysOff );
|
||||
setFrameStyle( TQFrame::NoFrame );
|
||||
mLeftView = new ItemView( this, "left_view" );
|
||||
addChild( mLeftView );
|
||||
|
||||
mRightView = new ItemView( this, "right_view" );
|
||||
addChild( mRightView );
|
||||
|
||||
mTimer = new TQTimer( this, "mTimer" );
|
||||
connect( mTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotScrollTimer() ) );
|
||||
|
||||
connect( mLeftView, TQT_SIGNAL( startService(KService::Ptr) ),
|
||||
TQT_SIGNAL( startService(KService::Ptr) ) );
|
||||
connect( mLeftView, TQT_SIGNAL( startURL(const TQString& ) ),
|
||||
TQT_SIGNAL( startURL(const TQString& ) ) );
|
||||
connect( mLeftView, TQT_SIGNAL( rightButtonPressed(TQListViewItem*,const TQPoint&,int) ),
|
||||
TQT_SIGNAL( rightButtonPressed(TQListViewItem*,const TQPoint&,int) ) );
|
||||
connect( mRightView, TQT_SIGNAL( startService(KService::Ptr) ),
|
||||
TQT_SIGNAL( startService(KService::Ptr) ) );
|
||||
connect( mRightView, TQT_SIGNAL( startURL(const TQString& ) ),
|
||||
TQT_SIGNAL( startURL(const TQString& ) ) );
|
||||
connect( mRightView, TQT_SIGNAL( rightButtonPressed(TQListViewItem*,const TQPoint&,int) ),
|
||||
TQT_SIGNAL( rightButtonPressed(TQListViewItem*,const TQPoint&,int) ) );
|
||||
|
||||
// wild hack to make sure it has correct width
|
||||
mLeftView->setVScrollBarMode( TQScrollView::AlwaysOn );
|
||||
mRightView->setVScrollBarMode( TQScrollView::AlwaysOn );
|
||||
mLeftView->setVScrollBarMode( TQScrollView::Auto );
|
||||
mRightView->setVScrollBarMode( TQScrollView::Auto );
|
||||
|
||||
mBackrow = new BackFrame( this );
|
||||
mBackrow->resize( 24, 100 );
|
||||
connect( mBackrow, TQT_SIGNAL( clicked() ), TQT_SIGNAL( backButtonClicked() ) );
|
||||
}
|
||||
|
||||
ItemView* FlipScrollView::prepareRightMove()
|
||||
{
|
||||
if ( mState != StoppedLeft )
|
||||
{
|
||||
mTimer->stop();
|
||||
ItemView *swap = mLeftView;
|
||||
mLeftView = mRightView;
|
||||
mRightView = swap;
|
||||
moveChild( mLeftView, 0, 0 );
|
||||
moveChild( mRightView, width(), 0 );
|
||||
mBackrow->hide();
|
||||
mRightView->resize( width(), height() );
|
||||
mLeftView->resize( width(), height() );
|
||||
setContentsPos( 0, 0 );
|
||||
}
|
||||
|
||||
mState = StoppedLeft;
|
||||
mRightView->clear();
|
||||
return mRightView;
|
||||
}
|
||||
|
||||
void FlipScrollView::showBackButton( bool enable )
|
||||
{
|
||||
kdDebug() << "FlipScrollView::showBackButton " << enable << endl;
|
||||
mShowBack = enable;
|
||||
}
|
||||
|
||||
ItemView* FlipScrollView::prepareLeftMove(bool clear)
|
||||
{
|
||||
if ( mState != StoppedRight )
|
||||
{
|
||||
mTimer->stop();
|
||||
ItemView *swap = mLeftView;
|
||||
mLeftView = mRightView;
|
||||
mRightView = swap;
|
||||
moveChild( mLeftView, 0, 0 );
|
||||
moveChild( mRightView, width(), 0 );
|
||||
mRightView->resize( width(), height() );
|
||||
mLeftView->resize( width(), height() );
|
||||
mBackrow->hide();
|
||||
setContentsPos( width(), 0 );
|
||||
}
|
||||
|
||||
mState = StoppedRight;
|
||||
if (clear)
|
||||
mLeftView->clear();
|
||||
return mLeftView;
|
||||
}
|
||||
|
||||
void FlipScrollView::viewportResizeEvent ( TQResizeEvent * )
|
||||
{
|
||||
mLeftView->resize( size() );
|
||||
mRightView->resize( width() - mBackrow->width(), height() );
|
||||
mBackrow->resize( mBackrow->width(), height() );
|
||||
resizeContents( width() * 2, height() );
|
||||
moveChild( mBackrow, width(), 0 );
|
||||
moveChild( mRightView, width() + mBackrow->width(), 0 );
|
||||
setContentsPos( 0, 0 );
|
||||
}
|
||||
|
||||
ItemView *FlipScrollView::currentView() const
|
||||
{
|
||||
if ( mState == StoppedRight )
|
||||
return mRightView;
|
||||
else
|
||||
return mLeftView;
|
||||
}
|
||||
|
||||
ItemView *FlipScrollView::leftView() const
|
||||
{
|
||||
return mLeftView;
|
||||
}
|
||||
|
||||
ItemView *FlipScrollView::rightView() const
|
||||
{
|
||||
return mRightView;
|
||||
}
|
||||
|
||||
FlipScrollView::~FlipScrollView() {}
|
||||
|
||||
static const int max_steps = 10;
|
||||
|
||||
void FlipScrollView::slotScrollTimer()
|
||||
{
|
||||
mStepsRemaining--;
|
||||
assert( mStepsRemaining >= 0 && mStepsRemaining < int(sizeof( scrollSteps ) / sizeof( double )) );
|
||||
if (KickerSettings::scrollFlipView())
|
||||
scrollBy( ( int )( mScrollDirection * mLeftView->width() * scrollSteps[ mStepsRemaining ] ), 0 );
|
||||
else
|
||||
scrollBy( ( int )( mScrollDirection * mLeftView->width()), 0 );
|
||||
|
||||
if ( mStepsRemaining == 0 )
|
||||
{
|
||||
if ( mState == ScrollingRight )
|
||||
{
|
||||
mState = StoppedRight;
|
||||
setContentsPos( width(), 0 );
|
||||
} else {
|
||||
mState = StoppedLeft;
|
||||
setContentsPos( 0, 0 );
|
||||
}
|
||||
|
||||
kdDebug() << "slotScrollTimer " << mShowBack << endl;
|
||||
|
||||
if ( mShowBack )
|
||||
{
|
||||
mBackrow->show();
|
||||
if ( mState == StoppedRight )
|
||||
{
|
||||
|
||||
if ( TQApplication::reverseLayout() )
|
||||
moveChild( mRightView, width(), 0 );
|
||||
else
|
||||
moveChild( mRightView, width() + mBackrow->width(), 0 );
|
||||
mRightView->resize( width() - mBackrow->width(), height() );
|
||||
mLeftView->resize( width(), height() );
|
||||
if ( TQApplication::reverseLayout() )
|
||||
moveChild( mBackrow, width() + mRightView->width(), 0 );
|
||||
else
|
||||
moveChild( mBackrow, width(), 0 );
|
||||
moveChild( mLeftView, 0, 0 );
|
||||
} else
|
||||
{
|
||||
moveChild( mRightView, width(), 0 );
|
||||
mRightView->resize( width(), height() );
|
||||
mLeftView->resize( width() - mBackrow->width(), height() );
|
||||
if ( TQApplication::reverseLayout() )
|
||||
{
|
||||
moveChild( mBackrow, mLeftView->width(), 0 );
|
||||
moveChild( mLeftView, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
moveChild( mBackrow, 0, 0 );
|
||||
moveChild( mLeftView, mBackrow->width(), 0 );
|
||||
}
|
||||
}
|
||||
} else
|
||||
mBackrow->hide();
|
||||
|
||||
if (!mSelectMenuPath.isEmpty()) {
|
||||
if (mSelectMenuPath=="kicker:/goup/") {
|
||||
currentView()->setSelected(currentView()->firstChild(),true);
|
||||
currentView()->firstChild()->repaint();
|
||||
}
|
||||
else {
|
||||
TQListViewItem * child = currentView()->firstChild();
|
||||
while( child ) {
|
||||
KMenuItem* kitem = dynamic_cast<KMenuItem*>(child);
|
||||
if (kitem && kitem->menuPath()==mSelectMenuPath) {
|
||||
currentView()->setSelected(child,true);
|
||||
kdDebug() << "child repaint\n";
|
||||
child->repaint();
|
||||
break;
|
||||
}
|
||||
child = child->nextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
mLeftView->setVScrollBarMode( TQScrollView::Auto );
|
||||
mRightView->setVScrollBarMode( TQScrollView::Auto );
|
||||
mTimer->stop();
|
||||
mLeftView->setMouseMoveSelects( true );
|
||||
mRightView->setMouseMoveSelects( true );
|
||||
}
|
||||
}
|
||||
|
||||
void FlipScrollView::flipScroll(const TQString& selectMenuPath)
|
||||
{
|
||||
if ( mState == StoppedLeft )
|
||||
{
|
||||
mState = ScrollingRight;
|
||||
mScrollDirection = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mState = ScrollingLeft;
|
||||
mScrollDirection = -1;
|
||||
}
|
||||
|
||||
mLeftView->setVScrollBarMode( TQScrollView::AlwaysOff );
|
||||
mRightView->setVScrollBarMode( TQScrollView::AlwaysOff );
|
||||
if (KickerSettings::scrollFlipView())
|
||||
mStepsRemaining = max_steps;
|
||||
else
|
||||
mStepsRemaining = 1;
|
||||
mTimer->start( 30 );
|
||||
mSelectMenuPath = selectMenuPath;
|
||||
if (!mSelectMenuPath.isEmpty()) {
|
||||
mLeftView->setMouseMoveSelects( false );
|
||||
mRightView->setMouseMoveSelects( false );
|
||||
}
|
||||
}
|
||||
|
||||
#include "flipscrollview.moc"
|
@ -0,0 +1,118 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Will Stephenson <wstephenson@novell.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
* Flip scroll menu
|
||||
* Each level of the menu is a separate TQListView
|
||||
* Child items are added to their own TQListView.
|
||||
* When a parent is clicked, we look up its child menu and insert
|
||||
* that in a TQScrollView, then scroll to it.
|
||||
*
|
||||
* Need to intercept TQListViewItems' parent param and instead of
|
||||
* inserting directly into parent, insert into parent item's listview
|
||||
*
|
||||
* So need
|
||||
* - adapted QLVI
|
||||
* - wrap QLV and offer same interface
|
||||
*/
|
||||
|
||||
#ifndef FLIPSCROLLVIEW_H
|
||||
#define FLIPSCROLLVIEW_H
|
||||
|
||||
#include <tqscrollview.h>
|
||||
#include <tqlistview.h>
|
||||
#include <tqframe.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqpainter.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include "service_mnu.h"
|
||||
|
||||
class ItemView;
|
||||
|
||||
class BackFrame : public TQFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BackFrame( TQWidget *parent );
|
||||
virtual void drawContents( TQPainter *p );
|
||||
|
||||
void enterEvent ( TQEvent * );
|
||||
void leaveEvent( TQEvent * );
|
||||
void mousePressEvent ( TQMouseEvent * e );
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
TQPixmap left_triangle;
|
||||
bool mouse_inside;
|
||||
};
|
||||
|
||||
class FlipScrollView : public TQScrollView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum State{ StoppedLeft, StoppedRight, ScrollingLeft, ScrollingRight };
|
||||
FlipScrollView( TQWidget * parent = 0, const char * name = 0 );
|
||||
~FlipScrollView();
|
||||
|
||||
ItemView *currentView() const;
|
||||
ItemView *leftView() const;
|
||||
ItemView *rightView() const;
|
||||
ItemView *prepareLeftMove(bool clear=true);
|
||||
ItemView *prepareRightMove();
|
||||
|
||||
void flipScroll(const TQString& selectMenuPath = TQString::null);
|
||||
void showBackButton(bool enable);
|
||||
bool showsBackButton() const {return mShowBack;}
|
||||
|
||||
protected slots:
|
||||
void slotScrollTimer();
|
||||
|
||||
signals:
|
||||
void startService(KService::Ptr kservice);
|
||||
void startURL(const TQString& u);
|
||||
void rightButtonPressed(TQListViewItem*,const TQPoint&,int);
|
||||
void backButtonClicked();
|
||||
|
||||
protected:
|
||||
void viewportResizeEvent ( TQResizeEvent * );
|
||||
|
||||
private:
|
||||
ItemView * mLeftView;
|
||||
ItemView * mRightView;
|
||||
// ItemView * mCurrentView;
|
||||
int mStepsRemaining;
|
||||
State mState;
|
||||
TQTimer * mTimer;
|
||||
BackFrame *mBackrow;
|
||||
TQString mSelectMenuPath;
|
||||
int mScrollDirection;
|
||||
bool mShowBack;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,260 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __itemview_h__
|
||||
#define __itemview_h__
|
||||
|
||||
#include <dcopobject.h>
|
||||
#include <tqintdict.h>
|
||||
#include <tqpixmap.h>
|
||||
#include <tqframe.h>
|
||||
#include <tqtoolbutton.h>
|
||||
#include <klistview.h>
|
||||
#include <tqdragobject.h>
|
||||
|
||||
#include "kmenubase.h"
|
||||
#include "kmenuitembase.h"
|
||||
#include "service_mnu.h"
|
||||
|
||||
class KickerClientMenu;
|
||||
class KBookmarkMenu;
|
||||
class KActionCollection;
|
||||
class KBookmarkOwner;
|
||||
class Panel;
|
||||
class TQWidgetStack;
|
||||
class KHistoryCombo;
|
||||
class TQScrollView;
|
||||
class PopupMenuTitle;
|
||||
class TQWidget;
|
||||
class TQVBoxLayout;
|
||||
class TQTimer;
|
||||
class KPixmap;
|
||||
|
||||
class KMenuItem : public TQListViewItem
|
||||
{
|
||||
public:
|
||||
KMenuItem(int nId, TQListView* parent) : TQListViewItem(parent), m_id(nId) { init(); }
|
||||
KMenuItem(int nId, TQListViewItem* parent) : TQListViewItem(parent), m_id(nId) { init(); }
|
||||
~KMenuItem();
|
||||
|
||||
void setIcon(const TQString& icon, int size);
|
||||
TQString icon() const { return m_icon; }
|
||||
void setTitle( const TQString& text );
|
||||
TQString title() const { return m_title; }
|
||||
void setToolTip( const TQString& text );
|
||||
TQString toolTip() const { return m_tooltip; }
|
||||
void setDescription(const TQString& text);
|
||||
TQString description() const { return m_description; }
|
||||
void setService(KService::Ptr& s) { m_s = s; }
|
||||
KService::Ptr service() { return m_s; }
|
||||
void setPath(const TQString& u) { m_path = u; }
|
||||
TQString path() const { return m_path; }
|
||||
void setMenuPath(const TQString& u) { m_menuPath = u; }
|
||||
TQString menuPath() const { return m_menuPath; }
|
||||
int id() const { return m_id; }
|
||||
void setHasChildren(bool flag);
|
||||
bool hasChildren() const { return m_has_children; }
|
||||
void makeGradient(KPixmap &off, const TQColor& c);
|
||||
|
||||
protected:
|
||||
virtual void paintCell(TQPainter* p, const TQColorGroup & cg, int column, int width, int align);
|
||||
virtual void paintCellInter(TQPainter* p, const TQColorGroup & cg, int column, int width, int align);
|
||||
virtual void setup();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
int m_id;
|
||||
KService::Ptr m_s;
|
||||
TQString m_title;
|
||||
TQString m_description;
|
||||
TQString m_path;
|
||||
TQString m_icon;
|
||||
TQString m_tooltip;
|
||||
TQString m_menuPath;
|
||||
float title_font_size;
|
||||
float description_font_size;
|
||||
bool m_has_children;
|
||||
int m_old_width;
|
||||
TQPixmap right_triangle;
|
||||
};
|
||||
|
||||
class KMenuItemSeparator : public KMenuItem
|
||||
{
|
||||
public:
|
||||
KMenuItemSeparator(int nId, TQListView* parent);
|
||||
virtual void setup();
|
||||
|
||||
virtual void paintCell(TQPainter* p, const TQColorGroup & cg, int column, int width, int align);
|
||||
void setLink(const TQString &text, const TQString &link = TQString::null );
|
||||
|
||||
TQString linkUrl() const { return m_link_url; }
|
||||
|
||||
/// returns true if the cursor has to change
|
||||
bool hitsLink(const TQPoint &pos);
|
||||
|
||||
protected:
|
||||
void preparePixmap(int width);
|
||||
TQPixmap pixmap;
|
||||
int left_margin;
|
||||
|
||||
private:
|
||||
TQListView* lv;
|
||||
int cached_width;
|
||||
TQString m_link_text, m_link_url;
|
||||
TQRect m_link_rect;
|
||||
|
||||
};
|
||||
|
||||
class KMenuItemHeader : public KMenuItemSeparator
|
||||
{
|
||||
public:
|
||||
KMenuItemHeader( int nId, const TQString &relpath, TQListView* parent);
|
||||
virtual void setup();
|
||||
|
||||
virtual void paintCell(TQPainter* p, const TQColorGroup & cg, int column, int width, int align);
|
||||
|
||||
private:
|
||||
TQListView* lv;
|
||||
TQStringList paths;
|
||||
TQStringList texts;
|
||||
TQStringList icons;
|
||||
TQPixmap left_triangle;
|
||||
};
|
||||
|
||||
class KMenuSpacer : public KMenuItem
|
||||
{
|
||||
public:
|
||||
KMenuSpacer(int nId, TQListView* parent);
|
||||
virtual void paintCell(TQPainter* p, const TQColorGroup & cg, int column, int width, int align);
|
||||
virtual void setup();
|
||||
|
||||
void setHeight(int);
|
||||
};
|
||||
|
||||
class ItemView : public KListView
|
||||
{
|
||||
friend class KMenuItem;
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
ItemView(TQWidget* parent, const char* name = 0);
|
||||
|
||||
KMenuItem* insertItem( const TQString& icon, const TQString& text, const TQString& description, int nId, int nIndex, KMenuItem* parentItem = 0 );
|
||||
KMenuItem* insertItem( const TQString& icon, const TQString& text, const TQString& description, const TQString& path, int nId, int nIndex, KMenuItem* parentItem = 0 );
|
||||
int insertItem( PopupMenuTitle*, int, int);
|
||||
int setItemEnabled(int id, bool enabled);
|
||||
KMenuItemSeparator *insertSeparator(int id, const TQString& text, int nIndex);
|
||||
KMenuItemHeader *insertHeader(int id, const TQString &relpath);
|
||||
KMenuItem* insertMenuItem(KService::Ptr & s, int nId, int nIndex = -1, KMenuItem* parentItem = 0,
|
||||
const TQString &aliasname = TQString::null, const TQString &label = TQString::null,
|
||||
const TQString &categoryIcon = TQString::null);
|
||||
KMenuItem* insertRecentlyItem(const TQString& s, int nId, int nIndex = -1);
|
||||
KMenuItem* insertDocumentItem(const TQString& s, int nId, int nIndex = -1 , const TQStringList* suppressGenericNames = 0,
|
||||
const TQString& aliasname = TQString::null);
|
||||
KMenuItem* insertSubItem(const TQString& icon, const TQString& caption, const TQString& description, const TQString& path, KMenuItem* parentItem);
|
||||
KMenuItem* findItem(int nId);
|
||||
|
||||
void setIconSize(int size) { m_iconSize = size; }
|
||||
void setMouseMoveSelects(bool select) { m_mouseMoveSelects = select; }
|
||||
void clear();
|
||||
int goodHeight();
|
||||
TQString path;
|
||||
void setBackPath( const TQString &str ) { m_back_url = str; }
|
||||
TQString backPath() const { return m_back_url; }
|
||||
|
||||
public slots:
|
||||
void slotItemClicked(TQListViewItem*);
|
||||
void slotMoveContent();
|
||||
|
||||
signals:
|
||||
void startService(KService::Ptr kservice);
|
||||
void startURL(const TQString& u);
|
||||
|
||||
protected:
|
||||
void contentsMouseMoveEvent(TQMouseEvent *e);
|
||||
void contentsMousePressEvent ( TQMouseEvent * e );
|
||||
void contentsWheelEvent(TQWheelEvent *e);
|
||||
void leaveEvent(TQEvent *e);
|
||||
virtual void resizeEvent ( TQResizeEvent * e );
|
||||
virtual void viewportPaintEvent ( TQPaintEvent * pe );
|
||||
virtual TQDragObject* dragObject ();
|
||||
virtual bool acceptDrag (TQDropEvent* event) const;
|
||||
virtual bool focusNextPrevChild(bool next);
|
||||
|
||||
private slots:
|
||||
void slotItemClicked(int button, TQListViewItem * item, const TQPoint & pos, int c );
|
||||
|
||||
private:
|
||||
KMenuItem* itemAtIndex(int nIndex);
|
||||
void moveItemToIndex(KMenuItem*, int);
|
||||
|
||||
TQWidget* m_itemBox;
|
||||
TQVBoxLayout* m_itemLayout;
|
||||
KMenuItem *m_lastOne;
|
||||
KMenuSpacer *m_spacer;
|
||||
|
||||
TQString m_back_url;
|
||||
|
||||
bool m_mouseMoveSelects;
|
||||
int m_iconSize;
|
||||
int m_old_contentY;
|
||||
};
|
||||
|
||||
class FavoritesItemView : public ItemView
|
||||
{
|
||||
public:
|
||||
FavoritesItemView(TQWidget* parent, const char* name = 0);
|
||||
|
||||
protected:
|
||||
virtual bool acceptDrag (TQDropEvent* event) const;
|
||||
};
|
||||
|
||||
class KMenuItemInfo
|
||||
{
|
||||
public:
|
||||
int m_id;
|
||||
KService::Ptr m_s;
|
||||
TQString m_title;
|
||||
TQString m_description;
|
||||
TQString m_path;
|
||||
TQString m_icon;
|
||||
};
|
||||
|
||||
class KMenuItemDrag : public TQDragObject
|
||||
{
|
||||
public:
|
||||
KMenuItemDrag(KMenuItem& item, TQWidget *dragSource);
|
||||
~KMenuItemDrag();
|
||||
|
||||
virtual const char * format(int i = 0) const;
|
||||
virtual TQByteArray encodedData(const char *) const;
|
||||
|
||||
static bool canDecode(const TQMimeSource * e);
|
||||
static bool decode(const TQMimeSource* e, KMenuItemInfo& item);
|
||||
|
||||
private:
|
||||
TQByteArray a;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,141 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Dirk Mueller <mueller@kde.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "k_mnu_stub.h"
|
||||
#include "k_new_mnu.h"
|
||||
#include "k_mnu.h"
|
||||
|
||||
void KMenuStub::removeClientMenu(int id)
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->removeClientMenu(id);
|
||||
return m_w.panelkmenu->removeClientMenu(id);
|
||||
}
|
||||
|
||||
int KMenuStub::insertClientMenu(KickerClientMenu *p)
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->insertClientMenu(p);
|
||||
return m_w.panelkmenu->insertClientMenu(p);
|
||||
}
|
||||
|
||||
void KMenuStub::adjustSize()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->adjustSize();
|
||||
return m_w.panelkmenu->adjustSize();
|
||||
}
|
||||
|
||||
void KMenuStub::hide()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->hide();
|
||||
return m_w.panelkmenu->hide();
|
||||
}
|
||||
|
||||
void KMenuStub::show()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->show();
|
||||
return m_w.panelkmenu->show();
|
||||
}
|
||||
|
||||
void KMenuStub::showMenu()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->showMenu();
|
||||
return m_w.panelkmenu->showMenu();
|
||||
}
|
||||
|
||||
#if 0
|
||||
void KMenuStub::resize()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->resize();
|
||||
return m_w.panelkmenu->resize();
|
||||
}
|
||||
#endif
|
||||
|
||||
void KMenuStub::popup(const TQPoint &pos, int indexAtPoint)
|
||||
{
|
||||
return m_type == t_KMenu ?
|
||||
m_w.kmenu->popup(pos, indexAtPoint)
|
||||
: m_w.panelkmenu->popup(pos, indexAtPoint);
|
||||
}
|
||||
|
||||
void KMenuStub::selectFirstItem()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->selectFirstItem();
|
||||
return m_w.panelkmenu->selectFirstItem();
|
||||
}
|
||||
|
||||
void KMenuStub::resize(int w, int h)
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->resize(w, h);
|
||||
return m_w.panelkmenu->resize(w, h);
|
||||
}
|
||||
|
||||
TQSize KMenuStub::sizeHint() const
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->sizeHint();
|
||||
return m_w.panelkmenu->sizeHint();
|
||||
}
|
||||
|
||||
bool KMenuStub::highlightMenuItem( const TQString &menuId )
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->highlightMenuItem(menuId);
|
||||
return m_w.panelkmenu->highlightMenuItem(menuId);
|
||||
}
|
||||
|
||||
void KMenuStub::clearRecentMenuItems()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->clearRecentAppsItems();
|
||||
return m_w.panelkmenu->clearRecentMenuItems();
|
||||
}
|
||||
|
||||
void KMenuStub::initialize()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->initialize();
|
||||
return m_w.panelkmenu->initialize();
|
||||
}
|
||||
|
||||
bool KMenuStub::isVisible() const
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu->isVisible();
|
||||
return m_w.panelkmenu->isVisible();
|
||||
}
|
||||
|
||||
TQWidget* KMenuStub::widget()
|
||||
{
|
||||
if(m_type == t_KMenu)
|
||||
return m_w.kmenu;
|
||||
return m_w.panelkmenu;
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Dirk Mueller <mueller@kde.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __k_mnu_stub_h__
|
||||
#define __k_mnu_stub_h__
|
||||
|
||||
#include <tqstring.h>
|
||||
#include <tqpoint.h>
|
||||
|
||||
class KickerClientMenu;
|
||||
class KMenu;
|
||||
class PanelKMenu;
|
||||
|
||||
|
||||
|
||||
|
||||
class KMenuStub
|
||||
{
|
||||
public:
|
||||
KMenuStub(KMenu* _kmenu)
|
||||
: m_type(t_KMenu) { m_w.kmenu = _kmenu; }
|
||||
KMenuStub(PanelKMenu* _panelkmenu)
|
||||
: m_type(t_PanelKMenu) { m_w.panelkmenu = _panelkmenu; }
|
||||
~KMenuStub() {}
|
||||
|
||||
void removeClientMenu(int id);
|
||||
int insertClientMenu(KickerClientMenu *p);
|
||||
void adjustSize();
|
||||
void hide();
|
||||
void show();
|
||||
void showMenu();
|
||||
void resize();
|
||||
void popup(const TQPoint &pos, int indexAtPoint = -1);
|
||||
void selectFirstItem();
|
||||
void resize(int, int);
|
||||
TQSize sizeHint() const;
|
||||
bool highlightMenuItem( const TQString &menuId );
|
||||
void clearRecentMenuItems();
|
||||
void initialize();
|
||||
|
||||
TQWidget* widget();
|
||||
|
||||
bool isVisible() const;
|
||||
private:
|
||||
enum {t_PanelKMenu, t_KMenu} m_type;
|
||||
union {
|
||||
KMenu* kmenu;
|
||||
PanelKMenu* panelkmenu;
|
||||
} m_w;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,343 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
|
||||
Copyright (c) 2006 Debajyoti Bera <dbera.web@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __k_new_mnu_h__
|
||||
#define __k_new_mnu_h__
|
||||
|
||||
#include <dcopobject.h>
|
||||
#include <tqintdict.h>
|
||||
#include <tqpixmap.h>
|
||||
#include <tqframe.h>
|
||||
#include <tqtoolbutton.h>
|
||||
#include <tqscrollview.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqbitmap.h>
|
||||
#include <tqvbox.h>
|
||||
#include <tqregexp.h>
|
||||
|
||||
#include <kabc/addressbook.h>
|
||||
#include <kabc/stdaddressbook.h>
|
||||
#include "../interfaces/kickoff-search-plugin.h"
|
||||
|
||||
// #include "kmenubase.h"
|
||||
#include "../core/kmenubase.h"
|
||||
#include "service_mnu.h"
|
||||
#include "query.h"
|
||||
|
||||
class KickerClientMenu;
|
||||
class KickoffTabBar;
|
||||
class KBookmarkMenu;
|
||||
class KActionCollection;
|
||||
class KBookmarkOwner;
|
||||
class Panel;
|
||||
class TQWidgetStack;
|
||||
class KHistoryCombo;
|
||||
class TQScrollView;
|
||||
class PopupMenuTitle;
|
||||
class MediaWatcher;
|
||||
class KURIFilterData;
|
||||
class KBookmarkGroup;
|
||||
class KBookmarkManager;
|
||||
class ItemView;
|
||||
class FlipScrollView;
|
||||
class TQListViewItem;
|
||||
class KMenuItem;
|
||||
class TQListView;
|
||||
class TQTabBar;
|
||||
class TQTab;
|
||||
|
||||
static TQString categories[14] = {I18N_NOOP("Actions"), I18N_NOOP("Applications"), I18N_NOOP("Bookmarks"),
|
||||
I18N_NOOP("Notes"), I18N_NOOP("Emails"), I18N_NOOP("Files"), I18N_NOOP("Music"),
|
||||
I18N_NOOP("Browsing History"), I18N_NOOP("Chat Logs"), I18N_NOOP("Feeds"),
|
||||
I18N_NOOP("Pictures"), I18N_NOOP("Videos"), I18N_NOOP("Documentation"),
|
||||
I18N_NOOP("Others")};
|
||||
|
||||
static TQString kerry_categories[14] = {"contacts", "applications", "webpages", "everything", "conversations",
|
||||
"everything", "media", "webpages", "conversations", "webpages", "images",
|
||||
"media", "everything", "everything"};
|
||||
|
||||
enum MenuOrientation { BottomUp, TopDown, UnDetermined };
|
||||
enum OverflowCategoryState { None, Filling, NotNeeded };
|
||||
|
||||
class KMenu : public KMenuBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY (bool KStyleMenuDropShadow READ useKStyleMenuDropShadow )
|
||||
|
||||
public:
|
||||
KMenu();
|
||||
~KMenu();
|
||||
|
||||
int insertClientMenu(KickerClientMenu *p);
|
||||
void removeClientMenu(int id);
|
||||
|
||||
bool useKStyleMenuDropShadow() const { return true; }
|
||||
|
||||
virtual void showMenu();
|
||||
virtual bool eventFilter(TQObject*, TQEvent*);
|
||||
|
||||
void clearRecentAppsItems();
|
||||
void clearRecentDocsItems();
|
||||
bool highlightMenuItem(const TQString& /*id*/) { return false;}
|
||||
|
||||
void selectFirstItem() {}
|
||||
void popup(const TQPoint&, int indexAtPoint);
|
||||
|
||||
enum MaskEffect { Plain, Dissolve };
|
||||
|
||||
virtual TQSize sizeHint() const;
|
||||
virtual TQSize minimumSizeHint() const;
|
||||
|
||||
void searchOver();
|
||||
void initCategoryTitlesUpdate();
|
||||
bool anotherHitMenuItemAllowed(int cat, bool count=true);
|
||||
void addHitMenuItem(HitMenuItem*);
|
||||
void insertSearchResult(HitMenuItem* item);
|
||||
|
||||
void updateCategoryTitles();
|
||||
|
||||
signals:
|
||||
void aboutToHide();
|
||||
void aboutToShow();
|
||||
|
||||
public slots:
|
||||
virtual void initialize();
|
||||
|
||||
virtual void hide();
|
||||
virtual void show();
|
||||
|
||||
void stackWidgetRaised(TQWidget*);
|
||||
|
||||
protected slots:
|
||||
void slotLock();
|
||||
void slotOpenHomepage();
|
||||
void slotLogout();
|
||||
void slotPopulateSessions();
|
||||
void slotSessionActivated( int );
|
||||
void slotGoSubMenu(const TQString& relPath);
|
||||
void slotGoBack();
|
||||
void slotGoExitMainMenu();
|
||||
void slotGoExitSubMenu(const TQString& url);
|
||||
void tabClicked(TQTab*);
|
||||
|
||||
void paletteChanged();
|
||||
virtual void configChanged();
|
||||
void updateRecent();
|
||||
|
||||
void initSearch();
|
||||
void searchAccept();
|
||||
void searchChanged(const TQString &);
|
||||
// when timeout happens or doQueryNow calls
|
||||
void doQuery (bool return_pressed = false);
|
||||
void searchActionClicked(TQListViewItem*);
|
||||
|
||||
void slotStartService(KService::Ptr);
|
||||
void slotStartURL(const TQString&);
|
||||
void slotContextMenuRequested( TQListViewItem * item, const TQPoint & pos, int col );
|
||||
|
||||
void clearedHistory();
|
||||
|
||||
void slotSloppyTimeout();
|
||||
|
||||
void slotContextMenu(int);
|
||||
void slotFavoritesMoved( TQListViewItem*, TQListViewItem*, TQListViewItem* );
|
||||
|
||||
void updateMedia();
|
||||
void slotFavDropped(TQDropEvent * e, TQListViewItem *after );
|
||||
void slotSuspend(int id);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(TQPaintEvent *);
|
||||
virtual void resizeEvent ( TQResizeEvent * );
|
||||
virtual void mousePressEvent ( TQMouseEvent * e );
|
||||
virtual void mouseReleaseEvent ( TQMouseEvent * e );
|
||||
virtual void mouseMoveEvent ( TQMouseEvent * e );
|
||||
|
||||
void doNewSession(bool lock);
|
||||
void createRecentMenuItems();
|
||||
void insertStaticItems();
|
||||
void insertStaticExitItems();
|
||||
void insertSuspendOption( int &id, int &index );
|
||||
virtual void clearSubmenus();
|
||||
// void raiseStackWidget(TQWidget *view);
|
||||
|
||||
bool runCommand();
|
||||
|
||||
void setupUi();
|
||||
|
||||
void saveConfig();
|
||||
void searchProgramList(TQString relPath);
|
||||
void searchBookmarks(KBookmarkGroup);
|
||||
void searchAddressbook();
|
||||
|
||||
void createNewProgramList();
|
||||
void createNewProgramList(TQString relPath);
|
||||
|
||||
void paintSearchTab( bool active );
|
||||
|
||||
void goSubMenu(const TQString& relPath, bool keyboard = false);
|
||||
void setOrientation(MenuOrientation orientation);
|
||||
|
||||
private:
|
||||
int serviceMenuStartId() { return 5242; }
|
||||
int serviceMenuEndId() { return 5242; }
|
||||
|
||||
void fillMenu( KServiceGroup::Ptr &_root, KServiceGroup::List &_list,
|
||||
const TQString &_relPath, ItemView* view, int & id );
|
||||
|
||||
void fillSubMenu(const TQString& relPath, ItemView *view);
|
||||
|
||||
TQPopupMenu *sessionsMenu;
|
||||
int client_id;
|
||||
bool delay_init;
|
||||
TQIntDict<KickerClientMenu> clients;
|
||||
KActionCollection *actionCollection;
|
||||
PopupMenuList dynamicSubMenus;
|
||||
|
||||
TQTimer m_sloppyTimer;
|
||||
TQTimer m_mediaFreeTimer;
|
||||
MediaWatcher * m_mediaWatcher;
|
||||
TQRegion m_sloppyRegion;
|
||||
TQRect m_sloppySource;
|
||||
bool m_sloppySourceClicked;
|
||||
TQWidget * m_sloppyWidget;
|
||||
ItemView * m_recentlyView;
|
||||
ItemView * m_favoriteView;
|
||||
ItemView * m_searchResultsWidget;
|
||||
TQListView * m_searchActions;
|
||||
FlipScrollView * m_browserView;
|
||||
ItemView * m_systemView;
|
||||
FlipScrollView * m_exitView;
|
||||
TQVBox * m_searchWidget;
|
||||
TQLabel * m_resizeHandle;
|
||||
|
||||
bool m_isresizing;
|
||||
// timer for search without pressing enter feature
|
||||
TQTimer *input_timer, *init_search_timer;
|
||||
|
||||
Query current_query;
|
||||
|
||||
bool dontQueryNow(const TQString &);
|
||||
|
||||
// start timeout timer to call doQuery is enough time has passed since last keypress
|
||||
void checkToDoQuery (const TQString &);
|
||||
// when return is pressed
|
||||
void doQueryNow ();
|
||||
void clearSearchResults(bool showHelp = true);
|
||||
|
||||
int *max_category_id; // maximum id in this category: max_category_id - base_category_id gives the current number of hits displayed in this category
|
||||
int *categorised_hit_total; // current number of hits returned in each category
|
||||
|
||||
bool ensureServiceRunning(const TQString & service);
|
||||
|
||||
TQString iconForHitMenuItem(HitMenuItem *hit_item);
|
||||
|
||||
int getHitMenuItemPosition (HitMenuItem *hit_item);
|
||||
TQMap<TQString, TQString> mimetype_iconstore;
|
||||
TQMap<TQString, TQString> media_mimetypes;
|
||||
// report error as a menu item
|
||||
void reportError (TQString err);
|
||||
void addToHistory();
|
||||
|
||||
int max_items(int category) const;
|
||||
TQString TOP_CATEGORY_STRING;
|
||||
bool *already_added;
|
||||
|
||||
void notifyServiceStarted(KService::Ptr service);
|
||||
void parseLine( bool final );
|
||||
TQString m_iconName;
|
||||
TQStringList m_middleFilters;
|
||||
TQStringList m_finalFilters;
|
||||
KURIFilterData* m_filterData;
|
||||
TQPtrList<HitMenuItem> m_current_menu_items;
|
||||
TQListViewItem *m_searchIndex, *m_searchInternet;
|
||||
|
||||
bool checkUriInMenu(const KURL &uri);
|
||||
|
||||
TQRegExp emailRegExp,uriRegExp,uri2RegExp,authRegExp;
|
||||
|
||||
KBookmarkManager *bookmarkManager;
|
||||
KABC::AddressBook* m_addressBook;
|
||||
|
||||
enum ContextMenuEntry { AddItemToPanel, EditItem, AddMenuToPanel, EditMenu,
|
||||
AddItemToDesktop, AddMenuToDesktop, PutIntoRunDialog,
|
||||
AddToFavorites, RemoveFromFavorites, ClearRecentlyUsedApps,
|
||||
ClearRecentlyUsedDocs };
|
||||
struct PopupPath
|
||||
{
|
||||
TQString title, description, icon, path, menuPath;
|
||||
};
|
||||
|
||||
enum KickoffTabEntry { FavoriteTab, ApplicationsTab, ComputerTab,
|
||||
HistoryTab, LeaveTab, SearchTab, NumTabs };
|
||||
|
||||
KPopupMenu* m_popupMenu;
|
||||
KService* m_popupService;
|
||||
PopupPath m_popupPath;
|
||||
|
||||
KickoffTabBar* m_tabBar;
|
||||
TQTab* m_tabs[NumTabs];
|
||||
|
||||
TQString newDesktopFile(const KURL& url, const TQString &directory);
|
||||
void updateRecentlyUsedApps(KService::Ptr &service);
|
||||
|
||||
TQPixmap main_border_lc;
|
||||
TQPixmap main_border_rc;
|
||||
TQPixmap main_border_tl;
|
||||
TQPixmap main_border_tr;
|
||||
TQPixmap button_box_left;
|
||||
|
||||
TQPixmap search_tab_left;
|
||||
TQPixmap search_tab_right;
|
||||
TQPixmap search_tab_center;
|
||||
|
||||
TQPixmap search_tab_top_left;
|
||||
TQPixmap search_tab_top_right;
|
||||
TQPixmap search_tab_top_center;
|
||||
|
||||
TQWidgetStack *m_stacker;
|
||||
|
||||
TQStringList m_programsInMenu;
|
||||
TQStringList m_newInstalledPrograms, m_seenPrograms;
|
||||
bool m_seenProgramsChanged;
|
||||
TQString m_currentDate;
|
||||
|
||||
MenuOrientation m_orientation;
|
||||
bool m_toolTipsEnabled;
|
||||
int m_media_id;
|
||||
|
||||
bool m_recentDirty, m_browserDirty, m_kerryInstalled, m_isShowing;
|
||||
|
||||
KickoffSearch::Plugin* m_search_plugin;
|
||||
TQObject* m_search_plugin_interface;
|
||||
|
||||
OverflowCategoryState m_overflowCategoryState;
|
||||
TQPtrList<HitMenuItem> m_overflowList;
|
||||
int m_overflowCategory;
|
||||
|
||||
void resetOverflowCategory();
|
||||
void fillOverflowCategory();
|
||||
|
||||
TQString insertBreaks(const TQString& text, TQFontMetrics fm, int width, TQString leadInsert = TQString::null);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,200 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
|
||||
Copyright (c) 2006 Dirk Mueller <mueller@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "kickoff_bar.h"
|
||||
#include "itemview.h"
|
||||
|
||||
#include <tqiconset.h>
|
||||
#include <tqpainter.h>
|
||||
#include <tqcursor.h>
|
||||
#include <tqstyle.h>
|
||||
#include <tqapplication.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include "kickerSettings.h"
|
||||
|
||||
KickoffTabBar::KickoffTabBar(TQWidget* parent, const char* name)
|
||||
: TQTabBar(parent, name), m_tabsActivated(true)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void KickoffTabBar::deactivateTabs(bool b)
|
||||
{
|
||||
m_tabsActivated = !b;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void KickoffTabBar::paint(TQPainter* p, TQTab* t, bool selected) const
|
||||
{
|
||||
TQStyle::SFlags flags = TQStyle::Style_Default;
|
||||
|
||||
if (isEnabled() && t->isEnabled())
|
||||
flags |= TQStyle::Style_Enabled;
|
||||
if ( m_tabsActivated && selected )
|
||||
flags |= TQStyle::Style_Selected;
|
||||
// else if(t == d->pressed)
|
||||
// flags |= TQStyle::Style_Sunken;
|
||||
//selection flags
|
||||
if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
|
||||
flags |= TQStyle::Style_MouseOver;
|
||||
style().drawControl( TQStyle::CE_TabBarTab, p, this, t->rect(),
|
||||
colorGroup(), flags, TQStyleOption(t) );
|
||||
|
||||
paintLabel( p, t->rect(), t, t->identifier() == keyboardFocusTab() );
|
||||
}
|
||||
|
||||
|
||||
void KickoffTabBar::paintLabel(TQPainter* p, const TQRect& br, TQTab* t, bool has_focus) const
|
||||
{
|
||||
TQRect r = br;
|
||||
|
||||
bool selected = m_tabsActivated && (currentTab() == t->identifier());
|
||||
int vframe = style().pixelMetric( TQStyle::PM_TabBarTabVSpace, this );
|
||||
|
||||
p->setFont( font() );
|
||||
TQFontMetrics fm = p->fontMetrics();
|
||||
int fw = fm.size( Qt::SingleLine|Qt::ShowPrefix, t->text() ).width();
|
||||
|
||||
TQRect rt(r);
|
||||
rt.setWidth(fw);
|
||||
|
||||
if ( t->iconSet())
|
||||
{
|
||||
// the tab has an iconset, draw it in the right mode
|
||||
TQIconSet::Mode mode = (t->isEnabled() && isEnabled())
|
||||
? TQIconSet::Normal : TQIconSet::Disabled;
|
||||
if ( mode == TQIconSet::Normal && has_focus )
|
||||
mode = TQIconSet::Active;
|
||||
TQPixmap pixmap = t->iconSet()->pixmap( TQIconSet::Large, mode );
|
||||
int pixw = pixmap.width();
|
||||
int pixh = pixmap.height();
|
||||
int xoff = br.x() + (br.width() - pixw)/2;
|
||||
int yoff = br.y() + (br.height() - 4 - pixh - ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) - vframe)/2;
|
||||
|
||||
p->drawPixmap( xoff, 4 + yoff, pixmap );
|
||||
|
||||
r.setTop(vframe/2 + yoff + pixh - 8);
|
||||
rt.setTop(vframe/2 + yoff + pixh - 8);
|
||||
rt.setHeight(((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + vframe/2);
|
||||
}
|
||||
else
|
||||
rt.setHeight(vframe/2 + fm.height());
|
||||
|
||||
rt.setWidth(fw+8);
|
||||
rt.moveCenter(r.center());
|
||||
|
||||
TQStyle::SFlags flags = TQStyle::Style_Default;
|
||||
|
||||
if (isEnabled() && t->isEnabled())
|
||||
flags |= TQStyle::Style_Enabled;
|
||||
if (has_focus)
|
||||
flags |= TQStyle::Style_HasFocus;
|
||||
if ( selected )
|
||||
flags |= TQStyle::Style_Selected;
|
||||
// else if(t == d->pressed)
|
||||
// flags |= TQStyle::Style_Sunken;
|
||||
if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
|
||||
flags |= TQStyle::Style_MouseOver;
|
||||
style().drawControl( TQStyle::CE_TabBarLabel, p, this, rt,
|
||||
t->isEnabled() ? colorGroup(): palette().disabled(),
|
||||
flags, TQStyleOption(t) );
|
||||
}
|
||||
|
||||
TQSize KickoffTabBar::sizeHint() const
|
||||
{
|
||||
TQSize s = TQTabBar::sizeHint();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void KickoffTabBar::layoutTabs()
|
||||
{
|
||||
TQTabBar::layoutTabs();
|
||||
|
||||
TQFontMetrics fm = fontMetrics();
|
||||
int fh = ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + 4;
|
||||
|
||||
int hframe = style().pixelMetric( TQStyle::PM_TabBarTabHSpace, this );
|
||||
int vframe = style().pixelMetric( TQStyle::PM_TabBarTabVSpace, this );
|
||||
int overlap = style().pixelMetric( TQStyle::PM_TabBarTabOverlap, this );
|
||||
|
||||
TQSize s;
|
||||
for (int t = 0; t < count(); ++t)
|
||||
{
|
||||
TQTab* tab = tabAt(t);
|
||||
if (tab->iconSet())
|
||||
s = s.expandedTo(tab->iconSet()->pixmap(TQIconSet::Large, TQIconSet::Normal).size());
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
for (int t = 0; t < count(); ++t) {
|
||||
TQTab* tab = tabAt(TQApplication::reverseLayout() ? count() - t - 1 : t);
|
||||
int h = fh;
|
||||
if (tab->iconSet())
|
||||
h += 4 + s.height() + 4;
|
||||
TQRect r = tab->rect();
|
||||
|
||||
int fw = fm.size( Qt::SingleLine|Qt::ShowPrefix, tab->text() ).width();
|
||||
int iw = 0;
|
||||
if ( tab->iconSet() != 0 )
|
||||
iw = tab->iconSet()->pixmap( TQIconSet::Large, TQIconSet::Normal ).width();
|
||||
int w = QMAX(iw, fw + 6 + 6 ) + hframe;
|
||||
h += ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + vframe;
|
||||
tab->setRect(TQRect(TQPoint(x, 0), style().sizeFromContents(TQStyle::CT_TabBarTab, this,
|
||||
TQSize(w, h), TQStyleOption(tab))));
|
||||
x += tab->rect().width() - overlap;
|
||||
}
|
||||
}
|
||||
|
||||
void KickoffTabBar::dragEnterEvent(TQDragEnterEvent* event)
|
||||
{
|
||||
event->accept(KMenuItemDrag::canDecode(event));
|
||||
}
|
||||
|
||||
void KickoffTabBar::dragMoveEvent(TQDragMoveEvent* event)
|
||||
{
|
||||
TQTab* t = selectTab(event->pos());
|
||||
|
||||
// ### uhhh, look away
|
||||
if (t && t->identifier() == 0)
|
||||
{
|
||||
setCurrentTab(t);
|
||||
}
|
||||
}
|
||||
|
||||
void KickoffTabBar::mousePressEvent( TQMouseEvent * e )
|
||||
{
|
||||
if ( e->button() != LeftButton ) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
TQTab *t = selectTab( e->pos() );
|
||||
if ( t && t->isEnabled() ) {
|
||||
emit tabClicked(t);
|
||||
}
|
||||
TQTabBar::mousePressEvent(e);
|
||||
}
|
||||
|
||||
#include "kickoff_bar.moc"
|
||||
// vim:cindent:sw=4:
|
@ -0,0 +1,53 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
|
||||
Copyright (c) 2006 Dirk Mueller <mueller@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __kickoff_bar_h__
|
||||
#define __kickoff_bar_h__
|
||||
|
||||
#include <tqtabbar.h>
|
||||
|
||||
class KickoffTabBar : public TQTabBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KickoffTabBar(TQWidget* parent, const char* name);
|
||||
|
||||
void deactivateTabs(bool b);
|
||||
virtual TQSize sizeHint() const;
|
||||
|
||||
protected:
|
||||
virtual void paint(TQPainter*, TQTab*, bool) const;
|
||||
virtual void paintLabel(TQPainter* p, const TQRect& br, TQTab* t, bool has_focus) const;
|
||||
virtual void layoutTabs();
|
||||
virtual void dragEnterEvent(TQDragEnterEvent*);
|
||||
virtual void dragMoveEvent(TQDragMoveEvent*);
|
||||
virtual void mousePressEvent ( TQMouseEvent * );
|
||||
|
||||
signals:
|
||||
void tabClicked(TQTab*);
|
||||
|
||||
private:
|
||||
bool m_tabsActivated;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,141 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>KMenuItemBase</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>KMenuItemBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>514</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>KMenuItemBase</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QLayoutWidget" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>layout11</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>itemTitle</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>itemDescription</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="paletteForegroundColor">
|
||||
<color>
|
||||
<red>188</red>
|
||||
<green>188</green>
|
||||
<blue>188</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout4</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>itemPixmap</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignTop|AlignHCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,57 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Kulow <coolo@novell.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "media_watcher.h"
|
||||
#include <kapplication.h>
|
||||
#include <kdebug.h>
|
||||
#include <dcopclient.h>
|
||||
#include <dcopref.h>
|
||||
|
||||
MediaWatcher::MediaWatcher( TQObject *parent ) :
|
||||
TQObject( parent ), DCOPObject("mediawatcher")
|
||||
{
|
||||
connectDCOPSignal( "kded", "mediamanager", "mediumAdded(TQString,bool)",
|
||||
"slotMediumAdded(TQString,bool)", true );
|
||||
connectDCOPSignal( "kded", "mediamanager", "mediumRemoved(TQString,bool)",
|
||||
"slotMediumAdded(TQString,bool)", true );
|
||||
connectDCOPSignal( "kded", "mediamanager", "mediumChanged(TQString,bool)",
|
||||
"slotMediumAdded(TQString,bool)", true );
|
||||
|
||||
updateDevices();
|
||||
}
|
||||
|
||||
void MediaWatcher::updateDevices()
|
||||
{
|
||||
DCOPRef nsd( "kded", "mediamanager" );
|
||||
nsd.setDCOPClient( kapp->dcopClient() );
|
||||
m_devices = nsd.call( "fullList" );
|
||||
}
|
||||
|
||||
void MediaWatcher::slotMediumAdded( TQString item, bool a )
|
||||
{
|
||||
updateDevices();
|
||||
|
||||
emit mediumChanged();
|
||||
}
|
||||
|
||||
#include "media_watcher.moc"
|
@ -0,0 +1,51 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Kulow <coolo@novell.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef _media_watcher_
|
||||
#define _media_watcher_
|
||||
|
||||
#include <dcopobject.h>
|
||||
#include <tqobject.h>
|
||||
#include <tqstringlist.h>
|
||||
|
||||
class MediaWatcher : public TQObject, public DCOPObject
|
||||
{
|
||||
Q_OBJECT
|
||||
K_DCOP
|
||||
|
||||
TQStringList m_devices;
|
||||
void updateDevices();
|
||||
|
||||
k_dcop:
|
||||
void slotMediumAdded(TQString medium, bool a);
|
||||
|
||||
signals:
|
||||
void mediumChanged();
|
||||
|
||||
public:
|
||||
MediaWatcher(TQObject *parent);
|
||||
|
||||
TQStringList devices() const { return m_devices; }
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mykickoffsearchinterface.h"
|
||||
#include "../ui/k_new_mnu.h"
|
||||
|
||||
MyKickoffSearchInterface::MyKickoffSearchInterface( KMenu* menu, TQObject* parent, const char* name )
|
||||
: KickoffSearchInterface( parent, name ), _menu( menu )
|
||||
{
|
||||
}
|
||||
|
||||
bool MyKickoffSearchInterface::anotherHitMenuItemAllowed(int cat)
|
||||
{
|
||||
return _menu->anotherHitMenuItemAllowed(cat);
|
||||
}
|
||||
|
||||
void MyKickoffSearchInterface::addHitMenuItem(HitMenuItem* item)
|
||||
{
|
||||
_menu->addHitMenuItem(item);
|
||||
}
|
||||
|
||||
|
||||
void MyKickoffSearchInterface::searchOver()
|
||||
{
|
||||
_menu->searchOver();
|
||||
}
|
||||
|
||||
void MyKickoffSearchInterface::initCategoryTitlesUpdate()
|
||||
{
|
||||
_menu->initCategoryTitlesUpdate();
|
||||
}
|
||||
|
||||
void MyKickoffSearchInterface::updateCategoryTitles()
|
||||
{
|
||||
_menu->updateCategoryTitles();
|
||||
}
|
||||
|
||||
#include "mykickoffsearchinterface.moc"
|
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Stephan Binner <binner@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MYKICKOFFSEARCHINTERFACE_H
|
||||
#define MYKICKOFFSEARCHINTERFACE_H
|
||||
|
||||
#include "../interfaces/kickoffsearchinterface.h"
|
||||
|
||||
class KMenu;
|
||||
|
||||
using namespace KickoffSearch;
|
||||
|
||||
class MyKickoffSearchInterface :public KickoffSearchInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyKickoffSearchInterface( KMenu*, TQObject* parent, const char* name = 0 );
|
||||
|
||||
bool anotherHitMenuItemAllowed(int cat);
|
||||
void addHitMenuItem(HitMenuItem* item);
|
||||
void searchOver();
|
||||
void initCategoryTitlesUpdate();
|
||||
void updateCategoryTitles();
|
||||
|
||||
private:
|
||||
KMenu* _menu;
|
||||
|
||||
};
|
||||
|
||||
#endif /* MYKICKOFFSEARCHINTERFACE_H */
|
@ -0,0 +1,136 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Binner <binner@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "query.h"
|
||||
#include <kdebug.h>
|
||||
|
||||
Query::Query()
|
||||
{
|
||||
alternatives.setAutoDelete(true);
|
||||
}
|
||||
|
||||
void Query::clear()
|
||||
{
|
||||
query_term = TQString::null;
|
||||
alternatives.clear();
|
||||
}
|
||||
|
||||
void Query::set(const TQString &term)
|
||||
{
|
||||
query_term = term;
|
||||
alternatives.clear();
|
||||
|
||||
current_alternative = new Alternative;
|
||||
current_part = TQString::null;
|
||||
within_quotes = false;
|
||||
exclude_part = false;
|
||||
|
||||
for (uint index=0;index<term.length();index++) {
|
||||
if (current_part.isEmpty() && query_term[index]=='-')
|
||||
exclude_part = true;
|
||||
else if (term[index]=='\'' || term[index]=='"') {
|
||||
if (within_quotes)
|
||||
add_term();
|
||||
else
|
||||
within_quotes = true;
|
||||
}
|
||||
else if (!within_quotes && query_term[index]==' ')
|
||||
add_term();
|
||||
else if (!exclude_part && !within_quotes && query_term[index]=='O' && index+1<term.length() && query_term[index+1]=='R') {
|
||||
index++;
|
||||
alternatives.append(current_alternative);
|
||||
current_alternative = new Alternative;
|
||||
within_quotes = false;
|
||||
exclude_part = false;
|
||||
current_part = TQString::null;
|
||||
}
|
||||
else
|
||||
current_part+=term[index];
|
||||
}
|
||||
add_term();
|
||||
alternatives.append(current_alternative);
|
||||
|
||||
#if 0
|
||||
for (Alternative* alt=alternatives.first(); alt; alt=alternatives.next()) {
|
||||
kdDebug() << "---" << endl;
|
||||
kdDebug() << "*** includes = " << alt->includes << endl;
|
||||
kdDebug() << "*** excludes = " << alt->excludes << endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Query::add_term() {
|
||||
if (!current_part.isEmpty()) {
|
||||
if (current_part.startsWith("*"))
|
||||
current_part=current_part.mid(1);
|
||||
|
||||
if (current_part.endsWith("*"))
|
||||
current_part=current_part.mid(0,current_part.length()-1);
|
||||
|
||||
if (exclude_part)
|
||||
current_alternative->excludes+=current_part.lower();
|
||||
else
|
||||
current_alternative->includes+=current_part.lower();
|
||||
}
|
||||
within_quotes = false;
|
||||
exclude_part = false;
|
||||
current_part = TQString::null;
|
||||
}
|
||||
|
||||
TQString Query::get() const
|
||||
{
|
||||
return query_term;
|
||||
}
|
||||
|
||||
bool Query::matches(const TQString &term)
|
||||
{
|
||||
TQString lower_term = term.lower();
|
||||
|
||||
for (Alternative* alt=alternatives.first(); alt; alt=alternatives.next()) {
|
||||
if (!alt->includes.count())
|
||||
continue;
|
||||
|
||||
bool next_alternative = false;
|
||||
|
||||
for ( TQStringList::ConstIterator it = alt->excludes.begin(); it != alt->excludes.end(); ++it ) {
|
||||
if ( lower_term.find(*it)!=-1 ) {
|
||||
next_alternative = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (next_alternative)
|
||||
continue;
|
||||
|
||||
for ( TQStringList::ConstIterator it = alt->includes.begin(); it != alt->includes.end(); ++it ) {
|
||||
if ( lower_term.find(*it)==-1 ) {
|
||||
next_alternative = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (next_alternative)
|
||||
continue;
|
||||
|
||||
//kdDebug() << "Found hit in '" << term << "'" << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*****************************************************************
|
||||
|
||||
Copyright (c) 2006 Stephan Binner <binner@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifndef QUERY_H
|
||||
#define QUERY_H
|
||||
|
||||
#include <tqstringlist.h>
|
||||
#include <tqptrlist.h>
|
||||
|
||||
class Alternative
|
||||
{
|
||||
public:
|
||||
TQStringList includes;
|
||||
TQStringList excludes;
|
||||
};
|
||||
|
||||
class Query
|
||||
{
|
||||
public:
|
||||
Query();
|
||||
void clear();
|
||||
void set(const TQString &);
|
||||
TQString get() const;
|
||||
bool matches(const TQString &);
|
||||
|
||||
private:
|
||||
TQString query_term;
|
||||
TQPtrList<Alternative> alternatives;
|
||||
|
||||
void add_term();
|
||||
TQString current_part;
|
||||
Alternative *current_alternative;
|
||||
bool within_quotes;
|
||||
bool exclude_part;
|
||||
};
|
||||
|
||||
#endif
|