-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 30 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.h | 43 |
2 files changed, 52 insertions, 21 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 807bddd..5a942a1 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -1,84 +1,86 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include "installdlg.h" #include "filterdlg.h" #include "promptdlg.h" #include "entrydlg.h" #include "packageinfodlg.h" +#include <opie2/ofiledialog.h> + #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qaction.h> #include <qdir.h> #include <qlayout.h> #include <qlineedit.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qtoolbar.h> #include <qwhatsthis.h> MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) : QMainWindow( parent, name, WStyle_ContextHelp ) , m_config( "packman" ) , m_packman( &m_config, this ) , m_menuBar( this ) , m_toolBar( this ) , m_findBar( this ) , m_widgetStack( this ) , m_packageList( this ) , m_statusWidget( this ) , m_statusText( &m_statusWidget ) , m_statusBar( &m_statusWidget ) , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) , m_iconInstalled( Resource::loadPixmap( "installed" ) ) , m_iconNull( m_iconUpdated.size() ) , m_filterName( QString::null ) , m_filterServer( QString::null ) , m_filterDest( QString::null ) , m_filterStatus( OPackageManager::NotDefined ) , m_filterCategory( QString::null ) { // setCaption( tr( "Package Manager" ) ); m_iconNull.fill( colorGroup().base() ); connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); // Initialize widget stack, package list and status widget initStatusWidget(); initPackageList(); m_widgetStack.addWidget( &m_statusWidget, 2 ); @@ -137,96 +139,102 @@ void MainWindow::initStatusWidget() } void MainWindow::initUI() { // Build menu and tool bars setToolBarsMovable( false ); m_menuBar.setHorizontalStretchable( true ); QMenuBar *mb = new QMenuBar( &m_menuBar ); mb->setMargin( 0 ); // Find toolbar addToolBar( &m_findBar, QMainWindow::Top, true ); m_findBar.setHorizontalStretchable( true ); m_findEdit = new QLineEdit( &m_findBar ); QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); m_findBar.setStretchableWidget( m_findEdit ); connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); // Packages menu QPopupMenu *popup = new QPopupMenu( this ); QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); a->addTo( popup ); a->addTo( &m_toolBar ); QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); actionUpgrade->addTo( popup ); actionUpgrade->addTo( &m_toolBar ); QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); actionDownload->addTo( popup ); actionDownload->addTo( &m_toolBar ); a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); a->addTo( popup ); a->addTo( &m_toolBar ); + a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); + a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); + connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); + a->addTo( popup ); + //a->addTo( &m_toolBar ); + popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to configure this application." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); a->addTo( popup ); mb->insertItem( tr( "Actions" ), popup ); // View menu popup = new QPopupMenu( this ); m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); m_actionShowNotInstalled->setToggleAction( true ); m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); m_actionShowNotInstalled->addTo( popup ); m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); m_actionShowInstalled->setToggleAction( true ); m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); m_actionShowInstalled->addTo( popup ); m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); m_actionShowUpdated->setToggleAction( true ); m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); m_actionShowUpdated->addTo( popup ); popup->insertSeparator(); m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), QString::null, 0, this, 0 ); m_actionFilter->setToggleAction( true ); m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); m_actionFilter->addTo( popup ); a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); a->addTo( popup ); popup->insertSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); @@ -474,96 +482,118 @@ void MainWindow::slotApply() { if ( !installList ) installList = new QStringList(); installList->append( item->text() ); } } } else { // Install package if ( !installList ) installList = new QStringList(); installList->append( item->text() ); } } } } // If nothing is selected, display message and exit if ( !removeList && !installList && !upgradeList ) { QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // Send command only if there are packages to process OPackage::Command removeCmd = OPackage::NotDefined; if ( removeList && !removeList->isEmpty() ) removeCmd = OPackage::Remove; OPackage::Command installCmd = OPackage::NotDefined; if ( installList && !installList->isEmpty() ) installCmd = OPackage::Install; OPackage::Command upgradeCmd = OPackage::NotDefined; if ( upgradeList && !upgradeList->isEmpty() ) upgradeCmd = OPackage::Upgrade; // Create package manager output widget InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, removeCmd, removeList, installCmd, installList, upgradeCmd, upgradeList ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } +void MainWindow::slotInstallLocal() +{ + // Display file open dialog with only package files + MimeTypes type; + QStringList packages; + packages << "application/ipkg"; + type.insert( tr( "Application Packages" ), packages ); + QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, + "/", QString::null, type ); + if ( !package.isNull() ) + { + // Install selected file + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, + OPackage::Install, new QStringList( package ) ); + connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); + + // Display widget + m_widgetStack.addWidget( dlg, 3 ); + m_widgetStack.raiseWidget( dlg ); + } +} + void MainWindow::slotCloseDlg() { // Close install dialog delete m_widgetStack.visibleWidget(); // Reload package list initPackageInfo(); // Update Opie launcher links QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; // Reapply any filters previously set if ( m_actionShowNotInstalled->isOn() ) slotShowNotInstalled(); else if ( m_actionShowInstalled->isOn() ) slotShowInstalled(); else if ( m_actionShowUpdated->isOn() ) slotShowUpdated(); else if ( m_actionFilter->isOn() ) slotFilter( true ); } void MainWindow::slotConfigure() { if ( m_packman.configureDlg( false ) ) { if ( PromptDlg::ask( tr( "Config updated" ), tr( "The configuration has been updated. Do you want to update server and package information now?" ), tr( "Yes" ), tr( "No" ), this ) == 1 ) { // Update package list and reload package info slotUpdate(); } } } void MainWindow::slotShowNotInstalled() { OPackageList *packageList; if ( m_actionShowNotInstalled->isOn() ) { m_actionShowInstalled->setOn( false ); m_actionShowUpdated->setOn( false ); m_actionFilter->setOn( false ); packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, OPackageManager::NotInstalled, QString::null ); diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index 632effb..7968614 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h @@ -1,139 +1,140 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> - .=l. - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include "opackagemanager.h" #include <qpe/config.h> #include <qlabel.h> #include <qlistview.h> #include <qmainwindow.h> #include <qpixmap.h> #include <qprogressbar.h> #include <qtoolbar.h> #include <qwidgetstack.h> class QAction; class QLineEdit; class MainWindow :public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); static QString appName() { return QString::fromLatin1( "packagemanager" ); }; protected: void closeEvent( QCloseEvent *event ); private: Config m_config; // Configuration file OPackageManager m_packman; // Package manager // Toolbars QToolBar m_menuBar; // Main toolbar containing menu QToolBar m_toolBar; // Main toolbar QToolBar m_findBar; // Find toolbar QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget QListView m_packageList; // Main list view of all packages QLineEdit *m_findEdit; // Line edit box used for find toolbar // Status widget controls QWidget m_statusWidget; // Widget to display status during long operations QLabel m_statusText; // Text status message QProgressBar m_statusBar; // Progress bar showing % completed // Icon pixmaps QPixmap m_iconUpdated; // Cached icon which shows when package can be updated QPixmap m_iconInstalled; // Cached icon which shows when package is installed QPixmap m_iconNull; // Cached icon which shows when package is not installed // Menu/tool bar actions QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed QAction *m_actionShowInstalled; // Action to show pakages currently installed QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available QAction *m_actionFilter; // Action to filter packages QAction *m_actionFindNext; // Action to find next match // Cached filter settings QString m_filterName; // Cached name filter value QString m_filterServer; // Cached server name filter value QString m_filterDest; // Cached destination name filter value OPackageManager::Status m_filterStatus; // Cached status filter value QString m_filterCategory; // Cached category filter value void initPackageList(); void initStatusWidget(); void initUI(); void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); void searchForPackage( const QString &text ); private slots: void initPackageInfo(); void slotWidgetStackShow( QWidget *widget ); // Status widget slots void slotInitStatusBar( int numSteps ); void slotStatusText( const QString &status ); void slotStatusBar( int currStep ); // Actions menu action slots void slotUpdate(); void slotUpgrade(); void slotDownload(); void slotApply(); + void slotInstallLocal(); void slotCloseDlg(); void slotConfigure(); // View menu action slots void slotShowNotInstalled(); void slotShowInstalled(); void slotShowUpdated(); void slotFilterChange(); void slotFilter( bool isOn ); // Find action slots void slotFindShowToolbar(); void slotFindHideToolbar(); void slotFindChanged( const QString &findText ); void slotFindNext(); // Other slots void slotDisplayPackageInfo( QListViewItem * ); }; #endif |