[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/kittenapplet/src
From: Jos van den Oever <jos () vandenoever ! info>
Date: 2006-06-14 21:58:13
Message-ID: 1150322293.460661.28917.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 551535 by vandenoever:
improvements to the kicker applet mouseover and key behavior
M +0 -4 jstream/Makefile.am
M +14 -5 kickerapplet/hitsview.cpp
M +1 -0 kickerapplet/hitsview.h
M +10 -11 kickerapplet/kittenlineedit.cpp
M +2 -1 kickerapplet/kittenlineedit.h
--- trunk/playground/base/kittenapplet/src/jstream/Makefile.am #551534:551535
@@ -13,8 +13,4 @@
$(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
$(XGETTEXT) *.cpp -o $(podir)/kio_jstream.pot
-noinst_PROGRAMS = kio_jstream_test
-kio_jstream_test_SOURCES = kio_jstream_test.cpp
-kio_jstream_test_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
-kio_jstream_test_LDADD = -lstreams -lkio
--- trunk/playground/base/kittenapplet/src/kickerapplet/hitsview.cpp #551534:551535
@@ -1,6 +1,7 @@
#include "hitsview.h"
#include <qlabel.h>
#include <qtimer.h>
+#include <qmessagebox.h>
#include "kittenlineedit.h"
HitsView::HitsView(KittenLineEdit* p) : QPopupMenu(p), parent(p) {
@@ -15,16 +16,24 @@
QPoint pp(parent->mapToGlobal(QPoint(0, 0)));
pp.setY(pp.y()-height());
QPopupMenu::move(pp);
- pp = QPoint(parent->mapToGlobal(QPoint(0, 0)));
- pp.setY(pp.y()-height());
- QPopupMenu::move(pp);
}
void
-HitsView::enterEvent(QEvent* e) {
+HitsView::enterEvent(QEvent*) {
hasmouse = true;
}
void
-HitsView::leaveEvent(QEvent* e) {
+HitsView::leaveEvent(QEvent*) {
hasmouse = false;
QTimer::singleShot( 200, parent, SLOT(hideMenu()) );
}
+void
+HitsView::keyPressEvent(QKeyEvent *e) {
+ if (count()
+ && ((e->key() == Qt::Key_Up && isItemActive(0))
+ || (e->key() == Qt::Key_Down && isItemActive(count()-1)))) {
+ setActiveItem(-1);
+ parent->setFocus();
+ return;
+ }
+ QPopupMenu::keyPressEvent(e);
+}
--- trunk/playground/base/kittenapplet/src/kickerapplet/hitsview.h #551534:551535
@@ -13,6 +13,7 @@
void showEvent(QShowEvent *);
void enterEvent(QEvent* e);
void leaveEvent(QEvent* e);
+ void keyPressEvent(QKeyEvent *e);
public:
HitsView(KittenLineEdit*);
bool hasMouse() const { return hasmouse; }
--- trunk/playground/base/kittenapplet/src/kickerapplet/kittenlineedit.cpp #551534:551535
@@ -93,23 +93,24 @@
menu->clear();
int last = (hits.hits.size() > 10) ? 10 : hits.hits.size();
- for (int i = last-1; i >= 0; --i) {
- addHit(hits.hits[i]);
+ for (int i = 0; i < last; ++i) {
+ HitMenuItem* hit = createHit(hits.hits[i]);
+ menu->insertItem(hit, i, i);
+ menu->connectItem( i, hit, SLOT(open()) );
}
if (last) {
if (menu->isVisible()) {
- menu->move();
- } else {
- menu->popup(QPoint(0, 0));
- setFocus();
+ menu->hide();
}
+ menu->popup(QPoint(0, 0));
+ setFocus();
} else {
menu->hide();
}
}
-void
-KittenLineEdit::addHit(const jstreams::IndexedDocument& hit) {
+HitMenuItem*
+KittenLineEdit::createHit(const jstreams::IndexedDocument& hit) const {
// get the appropriate icon
QString iconname = KMimeType::mimeType(hit.mimetype.c_str())->icon(QString::null,0);
QPixmap icon = kitteniconloader.loadIcon(iconname, KIcon::Panel);
@@ -127,7 +128,5 @@
name = hit.uri.substr(pos+1);
}
}
- HitMenuItem* item = new HitMenuItem(icon, name, hit.uri);
- int id = menu->insertItem(item);
- menu->connectItem( id, item, SLOT(open()) );
+ return new HitMenuItem(icon, name, hit.uri);
}
--- trunk/playground/base/kittenapplet/src/kickerapplet/kittenlineedit.h #551534:551535
@@ -8,6 +8,7 @@
class HitsView;
class QLineEdit;
class KPopupMenu;
+class HitMenuItem;
class KittenLineEdit : public QLineEdit {
Q_OBJECT
private:
@@ -18,7 +19,7 @@
const KIconLoader kitteniconloader;
private:
- void addHit(const jstreams::IndexedDocument& hit);
+ HitMenuItem* createHit(const jstreams::IndexedDocument& hit) const;
private slots:
void openQuery();
void slotTextChanged();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic