Пример #1
0
int main(int argc, char *argv[])
{

    KAboutData aboutData("photolayoutseditor",
                         0,
                         ki18n("Photo Layouts Editor"),
                         QString("").toUtf8(),
                         ki18n(""),
                         KAboutData::License_GPL,
                         ki18n(""),
                         ki18n(""),
                         QString("").toUtf8());

    KCmdLineArgs::init(argc,argv,&aboutData);

    KApplication a;

    PhotoLayoutsEditor * w = PhotoLayoutsEditor::instance(0);
    w->setAttribute(Qt::WA_DeleteOnClose, true);
    int height = QApplication::desktop()->height()-500;
    w->resize(round(height*16.0/9.0),height);
    QDesktopWidget * d = a.desktop();
    w->move(d->rect().center()-w->frameGeometry().center());
    w->show();

    int result = a.exec();

    return result;
}
Пример #2
0
App::App(QObject *parent) :
    QObject(parent)
{

    /* Changes application language on runtime */
    _languageSelector = new LanguageSelector();

    QDesktopWidget *desktop = QApplication::desktop();

    /* Widget that contains OpenGL view and info view */
    _screenWidget = new ScreenWidget();
    _screenWidget->setGeometry(desktop->rect());
    _viewportWidget = new ViewportWidget(_screenWidget);
    _infoWidget = new InfoWidget(_screenWidget);

    /* Main menu */
    _mw = new MainWindow(desktop, _screenWidget, _infoWidget,
                                    desktop->width(), desktop->height());

    /* Set up controller */
    _imageReader = new ImageReader();
    _controller = new Controller(_mw, _imageReader, _languageSelector);

    /* Metadata for debugging */
    _screenWidget->setObjectName(QString("ScreenWidget"));
    _viewportWidget->setObjectName(QString("ViewportWidget"));
    _infoWidget->setObjectName(QString("InfoWidget"));
    _mw->setObjectName(QString("MainWindow"));

}
Пример #3
0
PhotoLayoutsEditor::PhotoLayoutsEditor(QWidget * parent) :
    KXmlGuiWindow(parent),
    m_canvas(0),
    m_interface(0),
    d(new PhotoLayoutsEditorPriv)
{
    m_instance = this;
    componentData().setAboutData( PLEAboutData() );

    initIconsResource();
    setXMLFile("photolayoutseditorui.rc");
    setCaption("Photo Layouts Editor");

    loadEffects();
    loadBorders();
    setupActions();
    createWidgets();
    refreshActions();

    setAcceptDrops(true);
    int height = QApplication::desktop()->height()*0.8;
    resize(qRound(height*16.0/9.0),height);
    QDesktopWidget* d = KApplication::kApplication()->desktop();
    move(d->rect().center() - this->frameGeometry().center());
}
Пример #4
0
/*!
    \overload
    \internal
    Calculates the position at which the ScrollDial will
    be shown.
*/
QPoint QtScrollDial::popupPosition()
{
    // Get information about the users screen size
    QDesktopWidget desktop;
    QRect desktopRect = (desktop.rect());

    const int w = m_popup->sizeHint().width();
    const int h = m_popup->sizeHint().height();

    // 15 pixel is the popup's m_closeButton.height() / 2
    QPoint popupPosition(rect().right(), -15);

    QPoint globalPos = mapToGlobal(popupPosition);

    // if it does not fit on the right, move to the left
    if (globalPos.x() + w > desktopRect.right()) {
        globalPos.setX(globalPos.x() - width() - w);
    }

    if (globalPos.x() + w > desktopRect.right()) {
        globalPos.setX(desktopRect.right() - w);
    }
    if (globalPos.x() < desktopRect.left()) {
        globalPos.setX(desktopRect.left());
    }
    if (globalPos.y() < desktopRect.top()) {
        globalPos.setY(desktopRect.top());
    }
    if (globalPos.y() + h > desktopRect.bottom()) {
        globalPos.setY(desktopRect.bottom() - h);
    }

    return globalPos;
}
Пример #5
0
const QRect XfitMan::availableGeometry(int screen) const
{
    QDesktopWidget *d = QApplication::desktop();

    if (screen < 0 || screen >= d->screenCount())
        screen = d->primaryScreen();

    QRect available = d->screenGeometry(screen);

    // Iterate over all the client windows and subtract from the available
    // area the space they reserved on the edges (struts).
    // Note: _NET_WORKAREA is not reliable as it exposes only one
    // rectangular area spanning all screens.
    Display *display = QX11Info::display();
    int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen;

    Atom ret;
    int format, status;
    uchar* data = 0;
    ulong nitems, after;

    status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen),
                                atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW,
                                &ret, &format, &nitems, &after, &data);

    if (status == Success && ret == XA_WINDOW && format == 32 && nitems)
    {
        const QRect desktopGeometry = d->rect();

        Window* xids = (Window*) data;
        for (quint32 i = 0; i < nitems; ++i)
        {
            ulong nitems2;
            uchar* data2 = 0;
            status = XGetWindowProperty(display, xids[i],
                                        atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL,
                                        &ret, &format, &nitems2, &after, &data2);

            if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12)
            {
                ulong* struts = (ulong*) data2;

                QRect left(desktopGeometry.x(),
                           desktopGeometry.y() + struts[4],
                           struts[0],
                           struts[5] - struts[4]);
                if (available.intersects(left))
                    available.setX(left.width());

                QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1],
                            desktopGeometry.y() + struts[6],
                            struts[1],
                            struts[7] - struts[6]);
                if (available.intersects(right))
                    available.setWidth(right.x() - available.x());

                QRect top(desktopGeometry.x() + struts[8],
                          desktopGeometry.y(),
                          struts[9] - struts[8],
                          struts[2]);
                if (available.intersects(top))
                    available.setY(top.height());

                QRect bottom(desktopGeometry.x() + struts[10],
                             desktopGeometry.y() + desktopGeometry.height() - struts[3],
                             struts[11] - struts[10],
                             struts[3]);
                if (available.intersects(bottom))
                    available.setHeight(bottom.y() - available.y());
            }
            if (data2)
                XFree(data2);
        }
    }
    if (data)
        XFree(data);

    return available;
}