void ExecutionDomain::Deactivate(bool sync_dispatch) { // Flag ourselves as deactivated. This will prevent any new event sources // from being added to the sources_ list. We can then swap the contents of // the sources_ list with a temp list, leave the lock and deactivate all of // the sources at our leisure. fbl::DoublyLinkedList<fbl::RefPtr<EventSource>, EventSource::SourcesListTraits> to_deactivate; bool sync_needed = false; { fbl::AutoLock sources_lock(&sources_lock_); if (deactivated()) { ZX_DEBUG_ASSERT(sources_.is_empty()); } else { deactivated_.store(1u); to_deactivate.swap(sources_); } // If there are dispatch operations currently in flight, clear the // dispatch idle event and set the flag indicating to the dispatch // operation that it needs to set the event when it finishes. if (dispatch_in_progress_) { sync_needed = true; if (!dispatch_sync_in_progress_) { __UNUSED zx_status_t res; dispatch_sync_in_progress_ = true; res = dispatch_idle_evt_.signal(ZX_USER_SIGNAL_0, 0u); ZX_DEBUG_ASSERT(res == ZX_OK); } } } // Now deactivate all of our event sources and release all of our references. if (!to_deactivate.is_empty()) { for (auto& source : to_deactivate) { source.Deactivate(); } to_deactivate.clear(); } // Synchronize if needed if (sync_needed && sync_dispatch) { __UNUSED zx_status_t res; zx_signals_t pending; res = dispatch_idle_evt_.wait_one(ZX_USER_SIGNAL_0, zx::deadline_after(zx::sec(5)), &pending); ZX_DEBUG_ASSERT(res == ZX_OK); ZX_DEBUG_ASSERT((pending & ZX_USER_SIGNAL_0) != 0); } // Finally, exit our thread pool and release our reference to it. decltype(thread_pool_) pool; { fbl::AutoLock sources_lock(&sources_lock_); pool = std::move(thread_pool_); } if (pool != nullptr) pool->RemoveDomainFromPool(this); }
bool ExecutionDomain::AddPendingWork(EventSource* event_source) { ZX_DEBUG_ASSERT(event_source != nullptr); ZX_DEBUG_ASSERT(!event_source->InPendingList()); ZX_DEBUG_ASSERT(event_source->dispatch_state() == DispatchState::WaitingOnPort); // If this ExecutionDomain has become deactivated, then it is not accepting // any new pending work. Do not add the source to the pending work queue, // and do not tell the caller that it should be processing the queue when we // return. The event source is now in the Idle state. fbl::AutoLock sources_lock(&sources_lock_); if (deactivated()) { event_source->dispatch_state_ = DispatchState::Idle; return false; } // Add this event source to the back of the pending work queue, and tell the // caller whether or not it is responsible for processing the queue. bool ret = !dispatch_in_progress_; if (ret) { ZX_DEBUG_ASSERT(pending_work_.is_empty()); dispatch_in_progress_ = true; } event_source->dispatch_state_ = DispatchState::DispatchPending; pending_work_.push_back(fbl::WrapRefPtr(event_source)); return ret; }
bool LXQtWorldClockPopup::event(QEvent *event) { if (event->type() == QEvent::Close) emit deactivated(); return QDialog::event(event); }
ExecutionDomain::~ExecutionDomain() { // Assert that the Owner implementation properly deactivated itself // before destructing. ZX_DEBUG_ASSERT(deactivated()); ZX_DEBUG_ASSERT(sources_.is_empty()); ZX_DEBUG_ASSERT(!thread_pool_node_state_.InContainer()); }
void sJarvisNodeComponent::parseEvent(QString component, jarvisEvents event, QStringList args) { if(component != m_id) return; if (event == E_DISABLED) { emit disabled(); }else if(event == E_ENABLED) { emit enabled(); }else if(event == E_ACTIVATED) { emit activated(); }else if(event == E_DEACTIVATED) { emit deactivated(); }else if(event == E_RAW_READ) { emit rawRead(); emit rawRead(args); }else if(event == E_DATA_READ) { emit dataRead(); emit dataRead(args); }else if(event == E_COFFEE_MAKING) { emit coffeeMaking(); }else if(event == E_COFFEE_MADE) { emit coffeeMade(); } }
void AnalysisWidget::startEngine() { int index = ui.engineList->currentIndex(); stopEngine(); if(index != -1) { if(parentWidget() && !parentWidget()->isVisible()) { parentWidget()->show(); } ui.variationText->clear(); m_engine = Engine::newEngine(index); ui.vpcount->setEnabled(m_engine->providesMvp()); ui.label->setEnabled(m_engine->providesMvp()); if(!m_engine->providesMvp()) { ui.vpcount->setValue(1); } connect(m_engine, SIGNAL(activated()), SLOT(engineActivated())); connect(m_engine, SIGNAL(error(QProcess::ProcessError)), SLOT(engineError(QProcess::ProcessError))); connect(m_engine, SIGNAL(deactivated()), SLOT(engineDeactivated())); connect(m_engine, SIGNAL(analysisUpdated(const Analysis&)), SLOT(showAnalysis(const Analysis&))); m_engine->setMoveTime(m_moveTime); m_engine->activate(); QString key = QString("/") + objectName() + "/Engine"; AppSettings->setValue(key, ui.engineList->itemText(index)); } }
FrameEditor::FrameEditor(MediaManager *media, QWidget *parent) : FrameObject(parent), ui(new Ui::FrameEditor) { ui->setupUi(this); // Hidden in current version. It's not there yet. ui->button_atmosphere_library_refresh->hide(); ui->button_sfx_library_refresh->hide(); ui->button_singleshot_library_refresh->hide(); ui->button_music_library_refresh->hide(); QSettings settings; ui->tabs_ambienceeditor->setCurrentIndex(settings.value("EditorWindow/tab_active", 0).toInt()); // Splitters ui->splitter_atmosphere->restoreState(settings.value("EditorFrame/atmosphere_splitter").toByteArray()); ui->splitter_sfx->restoreState(settings.value("EditorFrame/sfx_splitter").toByteArray()); ui->splitter_singleshots->restoreState(settings.value("EditorFrame/singleshots_splitter").toByteArray()); ui->splitter_music->restoreState(settings.value("EditorFrame/music_splitter").toByteArray()); ui->splitter_hotkeys->restoreState(settings.value("EditorFrame/hotkeys_splitter").toByteArray()); ui->hotkeys_libraries_toolBox->setCurrentIndex(settings.value("EditorFrame/hotkeys_toolbox", 0).toInt()); // Preview //media_preview = new MediaContainer(media->system, this); media_preview = media->createContainer(); connect(ui->preview_play_pause, SIGNAL(toggled(bool)), this, SLOT(previewPlayPause(bool))); connect(ui->preview_play_pause, SIGNAL(fileDropped(QString,int)), this, SLOT(previewEnqueue(QString,int))); connect(media_preview, SIGNAL(finished(int)), this, SLOT(previewStop())); connect(media_preview, SIGNAL(trackPosition(int,int)), this, SLOT(previewSetSeek(int,int))); connect(this, SIGNAL(deactivated()), this, SLOT(previewStop())); }
void Task::setActive(bool a) { _active = a; emit changed(); if ( a ) emit activated(); else emit deactivated(); }
void QgsMapTool::deactivate() { if ( mAction ) mAction->setChecked( false ); if ( mButton ) mButton->setChecked( false ); emit deactivated(); }
void YaEventNotifierInformer::notifierVisibilityChanged() { bool enabled = notifier_->shouldBeVisible(); button()->setEnabled(enabled); if (enabled) emit activated(); else emit deactivated(); updateButton(); }
void LXQtWorldClock::activated(ActivationReason reason) { switch (reason) { case ILXQtPanelPlugin::Trigger: case ILXQtPanelPlugin::MiddleClick: break; default: return; } if (!mPopup) { mPopup = new LXQtWorldClockPopup(mContent); connect(mPopup, SIGNAL(deactivated()), SLOT(deletePopup())); if (reason == ILXQtPanelPlugin::Trigger) { mPopup->setObjectName(QLatin1String("WorldClockCalendar")); mPopup->layout()->setContentsMargins(0, 0, 0, 0); QCalendarWidget *calendarWidget = new QCalendarWidget(mPopup); mPopup->layout()->addWidget(calendarWidget); QString timeZoneName = mActiveTimeZone; if (timeZoneName == QLatin1String("local")) timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId()); QTimeZone timeZone(timeZoneName.toLatin1()); calendarWidget->setFirstDayOfWeek(QLocale(QLocale::AnyLanguage, timeZone.country()).firstDayOfWeek()); calendarWidget->setSelectedDate(QDateTime::currentDateTime().toTimeZone(timeZone).date()); } else { mPopup->setObjectName(QLatin1String("WorldClockPopup")); mPopupContent = new QLabel(mPopup); mPopup->layout()->addWidget(mPopupContent); mPopupContent->setAlignment(mContent->alignment()); updatePopupContent(); } mPopup->adjustSize(); mPopup->setGeometry(calculatePopupWindowPos(mPopup->size())); willShowWindow(mPopup); mPopup->show(); } else { deletePopup(); } }
Module::Module(QWidget *parent, const QVariantList &args) : KCModule(parent, args) , ui(new Ui::Module) , m_manager(new DriverManager(this)) { KAboutData *aboutData = new KAboutData("kcm-driver-manager", i18n("Driver Manager"), global_s_versionStringFull, QStringLiteral(""), KAboutLicense::LicenseKey::GPL_V3, i18n("Copyright 2013 Rohan Garg")); aboutData->addAuthor(i18n("Rohan Garg"), i18n("Author"), QStringLiteral("*****@*****.**")); aboutData->addAuthor(i18n("Harald Sitter"), i18n("Qt 5 port"), QStringLiteral("*****@*****.**")); setAboutData(aboutData); // We have no help so remove the button from the buttons. setButtons(buttons() ^ KCModule::Help); ui->setupUi(this); ui->progressBar->setVisible(false); connect(ui->reloadButton, SIGNAL(clicked(bool)), SLOT(load())); m_overlay = new KPixmapSequenceOverlayPainter(this); m_overlay->setWidget(this); #warning variable name QString label = xi18nc("@title/rich", "<title>Your computer requires no proprietary drivers</title>"); m_label = new QLabel(label, this); m_label->hide(); ui->driverOptionsVLayout->addWidget(m_label); //Debconf handling QString uuid = QUuid::createUuid().toString(); uuid.remove('{').remove('}').remove('-'); m_pipe = QDir::tempPath() % QLatin1String("/qapt-sock-") % uuid; m_debconfGui = new DebconfKde::DebconfGui(m_pipe, this); m_debconfGui->connect(m_debconfGui, SIGNAL(activated()), this, SLOT(showDebconf())); m_debconfGui->connect(m_debconfGui, SIGNAL(deactivated()), this, SLOT(hideDebconf())); m_debconfGui->hide(); connect(m_manager, SIGNAL(refreshFailed()), this, SLOT(onRefreshFailed())); connect(m_manager, SIGNAL(devicesReady(DeviceList)), this, SLOT(onDevicesReady(DeviceList))); connect(m_manager, SIGNAL(changeProgressChanged(int)), this, SLOT(progressChanged(int))); connect(m_manager, SIGNAL(changeFinished()), this, SLOT(finished())); connect(m_manager, SIGNAL(changeFailed(QString)), this, SLOT(failed(QString))); }
/*! \reimp */ void QUsbStorageGadgetProvider::deactivate() { if (value("active", false).toBool()) { if (QProcess::execute("/sbin/rmmod g_file_storage") == 0) { setValue("active", false); emit deactivated(); } else { emit deactivateFailed(); } } }
void UsbGadgetTask::activateEthernet() { QUsbEthernetGadget *ethernetGadget = new QUsbEthernetGadget; if (ethernetGadget && ethernetGadget->available()) { connect(ethernetGadget, SIGNAL(activated()), this, SLOT(ethernetActivated())); connect(ethernetGadget, SIGNAL(activateFailed()), this, SLOT(ethernetDeactivated())); connect(ethernetGadget, SIGNAL(deactivated()), this, SLOT(ethernetDeactivated())); ethernetGadget->activate(); m_gadget = ethernetGadget; } }
void TabbableWidget::changeEvent(QEvent* event) { AdvancedWidget<QWidget>::changeEvent(event); if (event->type() == QEvent::ActivationChange || event->type() == QEvent::WindowStateChange) { if (isActiveTab()) { activated(); } else { deactivated(); } } }
int EventFilter::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: activated(); break; case 1: deactivated(); break; default: ; } _id -= 2; } return _id; }
bool PlayGameEngine::createEngine_() { SB_PLAY_DEBUG("PlayGameEngine::createEngine_()"); stopBetweenMoves_ = AppSettings->getValue("/PlayGame/restartEngineBetweenMoves").toBool(); if (engine_) destroyEngine_(); EngineList elist; elist.restore(); int i = elist.names().indexOf(name_); if (i >= 0) { engine_ = Engine::newEngine(i); connect(engine_, SIGNAL(activated()), SLOT(engineActivated_())); connect(engine_, SIGNAL(readyOk()), SLOT(engineReadyOk_())); connect(engine_, SIGNAL(error(QProcess::ProcessError)), SLOT(engineError_(QProcess::ProcessError))); connect(engine_, SIGNAL(deactivated()), SLOT(engineDeactivated_())); connect(engine_, SIGNAL(analysisUpdated(Analysis)), SLOT(engineAnalysis_(const Analysis&))); connect(engine_, SIGNAL(bestMoveSend(SHATRA::Move)), SLOT(engineBestMove_(SHATRA::Move))); // debug if (engineDebug_) { connect(engine_, SIGNAL(engineDebug(Engine*,Engine::DebugType,QString)), engineDebug_, SLOT(slotEngineDebug(Engine*,Engine::DebugType,QString))); } connect(engine_, SIGNAL(engineDebug(Engine*,Engine::DebugType,QString)), SIGNAL(engineDebug(Engine*,Engine::DebugType,QString))); //if (!stopBetweenMoves_) engine_->activate(); SB_PLAY_DEBUG("PlayGameEngine::createEngine_(): created Engine " << name_); return true; } else { SB_PLAY_DEBUG("PlayGameEngine::createEngine_(): unknown Engine name " << name_); return false; } }
KMdiDockContainer::~KMdiDockContainer() { TQMap<KDockWidget*, int>::iterator it; while ( m_map.count() ) { it = m_map.begin(); KDockWidget *w = it.key(); if ( m_overlapButtons.contains( w ) ) { ( ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() ) )->removeButton( m_overlapButtons[w] ); m_overlapButtons.remove( w ); } m_map.remove( w ); w->undock(); } deactivated( this ); }
void ExecutionDomain::RemoveEventSource(EventSource* event_source) { fbl::AutoLock sources_lock(&sources_lock_); // Has this ExecutionDomain become deactivated? If so, then this // event_source may still be on a list (the local 'to_deactivate' list in // Deactivate), but it is not in the ExecutionDomain's sources_ list, so // there is nothing to do here. if (deactivated()) { ZX_DEBUG_ASSERT(sources_.is_empty()); return; } // If the event_source has not already been removed from the domain's list, do // so now. if (event_source->InExecutionDomain()) sources_.erase(*event_source); }
void KPrViewModePresentation::deactivate() { emit deactivated(); m_animationDirector->deactivate(); KoPAPageBase * page = m_view->activePage(); if ( m_endOfSlideShowPage ) { if ( page == m_endOfSlideShowPage ) { KPrDocument *document = static_cast<KPrDocument *>( m_view->kopaDocument() ); page = document->slideShow().last(); } } m_tool->deactivate(); if (!m_baseCanvas) return; m_baseCanvas->setParent( m_savedParent, Qt::Widget ); m_baseCanvas->setFocus(); m_baseCanvas->setWindowState( m_baseCanvas->windowState() & ~Qt::WindowFullScreen ); // reset m_baseCanvas->show(); KoCursor::setAutoHideCursor( m_baseCanvas, false ); m_baseCanvas->setMouseTracking( true ); m_view->setActivePage( page ); // only delete after the new page has been set delete m_endOfSlideShowPage; m_endOfSlideShowPage = 0; delete m_animationDirector; m_animationDirector = 0; if ( m_presenterViewWidget ) { m_presenterViewWidget->setWindowState( m_presenterViewWidget->windowState() & ~Qt::WindowFullScreen ); delete m_pvAnimationDirector; m_pvAnimationDirector = 0; delete m_presenterViewWidget; m_presenterViewWidget = 0; m_presenterViewCanvas = 0; } // make sure the page does not have an offset after finishing a presentation m_baseCanvas->setDocumentOffset(QPoint(0, 0)); }
void ExecutionDomain::DispatchPendingWork() { // While we have work waiting in the pending queue, dispatch it. // // TODO(johngro) : To prevent starvation issues, we should probably only // perform a finite amount of work, and unwind out into the port wait // operation to give other event source owners a chance if this ends up // going on for too long. while (true) { // Enter the sources lock and take a reference to the front of the // pending queue. If the pending work queue is empty, or we have been // deactivated, we are finished. fbl::RefPtr<EventSource> source; { fbl::AutoLock sources_lock(&sources_lock_); ZX_DEBUG_ASSERT(dispatch_in_progress_); if (deactivated() || pending_work_.is_empty()) { // Clear the pending work queue and the dispatch in progress // flag. If someone is attempting to synchronize with dispatch // operations in flight, set the event indicating that we are // now idle. pending_work_.clear(); dispatch_in_progress_ = false; if (dispatch_sync_in_progress_) { __UNUSED zx_status_t res; res = dispatch_idle_evt_.signal(0u, ZX_USER_SIGNAL_0); ZX_DEBUG_ASSERT(res == ZX_OK); } return; } source = pending_work_.begin().CopyPointer(); } // Attempt to transition to the Dispatching state. If this fails, it // means that we were canceled after we left the sources_lock_ but // before we managed to re-enter both the EventSource's object lock and // the execution domain's sources lock. If this is the case, just move // on to the next pending source. ZX_DEBUG_ASSERT(source != nullptr); if (source->BeginDispatching()) source->Dispatch(this); } }
KasTaskItem::KasTaskItem( KasTasker *parent, Task::Ptr task ) : KasItem( parent ), task_(task), thumbTimer(0), attentionTimer(0) { setIcon( icon() ); setAttention( task->demandsAttention() ); updateTask(false); connect( task, SIGNAL( changed(bool) ), this, SLOT( updateTask(bool) ) ); connect( task, SIGNAL( activated() ), this, SLOT( startAutoThumbnail() ) ); connect( task, SIGNAL( deactivated() ), this, SLOT( stopAutoThumbnail() ) ); connect( task, SIGNAL( iconChanged() ), this, SLOT( iconChanged() ) ); connect( task, SIGNAL( thumbnailChanged() ), this, SLOT( iconChanged() ) ); connect( this, SIGNAL(leftButtonClicked(QMouseEvent *)), SLOT(toggleActivateAction()) ); connect( this, SIGNAL(rightButtonClicked(QMouseEvent *)), SLOT(showWindowMenuAt(QMouseEvent *) ) ); attentionTimer = new QTimer( this, "attentionTimer" ); connect( attentionTimer, SIGNAL( timeout() ), SLOT( checkAttention() ) ); attentionTimer->start( CHECK_ATTENTION_DELAY ); }
zx_status_t ExecutionDomain::AddEventSource( fbl::RefPtr<EventSource>&& event_source) { if (event_source == nullptr) return ZX_ERR_INVALID_ARGS; // This check is a bit sketchy... This event_source should *never* be in // any ExecutionDomain's event_source list at this point in time, however if // it is, we don't really know what lock we need to obtain to make this // observation atomically. That said, the check will not mutate any state, // so it should be safe. It just might not catch a bad situation which // should never happen. ZX_DEBUG_ASSERT(!event_source->InExecutionDomain()); // If this ExecutionDomain has become deactivated, then it is not accepting // any new event sources. Fail the request to add this event_source. fbl::AutoLock sources_lock(&sources_lock_); if (deactivated()) return ZX_ERR_BAD_STATE; // We are still active. Transfer the reference to this event_source to our set // of sources. sources_.push_front(std::move(event_source)); return ZX_OK; }
void DockContainer::tabClicked(int t) { kdDebug(760) << "DockContainer::tabClicked()" << endl; bool call_makeVisible = !m_tabSwitching; m_tabSwitching = true; if((t != -1) && m_tb->isTabRaised(t)) { if(m_ws->isHidden()) { m_ws->show(); parentDockWidget()->restoreFromForcedFixedSize(); } if(!m_ws->widget(t)) { m_revMap[t]->manualDock(parentDockWidget(), KDockWidget::DockCenter, 20); if(call_makeVisible) m_revMap[t]->makeDockVisible(); // manualDock(parentDockWidget(),KDockWidget::DockCenter,20); m_tabSwitching = false; emit activated(this); return; } m_ws->raiseWidget(t); if(m_ws->widget(t)) { KDockWidget *tmpDw = static_cast< KDockWidget * >(m_ws->widget(t)->qt_cast("KDockWidget")); if(tmpDw) { if(tmpDw->getWidget()) tmpDw->getWidget()->setFocus(); } else kdDebug(760) << "Something really weird is going on" << endl; } else kdDebug(760) << "DockContainer::tabClicked(int): m_ws->widget(t)==0 " << endl; if(oldtab != t) m_tb->setTab(oldtab, false); m_tabSwitching = true; oldtab = t; emit activated(this); } else { // try save splitter position if(parentDockWidget() && parentDockWidget()->parent()) { KDockSplitter *sp = static_cast< KDockSplitter * >(parentDockWidget()->parent()->qt_cast("KDockSplitter")); if(sp) m_separatorPos = sp->separatorPos(); } m_previousTab = t; // oldtab=-1; if(m_block) return; emit deactivated(this); m_block = true; if(m_ws->widget(t)) { // ((KDockWidget*)m_ws->widget(t))->undock(); } m_block = false; m_ws->hide(); kdDebug(760) << "Fixed Width:" << m_tb->width() << endl; if(m_vertical) parentDockWidget()->setForcedFixedWidth(m_tb->width()); // strange why it worked before at all else parentDockWidget()->setForcedFixedHeight(m_tb->height()); // strange why it worked before at all } m_tabSwitching = false; }
QX::QX(QWidget *parent, Qt::WFlags f) : QWidget(parent) { Q_UNUSED(f); BuildMenu(); favouritesAction->setChecked(true); lineEdit = new QLineEdit("xterm", this); bOk = new QPushButton(this); bOk->setMinimumWidth(100); bOk->setText("Run"); connect(bOk, SIGNAL(clicked()), this, SLOT(okClicked())); lw = new QListWidget(this); connect(lw, SIGNAL(clicked(QModelIndex)), this, SLOT(listClicked())); lAppname = new QLabel(this); bResume = new QPushButton(this); bTerminate = new QPushButton(this); lAppname->setVisible(false); lAppname->setAlignment(Qt::AlignCenter); bResume->setVisible(false); bTerminate->setVisible(false); connect(bResume, SIGNAL(clicked()), this, SLOT(resumeClicked())); connect(bTerminate, SIGNAL(clicked()), this, SLOT(terminateClicked())); //------------------------------------------ grid=new QGridLayout(this); grid->addWidget(lineEdit,0,0); grid->addWidget(bOk,0,1); grid->addWidget(lw,1,0,1,2); grid->addWidget(lAppname,2,0,1,2); grid->addWidget(bResume,3,0,1,2); grid->addWidget(bTerminate,4,0,1,2); LoadFavourites(); scanner = new DesktopScanner(); FillApps(favouritesAction->isChecked()); //========================================== appRunScr = new AppRunningScreen(); connect(appRunScr, SIGNAL(deactivated()), this, SLOT(pauseApp())); connect(appRunScr, SIGNAL(keyPress(QKeyEvent *)), this, SLOT(keyPress(QKeyEvent *))); connect(appRunScr, SIGNAL(keyRelease(QKeyEvent *)), this, SLOT(keyRelease(QKeyEvent *))); process = NULL; xprocess = NULL; rotHelper = new RotateHelper(this, 0); wmTimer = new QTimer(this); connect(wmTimer, SIGNAL(timeout()), this, SLOT(processWmEvents())); screen = QX::ScreenMain; if(getenv("DISPLAY") == NULL) setenv("DISPLAY", "0:0", true); #if QTOPIA powerConstraint = QtopiaApplication::Disable; // Start the "QX" service that handles application switching. new QxService(this); #endif showScreen(QX::ScreenMain); }
/*? Test function for QUsbStorageGadgetProvider. This test: * Creates a QUsbStorageGadgetProvider. * Does simple set-get tests on QUsbStorageGadgetProvider attributes. * Activates and deactivates the gadget and ensures that the required signals are emitted. */ void tst_QUsbStorageGadget::providerTests() { QUsbManager *manager = new QUsbManager(this); // Test that there is no current usb gadget QList<QUsbGadget *> activeGadgets = manager->activeGadgets(); QVERIFY(activeGadgets.count() == 0); foreach (QUsbGadget *gadget, activeGadgets) delete gadget; // Test that the provider works as expected { QUsbStorageGadgetProvider *provider = new QUsbStorageGadgetProvider("Qt Extended"); // Set and test various attributes { if (provider->supportsProduct()) { provider->setProduct("Qt Extended Product"); QVERIFY(provider->product() == "Qt Extended Product"); } if (provider->supportsProductId()) { provider->setProductId(0x5454); QVERIFY(provider->productId() == 0x5454); } if (provider->supportsVendor()) { provider->setVendor("Qt Extended Vendor"); QVERIFY(provider->vendor() == "Qt Extended Vendor"); } if (provider->supportsVendorId()) { provider->setVendorId(0x5454); QVERIFY(provider->vendorId() == 0x5454); } QVERIFY(provider->backingStore().isEmpty()); provider->addBackingStore("/dev/partition1"); QVERIFY(provider->backingStore().count() == 1); QVERIFY(provider->backingStore().contains("/dev/partition1")); provider->addBackingStore("/dev/partition2"); QVERIFY(provider->backingStore().count() == 2); QVERIFY(provider->backingStore().contains("/dev/partition1")); QVERIFY(provider->backingStore().contains("/dev/partition2")); provider->removeBackingStore("/dev/partition1"); QVERIFY(provider->backingStore().count() == 1); QVERIFY(!provider->backingStore().contains("/dev/partition1")); QVERIFY(provider->backingStore().contains("/dev/partition2")); QStringList partitions; partitions << "/dev/partition3" << "/dev/partition4"; provider->setBackingStore(partitions); QVERIFY(provider->backingStore() == partitions); provider->setBackingStore(QStringList()); QVERIFY(provider->backingStore().isEmpty()); } // Activate and deactivate gadget if (QProcess::execute("/sbin/modinfo g_file_storage")) { QSKIP("This test requires the g_file_storage usb gadget driver", SkipSingle); } else { QVERIFY(manager->canActivate("Storage")); QSignalSpy activateSpy(provider, SIGNAL(activated())); QSignalSpy deactivateSpy(provider, SIGNAL(deactivated())); QTemporaryFile backingStore; backingStore.open(); backingStore.resize(5*1024*1024); provider->addBackingStore(backingStore.fileName()); provider->activate(); //QTRY_VERIFY(activateSpy.count() + deactivateSpy.count() == 1); activateSpy.clear(); deactivateSpy.clear(); QVERIFY(provider->active()); QList<QUsbGadget *> activeGadgets = manager->activeGadgets(); bool activated = false; foreach (QUsbGadget *gadget, activeGadgets) { if (gadget->gadget() == provider->gadget()) activated = true; delete gadget; } QVERIFY(activated); provider->deactivate(); //QTRY_VERIFY(activateSpy.count() + deactivateSpy.count() == 1); QVERIFY(!provider->active()); activeGadgets = manager->activeGadgets(); bool deactivated = true; foreach (QUsbGadget *gadget, activeGadgets) { if (gadget->gadget() == provider->gadget()) deactivated = false; delete gadget; } QVERIFY(deactivated); } delete provider; } delete manager; QValueSpaceObject::sync(); }
/** * @brief ConcertWidget::ConcertWidget * @param parent */ ConcertWidget::ConcertWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ConcertWidget) { ui->setupUi(this); ui->concertName->clear(); ui->artStackedWidget->setAnimation(QEasingCurve::OutCubic); ui->artStackedWidget->setSpeed(300); QFont font = ui->concertName->font(); font.setPointSize(font.pointSize()+4); ui->concertName->setFont(font); m_concert = 0; m_posterDownloadManager = new DownloadManager(this); connect(ui->poster, SIGNAL(clicked()), this, SLOT(chooseConcertPoster())); connect(ui->backdrop, SIGNAL(clicked()), this, SLOT(chooseConcertBackdrop())); connect(ui->logo, SIGNAL(clicked()), this, SLOT(chooseConcertLogo())); connect(ui->clearArt, SIGNAL(clicked()), this, SLOT(chooseConcertClearArt())); connect(ui->cdArt, SIGNAL(clicked()), this, SLOT(chooseConcertCdArt())); connect(ui->poster, SIGNAL(sigClose()), this, SLOT(deleteConcertPoster())); connect(ui->backdrop, SIGNAL(sigClose()), this, SLOT(deleteConcertBackdrop())); connect(ui->logo, SIGNAL(sigClose()), this, SLOT(deleteConcertLogo())); connect(ui->clearArt, SIGNAL(sigClose()), this, SLOT(deleteConcertClearArt())); connect(ui->cdArt, SIGNAL(sigClose()), this, SLOT(deleteConcertCdArt())); connect(m_posterDownloadManager, SIGNAL(downloadFinished(DownloadManagerElement)), this, SLOT(posterDownloadFinished(DownloadManagerElement))); connect(ui->name, SIGNAL(textChanged(QString)), this, SLOT(concertNameChanged(QString))); connect(ui->buttonRevert, SIGNAL(clicked()), this, SLOT(onRevertChanges())); connect(ui->buttonReloadStreamDetails, SIGNAL(clicked()), this, SLOT(onReloadStreamDetails())); ui->genreCloud->setText(tr("Genres")); ui->genreCloud->setPlaceholder(tr("Add Genre")); connect(ui->genreCloud, SIGNAL(activated(QString)), this, SLOT(addGenre(QString))); connect(ui->genreCloud, SIGNAL(deactivated(QString)), this, SLOT(removeGenre(QString))); ui->tagCloud->setText(tr("Tags")); ui->tagCloud->setPlaceholder(tr("Add Tag")); connect(ui->tagCloud, SIGNAL(activated(QString)), this, SLOT(addTag(QString))); connect(ui->tagCloud, SIGNAL(deactivated(QString)), this, SLOT(removeTag(QString))); ui->poster->setDefaultPixmap(QPixmap(":/img/film_reel.png")); ui->backdrop->setDefaultPixmap(QPixmap(":/img/pictures_alt.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->logo->setDefaultPixmap(QPixmap(":/img/pictures_alt.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->clearArt->setDefaultPixmap(QPixmap(":/img/pictures_alt.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->cdArt->setDefaultPixmap(QPixmap(":/img/pictures_alt.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation)); m_loadingMovie = new QMovie(":/img/spinner.gif"); m_loadingMovie->start(); setDisabledTrue(); clear(); m_savingWidget = new QLabel(this); m_savingWidget->setMovie(m_loadingMovie); m_savingWidget->hide(); connect(ui->fanarts, SIGNAL(sigRemoveImage(QByteArray)), this, SLOT(onRemoveExtraFanart(QByteArray))); connect(ui->fanarts, SIGNAL(sigRemoveImage(QString)), this, SLOT(onRemoveExtraFanart(QString))); connect(ui->btnAddExtraFanart, SIGNAL(clicked()), this, SLOT(onAddExtraFanart())); // Connect GUI change events to concert object connect(ui->name, SIGNAL(textEdited(QString)), this, SLOT(onNameChange(QString))); connect(ui->artist, SIGNAL(textEdited(QString)), this, SLOT(onArtistChange(QString))); connect(ui->album, SIGNAL(textEdited(QString)), this, SLOT(onAlbumChange(QString))); connect(ui->tagline, SIGNAL(textEdited(QString)), this, SLOT(onTaglineChange(QString))); connect(ui->rating, SIGNAL(valueChanged(double)), this, SLOT(onRatingChange(double))); connect(ui->trailer, SIGNAL(textEdited(QString)), this, SLOT(onTrailerChange(QString))); connect(ui->runtime, SIGNAL(valueChanged(int)), this, SLOT(onRuntimeChange(int))); connect(ui->playcount, SIGNAL(valueChanged(int)), this, SLOT(onPlayCountChange(int))); connect(ui->certification, SIGNAL(editTextChanged(QString)), this, SLOT(onCertificationChange(QString))); connect(ui->watched, SIGNAL(stateChanged(int)), this, SLOT(onWatchedChange(int))); connect(ui->released, SIGNAL(dateChanged(QDate)), this, SLOT(onReleasedChange(QDate))); connect(ui->lastPlayed, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(onLastWatchedChange(QDateTime))); connect(ui->overview, SIGNAL(textChanged()), this, SLOT(onOverviewChange())); connect(ui->videoAspectRatio, SIGNAL(valueChanged(double)), this, SLOT(onStreamDetailsEdited())); connect(ui->videoCodec, SIGNAL(textEdited(QString)), this, SLOT(onStreamDetailsEdited())); connect(ui->videoDuration, SIGNAL(timeChanged(QTime)), this, SLOT(onStreamDetailsEdited())); connect(ui->videoHeight, SIGNAL(valueChanged(int)), this, SLOT(onStreamDetailsEdited())); connect(ui->videoWidth, SIGNAL(valueChanged(int)), this, SLOT(onStreamDetailsEdited())); connect(ui->videoScantype, SIGNAL(textEdited(QString)), this, SLOT(onStreamDetailsEdited())); QPainter p; QPixmap revert(":/img/arrow_circle_left.png"); p.begin(&revert); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(revert.rect(), QColor(0, 0, 0, 200)); p.end(); ui->buttonRevert->setIcon(QIcon(revert)); ui->buttonRevert->setVisible(false); }
void KMdiDockContainer::tabClicked( int t ) { bool call_makeVisible = !m_tabSwitching; m_tabSwitching = true; if ( m_tb->isTabRaised( t ) ) { kdDebug( 760 ) << k_funcinfo << "Tab " << t << " was just activated" << endl; if ( m_ws->isHidden() ) { kdDebug( 760 ) << k_funcinfo << "Showing widgetstack for tab just clicked" << endl; m_ws->show(); parentDockWidget()->restoreFromForcedFixedSize(); } if ( !m_ws->widget( t ) ) { kdDebug( 760 ) << k_funcinfo << "Widget tab was clicked for is not in our stack" << endl; kdDebug( 760 ) << k_funcinfo << "Docking it back in" << endl; m_revMap[t]->manualDock( parentDockWidget(), KDockWidget::DockCenter, 20 ); if ( call_makeVisible ) m_revMap[t]->makeDockVisible(); m_tabSwitching = false; emit activated( this ); return ; } if ( m_ws->widget( t ) ) { m_ws->raiseWidget( t ); KDockWidget * tmpDw = ::tqqt_cast<KDockWidget*>( m_ws->widget( t ) ); if ( tmpDw ) { if ( tmpDw->getWidget() ) tmpDw->getWidget()->setFocus(); } else kdDebug( 760 ) << k_funcinfo << "Something really weird is going on" << endl; } else kdDebug( 760 ) << k_funcinfo << "We have no widget to handle in our stack." << endl; if ( oldtab != t ) m_tb->setTab( oldtab, false ); m_tabSwitching = true; oldtab = t; emit activated( this ); } else { kdDebug( 760 ) << k_funcinfo << "Tab " << t << " was just deactiviated" << endl; // try save splitter position if ( parentDockWidget() && parentDockWidget()->parent() ) { KDockSplitter * sp = ::tqqt_cast<KDockSplitter*>( parentDockWidget()->parent() ); if ( sp ) m_separatorPos = sp->separatorPos(); } m_previousTab = t; // oldtab=-1; if ( m_block ) return ; emit deactivated( this ); m_block = true; if ( m_ws->widget( t ) ) { // ((KDockWidget*)m_ws->widget(t))->undock(); } m_block = false; m_ws->hide (); kdDebug( 760 ) << k_funcinfo << "Fixed Width:" << m_tb->width() << endl; if ( !m_horizontal ) parentDockWidget()->setForcedFixedWidth( m_tb->width() ); // strange why it worked before at all else parentDockWidget()->setForcedFixedHeight( m_tb->height() ); // strange why it worked before at all } m_tabSwitching = false; }
void setActive(T *active) { m_active = active; if(active) activated(); else deactivated(); }