diff options
author | Fritz Elfert <felfert@to.com> | 2001-05-25 13:47:50 +0000 |
---|---|---|
committer | Fritz Elfert <felfert@to.com> | 2001-05-25 13:47:50 +0000 |
commit | cd6460a7f0067a2b1062c4cafab85af739a4c8fc (patch) | |
tree | dbd8704853b30e7777bb2ab674b5415e365e51f8 /kde2/klipsi | |
parent | a53d7a0ea99fec0ae82b50a04f84dce1a47fe89a (diff) | |
download | plptools-cd6460a7f0067a2b1062c4cafab85af739a4c8fc.tar.gz plptools-cd6460a7f0067a2b1062c4cafab85af739a4c8fc.tar.bz2 plptools-cd6460a7f0067a2b1062c4cafab85af739a4c8fc.zip |
Added Icons for states of Klipsi.
LMB click on klipsi icon now toggles enable/disable.
Diffstat (limited to 'kde2/klipsi')
-rw-r--r-- | kde2/klipsi/eventsrc | 13 | ||||
-rw-r--r-- | kde2/klipsi/hi22-action-klipsi_c.png | bin | 0 -> 1042 bytes | |||
-rw-r--r-- | kde2/klipsi/hi22-action-klipsi_cd.png | bin | 0 -> 1051 bytes | |||
-rw-r--r-- | kde2/klipsi/hi22-action-klipsi_d.png | bin | 0 -> 1072 bytes | |||
-rw-r--r-- | kde2/klipsi/main.cpp | 1 | ||||
-rw-r--r-- | kde2/klipsi/toplevel.cpp | 91 | ||||
-rw-r--r-- | kde2/klipsi/toplevel.h | 16 |
7 files changed, 93 insertions, 28 deletions
diff --git a/kde2/klipsi/eventsrc b/kde2/klipsi/eventsrc index 19d8ea5..8d0cc4c 100644 --- a/kde2/klipsi/eventsrc +++ b/kde2/klipsi/eventsrc @@ -1,6 +1,7 @@ [!Global!] IconName=klipsi -Comment=Klipsi +Comment=Klipsi - Psion clipboard +Comment[de]=Klipsi - Psion Zwischenablage [data received] Name=New data @@ -8,4 +9,12 @@ Name[de]=Neue Daten Comment=The Psion has sent new data to the clipboard. Comment[de]=Neue Daten wurden vom Psion in die Zwischenablage abgelegt. default_presentation=1 -default_sound=KDE_Beep_Pop.wav +default_sound=KDE_Beep_ShortBeep.wav + +[connected] +Name=Connected +Name[de]=Verbunden +Comment=Klipsi has connected to the Psion +Comment[de]=Klipsi hat eine Verbindung zum Psion hergestellt. +default_presentation=1 +default_sound=KDE_Beep_Connect.wav diff --git a/kde2/klipsi/hi22-action-klipsi_c.png b/kde2/klipsi/hi22-action-klipsi_c.png Binary files differnew file mode 100644 index 0000000..5b4dca5 --- /dev/null +++ b/kde2/klipsi/hi22-action-klipsi_c.png diff --git a/kde2/klipsi/hi22-action-klipsi_cd.png b/kde2/klipsi/hi22-action-klipsi_cd.png Binary files differnew file mode 100644 index 0000000..8acac44 --- /dev/null +++ b/kde2/klipsi/hi22-action-klipsi_cd.png diff --git a/kde2/klipsi/hi22-action-klipsi_d.png b/kde2/klipsi/hi22-action-klipsi_d.png Binary files differnew file mode 100644 index 0000000..b0d68ab --- /dev/null +++ b/kde2/klipsi/hi22-action-klipsi_d.png diff --git a/kde2/klipsi/main.cpp b/kde2/klipsi/main.cpp index 7ab2414..e0cbd71 100644 --- a/kde2/klipsi/main.cpp +++ b/kde2/klipsi/main.cpp @@ -52,7 +52,6 @@ int main(int argc, char *argv[]) exit(0); } KUniqueApplication app; - app.disableSessionManagement(); TopLevel *toplevel = new TopLevel(); diff --git a/kde2/klipsi/toplevel.cpp b/kde2/klipsi/toplevel.cpp index 51a6c9e..444502d 100644 --- a/kde2/klipsi/toplevel.cpp +++ b/kde2/klipsi/toplevel.cpp @@ -57,6 +57,8 @@ TopLevel::TopLevel() inSetting = false; mustListen = true; lastClipData = ""; + state = ENABLED; + constate = DISCONNECTED; menu->insertTitle(kapp->miniIcon(), i18n("Klipsi - Psion Clipboard")); menu->insertSeparator(); @@ -66,43 +68,73 @@ TopLevel::TopLevel() connect(clip, SIGNAL(dataChanged()), this, SLOT(slotClipboardChanged())); connect(timer, SIGNAL(timeout()), this, SLOT(slotTimer())); - icon = KGlobal::iconLoader()->loadIcon("klipsi", KIcon::Toolbar); - resize(icon.size()); + icons[ENABLED][DISCONNECTED] = + KGlobal::iconLoader()->loadIcon("klipsi", KIcon::Toolbar); + icons[ENABLED][CONNECTED] = + KGlobal::iconLoader()->loadIcon("klipsi_c", KIcon::Toolbar); + icons[DISABLED][DISCONNECTED] = + KGlobal::iconLoader()->loadIcon("klipsi_d", KIcon::Toolbar); + icons[DISABLED][CONNECTED] = + KGlobal::iconLoader()->loadIcon("klipsi_cd", KIcon::Toolbar); + + icon = &icons[state][constate]; + resize(icon->size()); + setBackgroundMode(X11ParentRelative); int interval = checkConnection() ? 500 : 5000; timer->start(interval, true); + + } TopLevel::~TopLevel() { + closeConnection(); + delete timer; + delete menu; +} + +void TopLevel:: +closeConnection() { if (rf) delete(rf); if (rc) delete(rc); if (rff) delete rff; - - delete timer; - delete menu; + rfsvSocket = 0; + rclipSocket = 0; + rf = 0; + rc = 0; + rff = 0; + mustListen = true; + constate = DISCONNECTED; + repaint(); } void TopLevel:: mousePressEvent(QMouseEvent *e) { - if ( e->button() == LeftButton || e->button() == RightButton ) + if (e->button() == RightButton) showPopupMenu(menu); + if (e->button() == LeftButton) { + state = (state == ENABLED) ? DISABLED : ENABLED; + repaint(); + } } void TopLevel:: paintEvent(QPaintEvent *) { QPainter p(this); - int x = (width() - icon.width()) / 2; - int y = (height() - icon.height()) / 2; + icon = &icons[state][constate]; + + int x = (width() - icon->width()) / 2; + int y = (height() - icon->height()) / 2; if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; - p.drawPixmap(x , y, icon); + p.drawPixmap(x , y, *icon); p.end(); } @@ -121,17 +153,24 @@ slotTimer() return; } + if (state == DISABLED) { + timer->start(500, true); + return; + } + if (mustListen) { res = rc->sendListen(); - if (res != rfsv::E_PSI_GEN_NONE) - cerr << "sendListen: " << res << endl; - else + if (res != rfsv::E_PSI_GEN_NONE) { + closeConnection(); + timer->start(5000, true); + return; + } else mustListen = false; } if ((res = rc->checkNotify()) != rfsv::E_PSI_GEN_NONE) { if (res != rfsv::E_PSI_FILE_EOF) { - cerr << "checkNotify: " << res << endl; + closeConnection(); timer->start(5000, true); return; } @@ -145,7 +184,7 @@ slotTimer() void TopLevel:: slotClipboardChanged() { - if (mustListen || inSetting) + if (mustListen || inSetting || (state == DISABLED)) return; Enum<rfsv::errs> res; @@ -169,7 +208,7 @@ slotClipboardChanged() inSend = false; if (res != rfsv::E_PSI_GEN_NONE) - cerr << "notify: " << res << endl; + closeConnection(); } void TopLevel:: @@ -257,8 +296,8 @@ putClipData(char *data) { if (res == rfsv::E_PSI_GEN_NONE) { while ((res = rc->checkNotify()) != rfsv::E_PSI_GEN_NONE) { if (res != rfsv::E_PSI_FILE_EOF) { - cerr << "waitN: " << res << endl; rf->fclose(fh); + closeConnection(); return; } } @@ -284,7 +323,7 @@ putClipData(char *data) { rf->fclose(fh); rf->fsetattr(CLIPFILE, 0x20, 0x07); } else - cerr << "replaceFile:" << res << endl; + closeConnection(); } void TopLevel:: @@ -355,11 +394,11 @@ getClipData() { } } else - cerr << "fopen: " << res << endl; + closeConnection(); free(buf); } } else - cerr << "fgetattr: " << res << endl; + closeConnection(); if (!clipData.isEmpty()) { inSetting = true; @@ -385,7 +424,6 @@ checkConnection() { if (!rfsvSocket) { rfsvSocket = new ppsocket(); if (!rfsvSocket->connect(NULL, sockNum)) { - cerr << "rclip: could not connect to ncpd" << endl; delete rfsvSocket; rfsvSocket = 0; return false; @@ -395,7 +433,6 @@ checkConnection() { if (!rclipSocket) { rclipSocket = new ppsocket(); if (!rclipSocket->connect(NULL, sockNum)) { - cerr << "rclip: could not connect to ncpd" << endl; delete rclipSocket; rclipSocket = 0; return false; @@ -409,10 +446,16 @@ checkConnection() { rf = rff->create(true); if (rf) { - if (!rc) + if (!rc) { rc = new rclip(rclipSocket); - if (rc->initClipbd() == rfsv::E_PSI_GEN_NONE) - return true; + if (rc->initClipbd() == rfsv::E_PSI_GEN_NONE) { + KNotifyClient::event("connected"); + constate = CONNECTED; + repaint(); + return true; + } else + closeConnection(); + } } return false; } diff --git a/kde2/klipsi/toplevel.h b/kde2/klipsi/toplevel.h index 4fbd275..1080e49 100644 --- a/kde2/klipsi/toplevel.h +++ b/kde2/klipsi/toplevel.h @@ -62,10 +62,21 @@ private slots: void slotMenuSelected(int); private: + enum { + ENABLED = 0, + DISABLED = 1, + } states; + + enum { + DISCONNECTED = 0, + CONNECTED = 1, + } constates; + void psiText2ascii(char *, int); void ascii2PsiText(char *, int); void putClipData(char *); void getClipData(); + void closeConnection(); bool checkConnection(); QClipboard *clip; @@ -79,10 +90,13 @@ private: rfsvfactory *rff; QString lastClipData; - QPixmap icon; + QPixmap *icon; + QPixmap icons[2][2]; bool inSend; bool inSetting; bool mustListen; + int state; + int constate; }; #endif |