#include "mythuihelper.h" #include "settings.h" #include "compat-mv.h" void ImageSelectSetting::addImageSelection(const QString& label, QImage* image, QString value, bool select) { images.push_back(image); addSelection(label, value, select); } ImageSelectSetting::~ImageSelectSetting() { Teardown(); } void ImageSelectSetting::deleteLater(void) { Teardown(); SelectSetting::deleteLater(); } void ImageSelectSetting::Teardown(void) { while (images.size()) { QImage *tmp = images.back(); images.pop_back(); delete tmp; } bxwidget = NULL; imagelabel = NULL; combo = NULL; } void ImageSelectSetting::imageSet(int num) { if (num >= (int)images.size()) return; if (!images[current]) return; QImage temp = *(images[current]); temp = temp.scaled((int)(184 * m_hmult), (int)(138 * m_hmult), Qt::KeepAspectRatio); QPixmap tmppix = QPixmap::fromImage(temp); imagelabel->setPixmap(tmppix); } QWidget* ImageSelectSetting::configWidget(ConfigurationGroup *cg, QWidget* parent, const char* widgetName) { int width = 0, height = 0; GetMythUI()->GetScreenSettings(width, m_wmult, height, m_hmult); bxwidget = new QWidget(parent); bxwidget->setObjectName(widgetName); QBoxLayout *layout = NULL; if (labelAboveWidget) { layout = new QVBoxLayout(); bxwidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum)); } else layout = new QHBoxLayout(); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); if (getLabel() != "") { QLabel *label = new QLabel(); label->setText(getLabel() + ":"); layout->addWidget(label); } combo = new MythComboBox(false); layout->addWidget(combo); QLabel *testlabel = new QLabel(); testlabel->setText(" "); layout->addWidget(testlabel); connect(bxwidget, SIGNAL(destroyed(QObject*)), this, SLOT(widgetDeleted(QObject*))); imagelabel = new QLabel(); layout->addWidget(imagelabel); for (unsigned int i = 0 ; i < images.size() ; ++i) combo->insertItem(labels[i]); if (isSet) combo->setCurrentIndex(current); else current = 0; if (images.size() != 0 && current < images.size() && images[current]) { QImage temp = *(images[current]); temp = temp.scaled((int)(184 * m_hmult), (int)(138 * m_hmult), Qt::KeepAspectRatio); QPixmap tmppix = QPixmap::fromImage(temp); imagelabel->setPixmap(tmppix); imagelabel->setMinimumHeight(tmppix.height()); } else { QPixmap tmppix((int)(184 * m_hmult), (int)(138 * m_hmult)); tmppix.fill(Qt::black); imagelabel->setPixmap(tmppix); imagelabel->setMinimumHeight(tmppix.height()); } connect(combo, SIGNAL(highlighted(int)), this, SLOT(setValue(int))); connect(combo, SIGNAL(highlighted(int)), this, SLOT(imageSet(int))); connect(combo, SIGNAL(activated(int)), this, SLOT(setValue(int))); connect(combo, SIGNAL(activated(int)), this, SLOT(imageSet(int))); connect(this, SIGNAL(selectionsCleared()), combo, SLOT(clear())); if (cg) connect(combo, SIGNAL(changeHelpText(QString)), cg, SIGNAL(changeHelpText(QString))); bxwidget->setLayout(layout); return bxwidget; } void ImageSelectSetting::widgetInvalid(QObject *obj) { if (bxwidget == obj) { bxwidget = NULL; imagelabel = NULL; combo = NULL; } } void ImageSelectSetting::setHelpText(const QString &str) { if (combo) combo->setHelpText(str); SelectSetting::setHelpText(str); }