Diffstat (limited to 'noncore/settings/packagemanager/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 4611404..486561d 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -19,40 +19,43 @@ | |||
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qdir.h> | ||
31 | #include <qlayout.h> | 32 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
34 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
35 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
36 | #include <qtimer.h> | 37 | #include <qtimer.h> |
37 | #include <qtoolbar.h> | 38 | #include <qtoolbar.h> |
38 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
39 | 40 | ||
41 | #include <qpe/qcopenvelope_qws.h> | ||
40 | #include <qpe/qpeapplication.h> | 42 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
42 | 44 | ||
43 | #include "mainwindow.h" | 45 | #include "mainwindow.h" |
44 | #include "installdlg.h" | 46 | #include "installdlg.h" |
45 | #include "filterdlg.h" | 47 | #include "filterdlg.h" |
46 | #include "promptdlg.h" | 48 | #include "promptdlg.h" |
49 | #include "entrydlg.h" | ||
47 | 50 | ||
48 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) | 51 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) |
49 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
50 | , m_config( "packman" ) | 53 | , m_config( "packman" ) |
51 | , m_packman( &m_config, this ) | 54 | , m_packman( &m_config, this ) |
52 | , m_menuBar( this ) | 55 | , m_menuBar( this ) |
53 | , m_toolBar( this ) | 56 | , m_toolBar( this ) |
54 | , m_findBar( this ) | 57 | , m_findBar( this ) |
55 | , m_widgetStack( this ) | 58 | , m_widgetStack( this ) |
56 | , m_packageList( this ) | 59 | , m_packageList( this ) |
57 | , m_statusWidget( this ) | 60 | , m_statusWidget( this ) |
58 | , m_statusText( &m_statusWidget ) | 61 | , m_statusText( &m_statusWidget ) |
@@ -153,33 +156,31 @@ void MainWindow::initUI() | |||
153 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 156 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
154 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 157 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
155 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 158 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
156 | a->addTo( popup ); | 159 | a->addTo( popup ); |
157 | a->addTo( &m_toolBar ); | 160 | a->addTo( &m_toolBar ); |
158 | 161 | ||
159 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 162 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
160 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 163 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
161 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 164 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
162 | actionUpgrade->addTo( popup ); | 165 | actionUpgrade->addTo( popup ); |
163 | actionUpgrade->addTo( &m_toolBar ); | 166 | actionUpgrade->addTo( &m_toolBar ); |
164 | 167 | ||
165 | /* | ||
166 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 168 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
167 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 169 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
168 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 170 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
169 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 171 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
170 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 172 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
171 | actionDownload->addTo( popup ); | 173 | actionDownload->addTo( popup ); |
172 | actionDownload->addTo( &m_toolBar ); | 174 | actionDownload->addTo( &m_toolBar ); |
173 | */ | ||
174 | 175 | ||
175 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 176 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
176 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 177 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
177 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 178 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
178 | a->addTo( popup ); | 179 | a->addTo( popup ); |
179 | a->addTo( &m_toolBar ); | 180 | a->addTo( &m_toolBar ); |
180 | 181 | ||
181 | popup->insertSeparator(); | 182 | popup->insertSeparator(); |
182 | 183 | ||
183 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
184 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 185 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
185 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 186 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
@@ -361,75 +362,71 @@ void MainWindow::slotUpdate() | |||
361 | void MainWindow::slotUpgrade() | 362 | void MainWindow::slotUpgrade() |
362 | { | 363 | { |
363 | // Create package manager output widget | 364 | // Create package manager output widget |
364 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, | 365 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, |
365 | OPackage::Upgrade ); | 366 | OPackage::Upgrade ); |
366 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); | 367 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); |
367 | 368 | ||
368 | // Display widget | 369 | // Display widget |
369 | m_widgetStack.addWidget( dlg, 3 ); | 370 | m_widgetStack.addWidget( dlg, 3 ); |
370 | m_widgetStack.raiseWidget( dlg ); | 371 | m_widgetStack.raiseWidget( dlg ); |
371 | } | 372 | } |
372 | 373 | ||
373 | /* | ||
374 | void MainWindow::slotDownload() | 374 | void MainWindow::slotDownload() |
375 | { | 375 | { |
376 | // Retrieve list of packages selected for download (if any) | 376 | // Retrieve list of packages selected for download (if any) |
377 | QStringList *workingPackages = new QStringList(); | 377 | QStringList *workingPackages = new QStringList(); |
378 | 378 | ||
379 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 379 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
380 | item != 0 ; | 380 | item != 0 ; |
381 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 381 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
382 | { | 382 | { |
383 | if ( item->isOn() ) | 383 | if ( item->isOn() ) |
384 | workingPackages->append( item->text() ); | 384 | workingPackages->append( item->text() ); |
385 | } | 385 | } |
386 | 386 | ||
387 | if ( workingPackages->isEmpty() ) | 387 | if ( workingPackages->isEmpty() ) |
388 | { | 388 | { |
389 | // No packages were selected, prompt for URL of package to download | 389 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
390 | return; | ||
390 | } | 391 | } |
391 | else | 392 | else |
392 | { | 393 | { |
393 | // Download selected packages | 394 | // Download selected packages |
394 | m_config.setGroup( "settings" ); | 395 | m_config.setGroup( "settings" ); |
395 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); | 396 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); |
396 | 397 | ||
397 | // QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this ); | 398 | bool ok = false; |
398 | // if ( ok && !text.isEmpty() ) | 399 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); |
399 | // workingDir = text; // user entered something and pressed ok | 400 | if ( ok && !text.isEmpty() ) |
400 | // else | 401 | workingDir = text; // user entered something and pressed ok |
401 | // return; // user entered nothing or pressed cancel | 402 | else |
403 | return; // user entered nothing or pressed cancel | ||
402 | 404 | ||
403 | // // Store download directory in config file | 405 | // Store download directory in config file |
404 | // m_config.writeEntry( "DownloadDir", workingDir ); | 406 | m_config.writeEntry( "DownloadDir", workingDir ); |
405 | 407 | ||
406 | // Get starting directory | 408 | // Get starting directory |
407 | // char initDir[PATH_MAX]; | 409 | QDir::setCurrent( workingDir ); |
408 | // getcwd( initDir, PATH_MAX ); | ||
409 | |||
410 | // Download packages | ||
411 | |||
412 | } | ||
413 | 410 | ||
414 | // Create package manager output widget | 411 | // Create package manager output widget |
415 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, | 412 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, |
416 | OPackage::Download, workingPackages ); | 413 | OPackage::Download, workingPackages ); |
417 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); | 414 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); |
418 | 415 | ||
419 | // Display widget | 416 | // Display widget |
420 | m_widgetStack.addWidget( dlg, 3 ); | 417 | m_widgetStack.addWidget( dlg, 3 ); |
421 | m_widgetStack.raiseWidget( dlg ); | 418 | m_widgetStack.raiseWidget( dlg ); |
422 | } | 419 | } |
423 | */ | 420 | } |
424 | 421 | ||
425 | void MainWindow::slotApply() | 422 | void MainWindow::slotApply() |
426 | { | 423 | { |
427 | QStringList *removeList = 0x0; | 424 | QStringList *removeList = 0x0; |
428 | QStringList *installList = 0x0; | 425 | QStringList *installList = 0x0; |
429 | QStringList *upgradeList = 0x0; | 426 | QStringList *upgradeList = 0x0; |
430 | 427 | ||
431 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 428 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
432 | item != 0 ; | 429 | item != 0 ; |
433 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 430 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
434 | { | 431 | { |
435 | if ( item->isOn() ) | 432 | if ( item->isOn() ) |
@@ -517,24 +514,29 @@ void MainWindow::slotApply() | |||
517 | // Display widget | 514 | // Display widget |
518 | m_widgetStack.addWidget( dlg, 3 ); | 515 | m_widgetStack.addWidget( dlg, 3 ); |
519 | m_widgetStack.raiseWidget( dlg ); | 516 | m_widgetStack.raiseWidget( dlg ); |
520 | } | 517 | } |
521 | 518 | ||
522 | void MainWindow::slotCloseInstallDlg() | 519 | void MainWindow::slotCloseInstallDlg() |
523 | { | 520 | { |
524 | // Close install dialog | 521 | // Close install dialog |
525 | delete m_widgetStack.visibleWidget(); | 522 | delete m_widgetStack.visibleWidget(); |
526 | 523 | ||
527 | // Reload package list | 524 | // Reload package list |
528 | initPackageInfo(); | 525 | initPackageInfo(); |
526 | |||
527 | // Update Opie launcher links | ||
528 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
529 | QString lf = QString::null; | ||
530 | e << lf; | ||
529 | } | 531 | } |
530 | 532 | ||
531 | void MainWindow::slotConfigure() | 533 | void MainWindow::slotConfigure() |
532 | { | 534 | { |
533 | if ( m_packman.configureDlg( false ) ) | 535 | if ( m_packman.configureDlg( false ) ) |
534 | { | 536 | { |
535 | if ( PromptDlg::ask( tr( "Config updated" ), | 537 | if ( PromptDlg::ask( tr( "Config updated" ), |
536 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), | 538 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), |
537 | tr( "Yes" ), tr( "No" ), this ) == 1 ) | 539 | tr( "Yes" ), tr( "No" ), this ) == 1 ) |
538 | { | 540 | { |
539 | // Update package list and reload package info | 541 | // Update package list and reload package info |
540 | slotUpdate(); | 542 | slotUpdate(); |