Ejemplo n.º 1
0
	rect surface_manager::desktop_rect(const i_surface& aSurface) const
	{
#ifdef WIN32
		HMONITOR monitor = MonitorFromWindow(reinterpret_cast<HWND>(aSurface.native_surface().native_handle()), MONITOR_DEFAULTTONEAREST);
		MONITORINFOEX mi;
		mi.cbSize = sizeof(mi);
		GetMonitorInfo(monitor, &mi);
		return basic_rect<LONG>{ basic_point<LONG>{ mi.rcWork.left, mi.rcWork.top }, basic_size<LONG>{ mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top } };
#else
		/* todo */
		rect rectSurface{ aSurface.surface_position(), aSurface.surface_size() };
		std::multimap<double, uint32_t> matches;
		for (uint32_t i = 0; i < display_count(); ++i)
		{
			rect rectDisplay = desktop_rect(i);
			rect rectIntersection = rectDisplay.intersection(rectSurface);
			if (!rectIntersection.empty())
				matches[rectIntersection.width() * rectIntersection.height()] = i;
		}
		if (matches.empty())
			return desktop_rect(0);
		return desktop_rect(matches.rbegin()->second);
#endif
	}
Ejemplo n.º 2
0
void PrettyImage::ShowFullsize() {
  // Work out how large to make the window, based on the size of the screen
  QRect desktop_rect(QApplication::desktop()->availableGeometry(this));
  QSize window_size(qMin(desktop_rect.width() - 20, image_.width()),
                    qMin(desktop_rect.height() - 20, image_.height()));

  // Create the window
  QScrollArea* window = new QScrollArea;
  window->setAttribute(Qt::WA_DeleteOnClose, true);
  window->setWindowTitle(tr("Clementine image viewer"));
  window->resize(window_size);

  // Create the label that displays the image
  QLabel* label = new QLabel(window);
  label->setPixmap(QPixmap::fromImage(image_));

  // Show the label in the window
  window->setWidget(label);
  window->setFrameShape(QFrame::NoFrame);
  window->show();
}