"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/customdialog.cpp" between
krename-4.0.9.tar.gz and krename-4.90.90.tar.gz

About: KRename is a batch file-renamer (KDE).

customdialog.cpp  (krename-4.0.9):customdialog.cpp  (krename-4.90.90)
skipping to change at line 22 skipping to change at line 22
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
#include "customdialog.h" #include "customdialog.h"
#include "krenamefile.h" #include "krenamefile.h"
CustomDialog::CustomDialog( const KRenameFile & file, QWidget* parent ) #include <KConfigGroup>
: KDialog( parent )
{ #include <QDialogButtonBox>
m_widget.setupUi( this->mainWidget() );
connect( m_widget.radioKRename, SIGNAL(clicked(bool)), this, SLOT(slotEnable CustomDialog::CustomDialog(const KRenameFile &file, QWidget *parent)
Controls())); : QDialog(parent)
connect( m_widget.radioInput, SIGNAL(clicked(bool)), this, SLOT(slotEnable {
Controls())); QWidget *mainWidget = new QWidget(this);
connect( m_widget.radioCustom, SIGNAL(clicked(bool)), this, SLOT(slotEnable QVBoxLayout *mainLayout = new QVBoxLayout;
Controls())); setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
m_widget.setupUi(mainWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QD
ialogButtonBox::Cancel);
connect(buttonBox, &QDialogButtonBox::accepted,
this, &CustomDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected,
this, &CustomDialog::reject);
mainLayout->addWidget(buttonBox);
connect(m_widget.radioKRename, &QRadioButton::clicked,
this, &CustomDialog::slotEnableControls);
connect(m_widget.radioInput, &QRadioButton::clicked,
this, &CustomDialog::slotEnableControls);
connect(m_widget.radioCustom, &QRadioButton::clicked,
this, &CustomDialog::slotEnableControls);
// Set default vallues // Set default vallues
m_widget.radioCustom->setChecked( true ); m_widget.radioCustom->setChecked(true);
m_widget.radioKRename->setChecked( false ); m_widget.radioKRename->setChecked(false);
m_widget.radioInput->setChecked( false ); m_widget.radioInput->setChecked(false);
QString srcFilename = file.srcFilename(); QString srcFilename = file.srcFilename();
if( !file.srcExtension().isEmpty() ) if (!file.srcExtension().isEmpty()) {
{ srcFilename += '.';
srcFilename += ".";
srcFilename += file.srcExtension(); srcFilename += file.srcExtension();
} }
QString krenameFilename = file.dstFilename(); QString krenameFilename = file.dstFilename();
if( !file.dstExtension().isEmpty() ) if (!file.dstExtension().isEmpty()) {
{ krenameFilename += '.';
krenameFilename += ".";
krenameFilename += file.dstExtension(); krenameFilename += file.dstExtension();
} }
if( !file.manualChanges().isNull() ) if (!file.manualChanges().isNull()) {
{ switch (file.manualChangeMode()) {
switch( file.manualChangeMode() ) case eManualChangeMode_Custom:
{ krenameFilename = file.manualChanges();
case eManualChangeMode_Custom: break;
krenameFilename = file.manualChanges(); case eManualChangeMode_Input:
break; m_widget.radioInput->setChecked(true);
case eManualChangeMode_Input: m_widget.radioKRename->setChecked(false);
m_widget.radioInput->setChecked( true ); m_widget.radioCustom->setChecked(false);
m_widget.radioKRename->setChecked( false ); srcFilename = file.manualChanges();
m_widget.radioCustom->setChecked( false ); break;
srcFilename = file.manualChanges(); case eManualChangeMode_None:
break; default:
case eManualChangeMode_None: break;
default:
break;
} }
} }
m_widget.labelPreview->setPixmap( file.icon() ); m_widget.labelPreview->setPixmap(file.icon());
m_widget.lineEditInput->setText( srcFilename ); m_widget.lineEditInput->setText(srcFilename);
m_widget.lineEditCustom->setText( krenameFilename ); m_widget.lineEditCustom->setText(krenameFilename);
slotEnableControls(); slotEnableControls();
KSharedConfigPtr config = KGlobal::config(); KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup group = config->group( QString("CustomDialogGroup") ); KConfigGroup group = config->group(QString("CustomDialogGroup"));
this->restoreDialogSize(group); restoreGeometry(group.readEntry<QByteArray>("Geometry", QByteArray()));
} }
CustomDialog::~CustomDialog() CustomDialog::~CustomDialog()
{ {
KSharedConfigPtr config = KGlobal::config(); KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup group = config->group( QString("CustomDialogGroup") ); KConfigGroup group = config->group(QString("CustomDialogGroup"));
this->saveDialogSize(group); group.writeEntry("Geometry", saveGeometry());
} }
void CustomDialog::slotEnableControls() void CustomDialog::slotEnableControls()
{ {
m_widget.lineEditCustom->setEnabled( m_widget.radioCustom->isChecked() ); m_widget.lineEditCustom->setEnabled(m_widget.radioCustom->isChecked());
m_widget.lineEditInput->setEnabled( m_widget.radioInput->isChecked() ); m_widget.lineEditInput->setEnabled(m_widget.radioInput->isChecked());
} }
bool CustomDialog::hasManualChanges() const bool CustomDialog::hasManualChanges() const
{ {
return !(m_widget.radioKRename->isChecked()); return !(m_widget.radioKRename->isChecked());
} }
const QString CustomDialog::manualChanges() const const QString CustomDialog::manualChanges() const
{ {
if( m_widget.radioCustom->isChecked() ) if (m_widget.radioCustom->isChecked()) {
return m_widget.lineEditCustom->text(); return m_widget.lineEditCustom->text();
else if( m_widget.radioInput->isChecked() ) } else if (m_widget.radioInput->isChecked()) {
return m_widget.lineEditInput->text(); return m_widget.lineEditInput->text();
else } else {
return QString::null; return QString();
}
} }
EManualChangeMode CustomDialog::manualChangeMode() const EManualChangeMode CustomDialog::manualChangeMode() const
{ {
if( m_widget.radioCustom->isChecked() ) if (m_widget.radioCustom->isChecked()) {
return eManualChangeMode_Custom; return eManualChangeMode_Custom;
else if( m_widget.radioInput->isChecked() ) } else if (m_widget.radioInput->isChecked()) {
return eManualChangeMode_Input; return eManualChangeMode_Input;
else } else {
return eManualChangeMode_None; return eManualChangeMode_None;
}
} }
#include "customdialog.moc"
 End of changes. 18 change blocks. 
53 lines changed or deleted 67 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)