bool WeatherApplicationExtension::initialize(const QString &){ QGraphicsObject* mWidget; box = new MyMWidget(); /* D-BUS */ new MeecastIf(box); QDBusConnection connection = QDBusConnection::sessionBus(); bool ret = connection.registerService("com.meecast.applet"); ret = connection.registerObject("/com/meecast/applet", box); EventFeedIf* client = new EventFeedIf("com.nokia.home.EventFeed", "/eventfeed", QDBusConnection::sessionBus(), 0); QObject::connect(client, SIGNAL(refreshRequested()), box, SLOT(refreshRequested())); QTimer::singleShot(1000, box, SLOT(refreshRequested())); /* Copy wallpaper */ if (!(QFile::exists("/home/user/.cache/com.meecast.omweather/wallpaper_MeeCast_original.png"))){ QDir dir("/home/user/.cache/com.meecast.omweather"); if (!dir.exists()) dir.mkpath("/home/user/.cache/com.meecast.omweather"); MGConfItem *wallpaperItem; wallpaperItem = new MGConfItem ("/desktop/meego/background/portrait/picture_filename"); if (QFile::exists(wallpaperItem->value().toString())) QFile::copy(wallpaperItem->value().toString(), "/home/user/.cache/com.meecast.omweather/wallpaper_MeeCast_original.png"); } // box->startpredeamon(); return true; }
/*! \internal offload common initialization functionality. */ void QContentSet::init() { if( d ) { d->setParent( this ); connect( d , SIGNAL(contentAboutToBeRemoved(int,int)), this, SIGNAL(contentAboutToBeRemoved(int,int)) ); connect( d , SIGNAL(contentAboutToBeInserted(int,int)), this, SIGNAL(contentAboutToBeInserted(int,int)) ); connect( d , SIGNAL(contentChanged(int,int)), this, SIGNAL(contentChanged(int,int)) ); connect( d , SIGNAL(contentRemoved()), this, SIGNAL(contentRemoved()) ); connect( d , SIGNAL(contentInserted()), this, SIGNAL(contentInserted()) ); connect( d , SIGNAL(contentChanged()), this, SIGNAL(changed()) ); #ifndef QTOPIA_CONTENT_INSTALLER connect(qApp, SIGNAL(contentChanged(QContentIdList,QContent::ChangeType)), d, SLOT(update())); connect(qApp, SIGNAL(contentChanged(QContentIdList,QContent::ChangeType)), this, SIGNAL(changed(QContentIdList,QContent::ChangeType)) ); connect(QContentUpdateManager::instance(), SIGNAL(refreshRequested()), d, SLOT(update())); #endif d->update(); } else {
/** * Tworzy obiekt widoku drzewa katalogu. * * Tworzy akcje widoku, które będą przypisane do menu kontekstowego. * * @param parent obiekt rodzica */ WorkspaceTreeView::WorkspaceTreeView( QWidget* parent): QTreeView(parent) { actionExpandOrCollapse = new QAction(tr("Expand"), this); connect(actionExpandOrCollapse, SIGNAL(triggered()), SLOT(expandOrCollapse())); actionLoad = new QAction(QIcon(":/icons/page_next.png"), tr("Load selected file"), this); connect(actionLoad, SIGNAL(triggered()), SLOT(load())); actionRemove = new QAction(QIcon(":/icons/page_remove.png"), tr("Remove selected"), this); connect(actionRemove, SIGNAL(triggered()), this, SIGNAL(removeRequested())); actionRefresh = new QAction(QIcon(":/icons/repeat.png"), tr("Refresh view"), this); connect(actionRefresh, SIGNAL(triggered()), this, SIGNAL(refreshRequested())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), settings("Zeal", "Zeal"), settingsDialog(zealList) { trayIcon = nullptr; trayIconMenu = nullptr; // Use the platform-specific proxy settings QNetworkProxyFactory::setUseSystemConfiguration(true); // server for detecting already running instances localServer = new QLocalServer(this); connect(localServer, &QLocalServer::newConnection, [&]() { QLocalSocket *connection = localServer->nextPendingConnection(); // Wait a little while the other side writes the bytes connection->waitForReadyRead(); QString indata = connection->readAll(); if(!indata.isEmpty()) { bringToFrontAndSearch(indata); } }); QLocalServer::removeServer(serverName); // remove in case previous instance crashed localServer->listen(serverName); // initialise icons #if defined(WIN32) || defined(OSX) icon = qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation); #else icon = QIcon::fromTheme("edit-find"); #endif setWindowIcon(icon); if(settings.value("hidingBehavior", "systray").toString() == "systray") createTrayIcon(); QKeySequence keySequence; if(settings.value("hotkey").isNull()) { keySequence = QKeySequence("Alt+Space"); } else { keySequence = settings.value("hotkey").value<QKeySequence>(); } // initialise key grabber connect(&nativeFilter, &ZealNativeEventFilter::gotHotKey, [&]() { if(!isVisible() || !isActiveWindow()) { bringToFront(true); } else { if(trayIcon) { hide(); } else { showMinimized(); } } }); qApp->eventDispatcher()->installNativeEventFilter(&nativeFilter); setHotKey(keySequence); // initialise docsets docsets->initialiseDocsets(); // initialise ui ui->setupUi(this); setupShortcuts(); restoreGeometry(settings.value("geometry").toByteArray()); ui->splitter->restoreState(settings.value("splitter").toByteArray()); connect(ui->splitter, &QSplitter::splitterMoved, [=](int, int) { settings.setValue("splitter", ui->splitter->saveState()); }); ui->webView->settings()->setFontSize(QWebSettings::MinimumFontSize, settings.value("minFontSize").toInt()); ZealNetworkAccessManager * zealNaManager = new ZealNetworkAccessManager(); ui->webView->page()->setNetworkAccessManager(zealNaManager); // menu ui->action_Quit->setShortcut(QKeySequence::Quit); connect(ui->action_Quit, &QAction::triggered, [=]() { settings.setValue("geometry", saveGeometry()); }); connect(ui->action_Quit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(&settingsDialog, SIGNAL(refreshRequested()), this, SLOT(refreshRequest())); connect(&settingsDialog, SIGNAL(minFontSizeChanged(int)), this, SLOT(changeMinFontSize(int))); connect(ui->action_Options, &QAction::triggered, [=]() { settingsDialog.setHotKey(hotKey); nativeFilter.setEnabled(false); if(settingsDialog.exec()) { setHotKey(settingsDialog.hotKey()); if(settings.value("hidingBehavior").toString() == "systray") { createTrayIcon(); } else if(trayIcon) { trayIcon->deleteLater(); trayIconMenu->deleteLater(); trayIcon = nullptr; trayIconMenu = nullptr; } } else { // cancelled - restore previous value ui->webView->settings()->setFontSize(QWebSettings::MinimumFontSize, settings.value("minFontSize").toInt()); } nativeFilter.setEnabled(true); ui->treeView->reset(); }); ui->action_Back->setShortcut(QKeySequence::Back); ui->action_Forward->setShortcut(QKeySequence::Forward); connect(ui->action_Back, &QAction::triggered, this, &MainWindow::back); connect(ui->action_Forward, &QAction::triggered, this, &MainWindow::forward); connect(ui->action_About, &QAction::triggered, [&]() { QMessageBox::about(this, "About Zeal", QString("This is Zeal ") + ZEAL_VERSION + " - a documentation browser.\n\n" "For details see http://zealdocs.org/"); }); connect(ui->action_About_QT, &QAction::triggered, [&]() { QMessageBox::aboutQt(this); }); displayViewActions(); // treeView and lineEdit ui->lineEdit->setTreeView(ui->treeView); ui->lineEdit->setFocus(); ui->treeView->setModel(&zealList); ui->treeView->setColumnHidden(1, true); ui->treeView->setItemDelegate(new ZealSearchItemDelegate(ui->treeView, ui->lineEdit, ui->treeView)); #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) && defined(WIN32) // overriding subElementRect doesn't work with Qt 5.0.0, but is required to display // selected item frame correctly in Windows (for patch see https://codereview.qt-project.org/#change,46559) // This is a workaround for Qt < 5.1 - selecting whole rows leads to always rendering the frame. // (Only the frame is larger than the list item, which is different from default behaviour.) ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows); #endif connect(ui->treeView, &QTreeView::clicked, [&](const QModelIndex& index) { ui->treeView->activated(index); }); connect(ui->treeView, &QTreeView::activated, [&](const QModelIndex& index) { if(!index.sibling(index.row(), 1).data().isNull()) { QStringList url_l = index.sibling(index.row(), 1).data().toString().split('#'); QUrl url = QUrl::fromLocalFile(url_l[0]); if(url_l.count() > 1) { url.setFragment(url_l[1]); } ui->webView->load(url); } }); connect(ui->forwardButton, &QPushButton::clicked, this, &MainWindow::forward); connect(ui->backButton, &QPushButton::clicked, this, &MainWindow::back); connect(ui->webView, &SearchableWebView::urlChanged, [&](const QUrl &url) { QString urlPath = url.path(); QString docsetName = getDocsetName(urlPath); QPixmap docsetMap = docsets->icon(docsetName).pixmap(32,32); // paint label with the icon ui->pageIcon->setPixmap(docsetMap); displayViewActions(); }); connect(ui->webView, &SearchableWebView::titleChanged, [&](const QString &title) { if (!title.isEmpty()) { ui->pageTitle->setText(title); } }); connect(&zealSearch, &ZealSearchModel::queryCompleted, [&]() { ui->treeView->setModel(&zealSearch); ui->treeView->reset(); ui->treeView->setColumnHidden(1, true); ui->treeView->setCurrentIndex(zealSearch.index(0, 0, QModelIndex())); ui->treeView->activated(ui->treeView->currentIndex()); }); connect(ui->lineEdit, &QLineEdit::textChanged, [&](const QString& text) { zealSearch.setQuery(text); if(text.isEmpty()) { ui->treeView->setModel(&zealList); } }); }