author | drw <drw> | 2005-06-04 00:13:32 (UTC) |
---|---|---|
committer | drw <drw> | 2005-06-04 00:13:32 (UTC) |
commit | c220c5e580c3cd0e16cf9a7c252a0f66b7034d02 (patch) (side-by-side diff) | |
tree | feec669d11c40c6f66fef806e42df0fdad4f6d5d | |
parent | 0fcaa971ee658effa1dc36205df6dfbc43a6b0ad (diff) | |
download | opie-c220c5e580c3cd0e16cf9a7c252a0f66b7034d02.zip opie-c220c5e580c3cd0e16cf9a7c252a0f66b7034d02.tar.gz opie-c220c5e580c3cd0e16cf9a7c252a0f66b7034d02.tar.bz2 |
Resource -> OResource, fix couple compile warnings and add .cvsignore files
8 files changed, 24 insertions, 12 deletions
diff --git a/noncore/applets/keyhelper/.cvsignore b/noncore/applets/keyhelper/.cvsignore new file mode 100644 index 0000000..9f2b524 --- a/dev/null +++ b/noncore/applets/keyhelper/.cvsignore @@ -0,0 +1,5 @@ +Makefile* +moc* +.moc* +.obj +.moc diff --git a/noncore/applets/keyhelper/keyhelperapplet/.cvsignore b/noncore/applets/keyhelper/keyhelperapplet/.cvsignore new file mode 100644 index 0000000..9f2b524 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/.cvsignore @@ -0,0 +1,5 @@ +Makefile* +moc* +.moc* +.obj +.moc diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp index 3c2298e..fc02862 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp @@ -1,94 +1,88 @@ #include "AnyLnk.h" #include "KHUtil.h" void AnyLnk::loadPixmap() { if(m_params.count() >= 3){ - QString& str = m_params[2]; - QImage image = Resource::loadImage(str); - if(image.isNull() == false){ - const QSize& size = AppLnkManager::getIconSize(); - m_pixmap.convertFromImage( - image.smoothScale(size.width(), size.height()) ); - } + m_pixmap = Opie::Core::OResource::loadPixmap( m_params[2], Opie::Core::OResource::SmallIcon ); } } void AnyLnk::parseText() { if(m_params.count() >= 2){ QString& str = m_params[1]; if(str != QString::null && str.length() > 0){ replaceKeyword(str); replaceDate(str); } } } void AnyLnk::replaceText(QString& str, const QString& s1, const QString& s2) { int index = 0; int idx; int len = s1.length(); idx = str.find(s1, index); for(;;){ idx = str.find(s1, index); if(idx < 0) break; str.replace(idx, len, s2); index = idx; } } void AnyLnk::replaceDate(QString& str) { time_t t; struct tm lct; char buf[4096]; int nLen; QString group; t = ::time(NULL); ::localtime_r(&t, &lct); ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); group = cfg.getGroup(); cfg.setGroup("Global"); QString charset = cfg.readEntry("SystemCharSet", "eucJP"); if(charset.length() == 0){ charset = "eucJP"; } cfg.setGroup(group); QTextCodec* codec = QTextCodec::codecForName(charset); if(codec == NULL){ codec = QTextCodec::codecForLocale(); } QTextDecoder* decoder = codec->makeDecoder(); QTextEncoder* encoder = codec->makeEncoder(); nLen = str.length(); QCString localeString = encoder->fromUnicode(str, nLen); memset(buf, '\0', sizeof(buf)); int n = ::strftime(buf, sizeof(buf), localeString, &lct); if(n > 0){ str = decoder->toUnicode(buf, n); } delete decoder; delete encoder; } void AnyLnk::replaceKeyword(QString& str) { QString txt; /* clipboard text */ QClipboard* cb = QApplication::clipboard(); if(cb == NULL){ txt == ""; } else { txt = cb->text(); } replaceText(str, "%clipboard%", txt); /* current app */ txt = KHUtil::currentApp(); replaceText(str, "%currentapp%", txt); } diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h index 9853942..d170e6d 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h @@ -1,45 +1,46 @@ #ifndef _ANYLNK_H_ #define _ANYLNK_H_ #include <time.h> #include <qstring.h> #include <qstringlist.h> #include <qpixmap.h> #include <qimage.h> #include <qclipboard.h> #include <qtextcodec.h> #include <qpe/qpeapplication.h> -#include <qpe/resource.h> + +#include <opie2/oresource.h> #include "AppLnkManager.h" #include "ConfigEx.h" class AnyLnk { public: AnyLnk(){} AnyLnk(const QStringList& params){ m_params = params; loadPixmap(); } virtual ~AnyLnk(){ } virtual bool isValid() = 0; virtual void execute() = 0; virtual QString name() = 0; virtual const QPixmap& pixmap() = 0; protected: QStringList m_params; QPixmap m_pixmap; virtual void loadPixmap(); virtual void parseText(); virtual void replaceText(QString& str, const QString& s1, const QString& s2); virtual void replaceDate(QString& str); virtual void replaceKeyword(QString& str); }; #endif /* _ANYLNK_H_ */ diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp index 1c3dbfe..dc6dd77 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp @@ -1,43 +1,43 @@ #ifndef _APPLNK_WRAPPER_H_ #define _APPLNK_WRAPPER_H_ #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include "AnyLnk.h" class AppLnkWrapper : public AnyLnk { public: AppLnkWrapper(){} AppLnkWrapper(const QStringList& params) : AnyLnk(params) { m_pLnk = new AppLnk(QPEApplication::qpeDir() + "apps/" + m_params[0] + ".desktop"); } virtual ~AppLnkWrapper(){ delete m_pLnk; } virtual bool isValid() { return(m_pLnk->isValid()); } virtual void execute(){ parseText(); m_pLnk->execute(m_params[1]); } virtual QString name() { return(m_pLnk->name()); } virtual const QPixmap& pixmap(){ if(m_pixmap.isNull()){ return(m_pLnk->pixmap()); } else { return(m_pixmap); } } protected: AppLnk* m_pLnk; }; -#endif /* _APPLNK_WRAPPER_H_ */
\ No newline at end of file +#endif /* _APPLNK_WRAPPER_H_ */ diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp index 7beb511..9fac51b 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp @@ -1,489 +1,489 @@ #include "KeyHelperWidget.h" #include "QSafeDataStream.h" #include "KHUtil.h" QWidget* g_Widget = NULL; int g_level = 0; static const char* _version_ = "1.2.2"; KeyHelperWidget::KeyHelperWidget(QWidget* parent, const char* name) - : QLabel(parent, name),disabled(Resource::loadPixmap("zkb-disabled")) + : QLabel(parent, name),disabled(Opie::Core::OResource::loadPixmap("zkb-disabled")) { qDebug("KeyHelperWidget::KeyHelperWidget()"); g_Widget = this; m_defHandler = NULL; //m_reset = false; m_reset = true; m_useFilter = false; m_pHelper = NULL; m_status = false; //unset(); initDebugLevel(); m_pHelper = new KeyHelper(); //qApp->installEventFilter(this); connect(qwsServer, SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), this, SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); m_pChannel = new QCopChannel("QPE/KeyHelper", this); connect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receiveMessage(const QCString&, const QByteArray&))); m_pSysChannel = new QCopChannel("QPE/System", this); connect(m_pSysChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(sysMessage(const QCString&, const QByteArray&))); //AppLnkManager::init(); setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize() ); setPixmap(disabled); init(); } KeyHelperWidget::~KeyHelperWidget() { qDebug("KeyHelperWidget::~KeyHelperWidget()"); disconnect(qwsServer, SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), this, SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); disconnect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receiveMessage(const QCString&, const QByteArray&))); unset(); if (m_pHelper) delete m_pHelper; if (m_pChannel) delete m_pChannel; if (m_pSysChannel) delete m_pSysChannel; m_pHelper = NULL; setDebugLevel(0); } void KeyHelperWidget::mouseReleaseEvent(QMouseEvent*) { ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); } void KeyHelperWidget::receiveMessage( const QCString& msg, const QByteArray& data) { if(m_pHelper == NULL){ return; } QSafeDataStream stream(data, IO_ReadOnly); if(msg == "event(int,int,int,int,int)"){ int unicode; int keycode; int modifiers; int isPress; int autoRepeat; stream >> unicode >> keycode >> modifiers >> isPress >> autoRepeat; doEvent(unicode, keycode, modifiers, isPress, autoRepeat); } else if(msg == "event(QString,int)"){ QString key; int isPress; stream >> key >> isPress; doEvent(key, isPress); } else if(msg == "enable()"){ enable(); } else if(msg == "disable()"){ disable(); } else if(msg == "pause()"){ pause(); } else if(msg == "restart()"){ restart(); } else if(msg == "reload()"){ m_xmlfile = QString::null; doReload(); } else if(msg == "reload(QString)"){ stream >> m_xmlfile; doReload(false); } else if(msg == "version()"){ version(); } else if(msg == "repeater(int)"){ int mode; stream >> mode; m_pHelper->m_oRepeater.setMode(mode); } else if(msg == "hook(QString)"){ QString s; stream >> s; m_pHelper->m_oAction.setHook(s.local8Bit()); } else if(msg == "unhook()"){ m_pHelper->m_oAction.setHook(""); } else if(msg == "config()"){ ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); } else if(msg == "config(QString)"){ QString name; stream >> name; if(name == QString::null){ ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); } else { ConfigEx::getInstance("keyhelper").setConfig(name); } } else if(msg == "capture(int)"){ int enable; stream >> enable; m_pHelper->m_oAction.setCapture(enable); } else if(msg == "statistics()"){ int level = g_level; if(level == 0){ setDebugLevel(1); } m_pHelper->statistics(); if(level == 0){ setDebugLevel(0); } } else if(msg == "dumpkeymap()"){ int level = g_level; if(level == 0){ setDebugLevel(1); } m_pHelper->dumpkeymap(); if(level == 0){ setDebugLevel(0); } } else if(msg == "debug(int)"){ int level; stream >> level; setDebugLevel(level); } } void KeyHelperWidget::doReload(bool showstatus) { ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); QString oldgroup = cfg.getGroup(); cfg.setGroup("Global"); m_status = false; if(showstatus && (cfg.readNumEntry("ShowStatusOnReload", 1) == 1)){ m_status = true; version(); QCopEnvelope("QPE/System", "busy()"); } cfg.setGroup(oldgroup); QTimer::singleShot(0, this, SLOT(reload())); } void KeyHelperWidget::doEvent(int unicode, int keycode, int modifiers, int isPress, int autoRepeat) { if(isPress == 0 || isPress == 1){ m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, isPress, autoRepeat); m_pHelper->m_oAction.doAction(); } else { /* press & release */ m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 1, autoRepeat); m_pHelper->m_oAction.doAction(); m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 0, autoRepeat); m_pHelper->m_oAction.doAction(); } } void KeyHelperWidget::doEvent(const QString& key, int isPress) { int unicode,keycode; int modifiers = 0; int pos; QString keyname = key; pos = keyname.find("+SHIFT", 0, FALSE); if(pos > 0){ modifiers |= Qt::ShiftButton; keyname.remove(pos, 6); } pos = keyname.find("+CTRL", 0, FALSE); if(pos > 0){ modifiers |= Qt::ControlButton; keyname.remove(pos, 5); } pos = keyname.find("+ALT", 0, FALSE); if(pos > 0){ modifiers |= Qt::AltButton; keyname.remove(pos, 4); } if(keyname.length() > 1){ unicode = 0xffff; keycode = KeyNames::getCode(keyname); /* get unicode */ const QWSServer::KeyMap* m; for(m=QWSServer::keyMap(); m->key_code != 0; m++){ if(m->key_code == keycode){ if(modifiers & Qt::ControlButton){ unicode = m->ctrl_unicode; } else if(modifiers & Qt::ShiftButton){ unicode = m->shift_unicode; } else { unicode = m->unicode; } break; } } } else { const QWSServer::KeyMap* m; keycode = 0; unicode = keyname[0].unicode(); /* check unicode */ for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ if(m->unicode == unicode){ keycode = m->key_code; break; } } /* check shift_unicode */ for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ if(m->shift_unicode == unicode){ keycode = m->key_code; modifiers |= Qt::ShiftButton; break; } } /* check ctrl_unicode */ for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ if(m->ctrl_unicode == unicode){ keycode = m->key_code; modifiers |= Qt::ControlButton; break; } } } doEvent(unicode, keycode, modifiers, isPress, 0); } void KeyHelperWidget::sysMessage( const QCString& msg, const QByteArray& data) { QSafeDataStream stream(data, IO_ReadOnly); if(msg == "linkChanged(QString)"){ ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); QString oldgroup = cfg.getGroup(); if(cfg.readNumEntry("DetectLinkChange", 1) == 1){ AppLnkManager::init(true); reload(); } cfg.setGroup(oldgroup); } } void MsgHandler(QtMsgType type, const char* msg) { switch(type){ case QtDebugMsg: if(g_level >= 2){ syslog(LOG_LOCAL5|LOG_DEBUG, "<2>%s", msg); } break; case QtWarningMsg: if(g_level >= 1){ syslog(LOG_LOCAL5|LOG_DEBUG, "<1>%s", msg); } break; default: break; } } void KeyHelperWidget::initDebugLevel() { ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); cfg.setGroup("Global"); int level = cfg.readNumEntry("DebugLevel", 0); setDebugLevel(level); } -void KeyHelperWidget::setDebugLevel(int level) +void KeyHelperWidget::setDebugLevel(int /*level*/) { #ifdef QT_QWS_EBX static bool noDebug = true; g_level = level; if(g_level > 0){ if(noDebug){ m_defHandler = qInstallMsgHandler(MsgHandler); noDebug = false; } } else { qInstallMsgHandler(m_defHandler); noDebug = true; } #endif } void KeyHelperWidget::enable() { m_enable = true; m_pHelper->enable(); //set(); QTimer::singleShot(0, this, SLOT(set())); } void KeyHelperWidget::disable() { m_enable = false; m_pHelper->disable(); unset(); } void KeyHelperWidget::pause() { m_saved = m_enable; disable(); } void KeyHelperWidget::restart() { if(m_saved){ enable(); } } void KeyHelperWidget::reload() { disable(); ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); cfg.reload(); if(m_pHelper->reload(m_xmlfile) == false){ if(m_status){ Global::statusMessage("KeyHelper: Load Error"); } } init(); if(m_status){ QCopEnvelope e("QPE/System", "notBusy(QString)"); const QString app = KHUtil::currentApp(); e << app; m_status = false; } } void KeyHelperWidget::version() { QString ver = "KeyHelper "; ver.append(_version_); Global::statusMessage(ver); } void KeyHelperWidget::init() { AppLnkManager::init(); #if 0 if(m_pHelper == NULL){ m_pHelper = new KeyHelper(); } #endif loadUseFilterApps(); enable(); } void KeyHelperWidget::set() { if(m_pHelper != NULL && m_enable == true && m_useFilter == false){ qWarning("KeyHelperWidget::set()"); m_pHelper->set(); } } void KeyHelperWidget::unset() { m_pHelper->unset(); } void KeyHelperWidget::loadUseFilterApps() { ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); cfg.setGroup("Global"); m_apps = cfg.readListEntry("UseFilterApps", ','); if(m_apps.isEmpty()){ /* default */ m_apps.append("CRIM"); m_apps.append("Jpn50Pad"); m_apps.append("JpnKtnPad"); m_apps.append("JpnNumPad"); m_apps.append("JpnSymPad"); m_apps.append("Keyboard"); m_apps.append("IMWidget"); /* IMKit */ m_apps.append("POBox"); /* QPOBox */ } } #if 0 void KeyHelperWidget::windowEvent(QWSWindow* w, QWSServer::WindowEvent e) { if(m_apps.contains(w->name())){ switch(e){ case QWSServer::Hide: case QWSServer::Destroy: m_useFilter = false; //m_reset = true; QTimer::singleShot(0, this, SLOT(set())); break; case QWSServer::Create: case QWSServer::Raise: case QWSServer::Show: m_useFilter = true; //m_reset = false; m_reset = true; break; default: break; } } else if(w->client()->identity() != NULL && w->name() != NULL){ switch(e){ #if 0 case QWSServer::Create: case QWSServer::Hide: if(m_useFilter == false && m_reset){ m_reset = false; set(); //QTimer::singleShot(0, this, SLOT(set())); } break; #else case QWSServer::Hide: case QWSServer::Destroy: //if(m_useFilter == false && m_reset){ if(m_reset){ m_reset = false; set(); //QTimer::singleShot(0, this, SLOT(set())); } break; case QWSServer::Create: case QWSServer::Raise: case QWSServer::Show: m_reset = true; break; #endif default: #if 0 if(m_reset == true){ m_reset = false; set(); } #endif break; } } if(w->name() != NULL){ qWarning("[%s][%s][%x][%s]", w->name().latin1(), w->caption().latin1(), e, w->client()->identity().latin1()); } } #endif bool KeyHelperWidget::eventFilter(QObject* o, QEvent* e) { return QWidget::eventFilter(o, e); } int KeyHelperWidget::position() { return 3; diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h index 4798c5c..0901081 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h @@ -1,75 +1,75 @@ #ifndef _KEY_HELPER_WIDGET_H_ #define _KEY_HELPER_WIDGET_H_ #include <qwidget.h> #include <qlabel.h> #include <qpixmap.h> #include <qtimer.h> #include <qaccel.h> #include <opie2/otaskbarapplet.h> #include <opie2/okeyfilter.h> +#include <opie2/oresource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include <qpe/global.h> -#include <qpe/resource.h> #include "KeyHelper.h" #include "AppLnkManager.h" #include "ConfigEx.h" #include <syslog.h> Q_EXPORT void MsgHandler(QtMsgType type, const char* msg); class KeyHelperWidget : public QLabel { Q_OBJECT public: KeyHelperWidget(QWidget* parent = 0, const char* name=0); ~KeyHelperWidget(); static int position(); virtual bool eventFilter(QObject* o, QEvent* e); public slots: //void windowEvent(QWSWindow* w, QWSServer::WindowEvent e); protected: QCopChannel* m_pChannel; QCopChannel* m_pSysChannel; QPixmap disabled; protected slots: void receiveMessage(const QCString& msg, const QByteArray& data); void sysMessage(const QCString& msg, const QByteArray& data); void reload(); void set(); void unset(); void init(); void mouseReleaseEvent(QMouseEvent*); private: void loadUseFilterApps(); void enable(); void disable(); void pause(); void restart(); void version(); void setDebugLevel(int level); void initDebugLevel(); bool m_reset; bool m_useFilter; bool m_status; QString m_xmlfile; msg_handler m_defHandler; bool m_enable; bool m_saved; QStringList m_apps; KeyHelper* m_pHelper; private slots: void doReload(bool showstatus=true); void doEvent(int,int,int,int,int); void doEvent(const QString&, int); }; #endif /* _KEY_HELPER_WIDGET_H_ */ diff --git a/noncore/applets/keyhelper/keyhelperconf/.cvsignore b/noncore/applets/keyhelper/keyhelperconf/.cvsignore new file mode 100644 index 0000000..f4d9255 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/.cvsignore @@ -0,0 +1,7 @@ +Makefile* +moc* +.moc* +.obj +.moc +KHCWidgetBase.cpp +KHCWidgetBase.h
\ No newline at end of file |