[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/raptor
From: Siraj Razick <siraj () kdemail ! net>
Date: 2006-12-31 19:05:54
Message-ID: 1167591954.715469.1964.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 618262 by siraj:
Ephracis Button port patch
M +2 -8 CMakeLists.txt
M +1 -0 README
M +6 -5 lib/CMakeLists.txt
M +127 -11 lib/raptorbutton.cpp
M +39 -9 lib/raptorbutton.h
--- trunk/playground/base/raptor/CMakeLists.txt #618261:618262
@@ -6,16 +6,10 @@
#set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include_directories( ${CMAKE_SOURCE_DIR}/kicker/applets/raptor/lib )
-#find_package(Qt4 REQUIRED)
-#find_package(KDE4 REQUIRED)
+find_package(Qt4 REQUIRED)
+find_package(KDE4 REQUIRED)
-##################
-# Folloing needed for Strigi to compile
-##################
-#find_package(JStreams REQUIRED)
-#find_package(Strigi REQUIRED)
-
SUBDIRS (lib)
SUBDIRS (menuviz)
--- trunk/playground/base/raptor/README #618261:618262
@@ -27,4 +27,5 @@
Mensur Zahiravic
Phobos Kapa
Nathanael Gogniat
+Christoffer Brodd-Reijer
TODO: who else likes to join?
--- trunk/playground/base/raptor/lib/CMakeLists.txt #618261:618262
@@ -2,15 +2,16 @@
set(plasmicraptor_LIB_SRCS
raptorbutton.cpp)
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} \
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
-kde4_automoc(${plasmicraptor_LIB_SRCS})
+KDE4_AUTOMOC(${plasmicraptor_LIB_SRCS})
-kde4_add_library(plasmicraptor SHARED ${plasmicraptor_LIB_SRCS})
+KDE4_ADD_LIBRARY(plasmicraptor SHARED ${plasmicraptor_LIB_SRCS})
-target_link_libraries(plasmicraptor kickermain konq ${KDE4_KDEUI_LIBS} \
${KDE4_KIO_LIBS} ${KDE4_KUTILS_LIBS} ) +TARGET_LINK_LIBRARIES( plasmicraptor \
kickermain konq ${QT_AND_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} \
${KDE4_KUTILS_LIBS} )
-set_target_properties(plasmicraptor PROPERTIES VERSION 1.0.0 SOVERSION 1 )
-install(TARGETS plasmicraptor DESTINATION ${LIB_INSTALL_DIR} )
+SET_TARGET_PROPERTIES(plasmicraptor PROPERTIES VERSION 1.0.0 SOVERSION 1 )
+INSTALL(TARGETS plasmicraptor DESTINATION ${LIB_INSTALL_DIR} )
########### install files ###############
--- trunk/playground/base/raptor/lib/raptorbutton.cpp #618261:618262
@@ -1,40 +1,156 @@
-//Qt
+/* Qt includes */
#ifdef Q_WS_X11
#include <QPaintDevice>
+#include <QPixmap.h>
+#include <QEvent.h>
+#include <QMouseEvent.h>
+#include <QPaintEvent.h>
+#include <QLabel.h>
#endif
-//KDE
+/* KDE includes */
#include "raptorbutton.h"
#include "raptorbutton.moc"
RaptorButton::RaptorButton(QWidget * parent, Qt::WindowFlags l ):QLabel(parent,l)
{
- setScreen(getCurrentScreen());
- setAcceptDrops(true); //support drag and drop of Button Skin Images
+ setScreen(getCurrentScreen());
+ setAcceptDrops(true); //support drag and drop of Button Skin Images
+ loadSkins();
+ m_toogle = false;
}
RaptorButton::~RaptorButton()
{
+}
+/* public */
+
+void RaptorButton::setImage(QPixmap pix, int screen)
+{
}
+void RaptorButton::enableButtonGlow(bool choice)
+{
+}
+
void RaptorButton::setScreen(int screen)
{
m_screen = screen;
}
+void RaptorButton::readConfig()
+{
+ ConfigInit().read();
+ ConfigInit().confskel->readConfig();
+}
-int RaptorButton::getCurrentScreen()
+void RaptorButton::loadSkin()
{
-#ifdef Q_WS_X11
-//TODO
-return QPaintDevice::x11AppScreen ();
-#endif
-return 0;
}
-//slot
+/* events */
+virtual void RaptorButton::paintEvent(QPaintEvent *pe)
+{
+ QPainter p;
+ if (!m_current_skin.isNull())
+ {
+ static const QRect r = QRect(pe->rect().x(), pe->rect().y(), m_current_skin.width, \
m_current_skin.height()); +
+ m_buffer = new QPixmap();
+ m_buffer->resize(r.size());
+ m_buffer->fill(this, r.topLeft());
+
+ p.begin(m_buffer, this);
+ p.translate(-r.x(), -r.y());
+ p.drawPixmap(r, m_current_skin);
+ p.end();
+
+ bitBlt(this, r.x(), r.y(), m_buffer, 0, 0, m_current_skin.width(), \
m_current_skin.height()); + delete m_buffer;
+ }
+}
+
+virtual void RaptorButton::enterEvent(QEvent *e)
+{
+ if (m_toogle)
+ m_current_skin = m_pressed_skin;
+ else
+ m_current_skin = m_hover_skin;
+
+ this->resize(m_current_skin.size());
+ this->update();
+}
+
+virtual void RaptorButton::leaveEvent(QEvent *e)
+{
+ if (m_toogle)
+ m_current_skin = m_pressed_skin;
+ else
+ m_current_skin = m_normal_skin;
+
+ this->resize(m_current_skin.size());
+ this->update();
+}
+
+virtual void RaptorButton::mousePressEvent(QMouseEvent *me)
+{
+ if (m_toogle)
+ {
+ m_current_skin = m_pressed_skin;
+ m_toogle = false;
+ this->resize(m_current_skin.size());
+ this->update();
+
+ emit hideMenu();
+ }
+ else
+ {
+ m_current_skin = m_pressed_skin;
+ m_toogle = true;
+ this->resize(m_current_skin.size());
+ this->update();
+
+ if (e->button() == Qt::LeftButton)
+ emit pressed();
+ }
+}
+
+/* public slots */
void RaptorButton::desktopChanged()
{
setScreen(getCurrentScreen());
}
+
+void RaptorButton::loadSkins()
+{
+ this->readConfig();
+ m_hover_skin = QPixmap(ConfigInit().m_RaptorHoverButtonPath);
+ m_pressed_skin = QPixmap(ConfigInit().m_RaptorPressedButtonPath);
+ m_normal_skin = QPixmap(ConfigInit().m_RaptorNormalButtonPath);
+ m_current_skin = m_normal_skin;
+
+ qDebug("Loaded skin: " + ConfigInit().m_RaptorNormalButtonPath);
+
+ this->resize(m_current_skin.width(), m_current_skin.height());
+ this->repaint();
+}
+
+void RaptorButton::toogle()
+{
+ m_current_skin = m_normal_skin;
+ this->resize(m_current_skin.size());
+ this->update();
+ if (!hasMouse())
+ m_toogle = false;
+}
+
+/* protected */
+int RaptorButton::getCurrentScreen()
+{
+ #ifdef Q_WS_X11
+ //TODO
+ return QPaintDevice::x11AppScreen ();
+ #endif
+ return 0;
+}
--- trunk/playground/base/raptor/lib/raptorbutton.h #618261:618262
@@ -9,31 +9,61 @@
class QWidget;
class QLabel;
+/*
+ * The menu button
+ *
+ * The button can have settings per desktop view.
+ */
class RaptorButton:public QLabel
{
Q_OBJECT
public:
RaptorButton(QWidget * parent = 0, Qt::WindowFlags f = 0);
~RaptorButton();
- /**
- * The button can have settings per desktop view.
- *
- * @param The screen number
- */
+ void setImage(QPixmap pix, int screen);
+ void enableButtonGlow(bool choice);
void setScreen(int screen);
+ void readConfig();
+ void loadSkin();
+
+ // events
+ virtual void paintEvent(QPaintEvent *pe);
+ virtual void enterEvent(QEvent *e);
+ virtual void leaveEvent(QEvent *e);
+ virtual void mousePressEvent(QMouseEvent *me);
+
public slots:
void desktopChanged();
+ void loadSkins();
+ void toogle();
+
+signals:
+ void pressed();
+ void hideMenu();
protected:
int getCurrentScreen();
+ // skin
+ QPixmap m_hover_skin;
+ QPixmap m_pressed_skin;
+ QPixmap m_normal_skin;
+ QPixmap m_current_skin;
+ QPixmap m_release_skin;
+
+ QString m_hover_path;
+ QString m_pressed_path;
+ QString m_normal_path;
+
+ QPixmap m_buffer;
+
+ // state of the button
+ bool m_toogle;
+
private:
-
int m_screen;
-
};
-#endif //RAPTOR_BUTTON_H
-
+#endif // RAPTOR_BUTTON_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic