[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/plasmaboard
From: Björn Ruberg <bjoern () ruberg-wegener ! de>
Date: 2009-08-02 14:58:50
Message-ID: 1249225130.174932.14379.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1005904 by ruberg:
Added a tooltip that displays the last clicked character - like you know it from \
other virtual keyboard (on iPhone for example) Worked on this for ages. Did not found \
a better solution then Plasma::Tooltip, what is not optimal
M +9 -4 AlphaNumKey.cpp
M +10 -1 AlphaNumKey.h
M +1 -0 BoardKey.cpp
M +1 -1 CMakeLists.txt
M +29 -0 widget.cpp
M +10 -1 widget.h
--- trunk/playground/base/plasma/applets/plasmaboard/AlphaNumKey.cpp #1005903:1005904
@@ -21,17 +21,17 @@
//#include "AlphaNumKey.h"
#include <kpushbutton.h>
#include "AlphaNumKey.h"
+#include "widget.h"
AlphaNumKey::AlphaNumKey(PlasmaboardWidget *parent):
BoardKey::BoardKey(parent){
- // TODO Auto-generated constructor stub
QObject::connect(static_cast<const KPushButton*>(this->nativeWidget()), SIGNAL( \
pressed() ), this, SLOT( sendKeycodePress() ) ); QObject::connect(static_cast<const \
KPushButton*>(this->nativeWidget()), SIGNAL( released() ), this, SLOT( \
sendKeycodeRelease() ) ); }
AlphaNumKey::~AlphaNumKey() {
- // TODO Auto-generated destructor stub
+
}
void AlphaNumKey::setKeycode(unsigned int keycodeP) {
@@ -39,6 +39,10 @@
setLabel(0);
}
+void AlphaNumKey::setText(const QString &text){
+ BoardKey::setText(text);
+}
+
void AlphaNumKey::setLabel(int level){
setText(QChar(Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),level))));
}
@@ -55,11 +59,12 @@
/*isAlternative ?
setText(QChar(Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),0)))) :
setText(QChar(Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),0))));*/
- }
+ }
}
void AlphaNumKey::sendKeycodePress() {
- Helpers::fakeKeyPress(getKeycode());
+ emit keySend(text());
+ Helpers::fakeKeyPress(getKeycode());
}
void AlphaNumKey::sendKeycodeRelease() {
--- trunk/playground/base/plasma/applets/plasmaboard/AlphaNumKey.h #1005903:1005904
@@ -22,23 +22,32 @@
#define ALPHANUMKEY_H_
#include "BoardKey.h"
+#include <QString>
class PlasmaboardWidget;
-class QString;
+
class AlphaNumKey: public BoardKey {
+
+ Q_OBJECT
+
public:
AlphaNumKey(PlasmaboardWidget *parent);
virtual ~AlphaNumKey();
void switchKey(bool isLevel2, bool isAlternative, bool isLocked);
void setKeycode(unsigned int keysym);
+ void setText(const QString &text);
void setLabel(int level);
public Q_SLOTS:
virtual void sendKeycodePress();
virtual void sendKeycodeRelease();
+signals:
+ void keySend ( QString text );
+
+
};
#endif /* ALPHANUMKEY_H_ */
--- trunk/playground/base/plasma/applets/plasmaboard/BoardKey.cpp #1005903:1005904
@@ -30,6 +30,7 @@
setMaximumSize(1000,1000);
setMinimumSize(10,10);
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored, \
QSizePolicy::DefaultType); + setZValue(0);
}
BoardKey::~BoardKey() {
--- trunk/playground/base/plasma/applets/plasmaboard/CMakeLists.txt #1005903:1005904
@@ -28,4 +28,4 @@
#install(FILES plasmaboard_key.svg
# DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/)
-
\ No newline at end of file
+
--- trunk/playground/base/plasma/applets/plasmaboard/widget.cpp #1005903:1005904
@@ -32,9 +32,16 @@
#include "ArrowLeftKey.h"
#include "ArrowRightKey.h"
#include <QPainter>
+#include <QGraphicsScene>
+#include <QGraphicsItem>
+#include <QGraphicsWidget>
+#include <QGraphicsLayoutItem>
+#include <QGraphicsLayout>
#include <QGraphicsGridLayout>
#include <KConfigGroup>
+#include <plasma/tooltipmanager.h>
+
#define BACKSPACEKEY 0
#define TABKEY 1
#define ENTERKEY 2
@@ -74,6 +81,12 @@
m_layout = new QGraphicsGridLayout(this);
extendedKeys = false;
basicKeys = false;
+
+ tooltipTimer = new QTimer(this);
+ connect(tooltipTimer, SIGNAL(timeout()), this, SLOT(clearTooltip()));
+
+
+ tooltip.setMainText("Plasmaboard");
}
@@ -267,6 +280,7 @@
while ( i < 48 ) {
alphaKeys[i] = new AlphaNumKey(this);
QObject::connect(alphaKeys[i], SIGNAL( clicked() ), this, SLOT( clear() ) );
+ QObject::connect(alphaKeys[i], SIGNAL( keySend ( QString ) ), this, \
SLOT( setTooltip( QString ) ) ); i++;
}
@@ -469,6 +483,7 @@
}
void PlasmaboardWidget::clear(){
+
bool change = false;
if(isLevel2){
Helpers::fakeKeyRelease(Helpers::keysymToKeycode(XK_Shift_L));
@@ -503,3 +518,17 @@
}
+void PlasmaboardWidget::setTooltip(QString text){
+ if(text != tooltip.mainText()){
+ clearTooltip();
+ tooltip.setMainText(text);
+ Plasma::ToolTipManager::self()->setContent(this, tooltip);
+ }
+ Plasma::ToolTipManager::self()->show(this);
+ tooltipTimer->start(1000);
+}
+
+void PlasmaboardWidget::clearTooltip(){
+ Plasma::ToolTipManager::self()->hide(this);
+ Plasma::ToolTipManager::self()->clearContent(this);
+}
--- trunk/playground/base/plasma/applets/plasmaboard/widget.h #1005903:1005904
@@ -24,6 +24,9 @@
#include "BoardKey.h"
#include <plasma/containment.h>
+#include <plasma/corona.h>
+#include <plasma/tooltipcontent.h>
+#include <QTimer>
#include "Helpers.h"
#define XK_TECHNICAL
@@ -69,11 +72,15 @@
*/
void clearAnything();
+
+
public Q_SLOTS:
void switchLevel();
void switchAlternative();
void switchCaps();
void clear();
+ void setTooltip(QString text);
+ void clearTooltip();
private:
AlphaNumKey *alphaKeys[48]; // normal keys labeled with symbols like a, b, c
@@ -81,10 +88,12 @@
FuncKey *extKeys[42]; // keys only shown in the extended layout as F1, F2,..
bool isLevel2; // second key level activated
bool isAlternative; // alternative key level activated
- bool isLocked; // is lock activated
+ bool isLocked; // is lock activddated
bool basicKeys; // are basic keys displayed
bool extendedKeys; // are extended keys displayed
QGraphicsGridLayout *m_layout;
+ Plasma::ToolTipContent tooltip;
+ QTimer *tooltipTimer;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic