void image_channels_param_t::set_channel_list( const std::vector<std::string>& channels) { if( !channel_list_.empty()) { std::string ch0, ch1, ch2, ch3; get_channel_names( ch0, ch1, ch2, ch3); channel_list_ = channels; set_channels( ch0, ch1, ch2, ch3); } else { channel_list_ = channels; value().assign( tuple4i_t( 0, 1, 2, 3)); } tuple4i_t ch( get_value<tuple4i_t>( *this)); if( red_combo_) { update_popup( red_combo_ , boost::get<0>( ch)); update_popup( green_combo_ , boost::get<1>( ch)); update_popup( blue_combo_ , boost::get<2>( ch)); update_popup( alpha_combo_ , boost::get<3>( ch)); } }
void image_channels_param_t::clear_channel_list() { channel_list_.clear(); value().assign( tuple4i_t( 0, 1, 2, 3)); if( red_combo_) { update_popup( red_combo_ , 0); update_popup( green_combo_ , 1); update_popup( blue_combo_ , 2); update_popup( alpha_combo_ , 3); } }
RComboBox::RComboBox(QWidget *parent) : CustomComboBox(parent) { this->setEditable(true); this->setInsertPolicy(QComboBox::NoInsert); completer = 0; timer = new QTimer(this); timer->setSingleShot(true); timeout = 1000; min_chars = 3; first = false; //this->lineEdit()->installEventFilter(this); connect(timer, SIGNAL(timeout()), SLOT(update_popup())); }
// ui QWidget *image_channels_param_t::do_create_widgets() { QWidget *top = new QWidget(); int current_height = 0; // popups { QLabel *label = new QLabel( top); red_combo_ = new QComboBox( top); red_combo_->setFocusPolicy( Qt::NoFocus); QSize s = red_combo_->sizeHint(); label->move( 0, current_height); label->resize( app().ui()->inspector().left_margin() - 5, s.height()); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter); label->setText( "Red"); red_combo_->move( app().ui()->inspector().left_margin(), current_height); red_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height()); connect( red_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int))); current_height = s.height() + 5; } { QLabel *label = new QLabel( top); green_combo_ = new QComboBox( top); green_combo_->setFocusPolicy( Qt::NoFocus); QSize s = green_combo_->sizeHint(); label->move( 0, current_height); label->resize( app().ui()->inspector().left_margin() - 5, s.height()); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter); label->setText( "Green"); green_combo_->move( app().ui()->inspector().left_margin(), current_height); green_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height()); connect( green_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int))); current_height += s.height() + 5; } { QLabel *label = new QLabel( top); blue_combo_ = new QComboBox( top); blue_combo_->setFocusPolicy( Qt::NoFocus); QSize s = blue_combo_->sizeHint(); label->move( 0, current_height); label->resize( app().ui()->inspector().left_margin() - 5, s.height()); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter); label->setText( "Blue"); blue_combo_->move( app().ui()->inspector().left_margin(), current_height); blue_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height()); connect( blue_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int))); current_height += s.height() + 5; } { QLabel *label = new QLabel( top); alpha_combo_ = new QComboBox( top); alpha_combo_->setFocusPolicy( Qt::NoFocus); QSize s = alpha_combo_->sizeHint(); label->move( 0, current_height); label->resize( app().ui()->inspector().left_margin() - 5, s.height()); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter); label->setText( "Alpha"); alpha_combo_->move( app().ui()->inspector().left_margin(), current_height); alpha_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height()); connect( alpha_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int))); current_height += s.height() + 5; } top->setMinimumSize( app().ui()->inspector().width(), current_height); top->setMaximumSize( app().ui()->inspector().width(), current_height); top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed); tuple4i_t ch( get_value<tuple4i_t>( *this)); update_popup( red_combo_ , boost::get<0>( ch)); update_popup( green_combo_ , boost::get<1>( ch)); update_popup( blue_combo_ , boost::get<2>( ch)); update_popup( alpha_combo_ , boost::get<3>( ch)); return top; }