int main(int argc, char **argv) { QApplication app(argc, argv); app.setWindowIcon(QIcon::fromTheme("applications-other")); KLocalizedString::setApplicationDomain("qapt-gst-helper"); KAboutData aboutData("qapt-gst-helper", i18nc("@title", "QApt Codec Searcher"), version, i18nc("@info", description), KAboutLicense::LicenseKey::GPL, i18nc("@info:credit", "(C) 2011 Jonathan Thomas")); aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"), QString(), QStringLiteral("*****@*****.**")); aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"), i18nc("@info:credit", "Qt 5 port"), QStringLiteral("*****@*****.**")); KAboutData::setApplicationData(aboutData); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption transientOption(QStringLiteral("transient-for"), i18nc("@info:shell", "Attaches the window to an X app specified by winid"), i18nc("@info:shell value name", "winid"), QStringLiteral("0")); parser.addOption(transientOption); parser.addPositionalArgument("GStreamer Info", i18nc("@info:shell", "GStreamer install info")); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); GError *error = nullptr; gst_init_check(&argc, &argv, &error); if (error) { // TODO: we should probably show an error message. API documention suggests // so at least. Then again explaining random init errors to the user // might be a bit tricky. #warning FIXME 3.1 show error msgbox when gstreamer init fails return GST_INSTALL_PLUGINS_ERROR; } // do not restore! if (app.isSessionRestored()) { exit(0); } int winId = parser.value(transientOption).toInt(); QStringList details = parser.positionalArguments(); PluginHelper pluginHelper(0, details, winId); pluginHelper.run(); return app.exec(); }
void CCurrencyConversionSamplePlugin::ChangeItems(const TCHAR* acode) { CComQIPtr<IGoogleDesktopDisplayPluginHelper> pluginHelper(m_pluginHelper); ATLVERIFY(SUCCEEDED(pluginHelper->RemoveAllContentItems())); unused(acode); // TODO: can be used to optimize redraw CString result; CStringArray tokens; Currencies::Tokenize(GetCurrencies(), &tokens); SYSTEMTIME systime = {0}; GetSystemTime(&systime); ATLVERIFY(tokens.GetCount() % 2 == 0); for (int i = 0; i < (int)tokens.GetCount(); i += 2) { CString currency = tokens.GetAt(i); // create a new item CCurrencyConversionSamplePluginContentItemImpl *curItem = NULL; ATLVERIFY(SUCCEEDED(CCurrencyConversionSamplePluginContentItemImpl:: CreateInstance(&curItem))); CComPtr<IGoogleDesktopDisplayContentItemHelper> itemHelper = NULL; curItem->GetUnknown()->QueryInterface( IID_IGoogleDesktopDisplayContentItemHelper, reinterpret_cast<void**>(&itemHelper)); // and set it's properties UINT flags = GDD_CONTENT_ITEM_FLAG_TIME_ABSOLUTE; CString strHeading; double rate = m_currencies->GetExchangeRate(currency); { CString s; s.Format(_T("%s,%.6f,"), currency, rate); result += s; } if (rate != 0.0) { if (m_invert != VARIANT_FALSE) { strHeading.Format(_T("1 %s = %.5f USD"), currency, 1.0 / rate); } else { strHeading.Format(_T("1 USD = %.5f %s"), rate, currency); } } else strHeading.Format(_T("%s ..."), currency); CComBSTR snippet; snippet.Append(L"1 USD in "); snippet.Append(currency); CComBSTR source(L"www.google.com"); CComBSTR heading(strHeading); CString tt; tt.Format(_T("%s - currency of %s"), Currencies::GetCurrencyName(currency), Currencies::GetCountries(currency)); CComBSTR tooltip = tt; DATE timeCreated; SystemTimeToVariantTime(&systime, &timeCreated); // do the actual setting of props ATLVERIFY(SUCCEEDED(itemHelper->put_heading(heading))); ATLVERIFY(SUCCEEDED(itemHelper->put_tooltip(tooltip))); ATLVERIFY(SUCCEEDED(itemHelper->put_source(source))); ATLVERIFY(SUCCEEDED(itemHelper->put_time_created(timeCreated))); ATLVERIFY(SUCCEEDED(itemHelper->put_snippet(snippet))); ATLVERIFY(SUCCEEDED(itemHelper->put_flags( static_cast<GoogleDesktopDisplayContentItemFlags>(flags)))); ATLVERIFY(SUCCEEDED(itemHelper->put_layout( static_cast<GoogleDesktopDisplayContentItemLayout>( GDD_CONTENT_ITEM_LAYOUT_NOWRAP_ITEMS)))); CComQIPtr<IGoogleDesktopDisplayContentItem> item(itemHelper); // Show the item in the sidebar and optionally in the notification // window if the sidebar is auto-hidden. GoogleDesktopContentItemDisplayOptions item_flags = static_cast<GoogleDesktopContentItemDisplayOptions>( GDD_ITEM_DISPLAY_IN_SIDEBAR | GDD_ITEM_DISPLAY_AS_NOTIFICATION_IF_SIDEBAR_HIDDEN); ATLVERIFY(SUCCEEDED(pluginHelper->AddContentItem(item, item_flags))); } // if we are in minimized mode, update the title with latest info. GoogleDesktopDisplayTileDisplayState display_state = GDD_TILE_DISPLAY_STATE_RESTORED; CComQIPtr<IGoogleDesktopDisplaySite> sidebar_site(m_spUnkSite); if (sidebar_site != NULL) // will be NULL during init time ATLVERIFY(SUCCEEDED(sidebar_site->get_display_state(&display_state))); if (display_state == GDD_TILE_DISPLAY_STATE_MINIMIZED) UpdateTitle(false); m_firstTime = false; int n = result.GetLength(); if (n > 0 && result.GetAt(n - 1) == L',') { result = result.Left(n - 1); } SysFreeString(m_bstrCurrencies); m_bstrCurrencies = SysAllocString(result); }