21#include <tqcombobox.h> 
   24#include <tqlineedit.h> 
   29#include <tdelistview.h> 
   32#include <kurlrequester.h> 
   33#include <tdemessagebox.h> 
   35#include <tdeapplication.h> 
   41#include "uploaddialog.h" 
   42#include "uploaddialog.moc" 
   46UploadDialog::UploadDialog( 
Engine *engine, TQWidget *parent ) :
 
   47  KDialogBase( Plain, i18n(
"Share Hot New Stuff"), Ok | Cancel, Cancel,
 
   48               parent, 0, false, true ),
 
   51  mEntryList.setAutoDelete( 
true );
 
   53  TQFrame *topPage = plainPage();
 
   55  TQGridLayout *topLayout = 
new TQGridLayout( topPage );
 
   56  topLayout->setSpacing( spacingHint() );
 
   58  TQLabel *nameLabel = 
new TQLabel( i18n(
"Name:"), topPage );
 
   59  topLayout->addWidget( nameLabel, 0, 0 );  
 
   60  mNameEdit = 
new TQLineEdit( topPage );
 
   61  topLayout->addWidget( mNameEdit, 0, 1 );
 
   63  TQLabel *authorLabel = 
new TQLabel( i18n(
"Author:"), topPage );
 
   64  topLayout->addWidget( authorLabel, 1, 0 );
 
   65  mAuthorEdit = 
new TQLineEdit( topPage );
 
   66  topLayout->addWidget( mAuthorEdit, 1, 1 );
 
   68  TQLabel *emailLabel = 
new TQLabel( i18n(
"Email:"), topPage );
 
   69  topLayout->addWidget( emailLabel, 2, 0 );
 
   70  mEmailEdit = 
new TQLineEdit( topPage );
 
   71  topLayout->addWidget( mEmailEdit, 2, 1 );
 
   73  TQLabel *versionLabel = 
new TQLabel( i18n(
"Version:"), topPage );
 
   74  topLayout->addWidget( versionLabel, 3, 0 );  
 
   75  mVersionEdit = 
new TQLineEdit( topPage );
 
   76  topLayout->addWidget( mVersionEdit, 3, 1 );
 
   78  TQLabel *releaseLabel = 
new TQLabel( i18n(
"Release:"), topPage );
 
   79  topLayout->addWidget( releaseLabel, 4, 0 );  
 
   80  mReleaseSpin = 
new TQSpinBox( topPage );
 
   81  mReleaseSpin->setMinValue( 1 );
 
   82  topLayout->addWidget( mReleaseSpin, 4, 1 );
 
   84  TQLabel *licenceLabel = 
new TQLabel( i18n(
"License:"), topPage );
 
   85  topLayout->addWidget( licenceLabel, 5, 0 );
 
   86  mLicenceCombo = 
new TQComboBox( topPage );
 
   87  mLicenceCombo->setEditable( 
true );
 
   88  mLicenceCombo->insertItem( i18n(
"GPL") );
 
   89  mLicenceCombo->insertItem( i18n(
"LGPL") );
 
   90  mLicenceCombo->insertItem( i18n(
"BSD") );
 
   91  topLayout->addWidget( mLicenceCombo, 5, 1 );
 
   93  TQLabel *languageLabel = 
new TQLabel( i18n(
"Language:"), topPage );
 
   94  topLayout->addWidget( languageLabel, 6, 0 );
 
   95  mLanguageCombo = 
new TQComboBox( topPage );
 
   96  topLayout->addWidget( mLanguageCombo, 6, 1 );
 
   97  mLanguageCombo->insertStringList( TDEGlobal::locale()->languageList() );
 
   99  TQLabel *previewLabel = 
new TQLabel( i18n(
"Preview URL:"), topPage );
 
  100  topLayout->addWidget( previewLabel, 7, 0 );
 
  101  mPreviewUrl = 
new KURLRequester( topPage );
 
  102  topLayout->addWidget( mPreviewUrl, 7, 1 );
 
  104  TQLabel *summaryLabel = 
new TQLabel( i18n(
"Summary:"), topPage );
 
  105  topLayout->addMultiCellWidget( summaryLabel, 8, 8, 0, 1 );
 
  106  mSummaryEdit = 
