1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPackageSelectorBase.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
21 #include <qmessagebox.h>
25 #define y2log_component "qt-pkg"
26 #include <ycp/y2log.h>
29 #include "QY2LayoutUtils.h"
31 #include "YQPackageSelectorBase.h"
32 #include "YQPkgChangesDialog.h"
33 #include "YQPkgConflictDialog.h"
34 #include "YQPkgDiskUsageList.h"
35 #include "YQPkgDiskUsageWarningDialog.h"
36 #include "YQPkgTextDialog.h"
37 #include "YQPkgObjList.h"
41 #include "YQApplication.h"
51 YQPackageSelectorBase::YQPackageSelectorBase( YWidget * parent,
53 : Q3VBox( (QWidget *) parent->widgetRep() )
54 , YPackageSelector( parent, modeFlags )
58 _showChangesDialog = false;
59 _pkgConflictDialog = 0;
61 _pkgConflictDialog = 0;
63 YQUI::setTextdomain( "packages-qt" );
64 setFont( YQUI::yqApp()->currentFont() );
65 YQUI::ui()->blockWmClose(); // Automatically undone after UI::RunPkgSelection()
67 _pkgConflictDialog = new YQPkgConflictDialog( this );
68 Q_CHECK_PTR( _pkgConflictDialog );
70 QString label = _( "Reset &Ignored Dependency Conflicts" );
71 _actionResetIgnoredDependencyProblems = new Q3Action( label, // text
73 (QKeySequence) 0, // accel
75 Q_CHECK_PTR( _actionResetIgnoredDependencyProblems );
77 connect( _actionResetIgnoredDependencyProblems, SIGNAL( activated() ),
78 this, SLOT ( resetIgnoredDependencyProblems() ) );
80 zyppPool().saveState<zypp::Package >();
81 zyppPool().saveState<zypp::Pattern >();
82 zyppPool().saveState<zypp::Selection>();
83 zyppPool().saveState<zypp::Language >();
84 zyppPool().saveState<zypp::Patch >();
88 // Handle WM_CLOSE like "Cancel"
91 connect( YQUI::ui(), SIGNAL( wmClose() ),
92 this, SLOT ( reject() ) );
94 y2milestone( "PackageSelectorBase init done" );
98 YQPackageSelectorBase::~YQPackageSelectorBase()
100 y2milestone( "Destroying PackageSelector" );
105 YQPackageSelectorBase::resolveDependencies()
107 if ( ! _pkgConflictDialog )
109 y2error( "No package conflict dialog existing" );
110 return QDialog::Accepted;
114 YQUI::ui()->busyCursor();
115 emit resolvingStarted();
117 int result = _pkgConflictDialog->solveAndShowConflicts();
119 emit resolvingFinished();
120 YQUI::ui()->normalCursor();
127 YQPackageSelectorBase::verifySystem()
129 if ( ! _pkgConflictDialog )
131 y2error( "No package conflict dialog existing" );
132 return QDialog::Accepted;
136 YQUI::ui()->busyCursor();
137 int result = _pkgConflictDialog->verifySystem();
138 YQUI::ui()->normalCursor();
140 if ( result == QDialog::Accepted )
142 QMessageBox::information( this, "",
143 _( "System dependencies verify OK." ),
152 YQPackageSelectorBase::checkDiskUsage()
154 if ( ! _diskUsageList )
156 return QDialog::Accepted;
159 if ( ! _diskUsageList->overflowWarning.inRange() )
160 return QDialog::Accepted;
163 // Translators: RichText ( HTML-like ) format
164 "<p><b>" + _( "Error: Out of disk space!" ) + "</b></p>"
166 "You can choose to install anyway if you know what you are doing, "
167 "but you risk getting a corrupted system that requires manual repairs. "
168 "If you are not absolutely sure how to handle such a case, "
169 "press <b>Cancel</b> now and deselect some packages."
172 return YQPkgDiskUsageWarningDialog::diskUsageWarning( msg,
173 100, _( "C&ontinue Anyway" ), _( "&Cancel" ) );
180 YQPackageSelectorBase::showAutoPkgList()
182 resolveDependencies();
184 // Show which packages are installed/deleted automatically
188 + _( "Automatic Changes" )
190 // Detailed explanation ( automatic word wrap! )
192 + _( "In addition to your manual selections, the following packages"
193 " have been changed to resolve dependencies:" )
196 YQPkgChangesDialog::showChangesDialog( msg,
198 QString::null, // rejectButtonLabel
199 true ); // showIfEmpty
205 YQPackageSelectorBase::reject()
208 zyppPool().diffState<zypp::Package >() ||
209 zyppPool().diffState<zypp::Pattern >() ||
210 zyppPool().diffState<zypp::Selection>() ||
211 zyppPool().diffState<zypp::Language >() ||
212 zyppPool().diffState<zypp::Patch >();
216 if ( zyppPool().diffState<zypp::Package>() )
217 y2milestone( "diffState() reports changed packages" );
219 if ( zyppPool().diffState<zypp::Pattern>() )
220 y2milestone( "diffState() reports changed patterns" );
222 if ( zyppPool().diffState<zypp::Selection>() )
223 y2milestone( "diffState() reports changed selections" );
225 if ( zyppPool().diffState<zypp::Language>() )
226 y2milestone( "diffState() reports changed languages" );
228 if ( zyppPool().diffState<zypp::Patch>() )
229 y2milestone( "diffState() reports changed patches" );
233 ( QMessageBox::warning( this, "",
234 _( "Abandon all changes?" ),
235 _( "&OK" ), _( "&Cancel" ), "",
236 1, // defaultButtonNumber (from 0)
237 1 ) // escapeButtonNumber
238 == 0 ) // Proceed upon button #0 ( OK )
241 zyppPool().restoreState<zypp::Package >();
242 zyppPool().restoreState<zypp::Pattern >();
243 zyppPool().restoreState<zypp::Selection>();
244 zyppPool().restoreState<zypp::Language >();
245 zyppPool().restoreState<zypp::Patch >();
247 y2milestone( "Closing PackageSelector with \"Cancel\"" );
248 YQUI::ui()->sendEvent( new YCancelEvent() );
254 YQPackageSelectorBase::accept()
256 bool confirmedAllLicenses;
260 // Force final dependency resolving
261 if ( resolveDependencies() == QDialog::Rejected )
264 confirmedAllLicenses = showPendingLicenseAgreements();
266 } while ( ! confirmedAllLicenses ); // Some packages will be set to S_TABOO - need another solver run
268 if ( _showChangesDialog )
270 // Show which packages are installed/deleted automatically
274 + _( "Automatic Changes" )
276 // Detailed explanation ( automatic word wrap! )
278 + _( "In addition to your manual selections, the following packages"
279 " have been changed to resolve dependencies:" )
282 if ( YQPkgChangesDialog::showChangesDialog( msg, _( "C&ontinue" ), _( "&Cancel" ) )
283 == QDialog::Rejected )
288 if ( checkDiskUsage() == QDialog::Rejected )
291 y2milestone( "Closing PackageSelector with \"Accept\"" );
292 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "accept" ) ) );
297 YQPackageSelectorBase::showPendingLicenseAgreements()
299 y2milestone( "Showing all pending license agreements" );
301 bool allConfirmed = true;
303 if ( onlineUpdateMode() )
304 allConfirmed = showPendingLicenseAgreements( zyppPatchesBegin(), zyppPatchesEnd() );
306 allConfirmed = showPendingLicenseAgreements( zyppPkgBegin(), zyppPkgEnd() ) && allConfirmed;
313 YQPackageSelectorBase::showPendingLicenseAgreements( ZyppPoolIterator begin, ZyppPoolIterator end )
315 bool allConfirmed = true;
317 for ( ZyppPoolIterator it = begin; it != end; ++it )
321 switch ( sel->status() )
328 if ( sel->candidateObj() )
330 string licenseText = sel->candidateObj()->licenseToConfirm();
332 if ( ! licenseText.empty() )
334 y2milestone( "Resolvable %s has a license agreement", sel->name().c_str() );
336 if( ! sel->hasLicenceConfirmed() )
338 y2debug( "Showing license agreement for resolvable %s", sel->name().c_str() );
339 allConfirmed = YQPkgObjListItem::showLicenseAgreement( sel ) && allConfirmed;
343 y2milestone( "Resolvable %s's license is already confirmed", sel->name().c_str() );
359 YQPackageSelectorBase::notImplemented()
361 QMessageBox::information( this, "",
362 _( "Not implemented yet. Sorry." ),
368 YQPackageSelectorBase::resetIgnoredDependencyProblems()
370 YQPkgConflictDialog::resetIgnoredDependencyProblems();
375 YQPackageSelectorBase::keyPressEvent( QKeyEvent * event )
379 unsigned special_combo = ( Qt::ControlButton | Qt::ShiftButton | Qt::AltButton );
381 if ( ( event->state() & special_combo ) == special_combo )
383 if ( event->key() == Qt::Key_A )
390 else if ( event->key() == Qt::Key_F5 ) // No matter if Ctrl/Alt/Shift pressed
392 YQUI::ui()->easterEgg();
397 QWidget::keyPressEvent( event );
401 int YQPackageSelectorBase::preferredWidth()
403 return max( 640, sizeHint().width() );
407 int YQPackageSelectorBase::preferredHeight()
409 return max( 480, sizeHint().height() );
414 YQPackageSelectorBase::setSize( int newWidth, int newHeight )
416 resize( newWidth, newHeight );
421 YQPackageSelectorBase::setEnabling( bool enabled )
423 QWidget::setEnabled( enabled );
428 YQPackageSelectorBase::setKeyboardFocus()
436 #include "YQPackageSelectorBase.moc"