📄 packguibase.cpp
字号:
consistencyHbox->addWidget( passwordConsistencyLabel ); passwordGrid->addMultiCellLayout ( consistencyHbox, 2, 2, 0, 1 ); encryptHeaders = new QCheckBox( i18n( "Encrypt headers" ), advancedWidget, "encryptHeaders" ); passwordGrid->addMultiCellWidget ( encryptHeaders, 3, 3, 0, 1 ); QSpacerItem* spacer_psw = new QSpacerItem( 20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding ); passwordGrid->addItem( spacer_psw, 4, 0 ); hbox_5->addLayout( passwordGrid, 0, 2 ); hbox_7 = new QHBoxLayout; hbox_7->setSpacing( 6 ); hbox_7->setMargin( 0 ); TextLabel8 = new QLabel( i18n( "Command line switches:" ), advancedWidget, "TextLabel8" ); TextLabel8->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); hbox_7->addWidget( TextLabel8 ); commandLineSwitches = new KHistoryCombo( advancedWidget, "commandLineSwitches" ); commandLineSwitches->setMaxCount(25); // remember 25 items commandLineSwitches->setDuplicatesEnabled(false); krConfig->setGroup("Archives"); QStringList list = krConfig->readListEntry("Command Line Switches"); commandLineSwitches->setHistoryItems(list); hbox_7->addWidget( commandLineSwitches ); hbox_5->addMultiCellLayout( hbox_7, 1, 1, 0, 2 ); advancedWidget->hide(); checkConsistency(); grid->addWidget( advancedWidget, 4, 0 ); hbox_6 = new QHBoxLayout; hbox_6->setSpacing( 6 ); hbox_6->setMargin( 0 ); advancedButton = new QPushButton( this, "advancedButton" ); advancedButton->setText( i18n( "&Advanced" ) + " >>" ); hbox_6->addWidget( advancedButton ); QSpacerItem* spacer_2 = new QSpacerItem( 140, 20, QSizePolicy::Expanding, QSizePolicy::Fixed ); hbox_6->addItem( spacer_2 ); okButton = new QPushButton( this, "okButton" ); okButton->setText( i18n( "Ok" ) ); okButton->setDefault( true ); hbox_6->addWidget( okButton ); cancelButton = new QPushButton( this, "cancelButton" ); cancelButton->setText( i18n( "Cancel" ) ); hbox_6->addWidget( cancelButton ); grid->addLayout( hbox_6, 6, 0 ); // signals and slots connections connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( advancedButton, SIGNAL( clicked() ), this, SLOT( expand() ) ); connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( browseButton, SIGNAL( clicked() ), this, SLOT( browse() ) );}/* * Destroys the object and frees any allocated resources */PackGUIBase::~PackGUIBase(){ // no need to delete child widgets, Qt does it all for us}void PackGUIBase::browse(){ qWarning( "PackGUIBase::browse(): Not implemented yet!" );}void PackGUIBase::expand() { expanded = !expanded; advancedButton->setText( i18n( "&Advanced" ) + ( expanded ? " <<" : " >>" ) ); if( expanded ) advancedWidget->show(); else { advancedWidget->hide(); layout()->activate(); QSize minSize = minimumSize(); resize( width(), minSize.height() ); } show();}void PackGUIBase::checkConsistency() { if( password->text().isEmpty() && passwordAgain->text().isEmpty()) { passwordConsistencyLabel->setPaletteForegroundColor( KGlobalSettings::textColor() ); passwordConsistencyLabel->setText( i18n( "No password specified" ) ); } else if( password->text() == passwordAgain->text() ) { passwordConsistencyLabel->setPaletteForegroundColor( KGlobalSettings::textColor() ); passwordConsistencyLabel->setText( i18n( "The passwords are equal" ) ); } else { passwordConsistencyLabel->setPaletteForegroundColor( Qt::red ); passwordConsistencyLabel->setText( i18n( "The passwords are different" ) ); } QString packer = typeData->currentText(); bool passworded = false; if( packer == "7z" || packer == "rar" || packer == "zip" || packer == "arj" ) passworded = true; passwordConsistencyLabel->setEnabled( passworded ); password->setEnabled( passworded ); passwordAgain->setEnabled( passworded ); TextLabel4->setEnabled( passworded ); TextLabel6->setEnabled( passworded ); encryptHeaders->setEnabled( packer == "rar" ); multipleVolume->setEnabled( packer == "rar" || packer == "arj" ); bool volumeEnabled = multipleVolume->isEnabled() && multipleVolume->isChecked(); volumeSpinBox->setEnabled( volumeEnabled ); volumeUnitCombo->setEnabled( volumeEnabled ); TextLabel7->setEnabled( volumeEnabled ); /* TODO */ setCompressionLevel->setEnabled( packer == "rar" || packer == "arj" || packer == "zip" || packer == "7z" ); bool sliderEnabled = setCompressionLevel->isEnabled() && setCompressionLevel->isChecked(); compressionSlider->setEnabled( sliderEnabled ); minLabel->setEnabled( sliderEnabled ); maxLabel->setEnabled( sliderEnabled );}bool PackGUIBase::extraProperties( QMap<QString,QString> & inMap ) { inMap.clear(); if( password->isEnabled() && passwordAgain->isEnabled() ) { if( password->text() != passwordAgain->text() ) { KMessageBox::error( this, i18n( "Cannot pack! The passwords are different!" ) ); return false; } if( !password->text().isEmpty() ) { inMap[ "Password" ] = password->text(); if( encryptHeaders->isEnabled() && encryptHeaders->isChecked() ) inMap[ "EncryptHeaders" ] = "1"; } } if( multipleVolume->isEnabled() && multipleVolume->isChecked() ) { KIO::filesize_t size = volumeSpinBox->value(); switch( volumeUnitCombo->currentItem() ) { case 2: size *= 1000; case 1: size *= 1000; default: break; } if( size < 10000 ) { KMessageBox::error( this, i18n( "Invalid volume size!" ) ); return false; } QString sbuffer; sbuffer.sprintf("%llu",size); inMap[ "VolumeSize" ] = sbuffer; } if( setCompressionLevel->isEnabled() && setCompressionLevel->isChecked() ) { inMap[ "CompressionLevel" ] = QString("%1").arg( compressionSlider->value() ); } QString cmdArgs = commandLineSwitches->currentText().stripWhiteSpace(); if( !cmdArgs.isEmpty() ) { bool firstChar = true; QChar quote = '\0'; for( unsigned i=0; i < cmdArgs.length(); i++ ) { QChar ch( cmdArgs[ i ] ); if( ch.isSpace() ) continue; if( ch == quote ) { quote = '\0'; continue; } if( firstChar && ch != '-' ) { KMessageBox::error( this, i18n( "Invalid command line switch!\nSwitch must start with '-'!" ) ); return false; } firstChar = false; if( quote == '"' ) continue; if( quote == '\0' && ( ch == '\'' || ch == '"' ) ) quote = ch; if( ch == '\\' ) { if( i == cmdArgs.length() - 1 ) { KMessageBox::error( this, i18n( "Invalid command line switch!\nBackslash cannot be the last character" ) ); return false; } i++; } } if( quote != '\0' ) { KMessageBox::error( this, i18n( "Invalid command line switch!\nUnclosed quotation mark!" ) ); return false; } commandLineSwitches->addToHistory( cmdArgs ); QStringList list = commandLineSwitches->historyItems(); krConfig->setGroup("Archives"); krConfig->writeEntry("Command Line Switches", list); inMap[ "CommandLineSwitches" ] = cmdArgs; } return true;}#include "packguibase.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -