void BatteryControllerSettings::setServiceType(const QString &t) { if (mServiceType == t) return; mServiceType = t; emit serviceTypeChanged(); }
void MetaDataEditor::readFile() { kDebug() << "readFile file" << filename; delete metadata; metadata = new Plasma::PackageMetadata( filename ); if ( !metadata->isValid() ) { kWarning() << "Package file " << filename << " is invalid"; } view->name_edit->setText( metadata->name() ); view->comment_edit->setText( metadata->description() ); // TODO: icon is missing // view->icon_edit->setText( desktopFile.readIcon() ); // view->icon_button->setIcon( desktopFile.readIcon() ); // connect( view->icon_button, SIGNAL(iconChanged(const QString &)), // view->icon_edit, SLOT(setText(const QString &)) ); if ( view->icon_edit->text().isEmpty() ) { view->icon_button->setIcon("kde"); } view->pluginname_edit->setText( metadata->pluginName() ); QString serviceType = metadata->serviceType(); if ( serviceType == QString("Plasma/Applet") ) { view->type_combo->setCurrentIndex(0); } else if ( serviceType == QString("Plasma/DataEngine") ) { view->type_combo->setCurrentIndex(1); } else if ( serviceType == QString("Plasma/Theme") ) { view->type_combo->setCurrentIndex(2); } else if ( serviceType == QString("Plasma/Runner") ) { view->type_combo->setCurrentIndex(3); } else { kWarning() << "Unknown service type" << serviceType; } serviceTypeChanged(); // Enforce the security restriction from package.cpp in the input field QRegExpValidator *pluginname_validator = new QRegExpValidator( view->pluginname_edit ); QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period. pluginname_validator->setRegExp(validatePluginName); view->pluginname_edit->setValidator(pluginname_validator); int idx = view->category_combo->findText(metadata->category()); if ( idx != -1 ) { view->category_combo->setCurrentIndex( idx ); } else { kWarning() << "Unknown category detected " << metadata->category() << "using miscellaneous instead"; view->category_combo->setCurrentIndex( view->category_combo->count()-1 ); // misc is last } view->version_edit->setText( metadata->version() ); view->website_edit->setText( metadata->website() ); view->author_edit->setText( metadata->author() ); view->email_edit->setText( metadata->email() ); view->license_edit->setText( metadata->license() ); }