42 #define YUILogComponent "qt-pkg"
45 #include <QApplication>
48 #include <QPushButton>
52 #include "YQPkgDiskUsageWarningDialog.h"
53 #include "YQPkgDiskUsageList.h"
54 #include "QY2LayoutUtils.h"
59 #define SPACING 2 // between subwidgets
60 #define MARGIN 4 // around the widget
64 const QString & message,
66 const QString & acceptButtonLabel,
67 const QString & rejectButtonLabel )
71 setWindowTitle( _(
"Disk Space Warning" ) );
74 setSizeGripEnabled(
true );
78 QVBoxLayout * layout =
new QVBoxLayout();
79 Q_CHECK_PTR( layout );
80 layout->setSpacing( SPACING );
81 layout->setMargin ( MARGIN );
85 QHBoxLayout * hbox =
new QHBoxLayout();
87 layout->addLayout( hbox );
93 QLabel * iconLabel =
new QLabel(
this );
94 Q_CHECK_PTR( iconLabel );
95 hbox->addWidget(iconLabel);
97 iconLabel->setPixmap( QApplication::style().stylePixmap( QStyle::SP_MessageBoxWarning ) );
99 iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
103 QLabel * label =
new QLabel( message,
this);
104 Q_CHECK_PTR( label );
105 hbox->addWidget(label);
106 label->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
107 label->setTextFormat( Qt::RichText );
108 label->setWordWrap(
true );
114 Q_CHECK_PTR( duList );
115 layout->addWidget( duList );
120 hbox =
new QHBoxLayout();
122 hbox->setSpacing( SPACING );
123 hbox->setMargin ( MARGIN );
124 layout->addLayout( hbox );
131 QPushButton * button =
new QPushButton( acceptButtonLabel,
this );
132 Q_CHECK_PTR( button );
133 hbox->addWidget(button);
135 connect( button, SIGNAL( clicked() ),
136 this, SLOT ( accept() ) );
141 if ( ! rejectButtonLabel.isEmpty() )
145 button =
new QPushButton( rejectButtonLabel,
this );
146 Q_CHECK_PTR( button );
147 hbox->addWidget(button);
149 connect( button, SIGNAL( clicked() ),
150 this, SLOT ( reject() ) );
159 button->setDefault(
true );
165 int thresholdPercent,
166 const QString & acceptButtonLabel,
167 const QString & rejectButtonLabel )
174 YQUI::ui()->normalCursor();
177 return dialog.result() == QDialog::Accepted;
183 #include "YQPkgDiskUsageWarningDialog.moc"
YQPkgDiskUsageWarningDialog(QWidget *parent, const QString &message, int thresholdPercent, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
static bool diskUsageWarning(const QString &message, int thresholdPercent, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
List of disk usage of all attached partitions.