33 #include <config-kleopatra.h>
48 #include <kleo/stl_util.h>
49 #include "libkleo/ui/filenamerequester.h"
58 #include <QAbstractButton>
62 #include <boost/bind.hpp>
68 using namespace Kleo::Crypto;
69 using namespace Kleo::Crypto::Gui;
70 using namespace boost;
74 class HLine :
public QFrame {
77 explicit HLine(
QWidget * p=0, Qt::WindowFlags f=0 )
80 setFrameStyle( QFrame::HLine|QFrame::Sunken );
87 explicit OperationsWidget(
QWidget * p=0 );
90 void setOutputDirectory(
const QString &
dir ) {
91 m_ui.outputDirectoryFNR.setFileName( dir );
94 QString outputDirectory()
const {
95 return m_ui.outputDirectoryFNR.fileName();
98 bool useOutputDirectory()
const {
99 return m_ui.useOutputDirectoryCB.isChecked();
102 void ensureIndexAvailable(
unsigned int idx );
105 return m_widgets.at( idx );
108 bool isComplete()
const {
return true; }
110 std::vector<DecryptVerifyOperationWidget*> m_widgets;
113 QCheckBox useOutputDirectoryCB;
114 QLabel outputDirectoryLB;
115 FileNameRequester outputDirectoryFNR;
120 explicit UI( OperationsWidget *
q );
125 class DecryptVerifyFilesWizard::Private {
126 friend class ::Kleo::Crypto::Gui::DecryptVerifyFilesWizard;
132 void ensureIndexAvailable(
unsigned int idx ) {
133 operationsPage.ensureIndexAvailable( idx );
137 OperationsWidget operationsPage;
143 :
Wizard( p, f ),
d( new Private( this ) )
151 d->operationsPage.setOutputDirectory( dir );
155 return d->operationsPage.outputDirectory();
159 return d->operationsPage.useOutputDirectory();
163 d->ensureIndexAvailable( idx );
164 return d->operationsPage.widget( idx );
167 void DecryptVerifyFilesWizard::onNext(
int id )
177 d->resultPage.setTaskCollection( coll );
189 std::vector<int> order;
192 q->setPageOrder( order );
193 operationsPage.setCommitPage(
true );
196 DecryptVerifyFilesWizard::Private::~Private() {}
204 OperationsWidget::OperationsWidget(
QWidget * p )
207 setTitle( i18n(
"<b>Choose operations to be performed</b>") );
208 setSubTitle( i18n(
"Here you can check and, if needed, override "
209 "the operations Kleopatra detected for the input given.") );
210 setCommitPage(
true );
211 setCustomNextButton( KGuiItem( i18n(
"&Decrypt/Verify" ) ) );
214 OperationsWidget::~OperationsWidget() {}
216 OperationsWidget::UI::UI( OperationsWidget *
q )
217 : useOutputDirectoryCB( i18n(
"Create all output files in a single folder" ), q ),
218 outputDirectoryLB( i18n(
"&Output folder:"), q ),
219 outputDirectoryFNR( q ),
232 outputDirectoryFNR.setFilter( QDir::Dirs );
234 useOutputDirectoryCB.setChecked(
true );
235 connect( &useOutputDirectoryCB, SIGNAL(toggled(
bool)), &outputDirectoryLB, SLOT(setEnabled(
bool)) );
236 connect( &useOutputDirectoryCB, SIGNAL(toggled(
bool)), &outputDirectoryFNR, SLOT(setEnabled(
bool)) );
238 assert( qobject_cast<QBoxLayout*>(scrollArea.widget()->layout()) );
239 static_cast<QBoxLayout*
>(scrollArea.widget()->layout())->addStretch( 1 );
240 outputDirectoryLB.setBuddy( &outputDirectoryFNR );
244 vlay.addWidget( &scrollArea, 1 );
245 vlay.addWidget( &useOutputDirectoryCB );
246 vlay.addLayout( &hlay );
247 hlay.addWidget( &outputDirectoryLB );
248 hlay.addWidget( &outputDirectoryFNR );
251 void OperationsWidget::ensureIndexAvailable(
unsigned int idx ) {
253 if ( idx < m_widgets.size() )
256 assert( m_ui.scrollArea.widget() );
257 assert( qobject_cast<QBoxLayout*>( m_ui.scrollArea.widget()->layout() ) );
258 QBoxLayout & blay = *
static_cast<QBoxLayout*
>( m_ui.scrollArea.widget()->layout() );
260 for (
unsigned int i = m_widgets.size() ; i < idx+1 ; ++i ) {
262 blay.insertWidget( blay.count()-1,
new HLine( m_ui.scrollArea.widget() ) );
264 blay.insertWidget( blay.count()-1, w );
266 m_widgets.push_back( w );
270 #include "decryptverifyfileswizard.moc"
271 #include "moc_decryptverifyfileswizard.cpp"
void setOutputDirectory(const QString &dir)
void linkActivated(const QString &link)
virtual void onNext(int currentId)
~DecryptVerifyFilesWizard()
DecryptVerifyOperationWidget * operationWidget(unsigned int idx)
void setTaskCollection(const boost::shared_ptr< TaskCollection > &coll)
bool useOutputDirectory() const
#define kleo_assert(cond)
static QString dir(const QString &id)
DecryptVerifyFilesWizard(QWidget *parent=0, Qt::WindowFlags f=0)
QString outputDirectory() const