Beispiel #1
0
int screenDepth(Widget* w)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    return QGuiApplication::screens().value(screenNumber(w))->depth();
#else
    return QApplication::desktop()->screen(screenNumber(w))->depth();
#endif
}
Beispiel #2
0
int screenDepth(Widget* w)
{
#if HAVE(QT5)
    return QGuiApplication::screens().value(screenNumber(w))->depth();
#else
    return QApplication::desktop()->screen(screenNumber(w))->depth();
#endif
}
Beispiel #3
0
FloatRect screenAvailableRect(Widget* widget)
{
#if HAVE(QT5)
    QRect r = QGuiApplication::screens().value(screenNumber(widget))->availableGeometry();
#else
    QRect r = QApplication::desktop()->availableGeometry(screenNumber(widget));
#endif
    return FloatRect(r.x(), r.y(), r.width(), r.height());
}
Beispiel #4
0
FloatRect screenRect(Widget* widget)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QRect r = QGuiApplication::screens().value(screenNumber(widget))->geometry();
#else
    QRect r = QApplication::desktop()->screenGeometry(screenNumber(widget));
#endif
    return FloatRect(r.x(), r.y(), r.width(), r.height());
}
Beispiel #5
0
//Resizes the window so that "content" will have "wanted" size.
//Requires that only the only resizeable widget contains "content".
//Window will be moved so that it does not cross monitors boundaries.
//If "wanted" size can't fit on the monitor, it will be resized
//depending on "keep_aspect". If false, height and width will be clipped.
//If true, it will be scaled so "content" keeps it aspect ratio.
//Function returns "content"'s new size.
QSize windowManager::resize_content( QSize wanted, QSize content, bool keep_aspect, bool only_upscale ){
	auto desktop = QApplication::desktop();
	//Get the difference in size between the content and the whole window
	QSize difference = window.frameGeometry().size() - content;
	
	//Prepare resize dimensions, but keep it within "space"
	auto getPosition = [&]( int monitor ){
		//Take the full area and subtract the constant widths (which doesn't scale with aspect)
		QRect space = desktop->availableGeometry( monitor );
		space.setSize( space.size() - difference );
		
		QRect position = constrain( space, QRect( contrain_point( space, window.pos() ), wanted ), keep_aspect );
		return std::make_pair( position, qsize_area( position.size() ) );
	};
	
	//Find the best monitor, but stay on the first monitor if several can fit the entire window
	auto best = getPosition( desktop->screenNumber( &window ) );
	for( int i=0; i<desktop->screenCount(); i++ )
		best = std::max( best, getPosition( i ), []( std::pair<QRect,int> a, std::pair<QRect,int> b ){ return a.second < b.second; } );
	
	//Move and resize window. We need to convert dimensions to window size though.
	window.move( best.first.topLeft() );
	window.resize( best.first.size() + window.size() - content );
	
	return best.first.size();
}
Beispiel #6
0
bool screenIsMonochrome(Widget* w)
{
#if HAVE(QT5)
    Q_UNUSED(w);
    // FIXME: In Qt 5 colorCount() isn't even implemented beyond returning 256 :)
    return false;
#else
    return QApplication::desktop()->screen(screenNumber(w))->colorCount() == 2;
#endif
}
Beispiel #7
0
int QDesktopWidget::screenNumber(const QWidget *w) const
{
    if (!w)
        return 0;

    QRect frame = w->frameGeometry();
    if (!w->isWindow())
        frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
    const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
    return screenNumber(midpoint);
}
Beispiel #8
0
const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const
{
    if (!widget) {
        qWarning("QDesktopWidget::availableGeometry(): Attempt "
                 "to get the available geometry of a null widget");
        return QRect();
    }
    QRect rect = QWidgetPrivate::screenGeometry(widget);
    if (rect.isNull())
        return availableGeometry(screenNumber(widget));
    else
        return rect;
}
Beispiel #9
0
	void TaskbarProxy::showPager (int x, int y, bool showThumbs)
	{
		if (Pager_)
		{
			Pager_->deleteLater ();
			return;
		}

		auto desktop = QApplication::desktop ();
		const auto screen = desktop->screenNumber ({ x, y });
		Pager_ = new PagerWindow (screen, showThumbs, Proxy_);
		new Util::AutoResizeMixin ({ x, y },
				[screen, desktop] () { return desktop->availableGeometry (screen); },
				Pager_);
		Pager_->show ();
	}
Beispiel #10
0
	QPixmap Plugin::GetPixmap () const
	{
		switch (Dialog_->GetMode ())
		{
		case ShooterDialog::Mode::LCWindowOverlay:
			return QPixmap::grabWindow (Proxy_->GetMainWindow ()->winId ());
		case ShooterDialog::Mode::LCWindow:
			return QPixmap::grabWidget (Proxy_->GetMainWindow ());
		case ShooterDialog::Mode::CurrentScreen:
		{
 			auto desk = qApp->desktop ();
			auto screen = desk->screen (desk->screenNumber (QCursor::pos ()));
			auto geom = desk->screenGeometry (QCursor::pos ());
			return QPixmap::grabWindow (screen->winId (),
					geom.x (), geom.y (), geom.width (), geom.height ());
		}
		case ShooterDialog::Mode::WholeDesktop:
			return QPixmap::grabWindow (qApp->desktop ()->winId ());
		}
	}
FloatRect screenAvailableRect(Widget* widget)
{
    QRect r = QGuiApplication::screens().value(screenNumber(widget))->availableGeometry();
    return FloatRect(r.x(), r.y(), r.width(), r.height());
}
int screenDepth(Widget* w)
{
    return QGuiApplication::screens().value(screenNumber(w))->depth();
}
Beispiel #13
0
bool screenIsMonochrome(Widget* w)
{
    return QApplication::desktop()->screen(screenNumber(w))->colorCount() == 2;
}
Beispiel #14
0
int screenDepth(Widget* w)
{
    return QApplication::desktop()->screen(screenNumber(w))->depth();
}
Beispiel #15
0
FloatRect screenAvailableRect(Widget* w)
{
    QRect r = QApplication::desktop()->availableGeometry(screenNumber(w));
    return FloatRect(r.x(), r.y(), r.width(), r.height());
}
bool screenIsMonochrome(Widget* w)
{
    return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2;
}