Example #1
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
}
Example #2
0
ActionWidget::ActionWidget( const ActionList *list, ConfigDialog* configWidget, QWidget *parent,
                            const char *name )
    : KVBox( parent ),
      advancedWidget( 0L )
{
    setObjectName(name);

    Q_ASSERT( list != 0L );

    QLabel *lblAction = new QLabel(
	  i18n("Action &list (right click to add/remove commands):"), this );

    listView = new ListView( configWidget, this );
    lblAction->setBuddy( listView );
    listView->addColumn( i18n("Regular Expression (see http://doc.trolltech.com/qregexp.html#details)") );
    listView->addColumn( i18n("Description") );

    listView->setRenameable(0);
    listView->setRenameable(1);
    listView->setItemsRenameable( true );
    listView->setItemsMovable( false );
//     listView->setAcceptDrops( true );
//     listView->setDropVisualizer( true );
//     listView->setDragEnabled( true );

    listView->setRootIsDecorated( true );
    listView->setMultiSelection( false );
    listView->setAllColumnsShowFocus( true );
    listView->setSelectionMode( Q3ListView::Single );
    connect( listView, SIGNAL(executed( Q3ListViewItem*, const QPoint&, int )),
             SLOT( slotItemChanged( Q3ListViewItem*, const QPoint& , int ) ));
    connect( listView, SIGNAL( selectionChanged ( Q3ListViewItem * )),
             SLOT(selectionChanged ( Q3ListViewItem * )));
    connect(listView,
            SIGNAL(contextMenu(K3ListView *, Q3ListViewItem *, const QPoint&)),
            SLOT( slotContextMenu(K3ListView*, Q3ListViewItem*, const QPoint&)));

    ClipAction *action   = 0L;
    ClipCommand *command = 0L;
    Q3ListViewItem *item  = 0L;
    Q3ListViewItem *child = 0L;
    Q3ListViewItem *after = 0L; // QListView's default inserting really sucks
    ActionListIterator it( *list );

    const QPixmap& doc = SmallIcon( "misc" );
    const QPixmap& exec = SmallIcon( "exec" );

    for ( action = it.current(); action; action = ++it ) {
        item = new Q3ListViewItem( listView, after,
                                  action->regExp(), action->description() );
        item->setPixmap( 0, doc );

        Q3PtrListIterator<ClipCommand> it2( action->commands() );
        for ( command = it2.current(); command; command = ++it2 ) {
            child = new Q3ListViewItem( item, after,
                                       command->command, command->description);
        if ( command->pixmap.isEmpty() )
            child->setPixmap( 0, exec );
        else
            child->setPixmap( 0, SmallIcon( command->pixmap ) );
            after = child;
        }
        after = item;
    }

    listView->setSorting( -1 ); // newly inserted items just append unsorted

    cbUseGUIRegExpEditor = new QCheckBox( i18n("&Use graphical editor for editing regular expressions" ), this );
    if ( KServiceTypeTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() )
    {
	cbUseGUIRegExpEditor->hide();
	cbUseGUIRegExpEditor->setChecked( false );
    }

    KHBox *box = new KHBox( this );
    box->setSpacing( KDialog::spacingHint() );
    QPushButton *button = new QPushButton( i18n("&Add Action"), box );
    connect( button, SIGNAL( clicked() ), SLOT( slotAddAction() ));

    delActionButton = new QPushButton( i18n("&Delete Action"), box );
    connect( delActionButton, SIGNAL( clicked() ), SLOT( slotDeleteAction() ));

    QLabel *label = new QLabel(i18n("Click on a highlighted item's column to change it. \"%s\" in a command will be replaced with the clipboard contents."), box);
    label->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
    label->setWordWrap( true );
    
    box->setStretchFactor( label, 5 );

    box = new KHBox( this );
    QPushButton *advanced = new QPushButton( i18n("Advanced..."), box );
    advanced->setFixedSize( advanced->sizeHint() );
    connect( advanced, SIGNAL( clicked() ), SLOT( slotAdvanced() ));
    (void) new QWidget( box ); // spacer

    delActionButton->setEnabled(listView->currentItem () !=0);
}