PanelWindow::PanelWindow(QString id)
{
    m_id = id;
    m_dockMode = false;
    m_screen = 0;
    m_horizontalAnchor = Center;
    m_verticalAnchor = Min;
    m_orientation = Horizontal;
    m_layoutPolicy = Normal;

    setStyleSheet("background-color: transparent");
	setAttribute(Qt::WA_TranslucentBackground);

	m_scene = new QGraphicsScene();
	m_scene->setBackgroundBrush(QBrush(Qt::NoBrush));

	m_panelItem = new PanelWindowGraphicsItem(this);
	m_scene->addItem(m_panelItem);

	m_view = new QGraphicsView(m_scene, this);
	m_view->setStyleSheet("border-style: none;");
	m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_view->setRenderHint(QPainter::Antialiasing);
	m_view->move(0, 0);

    readSettings();

    resize(adjustHardcodedPixelSize(512), adjustHardcodedPixelSize(48));
}
Exemple #2
0
void DockItem::updateContent()
{
	if(m_clients.isEmpty())
		return;

	QFontMetrics fontMetrics(m_textItem->font());
	QString shortName = fontMetrics.elidedText(m_clients[0]->name(), Qt::ElideRight, m_targetSize.width() - adjustHardcodedPixelSize(36));
	m_textItem->setText(shortName);
	m_textItem->setPos(adjustHardcodedPixelSize(28), m_dockApplet->panelWindow()->textBaseLine());

	m_iconItem->setPixmap(m_clients[0]->icon().pixmap(adjustHardcodedPixelSize(16)));
	m_iconItem->setPos(adjustHardcodedPixelSize(8), m_targetSize.height()/2 - adjustHardcodedPixelSize(8));

	// update();
}
int ApplicationsMenuStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const
{
	if(metric == QStyle::PM_SmallIconSize)
		return adjustHardcodedPixelSize(32);
	else
		return QPlastiqueStyle::pixelMetric(metric, option, widget);
}
ApplicationsMenuApplet::ApplicationsMenuApplet(PanelWindow* panelWindow)
	: Applet(panelWindow), m_menuOpened(false)
{
	m_menu = new QMenu();
	m_menu->setStyle(&m_style);
	m_menu->setFont(m_panelWindow->font());
	m_menu->setStyleSheet(QString().sprintf(menuStyleSheet,
		adjustHardcodedPixelSize(36),
		adjustHardcodedPixelSize(38),
		adjustHardcodedPixelSize(20),
		adjustHardcodedPixelSize(2),
		adjustHardcodedPixelSize(2),
		adjustHardcodedPixelSize(2)
	));
	m_subMenus.append(SubMenu(m_menu, "Accessories", "Utility", "applications-accessories"));
	m_subMenus.append(SubMenu(m_menu, "Development", "Development", "applications-development"));
	m_subMenus.append(SubMenu(m_menu, "Education", "Education", "applications-science"));
	m_subMenus.append(SubMenu(m_menu, "Office", "Office", "applications-office"));
	m_subMenus.append(SubMenu(m_menu, "Graphics", "Graphics", "applications-graphics"));
	m_subMenus.append(SubMenu(m_menu, "Multimedia", "AudioVideo", "applications-multimedia"));
	m_subMenus.append(SubMenu(m_menu, "Games", "Game", "applications-games"));
	m_subMenus.append(SubMenu(m_menu, "Network", "Network", "applications-internet"));
	m_subMenus.append(SubMenu(m_menu, "System", "System", "preferences-system"));
	m_subMenus.append(SubMenu(m_menu, "Settings", "Settings", "preferences-desktop"));
	m_subMenus.append(SubMenu(m_menu, "Other", "Other", "applications-other"));

	m_textItem = new TextGraphicsItem(this);
	m_textItem->setColor(Qt::white);
	m_textItem->setFont(m_panelWindow->font());
	m_textItem->setText(tr("Applications"));
}
Exemple #5
0
void DockApplet::updateLayout()
{
	// TODO: Vertical orientation support.

	int freeSpace = m_size.width();
	int spaceForOneClient = (m_dockItems.size() > 0) ? freeSpace/m_dockItems.size() : 0;
	int currentPosition = 0;
	for(int i = 0; i < m_dockItems.size(); i++)
	{
		int spaceForThisClient = spaceForOneClient;
		static const int maxSpace = adjustHardcodedPixelSize(256);
		if(spaceForThisClient > maxSpace)
			spaceForThisClient = maxSpace;
		m_dockItems[i]->setTargetPosition(QPoint(currentPosition, 0));
		m_dockItems[i]->setTargetSize(QSize(spaceForThisClient - 4, m_size.height()));
		m_dockItems[i]->startAnimation();
		currentPosition += spaceForThisClient;
	}

	// update();
}
Exemple #6
0
void DockItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
	painter->setPen(Qt::NoPen);
	QPointF center(m_size.width()/2.0, m_size.height() + adjustHardcodedPixelSize(32));
	QRectF rect(0.0, adjustHardcodedPixelSize(4), m_size.width(), m_size.height() - adjustHardcodedPixelSize(8));
	static const qreal roundRadius = adjustHardcodedPixelSize(3);

	{
		QRadialGradient gradient(center, adjustHardcodedPixelSize(200), center);
		gradient.setColorAt(0.0, QColor(255, 255, 255, 80 + static_cast<int>(80*m_highlightIntensity)));
		gradient.setColorAt(1.0, QColor(255, 255, 255, 0));
		painter->setBrush(QBrush(gradient));
		painter->drawRoundedRect(rect, roundRadius, roundRadius);
	}

	if(m_urgencyHighlightIntensity > 0.001)
	{
		QRadialGradient gradient(center, adjustHardcodedPixelSize(200), center);
		gradient.setColorAt(0.0, QColor(255, 100, 0, static_cast<int>(160*m_urgencyHighlightIntensity)));
		gradient.setColorAt(1.0, QColor(255, 255, 255, 0));
		painter->setBrush(QBrush(gradient));
		painter->drawRoundedRect(rect, roundRadius, roundRadius);
	}
}
TrayApplet::TrayApplet(PanelWindow* panelWindow)
	: Applet(panelWindow), m_initialized(false), m_iconSize(adjustHardcodedPixelSize(24)), m_spacing(adjustHardcodedPixelSize(4))
{
    setObjectName("Tray");
}
ApplicationsMenuApplet::ApplicationsMenuApplet(PanelWindow* panelWindow)
	: Applet(panelWindow),
	m_menuOpened(false),
	m_opacity(0.8),
	m_backgroundMenuColor("gray"),
	m_textMenuColor("white"),
	m_selectedMenuColor("darkGray"),
	m_backgroundSelectedMenuColor("white"),
	m_menuBorderColor("black"),
	m_menuBorderWidth(1),
	m_menuBorderRadiusTopLeft(0),
	m_menuBorderRadiusTopRight(0),
	m_menuBorderRadiusBottomLeft(0),
	m_menuBorderRadiusBottomRight(0)
{
	if (!xmlRead()) {
		qWarning("Don't read configuration applet file.");
	}
	m_menu = new QMenu();
	//
	m_menu->setAttribute(Qt::WA_TranslucentBackground, true);
	//
	m_menu->setStyle(&m_style);
	m_menu->setFont(m_panelWindow->font());
	m_menu->setStyleSheet(QString(menuStyleSheet)
		.arg(adjustHardcodedPixelSize(m_menuBorderWidth))				// 1
		.arg(m_menuBorderColor.name())									// 2
		.arg(adjustHardcodedPixelSize(m_menuBorderRadiusTopLeft))		// 3
		.arg(adjustHardcodedPixelSize(m_menuBorderRadiusTopRight))		// 4
		.arg(adjustHardcodedPixelSize(m_menuBorderRadiusBottomLeft))	// 5
		.arg(adjustHardcodedPixelSize(m_menuBorderRadiusBottomRight))	// 6
		.arg(m_backgroundMenuColor.name())								// 7
		.arg(adjustHardcodedPixelSize(24))								// 8
		.arg(m_textMenuColor.name())									// 9
		.arg(adjustHardcodedPixelSize(32))								// 10
		.arg(adjustHardcodedPixelSize(16))								// 11
		.arg(adjustHardcodedPixelSize(2))								// 12
		.arg(adjustHardcodedPixelSize(2))								// 13
		.arg(m_selectedMenuColor.name())								// 14
		.arg(m_backgroundSelectedMenuColor.name())						// 15
		.arg(adjustHardcodedPixelSize(2))								// 16
	);
	m_subMenus.append(SubMenu(m_menu, tr("Accessories"), "Utility", "applications-accessories"));
	m_subMenus.append(SubMenu(m_menu, tr("Development"), "Development", "applications-development"));
	m_subMenus.append(SubMenu(m_menu, tr("Education"), "Education", "applications-science"));
	m_subMenus.append(SubMenu(m_menu, tr("Office"), "Office", "applications-office"));
	m_subMenus.append(SubMenu(m_menu, tr("Graphics"), "Graphics", "applications-graphics"));
	m_subMenus.append(SubMenu(m_menu, tr("Multimedia"), "AudioVideo", "applications-multimedia"));
	m_subMenus.append(SubMenu(m_menu, tr("Games"), "Game", "applications-games"));
	m_subMenus.append(SubMenu(m_menu, tr("Network"), "Network", "applications-internet"));
	m_subMenus.append(SubMenu(m_menu, tr("System"), "System", "preferences-system"));
	m_subMenus.append(SubMenu(m_menu, tr("Settings"), "Settings", "preferences-desktop"));
	m_subMenus.append(SubMenu(m_menu, tr("Other"), "Other", "applications-other"));
//
	setOpacity(m_opacity);
	m_pixmapItem = new QGraphicsPixmapItem(this);
	if (m_icon.name().isEmpty())
		m_icon = QIcon::fromTheme("start-here-symbolic");
	m_pixmapItem->setPixmap(m_icon.pixmap(adjustHardcodedPixelSize(24), adjustHardcodedPixelSize(24)));
	m_pixmapItem->setOffset(4, 4);
//
	m_textItem = new TextGraphicsItem(this);
	m_textItem->setColor(Qt::white);
	m_textItem->setFont(m_panelWindow->font());
	m_textItem->setText(tr("Applications"));
	m_settingsUi = new Ui::AppletApplicationsMenuSettings;
}