[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-04-11 11:51:40
Message-ID: 1239450700.663017.22603.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 952198 by ruberg:

You can now switch between the basic keyboard and the extended keyboard



 M  +35 -4     PanelIcon.cpp  
 M  +7 -1      PanelIcon.h  
 M  +50 -18    widget.cpp  
 M  +3 -0      widget.h  


--- trunk/playground/base/plasma/applets/plasmaboard/PanelIcon.cpp #952197:952198
@@ -26,11 +26,12 @@
 	{
 		setAspectRatioMode(Plasma::IgnoreAspectRatio);
 		setPopupIcon("preferences-desktop-keyboard");
-
+		extendedMode = false;
 }
 
 void PanelIcon::init(){
 	setPassivePopup(true);
+
 	/*Plasma::ExtenderItem *eItem = new Plasma::ExtenderItem(extender());
 	extender()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
 
@@ -39,11 +40,35 @@
 	*/
 }
 
+void PanelIcon::toggleMode(){
+	if(contextSwitcher != NULL){
+		delete contextSwitcher;
+	}
+	if(!extendedMode){
+		contextSwitcher = new QAction(i18n("Switch to basic mode"), this);
+		if(m_plasmaboard != NULL){
+			m_plasmaboard->resetKeyboard();
+			m_plasmaboard->initExtendedKeyboard();
+		}
+		extendedMode = true;
+	}
+	else{
+		contextSwitcher = new QAction(i18n("Switch to extended mode"), this);
+		if(m_plasmaboard != NULL){
+			m_plasmaboard->resetKeyboard();
+			m_plasmaboard->initBasicKeyboard();
+		}
+		extendedMode = false;
+	}
+	connect(contextSwitcher, SIGNAL(triggered(bool)), this, SLOT(toggleMode()));
+}
+
 QGraphicsWidget *PanelIcon::graphicsWidget()
 {
-  if (!m_plasmaboard) {
-      m_plasmaboard = new PlasmaboardWidget(this);
-  }
+	if (!m_plasmaboard) {
+		m_plasmaboard = new PlasmaboardWidget(this);
+		toggleMode();
+	}
     return m_plasmaboard;
 }
 
@@ -55,7 +80,13 @@
 	}
 }*/
 
+QList<QAction*> PanelIcon::contextualActions(){
+	QList<QAction*> list;
+	list.append(contextSwitcher);
+	return list;
+}
 
+
 PanelIcon::~PanelIcon() {
 
 }
--- trunk/playground/base/plasma/applets/plasmaboard/PanelIcon.h #952197:952198
@@ -24,6 +24,7 @@
 #include <Plasma/PopupApplet>
 #include <Plasma/Extender>
 #include <Plasma/ExtenderItem>
+#include <QAction>
 
 #include "widget.h"
 
@@ -34,14 +35,19 @@
 	virtual ~PanelIcon();
 	void init();
 	QGraphicsWidget *graphicsWidget();
+	QList<QAction*> contextualActions();
 
+
 public Q_SLOTS:
 	//void initBatteryExtender(Plasma::ExtenderItem *item);
+	void toggleMode();
 
 private:
-	QGraphicsWidget *m_plasmaboard;
+	PlasmaboardWidget *m_plasmaboard;
 	const QVariantList args;
 	Plasma::ExtenderItem *eItem;
+	QAction *contextSwitcher;
+	bool extendedMode;
 
 };
 
--- trunk/playground/base/plasma/applets/plasmaboard/widget.cpp #952197:952198
@@ -44,35 +44,63 @@
 	isAlternative = false;
 	isLocked = false;
 	m_layout = new QGraphicsGridLayout(this);
+	extendedKeys = false;
+	basicKeys = false;
 
-	initExtendedKeyboard();
+	//initBasicKeyboard();
 }
 
 
 PlasmaboardWidget::~PlasmaboardWidget(){
 
-	int i = 0;
-	while ( i < 14 ) {
-		delete funcKeys[i];
-		i++;
+}
+
+void PlasmaboardWidget::init(){
+
+}
+
+void PlasmaboardWidget::resetKeyboard(){
+
+	int i = m_layout->count() - 1;
+	while(i >= 0){
+		m_layout->removeAt(i--);
 	}
 
 	i = 0;
-	while ( i < 48 ) {
-		delete alphaKeys[i];
-		i++;
+
+	if( basicKeys ){
+
+		while ( i < 14 ) {
+			delete funcKeys[i];
+			i++;
+		}
+
+		i = 0;
+		while ( i < 48 ) {
+			delete alphaKeys[i];
+			i++;
+		}
+		basicKeys = false;
 	}
-}
 
-void PlasmaboardWidget::init(){
-
+	i = 0;
+	if( extendedKeys ) {
+		while ( i < 26 ) {
+			delete extKeys[i];
+			i++;
+		}
+		extendedKeys = false;
+	}
 }
 
 void PlasmaboardWidget::initExtendedKeyboard(){
 
+	extendedKeys = true;
+
 	int i = 0;
 	while ( i < 26 ) {
 		extKeys[i] = new FuncKey(this);
+		QObject::connect(extKeys[i], SIGNAL( clicked() ), this, SLOT( clear() ) );
 		i++;
 	}
 
@@ -174,6 +202,8 @@
 
 void PlasmaboardWidget::initBasicKeyboard(int offset){
 
+	basicKeys = true;
+
 	// create objects
 	int i = 0;
 	while ( i < 14 ) {
@@ -241,17 +271,19 @@
 
 	for(int i = 0; i<numberOfCols; i++){
 		m_layout->setColumnPreferredWidth(i,width/numberOfCols);
-	}/*
-	for(int i = 0; i<numberOfRows; i++){
-		m_layout->setRowPreferredHeight(i,height/numberOfRows);
-		m_layout->setRowMaximumHeight(i,100);
-	}*/
+	}
 
+
+	m_layout->setColumnPreferredWidth(30,0);
+	m_layout->setColumnPreferredWidth(31,0);
+	m_layout->setColumnPreferredWidth(32,0);
+	m_layout->setColumnPreferredWidth(33,0);
+	m_layout->setColumnPreferredWidth(34,0);
+
+
 	m_layout->setSpacing(0);
 	m_layout->setContentsMargins(0,0,0,0);
 
-	setLayout(m_layout);
-
 	// set Keymap
 
 	alphaKeys[0]->setKeycode(49);
--- trunk/playground/base/plasma/applets/plasmaboard/widget.h #952197:952198
@@ -52,6 +52,7 @@
         void init();
         void initBasicKeyboard(int offset=0);
         void initExtendedKeyboard();
+        void resetKeyboard();
 
     public Q_SLOTS:
         void switchLevel();
@@ -66,6 +67,8 @@
 		bool isLevel2;
 		bool isAlternative;
 		bool isLocked;
+		bool basicKeys;
+		bool extendedKeys;
 		QGraphicsGridLayout *m_layout;
 
 		int width;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic