WindowPreview::WindowPreview(
		TaskManager::TaskItem *task,
		int index,
		SmoothToolTip *toolTip)
	: QWidget(),
	  m_background(new Plasma::FrameSvg(this)),
	  m_iconSpace(NULL),
	  m_previewSpace(NULL),
	  m_highlite(),
	  m_task(new Task(task, this)),
	  m_toolTip(toolTip),
	  m_previewSize(0, 0),
	  m_hover(false),
	  m_index(index),
	  m_activateTimer(NULL),
	  m_didPress(false),
	  m_dragStartPosition() {
	setMouseTracking(true);
	setAcceptDrops(true);

//	m_background->setImagePath("widgets/button");
	m_background->setImagePath("widgets/tasks");
	m_background->setElementPrefix(NORMAL);
	m_background->setCacheAllRenderedFrames(true);

	setPreviewSize();

	// placeholder for preview:
	if (toolTip->previewsAvailable()) {
		m_previewSpace = new QSpacerItem(
			0, 0,
			QSizePolicy::Minimum,
			QSizePolicy::Minimum);
	}

	switch (m_toolTip->applet()->previewLayout()) {
	case Applet::NewPreviewLayout:
		setNewLayout();
		break;
	case Applet::ClassicPreviewLayout:
	default:
		setClassicLayout();
	}
	
	setMaximumWidth(260);
	updateTheme();
	
	connect(m_background, SIGNAL(repaintNeeded()), this, SLOT(updateTheme()));
	connect(
		task, SIGNAL(changed(::TaskManager::TaskChanges)),
		this, SLOT(updateTask(::TaskManager::TaskChanges)));

	connect(&m_highlite, SIGNAL(animate(qreal)), this, SLOT(repaint()));
}
Beispiel #2
0
TaskSource::TaskSource(::TaskManager::Task *task, QObject *parent)
    : Plasma::DataContainer(parent),
      m_task(task)
{
    setObjectName(TasksEngine::getTaskName(task));
    setData("startup", false);
    setData("task", true);
    setData("className", task->className());
    setData("classClass", task->classClass());
    updateTask(TaskManager::EverythingChanged);
}
Beispiel #3
0
// XXX: do I have to tell the applet about this?
void Task::setWindowTask(TaskManager::TaskItem* taskItem) {
	m_type = TaskItem;
	if (m_task && m_task->task()) {
		disconnect(m_task->task(), 0, this, 0);
	}
	
	m_task = taskItem;
	m_abstractItem = qobject_cast<TaskManager::AbstractGroupableItem *>(taskItem);
	
	if (m_abstractItem) {
		connect(m_abstractItem, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed()));
	}
	
	connect(
		m_task, SIGNAL(changed(::TaskManager::TaskChanges)),
		this, SLOT(updateTask(::TaskManager::TaskChanges)));
	
	updateTask(::TaskManager::EverythingChanged);
	
	// for publishing the item geometry:
	emit gotTask();
}
Beispiel #4
0
Task::Task(TaskManager::AbstractGroupableItem *abstractItem, QObject *parent)
	: QObject(parent),
	  m_task(NULL),
	  m_group(NULL),
	  m_abstractItem(abstractItem),
	  m_flags(0),
	  m_type(OtherItem),
	  m_icon() {
	
	connect(
		abstractItem, SIGNAL(destroyed(QObject*)),
		this, SLOT(itemDestroyed()));
	
        if (abstractItem->itemType() == TaskManager::GroupItemType) {
                m_type  = GroupItem;
		m_group = static_cast<TaskManager::TaskGroup*>(abstractItem);
		connect(
			m_group, SIGNAL(changed(::TaskManager::TaskChanges)),
			this, SLOT(updateTask(::TaskManager::TaskChanges)));
		updateTask(::TaskManager::EverythingChanged);
	}
	else if (abstractItem->itemType() == TaskManager::LauncherItemType) {
		m_type = LauncherItem;
		m_launcher = static_cast<TaskManager::LauncherItem*>(abstractItem);
		connect(
			m_launcher, SIGNAL(changed(::TaskManager::TaskChanges)),
			this, SLOT(updateTask(::TaskManager::TaskChanges)));
		updateTask(::TaskManager::EverythingChanged);
	}
	else {
		m_task = static_cast<TaskManager::TaskItem*>(abstractItem);
		if (task()) {
			m_type = TaskItem;
			connect(
				m_task, SIGNAL(changed(::TaskManager::TaskChanges)),
				this, SLOT(updateTask(::TaskManager::TaskChanges)));
			updateTask(::TaskManager::EverythingChanged);
			emit gotTask();
		}
		else if (startup()) {
			m_type = StartupItem;
			connect(m_task, SIGNAL(gotTaskPointer()), this, SLOT(gotTaskPointer()));
			connect(
				m_task, SIGNAL(changed(::TaskManager::TaskChanges)),
				this, SLOT(updateTask(::TaskManager::TaskChanges)));
			updateTask(::TaskManager::EverythingChanged);
		}
	}
}
Beispiel #5
0
void Application::run(void)
{
	TRACE("Running");
	g_WaitScreen.Render();

	while(!g_Input.Quit)
	{
		GameState *state = states[gameState];

		ASSERT(0!=fme, "fme was null");
		ASSERT(0!=state, "state was null");

		// update the frame timer
		fme->Update();
		float frameLength = (float)min(fme->getLength(), (unsigned int)70);

		// Update the current game state
		state->update(frameLength);

		// update all tasks
		for(std::list<Task*>::const_iterator i=tasks.begin();
            i!=tasks.end(); ++i)
		{
			updateTask(*i, frameLength);
		}

		// Take out the garbage
        // TODO: this really only needs to be run periodically?
		tasks = pruneDeadTasks(tasks);

		// pump
		glFlush();
		g_Window.Flip();
		g_Input.Pump();

		// check for window resizing
		if(g_Input.ResizePending())
		{
			g_Window.Resize(g_Input.ResizeWidth(), g_Input.ResizeHeight());
		}
	}
}
Beispiel #6
0
void MainWindow::downloadUpdates(QString repo, int versionId, bool installOnExit)
{
	QLOG_INFO() << "Downloading updates.";
	// TODO: If the user chooses to update on exit, we should download updates in the
	// background.
	// Doing so is a bit complicated, because we'd have to make sure it finished downloading
	// before actually exiting MultiMC.
	ProgressDialog updateDlg(this);
	DownloadUpdateTask updateTask(repo, versionId, &updateDlg);
	// If the task succeeds, install the updates.
	if (updateDlg.exec(&updateTask))
	{
		UpdateFlags baseFlags = None;
		if(BuildConfig.UPDATER_DRY_RUN)
			baseFlags |= DryRun;
		if (installOnExit)
			MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | OnExit);
		else
			MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | RestartOnFinish);
	}
}
Beispiel #7
0
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 );
}
Beispiel #8
0
bool CCSceneBase::update(const CCTime &time)
{
    bool updated = false;

    // Remove any redundant scenes
    for( int i=0; i<childScenes.length; ++i )
    {
        CCSceneBase *scene = childScenes.list[i];
        if( scene->shouldDelete() )
        {
            removeChildScene( scene );
            i--;
            updated = true;
        }
    }

    if( enabled && deleteMe == false )
    {
        updated |= updateTask( time );
    }

    return updated;
}
Beispiel #9
0
/*!
 * Добавление задачи.
 */
