author | drw <drw> | 2005-03-03 19:15:30 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-03 19:15:30 (UTC) |
commit | 9c55e475ed3170488dd37ce8f36fa909397997bb (patch) (unidiff) | |
tree | f1fad490bc0d56059f8c26cfdf9002a831158a7c /noncore/settings/packagemanager/installdlg.cpp | |
parent | adb8960dfcdb18b698f313fc7e7d40209c65b01a (diff) | |
download | opie-9c55e475ed3170488dd37ce8f36fa909397997bb.zip opie-9c55e475ed3170488dd37ce8f36fa909397997bb.tar.gz opie-9c55e475ed3170488dd37ce8f36fa909397997bb.tar.bz2 |
Scale icons appropriately
Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 7dea591..36851b0 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -45,116 +45,119 @@ _;:, .> :=|. This file is free software; you can | |||
45 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | 47 | ||
48 | #include <sys/vfs.h> | 48 | #include <sys/vfs.h> |
49 | 49 | ||
50 | #include "opackagemanager.h" | 50 | #include "opackagemanager.h" |
51 | 51 | ||
52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, | 52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, |
53 | OPackage::Command command1, const QStringList &packages1, | 53 | OPackage::Command command1, const QStringList &packages1, |
54 | OPackage::Command command2, const QStringList &packages2, | 54 | OPackage::Command command2, const QStringList &packages2, |
55 | OPackage::Command command3, const QStringList &packages3 ) | 55 | OPackage::Command command3, const QStringList &packages3 ) |
56 | : QWidget( 0l ) | 56 | : QWidget( 0l ) |
57 | , m_packman( pm ) | 57 | , m_packman( pm ) |
58 | , m_installFound( false ) | 58 | , m_installFound( false ) |
59 | , m_numCommands( 0 ) | 59 | , m_numCommands( 0 ) |
60 | , m_currCommand( 0 ) | 60 | , m_currCommand( 0 ) |
61 | , m_destItem( 0l ) | 61 | , m_destItem( 0l ) |
62 | { | 62 | { |
63 | // Save command/package list information | 63 | // Save command/package list information |
64 | if ( command1 != OPackage::NotDefined ) | 64 | if ( command1 != OPackage::NotDefined ) |
65 | { | 65 | { |
66 | m_command[ m_numCommands ] = command1; | 66 | m_command[ m_numCommands ] = command1; |
67 | m_packages[ m_numCommands ] = packages1; | 67 | m_packages[ m_numCommands ] = packages1; |
68 | ++m_numCommands; | 68 | ++m_numCommands; |
69 | 69 | ||
70 | if ( command1 == OPackage::Install ) | 70 | if ( command1 == OPackage::Install ) |
71 | m_installFound = true; | 71 | m_installFound = true; |
72 | } | 72 | } |
73 | if ( command2 != OPackage::NotDefined ) | 73 | if ( command2 != OPackage::NotDefined ) |
74 | { | 74 | { |
75 | m_command[ m_numCommands ] = command2; | 75 | m_command[ m_numCommands ] = command2; |
76 | m_packages[ m_numCommands ] = packages2; | 76 | m_packages[ m_numCommands ] = packages2; |
77 | ++m_numCommands; | 77 | ++m_numCommands; |
78 | 78 | ||
79 | if ( command2 == OPackage::Install ) | 79 | if ( command2 == OPackage::Install ) |
80 | m_installFound = true; | 80 | m_installFound = true; |
81 | } | 81 | } |
82 | if ( command3 != OPackage::NotDefined ) | 82 | if ( command3 != OPackage::NotDefined ) |
83 | { | 83 | { |
84 | m_command[ m_numCommands ] = command3; | 84 | m_command[ m_numCommands ] = command3; |
85 | m_packages[ m_numCommands ] = packages3; | 85 | m_packages[ m_numCommands ] = packages3; |
86 | ++m_numCommands; | 86 | ++m_numCommands; |
87 | 87 | ||
88 | if ( command3 == OPackage::Install ) | 88 | if ( command3 == OPackage::Install ) |
89 | m_installFound = true; | 89 | m_installFound = true; |
90 | } | 90 | } |
91 | 91 | ||
92 | // Initialize UI | 92 | // Initialize UI |
93 | if ( parent ) | 93 | if ( parent ) |
94 | parent->setCaption( caption ); | 94 | parent->setCaption( caption ); |
95 | 95 | ||
96 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 96 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
97 | 97 | ||
98 | if ( m_installFound ) | 98 | if ( m_installFound ) |
99 | { | 99 | { |
100 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 100 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
101 | layout->addWidget( label, 0, 0 ); | 101 | layout->addWidget( label, 0, 0 ); |
102 | m_destination = new QComboBox( this ); | 102 | m_destination = new QComboBox( this ); |
103 | m_destination->insertStringList( m_packman->destinations() ); | 103 | m_destination->insertStringList( m_packman->destinations() ); |
104 | layout->addWidget( m_destination, 0, 1 ); | 104 | layout->addWidget( m_destination, 0, 1 ); |
105 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 105 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
106 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 106 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
107 | 107 | ||
108 | label = new QLabel( tr( "Space Avail" ), this ); | 108 | label = new QLabel( tr( "Space Avail" ), this ); |
109 | layout->addWidget( label, 1, 0 ); | 109 | layout->addWidget( label, 1, 0 ); |
110 | m_availSpace = new QLabel( this ); | 110 | m_availSpace = new QLabel( this ); |
111 | layout->addWidget( m_availSpace, 1, 1 ); | 111 | layout->addWidget( m_availSpace, 1, 1 ); |
112 | 112 | ||
113 | // TODO - select correct destination | 113 | // TODO - select correct destination |
114 | slotDisplayAvailSpace( m_destination->currentText() ); | 114 | slotDisplayAvailSpace( m_destination->currentText() ); |
115 | } | 115 | } |
116 | else | 116 | else |
117 | { | 117 | { |
118 | m_destination = 0l; | 118 | m_destination = 0l; |
119 | m_availSpace = 0l; | 119 | m_availSpace = 0l; |
120 | } | 120 | } |
121 | 121 | ||
122 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 122 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
123 | groupBox->layout()->setSpacing( 0 ); | 123 | groupBox->layout()->setSpacing( 0 ); |
124 | groupBox->layout()->setMargin( 4 ); | 124 | groupBox->layout()->setMargin( 4 ); |
125 | 125 | ||
126 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 126 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
127 | m_output = new QMultiLineEdit( groupBox ); | 127 | m_output = new QMultiLineEdit( groupBox ); |
128 | m_output->setReadOnly( true ); | 128 | m_output->setReadOnly( true ); |
129 | groupBoxLayout->addWidget( m_output ); | 129 | groupBoxLayout->addWidget( m_output ); |
130 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 130 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
131 | 131 | ||
132 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); | 132 | QPixmap pic; |
133 | pic.convertFromImage( Resource::loadImage( "packagemanager/apply" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
134 | m_btnStart = new QPushButton( pic, tr( "Start" ), this ); | ||
133 | layout->addWidget( m_btnStart, 3, 0 ); | 135 | layout->addWidget( m_btnStart, 3, 0 ); |
134 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 136 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
135 | 137 | ||
136 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 138 | pic.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
139 | m_btnOptions = new QPushButton( pic, tr( "Options" ), this ); | ||
137 | layout->addWidget( m_btnOptions, 3, 1 ); | 140 | layout->addWidget( m_btnOptions, 3, 1 ); |
138 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 141 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
139 | 142 | ||
140 | // Display packages being acted upon in output widget | 143 | // Display packages being acted upon in output widget |
141 | for( int i = 0; i < m_numCommands; i++ ) | 144 | for( int i = 0; i < m_numCommands; i++ ) |
142 | { | 145 | { |
143 | if ( !m_packages[ i ].isEmpty() ) | 146 | if ( !m_packages[ i ].isEmpty() ) |
144 | { | 147 | { |
145 | QString lineStr = tr( "Packages to " ); | 148 | QString lineStr = tr( "Packages to " ); |
146 | 149 | ||
147 | switch( m_command[ i ] ) | 150 | switch( m_command[ i ] ) |
148 | { | 151 | { |
149 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 152 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
150 | break; | 153 | break; |
151 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 154 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
152 | break; | 155 | break; |
153 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 156 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
154 | break; | 157 | break; |
155 | case OPackage::Download : lineStr.append( tr( "download" ) ); | 158 | case OPackage::Download : lineStr.append( tr( "download" ) ); |
156 | break; | 159 | break; |
157 | default : | 160 | default : |
158 | break; | 161 | break; |
159 | }; | 162 | }; |
160 | lineStr.append( ":\n" ); | 163 | lineStr.append( ":\n" ); |
@@ -196,116 +199,123 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | |||
196 | long div = 1024 / fs.f_bsize; | 199 | long div = 1024 / fs.f_bsize; |
197 | 200 | ||
198 | if ( !mult ) mult = 1; | 201 | if ( !mult ) mult = 1; |
199 | if ( !div ) div = 1; | 202 | if ( !div ) div = 1; |
200 | long avail = fs.f_bavail * mult / div; | 203 | long avail = fs.f_bavail * mult / div; |
201 | 204 | ||
202 | space = tr( "%1 Kb" ).arg( avail ); | 205 | space = tr( "%1 Kb" ).arg( avail ); |
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
206 | // Display available space | 209 | // Display available space |
207 | m_availSpace->setText( space ); | 210 | m_availSpace->setText( space ); |
208 | } | 211 | } |
209 | 212 | ||
210 | void InstallDlg::slotBtnStart() | 213 | void InstallDlg::slotBtnStart() |
211 | { | 214 | { |
212 | QString btnText = m_btnStart->text(); | 215 | QString btnText = m_btnStart->text(); |
213 | if ( btnText == tr( "Abort" ) ) | 216 | if ( btnText == tr( "Abort" ) ) |
214 | { | 217 | { |
215 | // Prevent unexecuted commands from executing | 218 | // Prevent unexecuted commands from executing |
216 | m_currCommand = 999; | 219 | m_currCommand = 999; |
217 | 220 | ||
218 | // Allow user to close dialog | 221 | // Allow user to close dialog |
219 | m_btnStart->setText( tr( "Close" ) ); | 222 | m_btnStart->setText( tr( "Close" ) ); |
220 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 223 | QPixmap pic; |
224 | pic.convertFromImage( Resource::loadImage( "enter" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
225 | m_btnStart->setIconSet( pic ); | ||
221 | return; | 226 | return; |
222 | } | 227 | } |
223 | else if ( btnText == tr( "Close" ) ) | 228 | else if ( btnText == tr( "Close" ) ) |
224 | { | 229 | { |
225 | // TODO - force reload of package data | 230 | // TODO - force reload of package data |
226 | emit closeInstallDlg(); | 231 | emit closeInstallDlg(); |
227 | return; | 232 | return; |
228 | } | 233 | } |
229 | 234 | ||
230 | // Start was clicked, start executing | 235 | // Start was clicked, start executing |
231 | QString dest; | 236 | QString dest; |
232 | if ( m_installFound ) | 237 | if ( m_installFound ) |
233 | { | 238 | { |
234 | dest = m_destination->currentText(); | 239 | dest = m_destination->currentText(); |
235 | m_destination->setEnabled( false ); | 240 | m_destination->setEnabled( false ); |
236 | } | 241 | } |
237 | 242 | ||
238 | m_btnOptions->setEnabled( false ); | 243 | m_btnOptions->setEnabled( false ); |
239 | if ( m_numCommands > 1 ) | 244 | if ( m_numCommands > 1 ) |
240 | { | 245 | { |
241 | m_btnStart->setText( tr( "Abort" ) ); | 246 | m_btnStart->setText( tr( "Abort" ) ); |
242 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 247 | QPixmap pic; |
248 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
249 | m_btnStart->setIconSet( pic ); | ||
243 | } | 250 | } |
244 | else | 251 | else |
245 | { | 252 | { |
246 | m_btnStart->setEnabled( false ); | 253 | m_btnStart->setEnabled( false ); |
247 | } | 254 | } |
248 | 255 | ||
249 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 256 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
250 | { | 257 | { |
251 | // Execute next command | 258 | // Execute next command |
252 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 259 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
253 | this, SLOT(slotOutput(const QString &)), true ); | 260 | this, SLOT(slotOutput(const QString &)), true ); |
254 | } | 261 | } |
255 | 262 | ||
256 | // All commands executed, allow user to close dialog | 263 | // All commands executed, allow user to close dialog |
257 | m_btnStart->setEnabled( true ); | 264 | m_btnStart->setEnabled( true ); |
258 | m_btnStart->setText( tr( "Close" ) ); | 265 | m_btnStart->setText( tr( "Close" ) ); |
259 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 266 | QPixmap pic; |
267 | pic.convertFromImage( Resource::loadImage( "enter" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
268 | m_btnStart->setIconSet( pic ); | ||
260 | 269 | ||
261 | m_btnOptions->setEnabled( true ); | 270 | m_btnOptions->setEnabled( true ); |
262 | m_btnOptions->setText( tr( "Save output" ) ); | 271 | m_btnOptions->setText( tr( "Save output" ) ); |
263 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 272 | pic.convertFromImage( Resource::loadImage( "save" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
273 | m_btnOptions->setIconSet( pic ); | ||
264 | } | 274 | } |
265 | 275 | ||
266 | void InstallDlg::slotBtnOptions() | 276 | void InstallDlg::slotBtnOptions() |
267 | { | 277 | { |
268 | QString btnText = m_btnOptions->text(); | 278 | QString btnText = m_btnOptions->text(); |
269 | if ( btnText == tr( "Options" ) ) | 279 | if ( btnText == tr( "Options" ) ) |
270 | { | 280 | { |
271 | // Display configuration dialog (only options tab is enabled) | 281 | // Display configuration dialog (only options tab is enabled) |
272 | m_packman->configureDlg( true ); | 282 | m_packman->configureDlg( true ); |
273 | return; | 283 | return; |
274 | } | 284 | } |
275 | 285 | ||
276 | // Save output was clicked | 286 | // Save output was clicked |
277 | QMap<QString, QStringList> map; | 287 | QMap<QString, QStringList> map; |
278 | map.insert( tr( "All" ), QStringList() ); | 288 | map.insert( tr( "All" ), QStringList() ); |
279 | QStringList text; | 289 | QStringList text; |
280 | text << "text/*"; | 290 | text << "text/*"; |
281 | map.insert(tr( "Text" ), text ); | 291 | map.insert(tr( "Text" ), text ); |
282 | text << "*"; | 292 | text << "*"; |
283 | map.insert( tr( "All" ), text ); | 293 | map.insert( tr( "All" ), text ); |
284 | 294 | ||
285 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 295 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
286 | if( !filename.isEmpty() ) | 296 | if( !filename.isEmpty() ) |
287 | { | 297 | { |
288 | QString currentFileName = QFileInfo( filename ).fileName(); | 298 | QString currentFileName = QFileInfo( filename ).fileName(); |
289 | DocLnk doc; | 299 | DocLnk doc; |
290 | doc.setType( "text/plain" ); | 300 | doc.setType( "text/plain" ); |
291 | doc.setFile( filename ); | 301 | doc.setFile( filename ); |
292 | doc.setName( currentFileName ); | 302 | doc.setName( currentFileName ); |
293 | FileManager fm; | 303 | FileManager fm; |
294 | fm.saveFile( doc, m_output->text() ); | 304 | fm.saveFile( doc, m_output->text() ); |
295 | } | 305 | } |
296 | } | 306 | } |
297 | 307 | ||
298 | void InstallDlg::slotOutput( const QString &msg ) | 308 | void InstallDlg::slotOutput( const QString &msg ) |
299 | { | 309 | { |
300 | // Allow processing of other events | 310 | // Allow processing of other events |
301 | qApp->processEvents(); | 311 | qApp->processEvents(); |
302 | 312 | ||
303 | QString lineStr = msg; | 313 | QString lineStr = msg; |
304 | if ( lineStr[lineStr.length()-1] == '\n' ) | 314 | if ( lineStr[lineStr.length()-1] == '\n' ) |
305 | lineStr.truncate( lineStr.length() - 1 ); | 315 | lineStr.truncate( lineStr.length() - 1 ); |
306 | m_output->append( lineStr ); | 316 | m_output->append( lineStr ); |
307 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 317 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
308 | 318 | ||
309 | // Update available space | 319 | // Update available space |
310 | slotDisplayAvailSpace( QString::null ); | 320 | slotDisplayAvailSpace( QString::null ); |
311 | } | 321 | } |