Ejemplo n.º 1
0
//BEGIN class BGMonitorArrangement
BGMonitorArrangement::BGMonitorArrangement(QWidget *parent)
    : QWidget(parent)
{
    m_pBGMonitor.resize(QApplication::desktop()->numScreens());

    int numScreens = QApplication::desktop()->numScreens();
    for (int screen = 0; screen < numScreens; ++screen) {
        ScreenPreviewWidget *previewWidget = new ScreenPreviewWidget(this);
        m_pBGMonitor[screen] = previewWidget;
        previewWidget->setWhatsThis(i18n("This picture of a monitor contains a preview of what the current settings will look like on your desktop."));

        connect(previewWidget, SIGNAL(imageDropped(QString)), this, SIGNAL(imageDropped(QString)));
        previewWidget->setFixedSize(180, 180);
    }

    parent->setFixedSize(210 * numScreens, 200);
    setFixedSize(210 * numScreens, 200);
    updateArrangement();
}
Ejemplo n.º 2
0
void BGMonitor::dropEvent(QDropEvent *e)
{
    if (!KURLDrag::canDecode(e))
        return;

    KURL::List uris;
    if (KURLDrag::decode(e, uris) && (uris.count() > 0)) {
        // TODO: Download remote file
        if (uris.first().isLocalFile())
           emit imageDropped(uris.first().path());
    }
}
Ejemplo n.º 3
0
/**
 * @brief handle image drops
 * @param event event info
 */
void CanvasView::dropEvent(QDropEvent *event)
{
	const QMimeData *data = event->mimeData();
	if(data->hasImage()) {
		emit imageDropped(qvariant_cast<QImage>(event->mimeData()->imageData()));
	} else if(data->hasUrls()) {
		emit urlDropped(event->mimeData()->urls().first());
	} else if(data->hasColor()) {
		emit colorDropped(event->mimeData()->colorData().value<QColor>());
	} else {
		// unsupported data
		return;
	}
	event->acceptProposedAction();
}
Ejemplo n.º 4
0
/**
 * @brief handle color and image drops
 * @param event event info
 *
 * @todo Reset the image modification state to unmodified
 */
void CanvasView::dropEvent(QDropEvent *event)
{
	emit imageDropped(event->mimeData()->urls().first().toLocalFile());
	event->acceptProposedAction();
}
Ejemplo n.º 5
0
BGDialog::BGDialog(QWidget *parent, const KSharedConfigPtr &_config)
    : BGDialog_UI(parent), m_readOnly(false)
{
    m_pGlobals = new KGlobalBackgroundSettings(_config);
    m_pDirs = KGlobal::dirs();
    m_previewUpdates = true;

    m_numScreens = QApplication::desktop()->numScreens();

    QString multiHead = getenv("KDE_MULTIHEAD");
    if (multiHead.toLower() == "true")
        m_numScreens = 1;

    m_screen = QApplication::desktop()->screenNumber(this);
    if (m_screen >= (int)m_numScreens)
        m_screen = m_numScreens - 1;

    getEScreen();
    m_copyAllScreens = true;

    if (m_numScreens < 2) {
        m_comboScreen->hide();
        m_buttonIdentifyScreens->hide();
        m_screen = 0;
        m_eScreen = 0;
    }

    connect(m_buttonIdentifyScreens, SIGNAL(clicked()), SLOT(slotIdentifyScreens()));

    // preview monitor
    m_pMonitorArrangement = new BGMonitorArrangement(m_screenArrangement);
    m_pMonitorArrangement->setObjectName("monitor arrangement");
    connect(m_pMonitorArrangement, SIGNAL(imageDropped(QString)), SLOT(slotImageDropped(QString)));
    if (m_numScreens > 1) {
        connect(m_comboScreen, SIGNAL(activated(int)),
                SLOT(slotSelectScreen(int)));
    }

    // background image settings
    QIcon iconSet = KIcon(QLatin1String("document-open"));
    QPixmap pixMap = iconSet.pixmap(
             style()->pixelMetric(QStyle::PM_SmallIconSize), QIcon::Normal);
    m_urlWallpaperButton->setIcon(iconSet);
    m_urlWallpaperButton->setFixedSize(pixMap.width() + 8, pixMap.height() + 8);
    m_urlWallpaperButton->setToolTip(i18n("Open file dialog"));

    connect(m_buttonGroupBackground, SIGNAL(clicked(int)),
            SLOT(slotWallpaperTypeChanged(int)));
    connect(m_urlWallpaperBox, SIGNAL(activated(int)),
            SLOT(slotWallpaper(int)));
    connect(m_urlWallpaperButton, SIGNAL(clicked()),
            SLOT(slotWallpaperSelection()));
    connect(m_comboWallpaperPos, SIGNAL(activated(int)),
            SLOT(slotWallpaperPos(int)));
    connect(m_buttonSetupWallpapers, SIGNAL(clicked()),
            SLOT(slotSetupMulti()));

    // set up the background colour stuff
    connect(m_colorPrimary, SIGNAL(changed(QColor)),
            SLOT(slotPrimaryColor(QColor)));
    connect(m_colorSecondary, SIGNAL(changed(QColor)),
            SLOT(slotSecondaryColor(QColor)));
    connect(m_comboPattern, SIGNAL(activated(int)),
            SLOT(slotPattern(int)));

    // blend
    connect(m_comboBlend, SIGNAL(activated(int)), SLOT(slotBlendMode(int)));
    connect(m_sliderBlend, SIGNAL(valueChanged(int)),
            SLOT(slotBlendBalance(int)));
    connect(m_cbBlendReverse, SIGNAL(toggled(bool)),
            SLOT(slotBlendReverse(bool)));

    // advanced options
    connect(m_buttonAdvanced, SIGNAL(clicked()),
            SLOT(slotAdvanced()));

    connect(m_buttonGetNew, SIGNAL(clicked()),
            SLOT(slotGetNewStuff()));

    // renderers
    if (m_numScreens > 1) {
        // Setup the merged-screen renderer
        KBackgroundRenderer *r = new KBackgroundRenderer(0, false, _config);
        m_renderer.insert(0, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));

        // Setup the common-screen renderer
        r = new KBackgroundRenderer(0, true, _config);
        m_renderer.insert(1, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));

        // Setup the remaining renderers for each screen
        for (unsigned j = 0; j < m_numScreens; ++j) {
            r = new KBackgroundRenderer(j, true, _config);
            m_renderer.insert(j + 2, r);
            connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));
        }
    } else {
        // set up the common desktop renderer
        KBackgroundRenderer *r = new KBackgroundRenderer(0, false, _config);
        m_renderer.insert(0, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));
    }

    // Random or InOrder
    m_slideShowRandom = eRenderer()->multiWallpaperMode();
    if (m_slideShowRandom == KBackgroundSettings::NoMultiRandom)
        m_slideShowRandom = KBackgroundSettings::Random;
    if (m_slideShowRandom == KBackgroundSettings::NoMulti)
        m_slideShowRandom = KBackgroundSettings::InOrder;

    // Wallpaper Position
    m_wallpaperPos = eRenderer()->wallpaperMode();
    if (m_wallpaperPos == KBackgroundSettings::NoWallpaper)
        m_wallpaperPos = KBackgroundSettings::Centred; // Default

    if (KGlobal::dirs()->isRestrictedResource("wallpaper")) {
        m_urlWallpaperButton->hide();
        m_buttonSetupWallpapers->hide();
        m_radioSlideShow->hide();
    }

    initUI();
    updateUI();

    connect(qApp->desktop(), SIGNAL(resized(int)), SLOT(desktopResized())); // RANDR support
}