Changeset View
Changeset View
Standalone View
Standalone View
plasma/applets/onlinequote/plasma-onlinequote.cpp
Show All 31 Lines | 30 | PlasmaOnlineQuote::PlasmaOnlineQuote(QObject *parent, const QVariantList &args) | |||
---|---|---|---|---|---|
32 | , m_svg(this) | 32 | , m_svg(this) | ||
33 | , m_icon("preferences-system-network") | 33 | , m_icon("preferences-system-network") | ||
34 | , m_widget(0) | 34 | , m_widget(0) | ||
35 | , m_price(0) | 35 | , m_price(0) | ||
36 | , m_profile(nullptr) | 36 | , m_profile(nullptr) | ||
37 | { | 37 | { | ||
38 | setHasConfigurationInterface(true); | 38 | setHasConfigurationInterface(true); | ||
39 | m_svg.setImagePath("widgets/background"); | 39 | m_svg.setImagePath("widgets/background"); | ||
40 | #if QT_VERSION < 0x050000 | 40 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | ||
41 | // this will get us the standard applet background, for free! | 41 | // this will get us the standard applet background, for free! | ||
42 | setBackgroundHints(DefaultBackground); | 42 | setBackgroundHints(DefaultBackground); | ||
43 | resize(200, 200); | 43 | resize(200, 200); | ||
44 | #endif | 44 | #endif | ||
45 | AlkOnlineQuotesProfileManager &manager = AlkOnlineQuotesProfileManager::instance(); | 45 | AlkOnlineQuotesProfileManager &manager = AlkOnlineQuotesProfileManager::instance(); | ||
46 | // manager is shared between plasmoids | 46 | // manager is shared between plasmoids | ||
47 | if(AlkOnlineQuotesProfileManager::instance().profiles().size() == 0) { | 47 | if(AlkOnlineQuotesProfileManager::instance().profiles().size() == 0) { | ||
48 | manager.addProfile(new AlkOnlineQuotesProfile("alkimia4", AlkOnlineQuotesProfile::Type::Alkimia4)); | 48 | manager.addProfile(new AlkOnlineQuotesProfile("alkimia4", AlkOnlineQuotesProfile::Type::Alkimia4)); | ||
49 | manager.addProfile(new AlkOnlineQuotesProfile("alkimia5", AlkOnlineQuotesProfile::Type::Alkimia5)); | 49 | manager.addProfile(new AlkOnlineQuotesProfile("alkimia5", AlkOnlineQuotesProfile::Type::Alkimia5)); | ||
50 | manager.addProfile(new AlkOnlineQuotesProfile("kmymoney4", AlkOnlineQuotesProfile::Type::KMyMoney4)); | 50 | manager.addProfile(new AlkOnlineQuotesProfile("kmymoney4", AlkOnlineQuotesProfile::Type::KMyMoney4)); | ||
51 | manager.addProfile(new AlkOnlineQuotesProfile("kmymoney5", AlkOnlineQuotesProfile::Type::KMyMoney5)); | 51 | manager.addProfile(new AlkOnlineQuotesProfile("kmymoney5", AlkOnlineQuotesProfile::Type::KMyMoney5)); | ||
52 | } | 52 | } | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | PlasmaOnlineQuote::~PlasmaOnlineQuote() | 55 | PlasmaOnlineQuote::~PlasmaOnlineQuote() | ||
56 | { | 56 | { | ||
57 | #if QT_VERSION < 0x050000 | 57 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | ||
58 | if (hasFailedToLaunch()) { | 58 | if (hasFailedToLaunch()) { | ||
59 | // Do some cleanup here | 59 | // Do some cleanup here | ||
60 | } else | 60 | } else | ||
61 | #endif | 61 | #endif | ||
62 | { | 62 | { | ||
63 | // Save settings | 63 | // Save settings | ||
64 | config().sync(); | 64 | config().sync(); | ||
65 | } | 65 | } | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | void PlasmaOnlineQuote::init() | 68 | void PlasmaOnlineQuote::init() | ||
69 | { | 69 | { | ||
70 | #if QT_VERSION < 0x050000 | 70 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | ||
71 | // A small demonstration of the setFailedToLaunch function | 71 | // A small demonstration of the setFailedToLaunch function | ||
72 | if (m_icon.isNull()) { | 72 | if (m_icon.isNull()) { | ||
73 | setFailedToLaunch(true, "No world to say hello"); | 73 | setFailedToLaunch(true, "No world to say hello"); | ||
74 | } | 74 | } | ||
75 | #endif | 75 | #endif | ||
76 | QString currentProfile = config().readEntry("profile"); | 76 | QString currentProfile = config().readEntry("profile"); | ||
77 | qDebug() << "reading current profile" << currentProfile; | 77 | qDebug() << "reading current profile" << currentProfile; | ||
78 | if (currentProfile.isEmpty()) | 78 | if (currentProfile.isEmpty()) | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
170 | 170 | | |||
171 | void PlasmaOnlineQuote::slotReceivedQuote(const QString &id, const QString &symbol, const QDate &date, const double &price) | 171 | void PlasmaOnlineQuote::slotReceivedQuote(const QString &id, const QString &symbol, const QDate &date, const double &price) | ||
172 | { | 172 | { | ||
173 | Q_UNUSED(id) | 173 | Q_UNUSED(id) | ||
174 | Q_UNUSED(symbol) | 174 | Q_UNUSED(symbol) | ||
175 | qDebug() << "got quote" << date << price; | 175 | qDebug() << "got quote" << date << price; | ||
176 | m_date = date; | 176 | m_date = date; | ||
177 | m_price = price; | 177 | m_price = price; | ||
178 | #if QT_VERSION < 0x050000 | 178 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | ||
179 | update(); | 179 | update(); | ||
180 | #else | 180 | #else | ||
181 | #warning how to update ui ? | 181 | #warning how to update ui ? | ||
182 | #endif | 182 | #endif | ||
183 | } | 183 | } | ||
184 | 184 | | |||
185 | void PlasmaOnlineQuote::paintInterface(QPainter *p, | 185 | void PlasmaOnlineQuote::paintInterface(QPainter *p, | ||
186 | const QStyleOptionGraphicsItem *option, const QRect &contentsRect) | 186 | const QStyleOptionGraphicsItem *option, const QRect &contentsRect) | ||
Show All 32 Lines |