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()));
}
Example #2
0
KLFLibEntry::KLFLibEntry(const QString& latex, const QDateTime& dt, const QImage& preview,
			 const QSize& previewsize, const QString& category, const QString& tags,
			 const KLFStyle& style)
  : KLFPropertizedObject("KLFLibEntry")
{
  initRegisteredProperties();
  setLatex(latex);
  setDateTime(dt);
  setPreview(preview);
  setPreviewSize(previewsize);
  setCategory(category);
  setTags(tags);
  setStyle(style);
}
void WindowPreview::updateTask(::TaskManager::TaskChanges changes) {
	bool doUpdate = false;
	QSize oldSize = size();

	if (changes & TaskManager::IconChanged) {
		const KIcon icon(m_task->icon());

		if (m_toolTip->previewsAvailable() && (m_task->type() == Task::StartupItem || m_task->type() == Task::LauncherItem)) {
			m_previewSize = icon.pixmap(BIG_ICON_SIZE).size();
		}
	
		switch (m_toolTip->applet()->previewLayout()) {
		case Applet::NewPreviewLayout:
			m_icon = icon.pixmap(BIG_ICON_SIZE);
			break;
		case Applet::ClassicPreviewLayout:
		default:
			m_icon = icon.pixmap(SMALL_ICON_SIZE);
		}
		
		doUpdate = true;
	}

	if (changes & TaskManager::NameChanged) {
		m_taskNameLabel->setText(m_task->text());
		doUpdate = true;
	}

	if (changes & TaskManager::GeometryChanged) {
		setPreviewSize();
		doUpdate = true;
	}

	if (changes & TaskManager::NameChanged) {
		m_taskNameLabel->setText(m_task->text());
		doUpdate = true;
	}
	
	if (doUpdate) {
		updateTheme();

		if (size() != oldSize) {
			emit sizeChanged();
		}
	}
}
Example #4
0
KLFLibEntry::KLFLibEntry(const QString& latex, const QDateTime& dt, const QImage& preview,
			 const KLFStyle& style)
  : KLFPropertizedObject("KLFLibEntry")
{
  initRegisteredProperties();
  QString latexonly = stripCategoryTagsFromLatex(latex);
  QString category = categoryFromLatex(latex);
  QString tags = tagsFromLatex(latex);
  QSize previewsize = preview.size();
  setLatex(latexonly);
  setDateTime(dt);
  setPreview(preview);
  setPreviewSize(previewsize);
  setCategory(category);
  setTags(tags);
  setStyle(style);
}
Example #5
0
PixmapPreviewSelector::PixmapPreviewSelector( QWidget * parent )
  : QWidget( parent )
{
    QHBoxLayout * mainlay = new QHBoxLayout( this );
    mainlay->setMargin( 0 );
    m_comboItems = new KComboBox( this );
    mainlay->addWidget( m_comboItems );
    m_iconLabel = new QLabel( this );
    mainlay->addWidget( m_iconLabel );
    m_iconLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
    m_iconLabel->setAlignment( Qt::AlignCenter );
    m_iconLabel->setFrameStyle( QFrame::StyledPanel );
    setPreviewSize( 32 );

    connect( m_comboItems, SIGNAL(currentIndexChanged(QString)), this, SLOT(iconComboChanged(QString)) );
    connect( m_comboItems, SIGNAL(editTextChanged(QString)), this, SLOT(iconComboChanged(QString)) );
}
Example #6
0
void ExportDlg::heightEditChangedSlot(const QString & text)
{
	if (widthEdit->hasFocus())
	{
		return;
	}

	if (text.toInt() == 0)
	{
		return;
	}

	int h = text.toInt();
	int w = imageSize.width() * h / imageSize.height();

	widthEdit->setText(QString::number(w));
	setPreviewSize(w, h);
}
Example #7
0
void ExportDlg::widthEditChangedSlot(const QString & text)
{
	if (heightEdit->hasFocus())
	{
		return;
	}

	if (text.toInt() == 0 )
	{
		return;
	}

	qDebug()<<(text);

	int w = text.toInt();
	int h = imageSize.height() * w / imageSize.width();
	heightEdit->setText(QString::number(h));
	setPreviewSize(w, h);
}