예제 #1
0
QWidget* HorizontalConfigurationGroup::configWidget(ConfigurationGroup *cg, 
                                                    QWidget* parent, 
                                                    const char* widgetName) 
{
    QGroupBox* widget = new QGroupBox(parent, widgetName);
    widget->setBackgroundOrigin(QWidget::WindowOrigin);

    if (!useframe)
        widget->setFrameShape(QFrame::NoFrame);

    QHBoxLayout *layout = NULL;

    float wmult = 0, hmult = 0;

    gContext->GetScreenSettings(wmult, hmult);

    if (uselabel)
    {
        int space = -1;
        int margin = (int)(28 * hmult);
        if (zeroSpace)
            space = 4;
        if (zeroMargin)
            margin = 4;

        layout = new QHBoxLayout(widget, margin, space);
        // This makes weird and bad things happen in qt -mdz 2002/12/28
        //widget->setInsideMargin(20);
        widget->setTitle(getLabel());
    }
    else
    {
        int space = -1;
        int margin = (int)(10 * hmult);
        if (zeroSpace)
            space = 4;
        if (zeroMargin)
            margin = 4;

        layout = new QHBoxLayout(widget, margin, space);
    }

    for(unsigned i = 0 ; i < children.size() ; ++i)
        if (children[i]->isVisible())
        {
            QWidget *child = children[i]->configWidget(cg, widget, NULL);
            layout->add(child);
            children[i]->setEnabled(children[i]->isEnabled());
        }

    if (cg)
    {
        connect(this, SIGNAL(changeHelpText(QString)), cg,
                SIGNAL(changeHelpText(QString)));
    }

    return widget;
}
DialogAddSourceDir::DialogAddSourceDir(QWidget* parent, const char* name) :
    KDialogBase(parent, name, true, i18n("Add source folder"), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false)
{
    QWidget* mainPanel = new QWidget(this, "mainPanel");
    setMainWidget(mainPanel);
    QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout");

    // append the directory panel
    QWidget* dirPanel = new QWidget(mainPanel, "dirPanel");
    mainPanelLayout->add(dirPanel);
    QHBoxLayout* dirLayout = new QHBoxLayout(dirPanel, 0, 5, "dirPanelLayout");

    QLabel* directoryLabel = new QLabel(i18n("Folder"), dirPanel, "directoryLabel");
    dirLayout->add(directoryLabel);
    QWhatsThis::add(dirPanel, i18n("<b>Folder</b><p>Enter the path to the folder you want to add to the <i>KPhotoBook</i> database.</p>"));

    m_currentDirectoryLineEdit = new KLineEdit(dirPanel, "dirLineEdit");
    m_currentDirectoryLineEdit->setMinimumWidth(300);
    m_currentDirectoryLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    dirLayout->add(m_currentDirectoryLineEdit);

    QObject::connect(m_currentDirectoryLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotTextChanged(const QString&)));

    QIconSet folderIconSet = KGlobal::iconLoader()->loadIconSet("folder", KIcon::Small, 24, false);
    QPushButton* dirButton = new QPushButton(folderIconSet, 0, dirPanel, "dirButton");
    dirButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    dirLayout->add(dirButton);

    QObject::connect(dirButton, SIGNAL(clicked()), this, SLOT(slotDirectoryButtonClicked()));

    // add checkbox
    m_recursiveCheckBox = new QCheckBox(i18n("Add folders recursively."), mainPanel, "recursiveCheckBox");
    m_recursiveCheckBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    mainPanelLayout->add(m_recursiveCheckBox);
    QWhatsThis::add(m_recursiveCheckBox, i18n("<b>Add folders recursively</b><p>If enabled, <i>KPhotoBook</i> will add the folder recursively, meaning that sub folders will be added to the database as well, while not following symbolic links to avoid an infinite loop.</p>"));

    // spacer
    mainPanelLayout->addStretch(1);

    // set the directory
    m_currentDirectoryLineEdit->setText(Settings::fileSystemLastAddedSourcedir());

    // set the focus
    m_currentDirectoryLineEdit->setFocus();
}
예제 #3
0
void KBabelView::showTryLaterMessageBox()
{
    if( !_showTryLaterBox ) return;

    KDialogBase *dialog= new KDialogBase(
		i18n("Information"),
		KDialogBase::Yes,
		KDialogBase::Yes, KDialogBase::Yes,
		this, "information", true, true,
		KStdGuiItem::ok() );

    QVBox *topcontents = new QVBox (dialog);
    topcontents->setSpacing(KDialog::spacingHint()*2);
    topcontents->setMargin(KDialog::marginHint()*2);

    QWidget *contents = new QWidget(topcontents);
    QHBoxLayout * lay = new QHBoxLayout(contents);
    lay->setSpacing(KDialog::spacingHint()*2);

    lay->addStretch(1);
    QLabel *label1 = new QLabel( contents);
    label1->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
    lay->add( label1 );
    QLabel *label2 = new QLabel( i18n("The search string has not been found yet.\n"
	         "However, the string might be found "
		 "in the files being searched at the moment.\n"
		 "Please try later."), contents);
    label2->setAlignment( Qt::AlignAuto | Qt::AlignVCenter | Qt::ExpandTabs | Qt::WordBreak );
    label2->setMinimumSize(label2->sizeHint());
    lay->add( label2 );
    lay->addStretch(1);

    QCheckBox *checkbox = new QCheckBox(i18n("Do not show in this find/replace session again"), topcontents);

    dialog->setMainWidget(topcontents);
    dialog->enableButtonSeparator(false);
    dialog->incInitialSize( QSize(50,0) );

    dialog->exec();

    _showTryLaterBox = !checkbox->isChecked();
    delete dialog;
}
예제 #4
0
bool KXSConfigDialog::create()
{
    QVBoxLayout *topLayout = new QVBoxLayout(plainPage(), spacingHint());
    QHBoxLayout *layout = new QHBoxLayout(topLayout, spacingHint());
    QVBox *controlLayout = new QVBox(plainPage());
    controlLayout->setSpacing(spacingHint());
    layout->addWidget(controlLayout);
    ((QBoxLayout*)controlLayout->layout())->addStrut(120);

    KConfig config(mConfigFile);

    QString xmlFile = "/doesntexist";
#ifdef XSCREENSAVER_CONFIG_DIR
    xmlFile = XSCREENSAVER_CONFIG_DIR;
#endif

    xmlFile += "/" + mExeName + ".xml";
    if ( QFile::exists( xmlFile ) ) {
	// We can use the xscreensaver xml config files.
	KXSXml xmlParser(controlLayout);
	xmlParser.parse( xmlFile );
	mConfigItemList = *xmlParser.items();
	QWidget *spacer = new QWidget(controlLayout);
	controlLayout->setStretchFactor(spacer, 1 );
	QString descr = xmlParser.description();
	if ( !descr.isEmpty() ) {
	    descr.replace('\n',' ');
	    descr = descr.simplifyWhiteSpace();
	    QLabel *l = new QLabel( i18n( descr.utf8() ), plainPage() );
	    l->setAlignment ( WordBreak );
 	    topLayout->addWidget( l );
 	}
    } else {
        // fall back to KDE's old config files.
	int idx = 0;
	while (true) {
	    QString group = QString("Arg%1").arg(idx);
	    if (config.hasGroup(group)) {
		config.setGroup(group);
		QString type = config.readEntry("Type");
		if (type == "Range") {
		    KXSRangeControl *rc = new KXSRangeControl(controlLayout, group, config);
		    mConfigItemList.append(rc);
		} else if (type == "DoubleRange") {
		    KXSDoubleRangeControl *rc =
			new KXSDoubleRangeControl(controlLayout, group, config);
		    mConfigItemList.append(rc);
		} else if (type == "Check") {
		    KXSCheckBoxControl *cc = new KXSCheckBoxControl(controlLayout, group,
			    config);
		    mConfigItemList.append(cc);
		} else if (type == "DropList") {
		    KXSDropListControl *dl = new KXSDropListControl(controlLayout, group,
			    config);
		    mConfigItemList.append(dl);
		}
	    } else {
		break;
	    }
	    idx++;
	}
	if ( idx == 0 )
	    return false;
    }

    QPtrListIterator<KXSConfigItem> it( mConfigItemList );
    KXSConfigItem *item;
    while ( (item = it.current()) != 0 ) {
	++it;
	item->read( config );
        QWidget *i = dynamic_cast<QWidget*>(item);
        if (i) {
            connect( i, SIGNAL(changed()), SLOT(slotChanged()) );
        }
    }

    mPreviewProc = new KProcess;
    connect(mPreviewProc, SIGNAL(processExited(KProcess *)),
	    SLOT(slotPreviewExited(KProcess *)));

    mPreviewTimer = new QTimer(this);
    connect(mPreviewTimer, SIGNAL(timeout()), SLOT(slotNewPreview()));

    mPreview = new QWidget(plainPage());
    mPreview->setFixedSize(250, 200);
    //  mPreview->setBackgroundMode(QWidget::NoBackground);
    mPreview->setBackgroundColor(Qt::black);

    layout->add(mPreview);
    show();

    // So that hacks can XSelectInput ButtonPressMask
    XSelectInput(qt_xdisplay(), mPreview->winId(), widgetEventMask );

    slotPreviewExited(0);
    return true;
}