Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 198 |
1 files changed, 153 insertions, 45 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index e577285..4aa83b5 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -20,2 +20,7 @@ using namespace std; | |||
20 | 20 | ||
21 | #include <qpe/qpemenubar.h> | ||
22 | #include <qpe/qpetoolbar.h> | ||
23 | #include <qpe/resource.h> | ||
24 | |||
25 | #include <qaction.h> | ||
21 | #include <qmenubar.h> | 26 | #include <qmenubar.h> |
@@ -24,2 +29,3 @@ using namespace std; | |||
24 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qwidgetstack.h> | ||
25 | 31 | ||
@@ -34,53 +40,124 @@ using namespace std; | |||
34 | 40 | ||
35 | MainWindow :: MainWindow( QWidget *p, char *name ) | 41 | MainWindow :: MainWindow() |
36 | :QMainWindow( p, name ) | 42 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
37 | { | 43 | { |
38 | #ifdef QWS | ||
39 | showMaximized(); | ||
40 | #endif | ||
41 | |||
42 | setCaption( tr( "AQPkg - Package Manager" ) ); | 44 | setCaption( tr( "AQPkg - Package Manager" ) ); |
43 | 45 | ||
44 | // Create our menu | ||
45 | help = new QPopupMenu( this ); | ||
46 | help->insertItem( tr( "General" ), this, SLOT(displayHelp()) ); | ||
47 | help->insertItem( tr( "About" ), this, SLOT(displayAbout()) ); | ||
48 | |||
49 | settings = new QPopupMenu( this ); | ||
50 | settings->insertItem( tr( "Settings" ), this, SLOT(displaySettings()) ); | ||
51 | |||
52 | edit = new QPopupMenu( this ); | ||
53 | edit->insertItem( tr( "Find" ), this, SLOT(searchForPackage()) ); | ||
54 | edit->insertItem( tr( "Find Next" ), this, SLOT(repeatSearchForPackage()) ); | ||
55 | |||
56 | filter = new QPopupMenu( this ); | ||
57 | mnuShowUninstalledPkgsId = filter->insertItem( tr( "Show Non-Installed Packages" ), this, SLOT(filterUninstalledPackages()) ); | ||
58 | mnuShowInstalledPkgsId = filter->insertItem( tr( "Show Installed Packages" ), this, SLOT(filterInstalledPackages()) ); | ||
59 | mnuShowUpgradedPkgsId = filter->insertItem( tr( "Show Updated Packages" ), this, SLOT(filterUpgradedPackages()) ); | ||
60 | filter->insertSeparator(); | ||
61 | mnuFilterByCategory = filter->insertItem( tr( "Filter By Category" ), this, SLOT(filterCategory()) ); | ||
62 | mnuSetFilterCategory = filter->insertItem( tr( "Set Filter Category" ), this, SLOT(setFilterCategory()) ); | ||
63 | |||
64 | // Create the main menu | ||
65 | menu = menuBar(); //new QMenuBar( this ); | ||
66 | menu->insertItem( tr( "Settings" ), settings ); | ||
67 | menu->insertItem( tr( "Edit" ), edit ); | ||
68 | menu->insertItem( tr( "Filter" ), filter ); | ||
69 | menu->insertItem( tr( "Help" ), help ); | ||
70 | |||
71 | // Create UI widgets | 46 | // Create UI widgets |
72 | stack = new QWidgetStack( this ); | 47 | progressWindow = new ProgressWidget( this ); |
48 | networkPkgWindow = new NetworkPackageManager( this ); | ||
73 | 49 | ||
74 | progressWindow = new ProgressWidget( stack ); | 50 | // Build menu and tool bars |
75 | stack->addWidget( progressWindow, 2 ); | 51 | setToolBarsMovable( FALSE ); |
76 | 52 | ||
77 | networkPkgWindow = new NetworkPackageManager( stack ); | 53 | QPEToolBar *bar = new QPEToolBar( this ); |
78 | connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); | 54 | bar->setHorizontalStretchable( TRUE ); |
79 | connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); | 55 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
80 | connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); | 56 | mb->setMargin( 0 ); |
81 | connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), | 57 | bar = new QPEToolBar( this ); |
82 | progressWindow, SLOT( setMessage( const QString & ) ) ); | 58 | |
83 | connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); | 59 | // Packages menu |
84 | stack->addWidget( networkPkgWindow, 1 ); | 60 | QPopupMenu *popup = new QPopupMenu( this ); |
61 | |||
62 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | ||
63 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | ||
64 | connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) ); | ||
65 | a->addTo( popup ); | ||
66 | a->addTo( bar ); | ||
67 | |||
68 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | ||
69 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | ||
70 | connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) ); | ||
71 | actionUpgrade->addTo( popup ); | ||
72 | actionUpgrade->addTo( bar ); | ||
73 | |||
74 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | ||
75 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | ||
76 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | ||
77 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | ||
78 | connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) ); | ||
79 | actionDownload->addTo( popup ); | ||
80 | actionDownload->addTo( bar ); | ||
81 | |||
82 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | ||
83 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | ||
84 | connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) ); | ||
85 | a->addTo( popup ); | ||
86 | a->addTo( bar ); | ||
87 | |||
88 | mb->insertItem( tr( "Packages" ), popup ); | ||
89 | |||
90 | // Search menu | ||
91 | popup = new QPopupMenu( this ); | ||
92 | |||
93 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | ||
94 | a->setWhatsThis( tr( "Click here to search for a specific package." ) ); | ||
95 | connect( a, SIGNAL( activated() ), this, SLOT( searchForPackage() ) ); | ||
96 | a->addTo( popup ); | ||
97 | |||
98 | a = new QAction( tr( "Find next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | ||
99 | a->setWhatsThis( tr( "Click here to search for the next package." ) ); | ||
100 | connect( a, SIGNAL( activated() ), this, SLOT( repeatSearchForPackage() ) ); | ||
101 | a->addTo( popup ); | ||
102 | |||
103 | // Show 'quick jump' keypad? | ||
104 | |||
105 | popup->insertSeparator(); | ||
106 | |||
107 | a = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | ||
108 | a->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | ||
109 | connect( a, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | ||
110 | a->addTo( popup ); | ||
111 | |||
112 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | ||
113 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | ||
114 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | ||
115 | a->addTo( popup ); | ||
116 | |||
117 | mb->insertItem( tr( "Search" ), popup ); | ||
118 | |||
119 | |||
120 | // View menu | ||
121 | popup = new QPopupMenu( this ); | ||
122 | |||
123 | a = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | ||
124 | a->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | ||
125 | connect( a, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | ||
126 | a->addTo( popup ); | ||
127 | |||
128 | a = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | ||
129 | a->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | ||
130 | connect( a, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | ||
131 | a->addTo( popup ); | ||
132 | |||
133 | a = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | ||
134 | a->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | ||
135 | connect( a, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | ||
136 | a->addTo( popup ); | ||
85 | 137 | ||
138 | popup->insertSeparator(); | ||
139 | |||
140 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); | ||
141 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | ||
142 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | ||
143 | a->addTo( popup ); | ||
144 | |||
145 | popup->insertSeparator(); | ||
146 | |||
147 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); | ||
148 | a->setWhatsThis( tr( "Click here for help." ) ); | ||
149 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); | ||
150 | a->addTo( popup ); | ||
151 | |||
152 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); | ||
153 | a->setWhatsThis( tr( "Click here for software version information." ) ); | ||
154 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); | ||
155 | a->addTo( popup ); | ||
156 | |||
157 | mb->insertItem( tr( "View" ), popup ); | ||
158 | |||
159 | // Create widget stack and add UI widgets | ||
160 | stack = new QWidgetStack( this ); | ||
161 | stack->addWidget( progressWindow, 2 ); | ||
162 | stack->addWidget( networkPkgWindow, 1 ); | ||
86 | setCentralWidget( stack ); | 163 | setCentralWidget( stack ); |
@@ -90,3 +167,2 @@ MainWindow :: MainWindow( QWidget *p, char *name ) | |||
90 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 167 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
91 | |||
92 | } | 168 | } |
@@ -101,2 +177,3 @@ void MainWindow :: init() | |||
101 | stack->raiseWidget( progressWindow ); | 177 | stack->raiseWidget( progressWindow ); |
178 | |||
102 | mgr = new DataManager(); | 179 | mgr = new DataManager(); |
@@ -107,4 +184,14 @@ void MainWindow :: init() | |||
107 | mgr->loadServers(); | 184 | mgr->loadServers(); |
185 | |||
108 | networkPkgWindow->setDataManager( mgr ); | 186 | networkPkgWindow->setDataManager( mgr ); |
109 | networkPkgWindow->updateData(); | 187 | networkPkgWindow->updateData(); |
188 | connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); | ||
189 | connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); | ||
190 | connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) ); | ||
191 | connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) ); | ||
192 | connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); | ||
193 | connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), | ||
194 | progressWindow, SLOT( setMessage( const QString & ) ) ); | ||
195 | connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); | ||
196 | |||
110 | stack->raiseWidget( networkPkgWindow ); | 197 | stack->raiseWidget( networkPkgWindow ); |
@@ -247 +334,22 @@ void MainWindow :: raiseProgressWidget() | |||
247 | } | 334 | } |
335 | |||
336 | void MainWindow :: enableUpgrade( bool enabled ) | ||
337 | { | ||
338 | actionUpgrade->setEnabled( enabled ); | ||
339 | } | ||
340 | |||
341 | void MainWindow :: enableDownload( bool enabled ) | ||
342 | { | ||
343 | if ( enabled ) | ||
344 | { | ||
345 | actionDownload->setIconSet( iconDownload ); | ||
346 | actionDownload->setText( tr( "Download" ) ); | ||
347 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | ||
348 | } | ||
349 | else | ||
350 | { | ||
351 | actionDownload->setIconSet( iconRemove ); | ||
352 | actionDownload->setText( tr( "Remove" ) ); | ||
353 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | ||
354 | } | ||
355 | } | ||