void WikipediaSettings::getLangs() { state=Loading; showSpinner(); available->clear(); selected->clear(); reload->setEnabled(false); cancel(); QUrl url("http://en.wikipedia.org/w/api.php"); #if QT_VERSION < 0x050000 QUrl &q=url; #else QUrlQuery q; #endif q.addQueryItem(QLatin1String("action"), QLatin1String("query")); q.addQueryItem(QLatin1String("meta"), QLatin1String("siteinfo")); q.addQueryItem(QLatin1String("siprop"), QLatin1String("interwikimap")); q.addQueryItem(QLatin1String("sifilteriw"), QLatin1String("local")); q.addQueryItem(QLatin1String("format"), QLatin1String("xml")); #if QT_VERSION >= 0x050000 url.setQuery(q); #endif job=NetworkAccessManager::self()->get(url); connect(job, SIGNAL(finished()), this, SLOT(parseLangs())); }
DynamicPage::DynamicPage(QWidget *p) : SinglePageWidget(p) { addAction = new Action(Icon("document-new"), i18n("Add"), this); editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this); removeAction = new Action(Icon("list-remove"), i18n("Remove"), this); toggleAction = new Action(this); ToolButton *addBtn=new ToolButton(this); ToolButton *editBtn=new ToolButton(this); ToolButton *removeBtn=new ToolButton(this); ToolButton *startBtn=new ToolButton(this); addBtn->setDefaultAction(addAction); editBtn->setDefaultAction(editAction); removeBtn->setDefaultAction(removeAction); startBtn->setDefaultAction(Dynamic::self()->startAct()); view->addAction(editAction); view->addAction(removeAction); view->addAction(Dynamic::self()->startAct()); view->alwaysShowHeader(); view->setMode(ItemView::Mode_List); connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions())); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(toggle())); connect(view, SIGNAL(headerClicked(int)), SLOT(headerClicked(int))); connect(MPDConnection::self(), SIGNAL(dynamicSupport(bool)), this, SLOT(remoteDynamicSupport(bool))); connect(addAction, SIGNAL(triggered()), SLOT(add())); connect(editAction, SIGNAL(triggered()), SLOT(edit())); connect(removeAction, SIGNAL(triggered()), SLOT(remove())); connect(Dynamic::self()->startAct(), SIGNAL(triggered()), SLOT(start())); connect(Dynamic::self()->stopAct(), SIGNAL(triggered()), SLOT(stop())); connect(toggleAction, SIGNAL(triggered()), SLOT(toggle())); connect(Dynamic::self(), SIGNAL(running(bool)), SLOT(running(bool))); connect(Dynamic::self(), SIGNAL(loadingList()), view, SLOT(showSpinner())); connect(Dynamic::self(), SIGNAL(loadedList()), view, SLOT(hideSpinner())); #ifdef Q_OS_WIN remoteRunningLabel=new StatusLabel(this); remoteRunningLabel->setType(StatusLabel::Error); #endif Dynamic::self()->stopAct()->setEnabled(false); proxy.setSourceModel(Dynamic::self()); view->setModel(&proxy); view->setDeleteAction(removeAction); view->setMode(ItemView::Mode_List); controlActions(); Configuration config(metaObject()->className()); view->load(config); controls=QList<QWidget *>() << addBtn << editBtn << removeBtn << startBtn; init(0, QList<QWidget *>(), controls); #ifdef Q_OS_WIN addWidget(remoteRunningLabel); enableWidgets(false); #endif }
DynamicPage::DynamicPage(QWidget *p) : QWidget(p) { setupUi(this); addAction = new Action(Icon("document-new"), i18n("Add"), this); editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this); removeAction = new Action(Icon("list-remove"), i18n("Remove"), this); toggleAction = new Action(this); addBtn->setDefaultAction(addAction); editBtn->setDefaultAction(editAction); removeBtn->setDefaultAction(removeAction); startBtn->setDefaultAction(Dynamic::self()->startAct()); stopBtn->setDefaultAction(Dynamic::self()->stopAct()); view->addAction(editAction); view->addAction(removeAction); view->addAction(Dynamic::self()->startAct()); connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions())); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(toggle())); connect(view, SIGNAL(searchItems()), this, SLOT(searchItems())); connect(MPDConnection::self(), SIGNAL(dynamicSupport(bool)), this, SLOT(remoteDynamicSupport(bool))); connect(addAction, SIGNAL(triggered()), SLOT(add())); connect(editAction, SIGNAL(triggered()), SLOT(edit())); connect(removeAction, SIGNAL(triggered()), SLOT(remove())); connect(Dynamic::self()->startAct(), SIGNAL(triggered()), SLOT(start())); connect(Dynamic::self()->stopAct(), SIGNAL(triggered()), SLOT(stop())); connect(toggleAction, SIGNAL(triggered()), SLOT(toggle())); connect(Dynamic::self(), SIGNAL(running(bool)), SLOT(running(bool))); connect(Dynamic::self(), SIGNAL(loadingList()), view, SLOT(showSpinner())); connect(Dynamic::self(), SIGNAL(loadedList()), view, SLOT(hideSpinner())); #ifdef Q_OS_WIN remoteRunningLabel->setType(StatusLabel::Error); enableWidgets(false); #else remoteRunningLabel->setVisible(false); #endif Dynamic::self()->stopAct()->setEnabled(false); proxy.setSourceModel(Dynamic::self()); view->setModel(&proxy); view->setDeleteAction(removeAction); view->setMode(ItemView::Mode_List); controlActions(); view->load(metaObject()->className()); }
MsgScreen::MsgScreen(QSize size, double scale, QString msg, QWidget *parent):Overlay(parent) { init(); this->msg = msg; scaleFactor = scale; screenSize = size; setMinimumSize(size); setMaximumSize(size); rectSize = rectSize*scale; iconSize = iconSize*scale; frameCenterOffset = frameCenterOffset*scale; rectPoint= QPoint((screenSize.width()-rectSize.width())/2,(screenSize.height()-rectSize.height())/2-frameCenterOffset); fontSize = fontSize * qSqrt(qSqrt(scaleFactor)); txtOffset = txtOffset*scaleFactor; txtBottomOffset = txtBottomOffset*scaleFactor; scrLayout = new QVBoxLayout(); showSpinner(true); }
SearchPage::SearchPage(QWidget *p) : QWidget(p) , state(-1) , model(this) , proxy(this) { setupUi(this); addToPlayQueue->setDefaultAction(StdActions::self()->addToPlayQueueAction); replacePlayQueue->setDefaultAction(StdActions::self()->replacePlayQueueAction); locateAction=new Action(Icon("edit-find"), i18n("Locate In Library"), this); view->allowTableView(new SearchTableView(view)); view->addAction(StdActions::self()->addToPlayQueueAction); view->addAction(StdActions::self()->replacePlayQueueAction); view->addAction(StdActions::self()->addWithPriorityAction); view->addAction(StdActions::self()->addToStoredPlaylistAction); #ifdef TAGLIB_FOUND #ifdef ENABLE_DEVICES_SUPPORT view->addAction(StdActions::self()->copyToDeviceAction); #endif #endif // TAGLIB_FOUND view->addAction(locateAction); connect(this, SIGNAL(add(const QStringList &, bool, quint8)), MPDConnection::self(), SLOT(add(const QStringList &, bool, quint8))); connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &))); connect(&model, SIGNAL(searching()), view, SLOT(showSpinner())); connect(&model, SIGNAL(searched()), view, SLOT(hideSpinner())); connect(&model, SIGNAL(statsUpdated(int, quint32)), this, SLOT(statsUpdated(int, quint32))); connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions())); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &))); connect(view, SIGNAL(searchItems()), this, SLOT(searchItems())); connect(MPDConnection::self(), SIGNAL(stateChanged(bool)), this, SLOT(setSearchCategories())); connect(locateAction, SIGNAL(triggered()), SLOT(locateSongs())); proxy.setSourceModel(&model); view->setModel(&proxy); view->setMode(ItemView::Mode_List); view->setPermanentSearch(); setSearchCategories(); view->setSearchCategory(Settings::self()->searchCategory()); statsUpdated(0, 0); }
void ArtistView::loadBio() { foreach (const QString &lang, engine->getLangs()) { QString prefix=engine->getPrefix(lang); QString cachedFile=cacheFileName(currentSong.artist, prefix, false, false); if (QFile::exists(cachedFile)) { QFile f(cachedFile); QtIOCompressor compressor(&f); compressor.setStreamFormat(QtIOCompressor::GzipFormat); if (compressor.open(QIODevice::ReadOnly)) { QString data=QString::fromUtf8(compressor.readAll()); if (!data.isEmpty()) { searchResponse(data, QString()); Utils::touchFile(cachedFile); return; } } } } showSpinner(); engine->search(QStringList() << currentSong.artist, ContextEngine::Artist); }
void WikipediaSettings::showEvent(QShowEvent *e) { if (Initial==state) { state=Loading; QByteArray data; QString fileName=localeFile(); if (QFile::exists(fileName)) { QFile f(fileName); QtIOCompressor compressor(&f); compressor.setStreamFormat(QtIOCompressor::GzipFormat); if (compressor.open(QIODevice::ReadOnly)) { data=compressor.readAll(); } } if (data.isEmpty()) { getLangs(); } else { showSpinner(); parseLangs(data); } } QWidget::showEvent(e); }
StreamsBrowsePage::StreamsBrowsePage(QWidget *p) : SinglePageWidget(p) , settings(0) { importAction = new Action(Icon("document-import"), i18n("Import Streams Into Favorites"), this); exportAction = new Action(Icon("document-export"), i18n("Export Favorite Streams"), this); addAction = ActionCollection::get()->createAction("addstream", i18n("Add New Stream To Favorites"), Icons::self()->addRadioStreamIcon); editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this); searchAction = new Action(Icons::self()->searchIcon, i18n("Seatch For Streams"), this); connect(searchAction, SIGNAL(triggered()), this, SIGNAL(searchForStreams())); // connect(view, SIGNAL(itemsSelected(bool)), addToPlaylist, SLOT(setEnabled(bool))); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &))); connect(view, SIGNAL(itemsSelected(bool)), SLOT(controlActions())); connect(addAction, SIGNAL(triggered()), this, SLOT(addStream())); connect(StreamsModel::self()->addBookmarkAct(), SIGNAL(triggered()), this, SLOT(addBookmark())); connect(StreamsModel::self()->configureDiAct(), SIGNAL(triggered()), this, SLOT(configureDi())); connect(StreamsModel::self()->reloadAct(), SIGNAL(triggered()), this, SLOT(reload())); connect(editAction, SIGNAL(triggered()), this, SLOT(edit())); connect(importAction, SIGNAL(triggered()), this, SLOT(importXml())); connect(exportAction, SIGNAL(triggered()), this, SLOT(exportXml())); connect(StreamsModel::self(), SIGNAL(error(const QString &)), this, SIGNAL(error(const QString &))); connect(StreamsModel::self(), SIGNAL(loading()), view, SLOT(showSpinner())); connect(StreamsModel::self(), SIGNAL(loaded()), view, SLOT(hideSpinner())); connect(StreamsModel::self(), SIGNAL(categoriesChanged()), view, SLOT(closeSearch())); connect(StreamsModel::self(), SIGNAL(favouritesLoaded()), SLOT(expandFavourites())); connect(StreamsModel::self(), SIGNAL(addedToFavourites(QString)), SLOT(addedToFavourites(QString))); connect(DigitallyImported::self(), SIGNAL(loginStatus(bool,QString)), SLOT(updateDiStatus())); connect(DigitallyImported::self(), SIGNAL(updated()), SLOT(updateDiStatus())); connect(view, SIGNAL(headerClicked(int)), SLOT(headerClicked(int))); StreamsModel::self()->configureDiAct()->setEnabled(false); proxy.setSourceModel(StreamsModel::self()); view->setModel(&proxy); view->setDeleteAction(StdActions::self()->removeAction); view->setSearchResetLevel(1); view->alwaysShowHeader(); Configuration config(metaObject()->className()); view->setMode(ItemView::Mode_DetailedTree); view->load(config); MenuButton *menuButton=new MenuButton(this); Action *configureAction=new Action(Icons::self()->configureIcon, i18n("Configure"), this); connect(configureAction, SIGNAL(triggered()), SLOT(configure())); menuButton->addAction(createViewMenu(QList<ItemView::Mode>() << ItemView::Mode_BasicTree << ItemView::Mode_SimpleTree << ItemView::Mode_DetailedTree << ItemView::Mode_List)); menuButton->addAction(configureAction); menuButton->addAction(StreamsModel::self()->configureDiAct()); menuButton->addSeparator(); menuButton->addAction(addAction); menuButton->addAction(StdActions::self()->removeAction); menuButton->addAction(editAction); menuButton->addAction(StreamsModel::self()->reloadAct()); menuButton->addSeparator(); menuButton->addAction(importAction); menuButton->addAction(exportAction); diStatusLabel=new ServiceStatusLabel(this); diStatusLabel->setText("DI", i18nc("Service name", "Digitally Imported")); connect(diStatusLabel, SIGNAL(clicked()), SLOT(diSettings())); updateDiStatus(); ToolButton *searchButton=new ToolButton(this); searchButton->setDefaultAction(searchAction); init(ReplacePlayQueue, QList<QWidget *>() << menuButton << diStatusLabel, QList<QWidget *>() << searchButton); view->addAction(editAction); view->addAction(StdActions::self()->removeAction); view->addAction(StreamsModel::self()->addToFavouritesAct()); view->addAction(StreamsModel::self()->addBookmarkAct()); view->addAction(StreamsModel::self()->reloadAct()); }
DynamicPage::DynamicPage(QWidget *p) : SinglePageWidget(p) { addAction = new Action(Icons::self()->addNewItemIcon, i18n("Add"), this); editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this); removeAction = new Action(Icons::self()->removeDynamicIcon, i18n("Remove"), this); toggleAction = new Action(this); ToolButton *addBtn=new ToolButton(this); ToolButton *editBtn=new ToolButton(this); ToolButton *removeBtn=new ToolButton(this); ToolButton *startBtn=new ToolButton(this); addBtn->setDefaultAction(addAction); editBtn->setDefaultAction(editAction); removeBtn->setDefaultAction(removeAction); startBtn->setDefaultAction(Dynamic::self()->startAct()); view->addAction(editAction); view->addAction(removeAction); view->addAction(Dynamic::self()->startAct()); view->alwaysShowHeader(); connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions())); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(toggle())); connect(view, SIGNAL(headerClicked(int)), SLOT(headerClicked(int))); connect(MPDConnection::self(), SIGNAL(dynamicSupport(bool)), this, SLOT(remoteDynamicSupport(bool))); connect(addAction, SIGNAL(triggered()), SLOT(add())); connect(editAction, SIGNAL(triggered()), SLOT(edit())); connect(removeAction, SIGNAL(triggered()), SLOT(remove())); connect(Dynamic::self()->startAct(), SIGNAL(triggered()), SLOT(start())); connect(Dynamic::self()->stopAct(), SIGNAL(triggered()), SLOT(stop())); connect(toggleAction, SIGNAL(triggered()), SLOT(toggle())); connect(Dynamic::self(), SIGNAL(running(bool)), SLOT(running(bool))); connect(Dynamic::self(), SIGNAL(loadingList()), view, SLOT(showSpinner())); connect(Dynamic::self(), SIGNAL(loadedList()), view, SLOT(hideSpinner())); #ifdef Q_OS_WIN remoteRunningLabel=new QLabel(this); remoteRunningLabel->setStyleSheet(QString(".QLabel {" "background-color: rgba(235, 187, 187, 196);" "border-radius: 3px;" "border: 1px solid red;" "padding: 4px;" "margin: 1px;" "color: black; }")); remoteRunningLabel->setText(i18n("Remote dynamizer is not running.")); #endif Dynamic::self()->stopAct()->setEnabled(false); proxy.setSourceModel(Dynamic::self()); view->setModel(&proxy); view->setDeleteAction(removeAction); view->setMode(ItemView::Mode_List); controlActions(); Configuration config(metaObject()->className()); view->load(config); controls=QList<QWidget *>() << addBtn << editBtn << removeBtn << startBtn; init(0, QList<QWidget *>(), controls); #ifdef Q_OS_WIN addWidget(remoteRunningLabel); enableWidgets(false); #endif }