void Worker::addTask(const QVariantMap &data)
{
  SCHAT_DEBUG_STREAM("[SendFile] Worker::add(), id:" << SimpleID::encode(data.value("id").toByteArray()));
  start();

  QByteArray id = data.value("id").toByteArray();
  if (m_tasks.contains(id)) {
    updateTask(id, data);
    return;
  }

  SendFileTask task(new Task(data));
  if (!task->transaction()->isValid())
    return;

  if (!task->init())
    return;

  connect(task.data(), SIGNAL(finished(QByteArray,qint64)), SIGNAL(finished(QByteArray,qint64)));
  connect(task.data(), SIGNAL(released(QByteArray)), SLOT(removeTask(QByteArray)));
  connect(task.data(), SIGNAL(progress(QByteArray,qint64,qint64,int)), SIGNAL(progress(QByteArray,qint64,qint64,int)));
  connect(task.data(), SIGNAL(started(QByteArray,qint64)), SIGNAL(started(QByteArray,qint64)));
  m_tasks[id] = task;
}
Beispiel #10
0
void QApplicationStatus::statusMessageReceived(const QList<QByteArray> &messageList)
{
    QByteArray topic;

    topic = messageList.at(0);
    m_rx.ParseFromArray(messageList.at(1).data(), messageList.at(1).size());

#ifdef QT_DEBUG
    std::string s;
    gpb::TextFormat::PrintToString(m_rx, &s);
    DEBUG_TAG(3, "status", "update" << topic << QString::fromStdString(s))
#endif

    if ((m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE)
            || (m_rx.type() == pb::MT_EMCSTAT_INCREMENTAL_UPDATE))
    {
        if ((topic == "motion") && m_rx.has_emc_status_motion()) {
            updateMotion(m_rx.emc_status_motion());
            if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE) {
                updateSync(MotionChannel);
            }
        }

        if ((topic == "config") && m_rx.has_emc_status_config()) {
            updateConfig(m_rx.emc_status_config());
            if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE) {
                updateSync(ConfigChannel);
            }
        }

        if ((topic == "io") && m_rx.has_emc_status_io()) {
            updateIo(m_rx.emc_status_io());
            if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE) {
                updateSync(IoChannel);
            }
        }

        if ((topic == "task") && m_rx.has_emc_status_task()) {
            updateTask(m_rx.emc_status_task());
            if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE) {
                updateSync(TaskChannel);
            }
        }

        if ((topic == "interp") && m_rx.has_emc_status_interp()) {
            updateInterp(m_rx.emc_status_interp());
            if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE) {
                updateSync(InterpChannel);
            }
        }

        if (m_rx.type() == pb::MT_EMCSTAT_FULL_UPDATE)
        {
            if (m_statusSocketState != Up)
            {
                m_statusSocketState = Up;
                updateState(Connected);
            }

            if (m_rx.has_pparams())
            {
                pb::ProtocolParameters pparams = m_rx.pparams();
                startStatusHeartbeat(pparams.keepalive_timer() * 2); // wait double the time of the hearbeat interval
            }
        }
        else
        {
            refreshStatusHeartbeat();
        }

        return;
    }
    else if (m_rx.type() == pb::MT_PING)
    {
        if (m_statusSocketState == Up)
        {
            refreshStatusHeartbeat();
        }
        else
        {
            updateState(Connecting);
            unsubscribe();  // clean up previous subscription
            subscribe();    // trigger a fresh subscribe
        }

        return;
    }

#ifdef QT_DEBUG
    gpb::TextFormat::PrintToString(m_rx, &s);
    DEBUG_TAG(1, "status", "update: unknown message type: " << QString::fromStdString(s))
#endif
}