void setButtonsEnabled(bool isEnabled) { m_add_button->setEnabled(isEnabled); QModelIndex index = m_list_widget->selectedIndex(); m_remove_button->setEnabled(isEnabled && index.isValid()); m_down_button->setEnabled(isEnabled && index.isValid() && index.row() < index.model()->rowCount()-1); m_up_button->setEnabled(isEnabled && index.isValid() && index.row() > 0); }
void EstateDetails::addButton(QString command, QString caption, bool enabled) { KPushButton *button = new KPushButton(caption, this); m_buttons.append(button); m_buttonCommandMap[(QObject *)button] = command; m_buttonBox->addWidget(button); if (m_estate) { QColor bgColor, fgColor; bgColor = m_estate->bgColor().light(110); fgColor = ( bgColor.red() + bgColor.green() + bgColor.blue() < 255 ) ? Qt::white : Qt::black; button->setPaletteForegroundColor( fgColor ); button->setPaletteBackgroundColor( bgColor ); } button->setEnabled(enabled); button->show(); connect(button, SIGNAL(pressed()), this, SLOT(buttonPressed())); }
MainWindow::MainWindow(QWidget *parent) : KMainWindow(parent) { QWidget *central_widget = new QWidget(this); QVBoxLayout *central_layout = new QVBoxLayout(this); QHBoxLayout *h_layout = new QHBoxLayout(this); QVBoxLayout *v_layout = new QVBoxLayout(this); QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(new QLabel(i18n("tag:"), this)); layout->addWidget(tag = new KLineEdit(this)); v_layout->addLayout(layout); layout = new QHBoxLayout(this); layout->addWidget(new QLabel(i18n("text:"), this)); layout->addWidget(text = new KTextEdit(this)); text->setMaximumHeight(100); v_layout->addLayout(layout); h_layout->addLayout(v_layout); KPushButton *button = new KPushButton(i18n("Search"), this); connect(button, SIGNAL(clicked()), this, SLOT(query())); h_layout->addWidget(button); central_layout->addLayout(h_layout); central_layout->addWidget(new QLabel(i18n("Result:"), this)); central_layout->addWidget(result = new KTextBrowser(this)); central_layout->addWidget(new QLabel(i18n("Url:"), this)); central_layout->addWidget(url = new KTextBrowser(this)); central_widget->setLayout(central_layout); setCentralWidget(central_widget); setMinimumSize(650,485); if (Nepomuk2::ResourceManager::instance()->init()) button->setEnabled(false); }
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const { QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]); KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]); const int itemHeight = sizeHint(option, index).height(); // Update the checkbox showing the service name and icon const QAbstractItemModel* model = index.model(); checkBox->setText(model->data(index).toString()); const QString iconName = model->data(index, Qt::DecorationRole).toString(); if (!iconName.isEmpty()) { checkBox->setIcon(KIcon(iconName)); } checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool()); const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool(); int checkBoxWidth = option.rect.width(); if (configurable) { checkBoxWidth -= configureButton->sizeHint().width(); } checkBox->resize(checkBoxWidth, checkBox->sizeHint().height()); checkBox->move(0, (itemHeight - checkBox->height()) / 2); // Update the configuration button if (configurable) { configureButton->setEnabled(checkBox->isChecked()); configureButton->setIcon(KIcon("configure")); configureButton->resize(configureButton->sizeHint()); configureButton->move(option.rect.right() - configureButton->width(), (itemHeight - configureButton->height()) / 2); } configureButton->setVisible(configurable); }
ConfigBackendsPage::ConfigBackendsPage( Config *_config, QWidget *parent ) : ConfigPageBase( parent ), config( _config ) { QVBoxLayout *box = new QVBoxLayout( this ); QFont groupFont; groupFont.setBold( true ); QLabel *lCdRipper = new QLabel( i18n("CD ripper"), this ); lCdRipper->setFont( groupFont ); box->addWidget( lCdRipper ); box->addSpacing( ConfigDialogSpacingSmall ); QHBoxLayout *ripperBox = new QHBoxLayout(); ripperBox->addSpacing( ConfigDialogOffset ); box->addLayout( ripperBox ); QLabel *lSelectorRipper = new QLabel( i18n("Use plugin:"), this ); ripperBox->addWidget( lSelectorRipper ); ripperBox->setStretchFactor( lSelectorRipper, 2 ); cSelectorRipper = new KComboBox( this ); cSelectorRipper->addItems( config->data.backends.rippers ); ripperBox->addWidget( cSelectorRipper ); ripperBox->setStretchFactor( cSelectorRipper, 1 ); connect( cSelectorRipper, SIGNAL(activated(int)), this, SLOT(somethingChanged()) ); connect( cSelectorRipper, SIGNAL(activated(const QString&)), this, SLOT(ripperChanged(const QString&)) ); pConfigureRipper = new KPushButton( KIcon("configure"), "", this ); pConfigureRipper->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() ); pConfigureRipper->setFlat( true ); ripperBox->addWidget( pConfigureRipper ); ripperBox->setStretchFactor( pConfigureRipper, 1 ); connect( pConfigureRipper, SIGNAL(clicked()), this, SLOT(configureRipper()) ); box->addSpacing( ConfigDialogSpacingBig ); QLabel *lFilters = new QLabel( i18n("Filters"), this ); lFilters->setFont( groupFont ); box->addWidget( lFilters ); box->addSpacing( ConfigDialogSpacingSmall ); QHBoxLayout *filterBox = new QHBoxLayout(); filterBox->addSpacing( ConfigDialogOffset ); box->addLayout( filterBox ); QGridLayout *filterGrid = new QGridLayout(); int row = 0; foreach( const QString filterPluginName, config->data.backends.filters ) { if( row == 0 ) { QLabel *lSelectorFilter = new QLabel( i18n("Enable plugins:"), this ); filterGrid->addWidget( lSelectorFilter, row, 0 ); } QCheckBox *newCheckBox = new QCheckBox( filterPluginName, this ); newCheckBox->setChecked( config->data.backends.enabledFilters.contains(filterPluginName) ); filterGrid->addWidget( newCheckBox, row, 1 ); filterCheckBoxes.append( newCheckBox ); connect( newCheckBox, SIGNAL(stateChanged(int)), this, SLOT(somethingChanged()) ); KPushButton *newConfigButton = new KPushButton( KIcon("configure"), "", this ); newConfigButton->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() ); newConfigButton->setFlat( true ); filterGrid->addWidget( newConfigButton, row, 2 ); connect( newConfigButton, SIGNAL(clicked()), this, SLOT(configureFilter()) ); filterConfigButtons.append( newConfigButton ); FilterPlugin *plugin = qobject_cast<FilterPlugin*>(config->pluginLoader()->backendPluginByName(filterPluginName)); if( plugin ) { newConfigButton->setEnabled( plugin->isConfigSupported(BackendPlugin::General,"") ); } else { newConfigButton->setEnabled( false ); } if( newConfigButton->isEnabled() ) newConfigButton->setToolTip( i18n("Configure %1 ...",filterPluginName) ); row++; } filterGrid->setColumnStretch( 0, 2 ); filterGrid->setColumnStretch( 1, 1 ); filterBox->addLayout( filterGrid ); box->addSpacing( ConfigDialogSpacingBig ); QLabel *lPriorities = new QLabel( i18n("Priorities"), this ); lPriorities->setFont( groupFont ); box->addWidget( lPriorities ); box->addSpacing( ConfigDialogSpacingSmall ); QVBoxLayout *formatBox = new QVBoxLayout(); box->addLayout( formatBox, 1 ); QHBoxLayout *formatSelectorBox = new QHBoxLayout(); formatSelectorBox->addSpacing( ConfigDialogOffset ); formatBox->addLayout( formatSelectorBox ); QLabel *lSelectorFormat = new QLabel( i18n("Configure plugin priorities for format:"), this ); formatSelectorBox->addWidget( lSelectorFormat ); cSelectorFormat = new KComboBox( this ); cSelectorFormat->addItems( config->pluginLoader()->formatList(PluginLoader::Possibilities(PluginLoader::Encode|PluginLoader::Decode|PluginLoader::ReplayGain),PluginLoader::CompressionType(PluginLoader::InferiorQuality|PluginLoader::Lossy|PluginLoader::Lossless|PluginLoader::Hybrid)) ); cSelectorFormat->removeItem( cSelectorFormat->findText("wav") ); cSelectorFormat->removeItem( cSelectorFormat->findText("audio cd") ); formatSelectorBox->addWidget( cSelectorFormat ); connect( cSelectorFormat, SIGNAL(activated(const QString&)), this, SLOT(formatChanged(const QString&)) ); formatSelectorBox->addStretch(); QHBoxLayout *formatBackendsBox = new QHBoxLayout(); formatBackendsBox->addSpacing( ConfigDialogOffset ); formatBox->addLayout( formatBackendsBox ); decoderList = new BackendsListWidget( i18n("Decoder"), config, this ); formatBackendsBox->addWidget( decoderList ); connect( decoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) ); encoderList = new BackendsListWidget( i18n("Encoder"), config, this ); formatBackendsBox->addWidget( encoderList ); connect( encoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) ); replaygainList = new BackendsListWidget( i18n("Replay Gain"), config, this ); formatBackendsBox->addWidget( replaygainList ); connect( replaygainList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) ); QHBoxLayout *optimizationsBox = new QHBoxLayout(); optimizationsBox->addSpacing( ConfigDialogOffset ); formatBox->addLayout( optimizationsBox ); optimizationsBox->addStretch(); pShowOptimizations = new KPushButton( KIcon("games-solve"), i18n("Show possible optimizations"), this ); optimizationsBox->addWidget( pShowOptimizations ); connect( pShowOptimizations, SIGNAL(clicked()), this, SLOT(showOptimizations()) ); optimizationsBox->addStretch(); box->addStretch( 2 ); ripperChanged( cSelectorRipper->currentText() ); formatChanged( cSelectorFormat->currentText() ); }