Example #1
0
GroupRadioButton::GroupRadioButton(const QString &text, QGroupBox *parent)
: QRadioButton(text, parent->parentWidget())
{
	m_grp = parent;
	QSize s = sizeHint();
	resize(s.width() + 3, s.height());
	move(parent->x() + GRP_RADIO_POS, parent->y() - s.height() / 2);
	parent->installEventFilter(this);
	if (parent->parentWidget()->layout() && parent->parentWidget()->layout()->inherits("QVBoxLayout")){
		QVBoxLayout *lay = static_cast<QVBoxLayout*>(parent->parentWidget()->layout());
		QLayoutIterator it = lay->iterator();
		int pos = lay->findWidget(parent);
		if (pos >= 0)
			lay->insertSpacing(pos, s.height() / 2);
	}
	setAutoMask(false);
	connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool)));
	QObjectList *l = m_grp->parentWidget()->queryList("QRadioButton");
	QObjectListIt it(*l);
	QObject *obj;
	while ((obj=it.current()) != NULL){
		if (obj != this)
			break;
		++it;
    }
	delete l;     		
	if (obj == NULL)
		setChecked(true);
	slotToggled(isChecked());
}
Example #2
0
RadioGroup::RadioGroup(QWidget *parent, const char *name)
        : QGroupBox(parent, name)
{
    m_bInit  = false;
    m_button = new GrpRadioButton(parent);
    QSize s = m_button->sizeHint();
    connect(m_button, SIGNAL(destroyed()), this, SLOT(radioDestroyed()));
    if (parentWidget()->layout() && parentWidget()->layout()->inherits("QVBoxLayout")){
        QVBoxLayout *lay = static_cast<QVBoxLayout*>(parentWidget()->layout());
        QLayoutIterator it = lay->iterator();
        int pos = lay->findWidget(this);
        if (pos >= 0){
            lay->insertSpacing(pos, s.height() / 2);
        }else{
            lay->addSpacing(s.height() / 2);
        }
    }
    connect(m_button, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool)));
    QObjectList *l = parentWidget()->queryList("QRadioButton");
    QObjectListIt it(*l);
    QObject *obj;
    while ((obj=it.current()) != NULL){
        if (obj != this)
            break;
        ++it;
    }
    delete l;
    if (obj == NULL)
        m_button->setChecked(true);
    QTimer::singleShot(0, this, SLOT(slotToggled()));
}
Example #3
0
RecordDialog::RecordDialog(QWidget *parent, const char *name)
    :QDialog(parent, name, TRUE)
{
	QVBoxLayout *layout = new QVBoxLayout(this);
	QHBoxLayout *hlayout = new QHBoxLayout(this);

	layout->insertSpacing(0,5);

	output = new QMultiLineEdit(this, "output");
	output->setReadOnly(true);
	output->setWordWrap(QMultiLineEdit::WidgetWidth);
	output->setText(tr("Please enter the name of the new remote, and press Next\n"));

	layout->insertWidget(-1, output);
	layout->insertSpacing(-1, 5);
	layout->insertLayout(-1, hlayout);
	layout->insertSpacing(-1, 5);

	hlayout->insertSpacing(0, 5);
	input = new QLineEdit(this, "input");
	hlayout->insertWidget(-1, input, 1);
	hlayout->insertSpacing(-1, 5);

	nextbtn = new QPushButton(tr("Next"), this, "next");
	nextbtn->setDefault(true);
	hlayout->insertWidget(-1, nextbtn);
	hlayout->insertSpacing(-1, 5);
	connect(nextbtn, SIGNAL(clicked()), this, SLOT(nextPressed()) );

	setCaption(tr("Learn Remote"));
	input->setFocus();

	stepnum = 0;
	outputenabled = false;
	writeok = true;
	ignorekill = false;

	record = new OProcess;

	// We need to stop lircd because irrecord accesses the IR device directly
	lh = new LircHandler();
	lh->stopLircd();
}
Example #4
0
GroupRadioButton::GroupRadioButton(const QString &text, QGroupBox *parent)
: QRadioButton(text, parent->parentWidget())
{
	QSize s = sizeHint();
	resize(s.width() + 3, s.height());
	move(parent->x() + GRP_RADIO_POS, parent->y() - s.height() / 2);
	parent->installEventFilter(this);
	if (parent->parentWidget()->layout() && parent->parentWidget()->layout()->inherits("QVBoxLayout")){
		QVBoxLayout *lay = static_cast<QVBoxLayout*>(parent->parentWidget()->layout());
		QLayoutIterator it = lay->iterator();
		int pos = lay->findWidget(parent);
		if (pos >= 0)
			lay->insertSpacing(pos, s.height() / 2);
	}
	setAutoMask(false);
}
Example #5
0
awayscreen::awayscreen(QWidget *parent) :
    QWidget(parent)
{
    // the away screen provides the user an AWAY MODE with the tap of a button
    // it is meant to be used for long periods of away time (i.e. vacation)
    // it is called from the mainwindow

    // title
    awayLabel = new QLabel("System is using energy saving AWAY MODE");
    awayLabel->setAlignment(Qt::AlignHCenter);
    awayLabel->setObjectName("awayLabel");

    // green leaf
    ecoLabel = new QLabel();
    ecoLabel->setAlignment(Qt::AlignHCenter);
    QPixmap *ecoLeaf = new QPixmap(":/Images/eco-leaf.png");
    *ecoLeaf = ecoLeaf->scaled(60,60,Qt::KeepAspectRatio);
    ecoLabel->setPixmap(*ecoLeaf);
    ecoLabel->setObjectName("ecoLabel");
    ecoLabel->setAlignment(Qt::AlignTop);

    // provides current temp - same value as listed in mainwindow adjust dynamically
    currentTempLabel = new QLabel;
    currentTempLabel->setText(QString::number(thermostatwidget::currentTempStatic)+"°");
    currentTempLabel->setAlignment(Qt::AlignHCenter);
    currentTempLabel->setObjectName("currentTemp");
    currentTempLabel->setMargin(0);

    // inside label
    QLabel *insideLabel = new QLabel("Inside");
    insideLabel->setAlignment(Qt::AlignHCenter);
    insideLabel->setMargin(0);

    // layout for current temp
    QVBoxLayout *currentLayout = new QVBoxLayout;
    currentLayout->addStretch();
    currentLayout->addWidget(insideLabel);
    currentLayout->addWidget(currentTempLabel);
    currentLayout->addStretch();

    // upper bound control widget
    upperBound = new QSpinBox;
    upperBound->setValue(84);
    upperBound->setSuffix("°");
    upperBound->findChild<QLineEdit*>()->setReadOnly(true);

    // lower bound control widget
    lowerBound = new QSpinBox;
    lowerBound->setValue(60);
    lowerBound->setSuffix("°");
    lowerBound->findChild<QLineEdit*>()->setReadOnly(true);

    // upper and lower bound labels
    QLabel *heatTo = new QLabel("Heat to");
    heatTo->setAlignment(Qt::AlignHCenter);
    QLabel *coolTo = new QLabel("Cool to");
    coolTo->setAlignment(Qt::AlignHCenter);

    // combines upper and lower bounds into one layout
    QVBoxLayout *boundsLayout = new QVBoxLayout;
    boundsLayout->addStretch();
    boundsLayout->addWidget(coolTo);
    boundsLayout->addWidget(upperBound);
    boundsLayout->addWidget(heatTo);
    boundsLayout->addWidget(lowerBound);
    boundsLayout->addStretch();

    // combines current temp layout and bounds layout
    QHBoxLayout *centerLayout = new QHBoxLayout;
    centerLayout->addStretch();
    centerLayout->addLayout(currentLayout);
    centerLayout->addSpacing(20);
    centerLayout->addLayout(boundsLayout);
    centerLayout->addStretch();

    // combines center layout with title
    QVBoxLayout *rightLayout = new QVBoxLayout;
    rightLayout->addWidget(awayLabel);
    rightLayout->insertSpacing(1,10);
    rightLayout->addLayout(centerLayout);

    // combines existing layout with green leaf
    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(ecoLabel);
    topLayout->addLayout(rightLayout);

    // button to return to main screen
    QPushButton *backButton = new QPushButton("I'm Back!");
    backButton->setFocusPolicy(Qt::NoFocus);
    connect(backButton,SIGNAL(clicked()),this,SLOT(close()));

    // adds back button to provide final layout
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->insertSpacing(2,10);
    mainLayout->addWidget(backButton);
    mainLayout->setAlignment(centerLayout,Qt::AlignHCenter);

    // show final layout
    setLayout(mainLayout);
}
Example #6
0
void BehaviorConfig_Shorten::slotConfigureClicked()
{
    qCDebug(CHOQOK);
    KPluginInfo pluginInfo = availablePlugins.value(shortenPlugins->itemData(shortenPlugins->currentIndex()).toString());
    qCDebug(CHOQOK) << pluginInfo.name() << pluginInfo.kcmServices().count();

    QPointer<QDialog> configDialog = new QDialog(this);
    configDialog->setWindowTitle(pluginInfo.name());
    // The number of KCModuleProxies in use determines whether to use a tabwidget
    QTabWidget *newTabWidget = 0;
    // Widget to use for the setting dialog's main widget,
    // either a QTabWidget or a KCModuleProxy
    QWidget *mainWidget = 0;
    // Widget to use as the KCModuleProxy's parent.
    // The first proxy is owned by the dialog itself
    QWidget *moduleProxyParentWidget = configDialog;

    for (const KService::Ptr &servicePtr: pluginInfo.kcmServices()) {
        if (!servicePtr->noDisplay()) {
            KCModuleInfo moduleInfo(servicePtr);
            KCModuleProxy *currentModuleProxy = new KCModuleProxy(moduleInfo, moduleProxyParentWidget);
            if (currentModuleProxy->realModule()) {
                moduleProxyList << currentModuleProxy;
                if (mainWidget && !newTabWidget) {
                    // we already created one KCModuleProxy, so we need a tab widget.
                    // Move the first proxy into the tab widget and ensure this and subsequent
                    // proxies are in the tab widget
                    newTabWidget = new QTabWidget(configDialog);
                    moduleProxyParentWidget = newTabWidget;
                    mainWidget->setParent(newTabWidget);
                    KCModuleProxy *moduleProxy = qobject_cast<KCModuleProxy *>(mainWidget);
                    if (moduleProxy) {
                        newTabWidget->addTab(mainWidget, moduleProxy->moduleInfo().moduleName());
                        mainWidget = newTabWidget;
                    } else {
                        delete newTabWidget;
                        newTabWidget = 0;
                        moduleProxyParentWidget = configDialog;
                        mainWidget->setParent(0);
                    }
                }

                if (newTabWidget) {
                    newTabWidget->addTab(currentModuleProxy, servicePtr->name());
                } else {
                    mainWidget = currentModuleProxy;
                }
            } else {
                delete currentModuleProxy;
            }
        }
    }

    // it could happen that we had services to show, but none of them were real modules.
    if (moduleProxyList.count()) {
        QWidget *showWidget = new QWidget(configDialog);
        QVBoxLayout *layout = new QVBoxLayout;
        showWidget->setLayout(layout);
        layout->addWidget(mainWidget);
        layout->insertSpacing(-1, QApplication::style()->pixelMetric(QStyle::PM_DialogButtonsSeparator));

        QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
        QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
        okButton->setDefault(true);
        okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
        connect(buttonBox, &QDialogButtonBox::accepted, configDialog.data(), &QDialog::accept);
        connect(buttonBox, &QDialogButtonBox::rejected, configDialog.data(), &QDialog::reject);
        layout->addWidget(buttonBox);
        showWidget->adjustSize();

//         connect(&configDialog, SIGNAL(defaultClicked()), this, SLOT(slotDefaultClicked()));

        if (configDialog->exec() == QDialog::Accepted) {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QLatin1String("X-KDE-ParentComponents")).toStringList();
                moduleProxy->save();
            }
        } else {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                moduleProxy->load();
            }
        }

        qDeleteAll(moduleProxyList);
        moduleProxyList.clear();
    }
}