Пример #1
1
void ScreenSelector::grabColor()
{
    m_selectionRect = m_selectionRect.normalized();
    QDesktopWidget* desktop = QApplication::desktop();
    int screenNum = desktop->screenNumber(m_selectionRect.topLeft());
    QScreen* screen = QGuiApplication::screens()[screenNum];
    QPixmap screenGrab = screen->grabWindow(desktop->winId(),
        m_selectionRect.x(), m_selectionRect.y(), m_selectionRect.width(), m_selectionRect.height());
    QImage image = screenGrab.toImage();
    int numPixel = image.width() * image.height();
    int sumR = 0;
    int sumG = 0;
    int sumB = 0;

    for (int x = 0; x < image.width(); ++x) {
        for (int y = 0; y < image.height(); ++y) {
            QColor color = image.pixel(x, y);
            sumR += color.red();
            sumG += color.green();
            sumB += color.blue();
        }
    }

    QColor avgColor(sumR / numPixel, sumG / numPixel, sumB / numPixel);
    emit colorPicked(avgColor);
}
Пример #2
0
void tst_QDesktopWidget::screenNumberForQPoint()
{
    // make sure QDesktopWidget::screenNumber(QPoint) returns the correct screen
    QDesktopWidget *desktopWidget = QApplication::desktop();
    QRect allScreens;
    for (int i = 0; i < desktopWidget->numScreens(); ++i) {
        QRect screenGeometry = desktopWidget->screenGeometry(i);
        QCOMPARE(desktopWidget->screenNumber(screenGeometry.center()), i);
        allScreens |= screenGeometry;
    }

    // make sure QDesktopWidget::screenNumber(QPoint) returns a valid screen for points that aren't on any screen
    int screen;
    screen = desktopWidget->screenNumber(allScreens.topLeft() - QPoint(1, 1));

#ifdef Q_WS_QWS
    QEXPECT_FAIL("", "Task 151710", Abort);
#endif
    QVERIFY(screen >= 0 && screen < desktopWidget->numScreens());
    screen = desktopWidget->screenNumber(allScreens.topRight() + QPoint(1, 1));
    QVERIFY(screen >= 0 && screen < desktopWidget->numScreens());
    screen = desktopWidget->screenNumber(allScreens.bottomLeft() - QPoint(1, 1));
    QVERIFY(screen >= 0 && screen < desktopWidget->numScreens());
    screen = desktopWidget->screenNumber(allScreens.bottomRight() + QPoint(1, 1));
    QVERIFY(screen >= 0 && screen < desktopWidget->numScreens());
}
Пример #3
0
void AutoExpandableDialog::showEvent(QShowEvent *e) {
  // Overriding showEvent is required for consistent UI with fixed size under custom DPI
  // Show dialog
  QDialog::showEvent(e);
  // and resize textbox to fit the text

  // NOTE: For some strange reason QFontMetrics gets more accurate
  // when called from showEvent. Only 6 symbols off instead of 11 symbols off.
  int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
  int screenW = QApplication::desktop()->width() / 4;
  int wd = textW;

  if (!windowTitle().isEmpty()) {
    int _w = fontMetrics().width(windowTitle());
    if (_w > wd)
      wd = _w;
  }

  if (!ui->textLabel->text().isEmpty()) {
    int _w = ui->textLabel->fontMetrics().width(ui->textLabel->text());
    if (_w > wd)
      wd = _w;
  }


  // Now resize the dialog to fit the contents
  // Maximum value is whichever is smaller:
  // 1. screen width / 4
  // 2. max width of text from either of: label, title, textedit
  // If the value is less than dialog default size default size is used
  wd = textW < screenW ? textW : screenW;
  if (wd > width())
    resize(width() - ui->horizontalLayout->sizeHint().width() + wd, height());

  // Use old dialog behavior: prohibit resizing the dialog
  setFixedHeight(height());

  // Update geometry: center on screen
  QDesktopWidget *desk = QApplication::desktop();
  MainWindow *wnd = qobject_cast<MainWindow*>(QApplication::activeWindow());
  QPoint p = QCursor::pos();

  int screenNum = 0;
  if (wnd == 0)
    screenNum = desk->screenNumber(p);
  else if (!wnd->isHidden())
    screenNum = desk->screenNumber(wnd);
  else
    screenNum = desk->screenNumber(p);

  QRect screenRes = desk->screenGeometry(screenNum);

  QRect geom = geometry();
  geom.moveCenter(QPoint(screenRes.width() / 2, screenRes.height() / 2));
  setGeometry(geom);
}
void tst_QDesktopWidget::screenNumberForQWidget()
{
    QDesktopWidget desktop;

    QCOMPARE(desktop.screenNumber(0), 0);

    QWidget widget;
    widget.show();
    QApplication::processEvents();
    QVERIFY(widget.isVisible());

    int widgetScreen = desktop.screenNumber(&widget);
    QVERIFY(widgetScreen > -1);
    QVERIFY(widgetScreen < desktop.numScreens());
}
Пример #5
0
void tst_QDesktopWidget::screenNumberForQWidget()
{
    QDesktopWidget desktop;

    QCOMPARE(desktop.screenNumber(0), 0);

    QWidget widget;
    widget.show();
    QTest::qWaitForWindowShown(&widget);
    QVERIFY(widget.isVisible());

    int widgetScreen = desktop.screenNumber(&widget);
    QVERIFY(widgetScreen > -1);
    QVERIFY(widgetScreen < desktop.numScreens());
}
Пример #6
0
QColor Overlay::grabScreenColor(const QPoint &p)
{
    QDesktopWidget *desktop = QApplication::desktop();
    QPixmap pixmap = QGuiApplication::screens().at(desktop->screenNumber())->grabWindow(desktop->winId(), p.x(), p.y(), 1, 1);
    QImage i = pixmap.toImage();
    return i.pixel(0, 0);
}
Пример #7
0
void MainWindow::triggerNews() {
    if (ui->groupBox_browser->isHidden()) {
        ui->statusBar->showMessage("Loading page...");
        ui->webView->setUrl(newsUrl);

        if (!isMaximized()) {
            QDesktopWidget* mydesk = QApplication::desktop();
            int screen = mydesk->screenNumber(this);
            QRect screenSize = mydesk->screenGeometry(screen);
            QRect windowGeometry = this->geometry();

            int difference = 811 - 356;

            if (windowGeometry.height() + difference + pos().y() > screenSize.bottom()) {
                this->move(pos().x(), pos().y() - (windowGeometry.height() + difference + pos().y() - screenSize.bottom()));
            }

            this->resize(907, 811);
        }

        ui->actionShow_news->setText("Hide news");
        //ui->actionShow_news->setChecked(true);
        ui->groupBox_browser->show();
    } else {
        ui->groupBox_browser->hide();

        if (!isMaximized())
            this->resize(907, 256);

        //ui->actionShow_news->setChecked(false);
        ui->actionShow_news->setText("Show news");
    }
}
Пример #8
0
NxClientThread::NxClientThread(QObject *parent)
        : QThread(parent),
        m_host(std::string()),
        m_port(0),
        m_privateKey(std::string()),
        m_xid(0),
        m_stopped(false)
{
    m_client.setSessionData(&m_data);

    QDesktopWidget *desktop = QApplication::desktop();
    int currentScreen = desktop->screenNumber();
    QRect rect = desktop->screenGeometry(currentScreen);
    m_client.setResolution(rect.width(), rect.height());
    m_client.setDepth(24);
    m_client.setRender(true);

    m_data.sessionName = "krdcSession";
    m_data.cache = 8;
    m_data.images = 32;
    m_data.linkType = "adsl";
    m_data.render = true;
    m_data.backingstore = "when_requested";
    m_data.imageCompressionMethod = 2;
    m_data.keyboard = "defkeymap";
    m_data.media = false;
    m_data.agentServer = "";
    m_data.agentUser = "";
    m_data.agentPass = "";
    m_data.cups = 0;
    m_data.suspended = false;
    m_data.fullscreen = false;
    m_data.encryption = true;
    m_data.terminate = false;
}
Пример #9
0
void VisibleAreaMode::stop(int x, int y) {
    toolbar_.appView().setMouseTracking(false);

    move(x, y);
    const int padding = 10;

    QDesktopWidget *desktop = QApplication::desktop();
    QRect geo = desktop->screenGeometry(desktop->screenNumber(QCursor::pos()));

    // Width
    int formX = area.x + area.width + 28;
    int screenWidth = geo.width();
    int formWidth = toolbar_.width();

    if (formX + formWidth + padding > screenWidth) {
        formX = screenWidth - formWidth - padding;
    }

    // Height
    int formHeight = toolbar_.height();
    int formY = area.y + area.height / 2 - formHeight / 2;
    int screenHeight = geo.height();

    if (formY < padding) {
        formY = padding;
    } else if (formY + formHeight + padding > screenHeight) {
        formY = screenHeight - formHeight - padding;
    }

    toolbar_.setGeometry(formX, formY, formWidth, formHeight);
    toolbar_.show();
}
Пример #10
0
void VisibleAreaMode::set(int x, int y, int width, int height) {
    int sceneWidth = scene_.width(),
        sceneHeight = scene_.height();

    rectTop->setRect(0, 0, sceneWidth, y);
    rectBottom->setRect(0, y + height, sceneWidth, sceneHeight - y - height);
    rectLeft->setRect(0, y, x, height);
    rectRight->setRect(x + width, y, sceneWidth - x - width, height);

    QDesktopWidget *desktop = QApplication::desktop();
    QRect geo = desktop->screenGeometry(desktop->screenNumber(QCursor::pos()));

    int screenWidth = geo.width();
    int screenHeight = geo.height();

    // Horizontal and vertical lines
    if (0 == width && 0 == height) {
        lineTop->setLine(0, y, screenWidth, y);
        lineLeft->setLine(x, 0, x, screenHeight);
        return;
    }

    lineTop->setLine(0, y - 1, screenWidth, y - 1);
    lineBottom->setLine(0, y + height + 1, screenWidth, y + height + 1);
    lineLeft->setLine(x - 1, 0, x - 1, screenHeight);
    lineRight->setLine(x + width + 1, 0, x + width + 1, sceneHeight);
}
Пример #11
0
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
    QWidget *widget = QWidget::find(window);
    if (!widget)
        return QPixmap();

    QRect grabRect = widget->frameGeometry();
    if (!widget->isWindow())
        grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
    if (w < 0)
        w = widget->width() - x;
    if (h < 0)
        h = widget->height() - y;
    grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));

    QScreen *screen = qt_screen;
    QDesktopWidget *desktop = QApplication::desktop();
    if (!desktop)
        return QPixmap();
    if (desktop->numScreens() > 1) {
        const int screenNo = desktop->screenNumber(widget);
        if (screenNo != -1)
            screen = qt_screen->subScreens().at(screenNo);
        grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
    }

    if (screen->pixelFormat() == QImage::Format_Invalid) {
        qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
        return QPixmap();
    }

    if (screen->isTransformed()) {
        const QSize screenSize(screen->width(), screen->height());
        grabRect = screen->mapToDevice(grabRect, screenSize);
    }

    QWSDisplay::grab(false);
    QPixmap pixmap;
    QImage img(screen->base(),
               screen->deviceWidth(), screen->deviceHeight(),
               screen->linestep(), screen->pixelFormat());
    img = img.copy(grabRect);
    QWSDisplay::ungrab();

    if (screen->isTransformed()) {
        QMatrix matrix;
        switch (screen->transformOrientation()) {
        case 1: matrix.rotate(90); break;
        case 2: matrix.rotate(180); break;
        case 3: matrix.rotate(270); break;
        default: break;
        }
        img = img.transformed(matrix);
    }

    if (screen->pixelType() == QScreen::BGRPixel)
        img = img.rgbSwapped();

    return QPixmap::fromImage(img);
}
void BubbleManager::consumeEntities()
{
    if (!m_currentNotify.isNull()) {
        m_currentNotify->deleteLater();
        m_currentNotify = nullptr;
    }

    if (m_entities.isEmpty()) {
        m_currentNotify = nullptr;
        return;
    }

    m_currentNotify = m_entities.dequeue();

    QDesktopWidget *desktop = QApplication::desktop();
    int pointerScreen = desktop->screenNumber(QCursor::pos());
    int primaryScreen = desktop->primaryScreen();
    QWidget *pScreenWidget = desktop->screen(primaryScreen);

    if (checkDockExistence()) {
        m_dockGeometry = m_dbusdockinterface->geometry();
    }

    if (checkControlCenterExistence())
        m_ccGeometry = m_dbusControlCenter->rect();

    if (checkControlCenterExistence() && pointerScreen == primaryScreen)
        bindControlCenterX();

    if (pointerScreen != primaryScreen)
        pScreenWidget = desktop->screen(pointerScreen);

    m_bubble->setBasePosition(getX(), getY(), pScreenWidget->geometry());
    m_bubble->setEntity(m_currentNotify);
}
Пример #13
0
dlgPrint::dlgPrint( QWidget* parent, CardInformation& CI_Data, GenPur::UI_LANGUAGE lng, QString const& cardTypeText)
    : QDialog(parent)
    , m_CI_Data(CI_Data)
    , m_CurrReaderName("")
{
    if (CI_Data.isDataLoaded())
    {
        PTEID_EIDCard*	Card = dynamic_cast<PTEID_EIDCard*>(m_CI_Data.m_pCard);
        ui.setupUi(this);
        setFixedSize(420, 245);
        const QIcon Ico = QIcon( ":/images/Images/Icons/Print.png" );
        this->setWindowIcon( Ico );

        QDesktopWidget* desktop = QApplication::desktop();
        int screenNr = desktop->screenNumber();
        QRect rect = desktop->availableGeometry(screenNr);
        int height = rect.height();

        int thiswidth = this->width();
        int thisheight = this->height();

        if (thisheight > height)
        {
            this->resize(thiswidth,height-20); //make sure the window fits
        }

        CI_Data.LoadData(*Card,m_CurrReaderName);
    }

}
Пример #14
0
void MenuManager::kmenuAccelActivated()
{
    if(m_kmenu->isVisible())
    {
        m_kmenu->hide();
        return;
    }

    m_kmenu->initialize();

    if(m_kbuttons.isEmpty())
    {
        // no button to use, make it behave like a desktop menu
        QPoint p;
        // Popup the K-menu at the center of the screen.
        QDesktopWidget *desktop = KApplication::desktop();
        QRect r = desktop->screenGeometry(desktop->screenNumber(QCursor::pos()));
        // kMenu->rect() is not valid before showing, use sizeHint()
        p = r.center() - QRect(QPoint(0, 0), m_kmenu->sizeHint()).center();
        m_kmenu->popup(p);

        // when the cursor is in the area where the menu pops up,
        // the item under the cursor gets selected. The single shot
        // avoids this from happening by allowing the item to be selected
        // when the event loop is enterred, and then resetting it.
        QTimer::singleShot(0, this, SLOT(slotSetKMenuItemActive()));
    }
    else
    {
        // We need the kmenu's size to place it at the right position.
        // We cannot rely on the popup menu's current size(), if it wasn't
        // shown before, so we resize it here according to its sizeHint().
        const QSize size = m_kmenu->sizeHint();
        m_kmenu->resize(size.width(), size.height());

        PanelPopupButton *button = findKButtonFor(m_kmenu);

        // let's unhide the panel while we're at it. traverse the widget
        // hierarchy until we find the panel, if any
        QObject *menuParent = button->parent();
        while(menuParent)
        {
            ExtensionContainer *ext = dynamic_cast< ExtensionContainer * >(menuParent);

            if(ext)
            {
                ext->unhideIfHidden();
                // make sure it's unhidden before we use it to figure out
                // where to popup
                qApp->processEvents();
                break;
            }

            menuParent = menuParent->parent();
        }

        button->showMenu();
    }
}
Пример #15
0
qreal TopMenuBar::glowBarOpacity()
{
    QPoint cursorPos = QCursor::pos();
    QDesktopWidget *desktop = QApplication::desktop();
    int screen = desktop->screenNumber(cursorPos);
    QRect desktopRect = desktop->availableGeometry(screen);
    return 1.0 - ((cursorPos.y() - desktopRect.y())/qreal(desktopRect.height())*2.0);
}
Пример #16
0
void QKineticScroller::setDpiFromWidget(QWidget *widget)
{
    Q_D(QKineticScroller);

    QDesktopWidget *dw = QApplication::desktop();
    QPointF dpi = d->realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen());
    setDpi((dpi.x() + dpi.y()) / qreal(2));
}
Пример #17
0
int
ScreenInfo::cornerScreen(Corner corner) const
{
    QDesktopWidget* desktop = QApplication::desktop();
    switch(corner) {
        case TopLeft:
            return desktop->screenNumber(QPoint());
        case TopRight:
            return desktop->screenNumber(QPoint(desktop->width(), 0));
        case BottomLeft:
            return desktop->screenNumber(QPoint(0, desktop->height()));
        case BottomRight:
            return desktop->screenNumber(QPoint(desktop->width(), desktop->height()));
        default:
            return desktop->screenNumber(QPoint());
    }
}
Пример #18
0
ThumbnailView::ThumbnailView( QWidget* parent )
    : QListView( parent )
{
    QDesktopWidget *desktop = QApplication::desktop();
    resize(desktop->availableGeometry(desktop->screenNumber(this)).width(), height());  //### workaround to make view layout properly on first view.
    setMovement( QListView::Static );
    setFrameStyle(QFrame::NoFrame);
    connect( this, SIGNAL(pressed(QModelIndex)), this, SLOT(emitSelected(QModelIndex)) );
}
QPair<QRect, bool> BubbleManager::screensInfo(const QPoint &point) const
{
    QDesktopWidget *desktop = QApplication::desktop();
    int pointScreen = desktop->screenNumber(point);
    int primaryScreen = desktop->primaryScreen();

    QRect rect = desktop->screenGeometry(pointScreen);

    return QPair<QRect, bool>(rect, (pointScreen == primaryScreen));
}
Пример #20
0
void Window::setupImagePosition()
{
    QPoint cursorPos = QCursor::pos();

    QDesktopWidget * desktop = QApplication::desktop();
    int screenNum = desktop->screenNumber(cursorPos);
    QWidget * screen = desktop->screen(screenNum);

    m_image->move(screen->geometry().center() - m_image->rect().center());
}
Пример #21
0
QPoint Utils::Misc::screenCenter(const QWidget *w)
{
    // Returns the QPoint which the widget will be placed center on screen (where parent resides)

    QWidget *parent = w->parentWidget();
    QDesktopWidget *desktop = QApplication::desktop();
    int scrn = desktop->screenNumber(parent);  // fallback to `primaryScreen` when parent is invalid
    QRect r = desktop->availableGeometry(scrn);
    return QPoint(r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2);
}
Пример #22
0
void B9Projector::resizeEvent ( QResizeEvent * pEvent )
{	
    pEvent->accept();
    QImage newImage(width(),height(),QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&newImage);
	painter.drawImage(QPoint(0,0), mImage);
	mImage = newImage;
    createNormalizedMask();
	drawAll();
	QDesktopWidget dt;
	emit newGeometry (dt.screenNumber(), geometry());
}
Пример #23
0
void DisplayWrapper::dw_init(bool filter, int minWidth, int minHeight)
{
  base_height = base_width = 0;
  base_bpp = 0;

  DEVMODE devmode;
  DWORD modenum = 0;
  VideoModeInfo mode;

  modes.clear();
  modeNames.clear();

  // get current display
  wchar_t *device = NULL;
  DISPLAY_DEVICE display_device;
  display_device.cb = sizeof(DISPLAY_DEVICE);

  if (base_widget)
  {
    QDesktopWidget desktop;
    int screen = desktop.screenNumber(base_widget);
    if (screen >= 0)
    {
      if (EnumDisplayDevices(NULL, screen, &display_device, 0))
      {
        device = display_device.DeviceName;
        //qDebug() << QString::fromWCharArray(device);
      }
    }
  }

  // enumerate display modes
  while (EnumDisplaySettings(device, modenum, &devmode))
  {
    if (devmode.dmPelsWidth >= minWidth && devmode.dmPelsHeight >= minHeight)
    {
      modeNames.append(QString("%1 x %2")
                       .arg(devmode.dmPelsWidth)
                       .arg(devmode.dmPelsHeight)
                       );

      mode.width = devmode.dmPelsWidth;
      mode.height = devmode.dmPelsHeight;
      mode.bpp = devmode.dmBitsPerPel;
      modes.append(mode);
    }
    modenum++;
  }

  if (filter)
    modeNames.removeDuplicates();
}
Пример #24
0
int UBCustomCaptureWindow::execute(const QPixmap &pScreenPixmap)
{
    mWholeScreenPixmap = pScreenPixmap;

    QDesktopWidget *desktop = QApplication::desktop();
    int currentScreen = desktop->screenNumber(QCursor::pos());
    setGeometry(desktop->screenGeometry(currentScreen));

    showFullScreen();
    setWindowOpacity(1.0);

    return exec();
}
Пример #25
0
static QRect screenRect( QWidget *w, int screen )
{
  QDesktopWidget *desktop = QApplication::desktop();
  KConfig gc("kdeglobals", false, false);
  gc.setGroup("Windows");
  if (desktop->isVirtualDesktop() &&
      gc.readBoolEntry("XineramaEnabled", true) &&
      gc.readBoolEntry("XineramaPlacementEnabled", true)) {
    if ( screen < 0 || screen >= desktop->numScreens() ) {
      if ( screen == -1 ) {
        screen = desktop->primaryScreen();
      } else if ( screen == -3 ) {
        screen = desktop->screenNumber( QCursor::pos() );
      } else {
        screen = desktop->screenNumber( w );
      }
    }
    return desktop->availableGeometry(screen);
  } else {
    return desktop->geometry();
  }
}
Пример #26
0
void BrowserDialog::maximizeWidth()
{
    int viewportWidth = getCurrentView()->page()->viewportSize().width();
    int frameWidth = width() - viewportWidth;

    int contentWidth = getCurrentView()->page()->mainFrame()->contentsSize().width();

    QDesktopWidget screen;
    int currentScreen = screen.screenNumber(this);
    int screenWidth = screen.screenGeometry(currentScreen).size().width();

    int targetWidth = std::min<int>(std::max<int>(viewportWidth, contentWidth) + frameWidth, screenWidth);
    this->resize(targetWidth, height());
}
Пример #27
0
void CMainWindow::centerWindow()
{
    int screen = 0;
    QWidget *w = window();
    QDesktopWidget *desktop = QApplication::desktop();
    if (w) {
        screen = desktop->screenNumber(w);
    } else if (desktop->isVirtualDesktop()) {
        screen = desktop->screenNumber(QCursor::pos());
    } else {
        screen = desktop->screenNumber(this);
    }
    QRect rect(desktop->availableGeometry(screen));
        int h = 80*rect.height()/100;
    QSize nw(135*h/100,h);
    if (nw.width()<1000) nw.setWidth(80*rect.width()/100);
    resize(nw);
    move(rect.width()/2 - frameGeometry().width()/2,
         rect.height()/2 - frameGeometry().height()/2);

    QList<int> sz;
    sz << nw.width()/4 << 3*nw.width()/4;
    ui->splitter->setSizes(sz);
}
Пример #28
0
void TermWindow::HideWindow() {
    //Now setup the animation
    //Note: Do *not* use the private settings/variables because it may be changing right now - use the current geometry *ONLY*
    animRunning = 0;
    ANIM->setStartValue(this->geometry());
    QDesktopWidget *desk = QApplication::desktop();
    int screen = desk->screenNumber(this); //which screen it is currently on
    if(desk->availableGeometry(screen).top() == this->geometry().top()) { //use top edge
        ANIM->setEndValue( QRect(this->x(), this->y(), this->width(), 0) ); //same location - no height
    } else {
        ANIM->setEndValue( QRect(this->x(), this->y()+this->height(), this->width(), 0) ); //same location - no height
    }
    this->show();
    ANIM->start();
}
Пример #29
0
QRect KGlobalSettings::desktopGeometry(const QPoint& point)
{
    QDesktopWidget *dw = QApplication::desktop();

    if (dw->isVirtualDesktop()) {
        KConfigGroup group(KGlobal::config(), "Windows");
        if (group.readBoolEntry("XineramaEnabled", true) &&
            group.readBoolEntry("XineramaPlacementEnabled", true)) {
            return dw->screenGeometry(dw->screenNumber(point));
        } else {
            return dw->geometry();
        }
    } else {
        return dw->geometry();
    }
}
Пример #30
0
int main ( int argc, char *argv[] )
{

     KAboutData aboutData ( "SUSEgreeter", 0, ki18n ( "SUSEgreeter" ), "0.1",
                            ki18n ( "SUSEgreeter" ), KAboutData::License_GPL, ki18n ( "(c) 2001, Adrian Schroeter" ) );
     aboutData.addAuthor ( ki18n ( "Adrian Schroeter" ), KLocalizedString(), "*****@*****.**" );

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

     KLocale::setMainCatalog ( "SUSEgreeter" );

     KApplication a;

     KGlobal::locale()->insertCatalog ( QString::fromLatin1 ( "kpersonalizer" ) );

     // first, reset the startup from true (see desktop file in share/autostart) to false
     KConfig SUSEgreeterrc ( "SUSEgreeterrc" );
     KConfigGroup grp = SUSEgreeterrc.group ( "General" );
     bool ktip = ( grp.readEntry ( "FirstLogin113", true ) );
     grp.writeEntry ( "FirstLogin113", false );
     grp.sync();

     SUSEgreetings greeter;
     a.setTopWidget ( &greeter );
     greeter.adjustSize();

     QDesktopWidget *dsk = kapp->desktop();
     QRect scr = dsk->screenGeometry ( dsk->screenNumber ( QPoint ( 0, 0 ) ) );
     QRect grt ( 0, 0, greeter.width(), greeter.height() );
     grt.moveCenter ( scr.center() );
     greeter.setGeometry ( grt );
     greeter.show();

     int ret = a.exec();
     if ( ktip ) { // only run if we set this to true in the constructor. then SUSEgreeter didn't run before
          // set the ktiprc file entry to true. The global one is set to false for starting SUSEgreeter
#if 0
          KConfig ktiprc ( "ktiprc" );
          KConfigGroup group = ktiprc.group ( "TipOfDay" );
          group.writeEntry ( "RunOnStart", true );
          ktiprc.sync();
#endif

//      kapp->dcopClient()->send("kicker", "kicker", "showKMenu()", "");
     }
     return ret;
}