You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
207 lines
6.8 KiB
207 lines
6.8 KiB
15 years ago
|
/*
|
||
|
This file is part of KOrganizer.
|
||
|
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqcombobox.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqlineedit.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqstring.h>
|
||
15 years ago
|
#include <ktextedit.h>
|
||
|
|
||
12 years ago
|
#include <tdelistview.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <kurlrequester.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <kuser.h>
|
||
|
|
||
|
#include "engine.h"
|
||
|
#include "entry.h"
|
||
|
|
||
|
#include "uploaddialog.h"
|
||
|
#include "uploaddialog.moc"
|
||
|
|
||
|
using namespace KNS;
|
||
|
|
||
15 years ago
|
UploadDialog::UploadDialog( Engine *engine, TQWidget *parent ) :
|
||
15 years ago
|
KDialogBase( Plain, i18n("Share Hot New Stuff"), Ok | Cancel, Cancel,
|
||
|
parent, 0, false, true ),
|
||
|
mEngine( engine )
|
||
|
{
|
||
|
mEntryList.setAutoDelete( true );
|
||
|
|
||
15 years ago
|
TQFrame *topPage = plainPage();
|
||
15 years ago
|
|
||
15 years ago
|
TQGridLayout *topLayout = new TQGridLayout( topPage );
|
||
15 years ago
|
topLayout->setSpacing( spacingHint() );
|
||
|
|
||
15 years ago
|
TQLabel *nameLabel = new TQLabel( i18n("Name:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( nameLabel, 0, 0 );
|
||
15 years ago
|
mNameEdit = new TQLineEdit( topPage );
|
||
15 years ago
|
topLayout->addWidget( mNameEdit, 0, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *authorLabel = new TQLabel( i18n("Author:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( authorLabel, 1, 0 );
|
||
15 years ago
|
mAuthorEdit = new TQLineEdit( topPage );
|
||
15 years ago
|
topLayout->addWidget( mAuthorEdit, 1, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *emailLabel = new TQLabel( i18n("Email:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( emailLabel, 2, 0 );
|
||
15 years ago
|
mEmailEdit = new TQLineEdit( topPage );
|
||
15 years ago
|
topLayout->addWidget( mEmailEdit, 2, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *versionLabel = new TQLabel( i18n("Version:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( versionLabel, 3, 0 );
|
||
15 years ago
|
mVersionEdit = new TQLineEdit( topPage );
|
||
15 years ago
|
topLayout->addWidget( mVersionEdit, 3, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *releaseLabel = new TQLabel( i18n("Release:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( releaseLabel, 4, 0 );
|
||
15 years ago
|
mReleaseSpin = new TQSpinBox( topPage );
|
||
15 years ago
|
mReleaseSpin->setMinValue( 1 );
|
||
|
topLayout->addWidget( mReleaseSpin, 4, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *licenceLabel = new TQLabel( i18n("License:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( licenceLabel, 5, 0 );
|
||
15 years ago
|
mLicenceCombo = new TQComboBox( topPage );
|
||
15 years ago
|
mLicenceCombo->setEditable( true );
|
||
|
mLicenceCombo->insertItem( i18n("GPL") );
|
||
|
mLicenceCombo->insertItem( i18n("LGPL") );
|
||
|
mLicenceCombo->insertItem( i18n("BSD") );
|
||
|
topLayout->addWidget( mLicenceCombo, 5, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *languageLabel = new TQLabel( i18n("Language:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( languageLabel, 6, 0 );
|
||
15 years ago
|
mLanguageCombo = new TQComboBox( topPage );
|
||
15 years ago
|
topLayout->addWidget( mLanguageCombo, 6, 1 );
|
||
12 years ago
|
mLanguageCombo->insertStringList( TDEGlobal::locale()->languageList() );
|
||
15 years ago
|
|
||
15 years ago
|
TQLabel *previewLabel = new TQLabel( i18n("Preview URL:"), topPage );
|
||
15 years ago
|
topLayout->addWidget( previewLabel, 7, 0 );
|
||
|
mPreviewUrl = new KURLRequester( topPage );
|
||
|
topLayout->addWidget( mPreviewUrl, 7, 1 );
|
||
|
|
||
15 years ago
|
TQLabel *summaryLabel = new TQLabel( i18n("Summary:"), topPage );
|
||
15 years ago
|
topLayout->addMultiCellWidget( summaryLabel, 8, 8, 0, 1 );
|
||
|
mSummaryEdit = new KTextEdit( topPage );
|
||
|
topLayout->addMultiCellWidget( mSummaryEdit, 9, 9, 0, 1 );
|
||
|
|
||
|
KUser user;
|
||
|
mAuthorEdit->setText(user.fullName());
|
||
|
}
|
||
|
|
||
|
UploadDialog::~UploadDialog()
|
||
|
{
|
||
|
mEntryList.clear();
|
||
|
}
|
||
|
|
||
|
void UploadDialog::slotOk()
|
||
|
{
|
||
|
if ( mNameEdit->text().isEmpty() ) {
|
||
|
KMessageBox::error( this, i18n("Please put in a name.") );
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Entry *entry = new Entry;
|
||
|
|
||
|
mEntryList.append( entry );
|
||
|
|
||
|
entry->setName( mNameEdit->text() );
|
||
|
entry->setAuthor( mAuthorEdit->text() );
|
||
|
entry->setAuthorEmail( mEmailEdit->text() );
|
||
|
entry->setVersion( mVersionEdit->text() );
|
||
|
entry->setRelease( mReleaseSpin->value() );
|
||
|
entry->setLicence( mLicenceCombo->currentText() );
|
||
|
entry->setPreview( KURL( mPreviewUrl->url().section("/", -1) ), mLanguageCombo->currentText() );
|
||
|
entry->setSummary( mSummaryEdit->text(), mLanguageCombo->currentText() );
|
||
|
|
||
|
if ( mPayloadUrl.isValid() ) {
|
||
12 years ago
|
TDEConfig *conf = kapp->config();
|
||
10 years ago
|
conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
|
||
15 years ago
|
conf->writeEntry("name", mNameEdit->text());
|
||
|
conf->writeEntry("author", mAuthorEdit->text());
|
||
|
conf->writeEntry("email", mEmailEdit->text());
|
||
|
conf->writeEntry("version", mVersionEdit->text());
|
||
|
conf->writeEntry("release", mReleaseSpin->value());
|
||
|
conf->writeEntry("licence", mLicenceCombo->currentText());
|
||
|
conf->writeEntry("preview", mPreviewUrl->url());
|
||
|
conf->writeEntry("summary", mSummaryEdit->text());
|
||
|
conf->writeEntry("language", mLanguageCombo->currentText());
|
||
|
conf->sync();
|
||
|
}
|
||
|
|
||
|
mEngine->upload( entry );
|
||
|
|
||
|
accept();
|
||
|
}
|
||
|
|
||
15 years ago
|
void UploadDialog::setPreviewFile( const TQString &previewFile )
|
||
15 years ago
|
{
|
||
|
mPreviewUrl->setURL( previewFile );
|
||
|
}
|
||
|
|
||
15 years ago
|
void UploadDialog::setPayloadFile( const TQString &payloadFile )
|
||
15 years ago
|
{
|
||
|
mPayloadUrl = payloadFile;
|
||
|
|
||
12 years ago
|
TDEConfig *conf = kapp->config();
|
||
10 years ago
|
conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
|
||
15 years ago
|
TQString name = conf->readEntry("name");
|
||
|
TQString author = conf->readEntry("author");
|
||
|
TQString email = conf->readEntry("email");
|
||
|
TQString version = conf->readEntry("version");
|
||
|
TQString release = conf->readEntry("release");
|
||
|
TQString preview = conf->readEntry("preview");
|
||
|
TQString summary = conf->readEntry("summary");
|
||
|
TQString lang = conf->readEntry("language");
|
||
|
TQString licence = conf->readEntry("licence");
|
||
15 years ago
|
|
||
|
mNameEdit->clear();
|
||
|
mAuthorEdit->clear();
|
||
|
mEmailEdit->clear();
|
||
|
mVersionEdit->clear();
|
||
|
mReleaseSpin->setValue(1);
|
||
|
mPreviewUrl->clear();
|
||
|
mSummaryEdit->clear();
|
||
|
mLanguageCombo->setCurrentItem(0);
|
||
|
mLicenceCombo->setCurrentItem(0);
|
||
|
|
||
|
if(!name.isNull())
|
||
|
{
|
||
15 years ago
|
int prefill = KMessageBox::questionYesNo(this, i18n("Old upload information found, fill out fields?"),TQString::null,i18n("Fill Out"),i18n("Do Not Fill Out"));
|
||
15 years ago
|
if(prefill == KMessageBox::Yes)
|
||
|
{
|
||
|
mNameEdit->setText(name);
|
||
|
mAuthorEdit->setText(author);
|
||
|
mEmailEdit->setText(email);
|
||
|
mVersionEdit->setText(version);
|
||
|
mReleaseSpin->setValue(release.toInt());
|
||
|
mPreviewUrl->setURL(preview);
|
||
|
mSummaryEdit->setText(summary);
|
||
|
if(!lang.isEmpty()) mLanguageCombo->setCurrentText(lang);
|
||
|
if(!licence.isEmpty()) mLicenceCombo->setCurrentText(licence);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|