Add movie cache

pull/1/head
Timothy Pearson 12 years ago
parent 851d4cc245
commit 3a8c577420

@ -176,7 +176,7 @@ TQMovie DeviceTrayComponent::movieForState(TDENetworkConnectionStatus::TDENetwor
if (moviePath != "") {
if (m_tray) {
if (m_tray->m_movieCache.contains(moviePath)) {
return m_tray->m_movieCache[moviePath];
return TQMovie(m_tray->m_movieCache[moviePath]);
}
}
if (m_tray) {

@ -56,6 +56,7 @@
#include <tqlabel.h>
#include <tqapplication.h>
#include <tqdialog.h>
#include <tqfile.h>
#include "devicetraycomponent.h"
#include "tdenetman-tray.h"
@ -857,22 +858,24 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
|| (current_vpn_state & TDENetworkGlobalManagerFlags::VPNConfiguringProtocols)
|| (current_vpn_state & TDENetworkGlobalManagerFlags::VPNVerifyingProtocols)) {
int frame = -1;
if (movie())
if (movie()) {
frame = movie()->frameNumber();
}
// set the movie
if ((current_vpn_state & TDENetworkGlobalManagerFlags::VPNEstablishingLink)
|| (current_vpn_state & TDENetworkGlobalManagerFlags::VPNNeedAuthorization)) {
setMovie(TQMovie(KGlobal::iconLoader()->moviePath("nm_stage02_connecting_vpn", KIcon::Panel)));
setMovie(TQMovie(m_movieCache["nm_stage02_connecting_vpn"]));
}
if ((current_vpn_state & TDENetworkGlobalManagerFlags::VPNConfiguringProtocols)
|| (current_vpn_state & TDENetworkGlobalManagerFlags::VPNVerifyingProtocols)) {
setMovie(TQMovie(KGlobal::iconLoader()->moviePath("nm_stage03_connecting_vpn", KIcon::Panel)));
setMovie(TQMovie(m_movieCache["nm_stage03_connecting_vpn"]));
}
// start at the same frame as the movie before
if (frame > 0)
if (frame > 0) {
movie()->step(frame);
}
// start the animation
movie()->unpause();
@ -985,6 +988,21 @@ TQMovie Tray::movieForName(TQString moviePath)
}
}
TQByteArray Tray::movieFileData(TQString movieName) {
TQByteArray ret;
TQString fileName = KGlobal::iconLoader()->moviePath(movieName, KIcon::Panel, width());
if (fileName != "") {
TQFile file(fileName);
if (file.exists()) {
if (file.open(IO_ReadOnly)) {
ret = file.readAll();
file.close();
}
}
}
return ret;
}
void Tray::updateGraphicsCache() {
m_pixmapCache["tdenetworkmanager"] = pixmapForName("tdenetworkmanager");
m_pixmapCache["tdenetworkmanager_disabled"] = pixmapForName("tdenetworkmanager_disabled");
@ -997,12 +1015,15 @@ void Tray::updateGraphicsCache() {
m_pixmapCache["nm_signal_75"] = pixmapForName("nm_signal_75");
m_pixmapCache["nm_signal_100"] = pixmapForName("nm_signal_100");
// FIXME
// TQMovie objects are explicitly shared
// A cache cannot be implemented until these objects support deep copy!
// m_movieCache["nm_stage01_connecting"] = movieForName("nm_stage01_connecting");
// m_movieCache["nm_stage02_connecting"] = movieForName("nm_stage02_connecting");
// m_movieCache["nm_stage03_connecting"] = movieForName("nm_stage03_connecting");
m_movieCache["nm_stage01_connecting"] = movieFileData("nm_stage01_connecting");
m_movieCache["nm_stage02_connecting"] = movieFileData("nm_stage02_connecting");
m_movieCache["nm_stage03_connecting"] = movieFileData("nm_stage03_connecting");
m_movieCache["nm_stage02_connecting_vpn"] = movieFileData("nm_stage02_connecting_vpn");
m_movieCache["nm_stage03_connecting_vpn"] = movieFileData("nm_stage03_connecting_vpn");
}
void Tray::resizeEvent(TQResizeEvent *) {
updateGraphicsCache();
}
Tray::Tray() : KSystemTray()

@ -109,6 +109,9 @@ class Tray : public KSystemTray
void trayUiChanged();
void slotEditNotifications();
protected:
void resizeEvent(TQResizeEvent *);
private slots:
void slotGenericDeviceAdded(TDEGenericDevice*);
void slotGenericDeviceRemoved(TDEGenericDevice*);
@ -116,13 +119,14 @@ class Tray : public KSystemTray
void slotVPNEventHandler(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
private:
TQByteArray movieFileData(TQString movieName);
TQMovie movieForName(TQString moviePath);
TQPixmap pixmapForName(TQString pixmapPath);
void updateGraphicsCache();
public:
TQMap<TQString, TQMovie> m_movieCache;
TQMap<TQString, TQByteArray> m_movieCache;
TQMap<TQString, TQPixmap> m_pixmapCache;
private:

Loading…
Cancel
Save