new KTextEdit( topPage );
 
  107  topLayout->addMultiCellWidget( mSummaryEdit, 9, 9, 0, 1 );
 
  110  mAuthorEdit->setText(user.fullName());
 
  118void UploadDialog::slotOk()
 
  120  if ( mNameEdit->text().isEmpty() ) {
 
  121    KMessageBox::error( 
this, i18n(
"Please put in a name.") );
 
  127  mEntryList.append( entry );
 
  129  entry->
setName( mNameEdit->text() );
 
  134  entry->
setLicence( mLicenceCombo->currentText() );
 
  135  entry->
setPreview( KURL( mPreviewUrl->url().section(
"/", -1) ), mLanguageCombo->currentText() );
 
  136  entry->
setSummary( mSummaryEdit->text(), mLanguageCombo->currentText() );
 
  138  if ( mPayloadUrl.isValid() ) {
 
  139    TDEConfig *conf = tdeApp->config();
 
  140    conf->setGroup( TQString(
"TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
 
  141    conf->writeEntry(
"name", mNameEdit->text());
 
  142    conf->writeEntry(
"author", mAuthorEdit->text());
 
  143    conf->writeEntry(
"email", mEmailEdit->text());
 
  144    conf->writeEntry(
"version", mVersionEdit->text());
 
  145    conf->writeEntry(
"release", mReleaseSpin->value());
 
  146    conf->writeEntry(
"licence", mLicenceCombo->currentText());
 
  147    conf->writeEntry(
"preview", mPreviewUrl->url());
 
  148    conf->writeEntry(
"summary", mSummaryEdit->text());
 
  149    conf->writeEntry(
"language", mLanguageCombo->currentText());
 
  160  mPreviewUrl->setURL( previewFile );
 
  165  mPayloadUrl = payloadFile;
 
  167  TDEConfig *conf = tdeApp->config();
 
  168  conf->setGroup( TQString(
"TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
 
  169  TQString name = conf->readEntry(
"name");
 
  170  TQString author = conf->readEntry(
"author");
 
  171  TQString email = conf->readEntry(
"email");
 
  172  TQString version = conf->readEntry(
"version");
 
  173  TQString release = conf->readEntry(
"release");
 
  174  TQString preview = conf->readEntry(
"preview");
 
  175  TQString summary = conf->readEntry(
"summary");
 
  176  TQString lang = conf->readEntry(
"language");
 
  177  TQString licence = conf->readEntry(
"licence");
 
  180  mAuthorEdit->clear();
 
  182  mVersionEdit->clear();
 
  183  mReleaseSpin->setValue(1);
 
  184  mPreviewUrl->clear();
 
  185  mSummaryEdit->clear();
 
  186  mLanguageCombo->setCurrentItem(0);
 
  187  mLicenceCombo->setCurrentItem(0);
 
  191    int prefill = KMessageBox::questionYesNo(
this, i18n(
"Old upload information found, fill out fields?"),TQString::null,i18n(
"Fill Out"),i18n(
"Do Not Fill Out"));
 
  192    if(prefill == KMessageBox::Yes)
 
  194      mNameEdit->setText(name);
 
  195      mAuthorEdit->setText(author);
 
  196      mEmailEdit->setText(email);
 
  197      mVersionEdit->setText(version);
 
  198      mReleaseSpin->setValue(release.toInt());
 
  199      mPreviewUrl->setURL(preview);
 
  200      mSummaryEdit->setText(summary);
 
  201      if(!lang.isEmpty()) mLanguageCombo->setCurrentText(lang);
 
  202      if(!licence.isEmpty()) mLicenceCombo->setCurrentText(licence);
 
Central class combining all possible TDENewStuff operations.
void upload(const TQString &fileName=TQString::null, const TQString &previewName=TQString::null)
Initiates the upload process, invoking the provider selection dialog and the file upload dialog.
TDENewStuff data entry container.
void setSummary(const TQString &, const TQString &lang=TQString::null)
Sets a short description on what the object is all about.
void setLicence(const TQString &)
Sets the license (abbreviation) applicable to the object.
void setName(const TQString &)
Sets the (unique) name for this data object.
void setAuthorEmail(const TQString &)
Sets the email address of the object's author.
void setRelease(int)
Sets the release number, which is increased for feature-equal objects with the same version number,...
void setVersion(const TQString &)
Sets the version number.
void setPreview(const KURL &, const TQString &lang=TQString::null)
Sets the object's preview file, if available.
void setAuthor(const TQString &)
Sets the full name of the object's author.
~UploadDialog()
Destructor.
void setPayloadFile(const TQString &payloadFile)
Sets the payload filename.
void setPreviewFile(const TQString &previewFile)
Sets the preview filename.
Handles security releated issues, like signing, verifying.