38 #include "tests/testkget.h"
41 #include <kapplication.h>
42 #include <kstandarddirs.h>
43 #include <KInputDialog>
44 #include <kmessagebox.h>
45 #include <knotifyconfigwidget.h>
46 #include <kfiledialog.h>
47 #include <ktoolinvocation.h>
49 #include <kiconloader.h>
50 #include <kstandardaction.h>
53 #include <kactionmenu.h>
54 #include <KSelectAction>
56 #include <kicondialog.h>
60 #include <QtTest/QtTest>
67 m_startWithoutAnimation(startWithoutAnimation),
68 m_doTesting(doTesting),
73 qApp->setQuitOnLastWindowClosed(
false);
74 setAttribute(Qt::WA_DeleteOnClose,
false);
84 setupGUI(ToolBar | Keys | Save | Create);
86 setCentralWidget(m_viewsContainer);
90 setPlainCaption(i18n(
"KGet"));
117 return QSize(738, 380);
120 int MainWindow::transfersPercent()
123 int activeTransfers = 0;
131 if (activeTransfers > 0) {
132 return percent/activeTransfers;
139 void MainWindow::setupActions()
141 KAction *newDownloadAction = actionCollection()->addAction(
"new_download");
142 newDownloadAction->setText(i18n(
"&New Download..."));
143 newDownloadAction->setIcon(KIcon(
"document-new"));
144 newDownloadAction->setShortcuts(KShortcut(
"Ctrl+N"));
145 newDownloadAction->setHelpText(i18n(
"Opens a dialog to add a transfer to the list"));
146 connect(newDownloadAction, SIGNAL(triggered()), SLOT(slotNewTransfer()));
148 KAction *openAction = actionCollection()->addAction(
"import_transfers");
149 openAction->setText(i18n(
"&Import Transfers..."));
150 openAction->setIcon(KIcon(
"document-open"));
151 openAction->setShortcuts(KShortcut(
"Ctrl+I"));
152 openAction->setHelpText(i18n(
"Imports a list of transfers"));
153 connect(openAction, SIGNAL(triggered()), SLOT(slotImportTransfers()));
155 KAction *exportAction = actionCollection()->addAction(
"export_transfers");
156 exportAction->setText(i18n(
"&Export Transfers List..."));
157 exportAction->setIcon(KIcon(
"document-export"));
158 exportAction->setShortcuts(KShortcut(
"Ctrl+E"));
159 exportAction->setHelpText(i18n(
"Exports the current transfers into a file"));
160 connect(exportAction, SIGNAL(triggered()), SLOT(slotExportTransfers()));
162 KAction *createMetalinkAction = actionCollection()->addAction(
"create_metalink");
163 createMetalinkAction->setText(i18n(
"&Create a Metalink..."));
164 createMetalinkAction->setIcon(KIcon(
"journal-new"));
165 createMetalinkAction->setHelpText(i18n(
"Creates or modifies a metalink and saves it on disk"));
166 connect(createMetalinkAction, SIGNAL(triggered()), SLOT(slotCreateMetalink()));
168 KAction *priorityTop = actionCollection()->addAction(
"priority_top");
169 priorityTop->setText(i18n(
"Top Priority"));
170 priorityTop->setIcon(KIcon(
"arrow-up-double"));
171 priorityTop->setShortcuts(KShortcut(
"Ctrl+PgUp"));
172 priorityTop->setHelpText(i18n(
"Download selected transfer first"));
173 connect(priorityTop, SIGNAL(triggered()),
this, SLOT(slotPriorityTop()));
175 KAction *priorityBottom = actionCollection()->addAction(
"priority_bottom");
176 priorityBottom->setText(i18n(
"Least Priority"));
177 priorityBottom->setIcon(KIcon(
"arrow-down-double"));
178 priorityBottom->setShortcuts(KShortcut(
"Ctrl+PgDown"));
179 priorityBottom->setHelpText(i18n(
"Download selected transfer last"));
180 connect(priorityBottom, SIGNAL(triggered()),
this, SLOT(slotPriorityBottom()));
182 KAction *priorityUp = actionCollection()->addAction(
"priority_up");
183 priorityUp->setText(i18n(
"Increase Priority"));
184 priorityUp->setIcon(KIcon(
"arrow-up"));
185 priorityUp->setShortcuts(KShortcut(
"Ctrl+Up"));
186 priorityUp->setHelpText(i18n(
"Increase priority for selected transfer"));
187 connect(priorityUp, SIGNAL(triggered()),
this, SLOT(slotPriorityUp()));
189 KAction *priorityDown = actionCollection()->addAction(
"priority_down");
190 priorityDown->setText(i18n(
"Decrease Priority"));
191 priorityDown->setIcon(KIcon(
"arrow-down"));
192 priorityDown->setShortcuts(KShortcut(
"Ctrl+Down"));
193 priorityDown->setHelpText(i18n(
"Decrease priority for selected transfer"));
194 connect(priorityDown, SIGNAL(triggered()),
this, SLOT(slotPriorityDown()));
197 KAction *deleteGroupAction = actionCollection()->addAction(
"delete_groups");
198 deleteGroupAction->setText(i18n(
"Delete Group"));
199 deleteGroupAction->setIcon(KIcon(
"edit-delete"));
200 deleteGroupAction->setHelpText(i18n(
"Delete selected group"));
201 connect(deleteGroupAction, SIGNAL(triggered()), SLOT(slotDeleteGroup()));
203 KAction *renameGroupAction = actionCollection()->addAction(
"rename_groups");
204 renameGroupAction->setText(i18n(
"Rename Group..."));
205 renameGroupAction->setIcon(KIcon(
"edit-rename"));
206 connect(renameGroupAction, SIGNAL(triggered()), SLOT(slotRenameGroup()));
208 KAction *setIconGroupAction = actionCollection()->addAction(
"seticon_groups");
209 setIconGroupAction->setText(i18n(
"Set Icon..."));
210 setIconGroupAction->setIcon(KIcon(
"preferences-desktop-icons"));
211 setIconGroupAction->setHelpText(i18n(
"Select a custom icon for the selected group"));
212 connect(setIconGroupAction, SIGNAL(triggered()), SLOT(slotSetIconGroup()));
214 m_autoPasteAction =
new KToggleAction(KIcon(
"edit-paste"),
215 i18n(
"Auto-Paste Mode"), actionCollection());
216 actionCollection()->addAction(
"auto_paste", m_autoPasteAction);
218 m_autoPasteAction->setWhatsThis(i18n(
"<b>Auto paste</b> button toggles the auto-paste mode "
219 "on and off.\nWhen set, KGet will periodically scan "
220 "the clipboard for URLs and paste them automatically."));
221 connect(m_autoPasteAction, SIGNAL(triggered()), SLOT(slotToggleAutoPaste()));
223 m_konquerorIntegration =
new KToggleAction(KIcon(
"konqueror"),
224 i18n(
"Use KGet as Konqueror Download Manager"), actionCollection());
225 actionCollection()->addAction(
"konqueror_integration", m_konquerorIntegration);
226 connect(m_konquerorIntegration, SIGNAL(triggered(
bool)), SLOT(slotTrayKonquerorIntegration(
bool)));
230 KStandardAction::quit(
this, SLOT(
slotQuit()), actionCollection());
232 KStandardAction::preferences(
this, SLOT(slotPreferences()), actionCollection());
234 KStandardAction::configureNotifications(
this, SLOT(slotConfigureNotifications()), actionCollection());
235 m_menubarAction = KStandardAction::showMenubar(
this, SLOT(slotShowMenubar()), actionCollection());
236 m_menubarAction->setChecked(!menuBar()->isHidden());
239 actionCollection()->addAction(KStandardAction::SelectAll,
"select_all", m_viewsContainer, SLOT(selectAll()));
241 KAction *deleteSelectedAction = actionCollection()->addAction(
"delete_selected_download");
242 deleteSelectedAction->setText(i18nc(
"delete selected transfer item",
"Remove Selected"));
243 deleteSelectedAction->setIcon(KIcon(
"edit-delete"));
244 deleteSelectedAction->setShortcuts(KShortcut(
"Del"));
245 deleteSelectedAction->setHelpText(i18n(
"Removes selected transfer and deletes files from disk if it's not finished"));
246 connect(deleteSelectedAction, SIGNAL(triggered()), SLOT(slotDeleteSelected()));
248 KAction *deleteAllFinishedAction = actionCollection()->addAction(
"delete_all_finished");
249 deleteAllFinishedAction->setText(i18nc(
"delete all finished transfers",
"Remove All Finished"));
250 deleteAllFinishedAction->setIcon(KIcon(
"edit-clear-list"));
251 deleteAllFinishedAction->setHelpText(i18n(
"Removes all finished transfers and leaves all files on disk"));
252 connect(deleteAllFinishedAction, SIGNAL(triggered()), SLOT(slotDeleteFinished()));
254 KAction *deleteSelectedIncludingFilesAction = actionCollection()->addAction(
"delete_selected_download_including_files");
255 deleteSelectedIncludingFilesAction->setText(i18nc(
"delete selected transfer item and files",
"Remove Selected and Delete Files"));
256 deleteSelectedIncludingFilesAction->setIcon(KIcon(
"edit-delete"));
257 deleteSelectedIncludingFilesAction->setHelpText(i18n(
"Removes selected transfer and deletes files from disk in any case"));
258 connect(deleteSelectedIncludingFilesAction, SIGNAL(triggered()), SLOT(slotDeleteSelectedIncludingFiles()));
260 KAction *redownloadSelectedAction = actionCollection()->addAction(
"redownload_selected_download");
261 redownloadSelectedAction->setText(i18nc(
"redownload selected transfer item",
"Redownload Selected"));
262 redownloadSelectedAction->setIcon(KIcon(
"view-refresh"));
263 connect(redownloadSelectedAction, SIGNAL(triggered()), SLOT(slotRedownloadSelected()));
265 KAction *startAllAction = actionCollection()->addAction(
"start_all_download");
266 startAllAction->setText(i18n(
"Start All"));
267 startAllAction->setIcon(KIcon(
"media-seek-forward"));
268 startAllAction->setShortcuts(KShortcut(
"Ctrl+R"));
269 startAllAction->setHelpText(i18n(
"Starts / resumes all transfers"));
270 connect(startAllAction, SIGNAL(triggered()), SLOT(slotStartAllDownload()));
272 KAction *startSelectedAction = actionCollection()->addAction(
"start_selected_download");
273 startSelectedAction->setText(i18n(
"Start Selected"));
274 startSelectedAction->setIcon(KIcon(
"media-playback-start"));
275 startSelectedAction->setHelpText(i18n(
"Starts / resumes selected transfer"));
276 connect(startSelectedAction, SIGNAL(triggered()), SLOT(slotStartSelectedDownload()));
278 KAction *stopAllAction = actionCollection()->addAction(
"stop_all_download");
279 stopAllAction->setText(i18n(
"Pause All"));
280 stopAllAction->setIcon(KIcon(
"media-playback-pause"));
281 stopAllAction->setShortcuts(KShortcut(
"Ctrl+P"));
282 stopAllAction->setHelpText(i18n(
"Pauses all transfers"));
283 connect(stopAllAction, SIGNAL(triggered()), SLOT(slotStopAllDownload()));
285 KAction *stopSelectedAction = actionCollection()->addAction(
"stop_selected_download");
286 stopSelectedAction->setText(i18n(
"Stop Selected"));
287 stopSelectedAction->setIcon(KIcon(
"media-playback-pause"));
288 stopSelectedAction->setHelpText(i18n(
"Pauses selected transfer"));
289 connect(stopSelectedAction, SIGNAL(triggered()), SLOT(slotStopSelectedDownload()));
291 KActionMenu *startActionMenu =
new KActionMenu(KIcon(
"media-playback-start"), i18n(
"Start"),
293 actionCollection()->addAction(
"start_menu", startActionMenu);
294 startActionMenu->setDelayed(
true);
295 startActionMenu->addAction(startSelectedAction);
296 startActionMenu->addAction(startAllAction);
297 connect(startActionMenu, SIGNAL(triggered()), SLOT(slotStartDownload()));
299 KActionMenu *stopActionMenu =
new KActionMenu(KIcon(
"media-playback-pause"), i18n(
"Pause"),
301 actionCollection()->addAction(
"stop_menu", stopActionMenu);
302 stopActionMenu->setDelayed(
true);
303 stopActionMenu->addAction(stopSelectedAction);
304 stopActionMenu->addAction(stopAllAction);
305 connect(stopActionMenu, SIGNAL(triggered()), SLOT(slotStopDownload()));
307 KAction *openDestAction = actionCollection()->addAction(
"transfer_open_dest");
308 openDestAction->setText(i18n(
"Open Destination"));
309 openDestAction->setIcon(KIcon(
"document-open"));
310 connect(openDestAction, SIGNAL(triggered()), SLOT(slotTransfersOpenDest()));
312 KAction *openFileAction = actionCollection()->addAction(
"transfer_open_file");
313 openFileAction->setText(i18n(
"Open File"));
314 openFileAction->setIcon(KIcon(
"document-open"));
315 connect(openFileAction, SIGNAL(triggered()), SLOT(slotTransfersOpenFile()));
317 KAction *showDetailsAction =
new KToggleAction(KIcon(
"document-properties"), i18n(
"Show Details"), actionCollection());
318 actionCollection()->addAction(
"transfer_show_details", showDetailsAction);
319 connect(showDetailsAction, SIGNAL(triggered()), SLOT(slotTransfersShowDetails()));
321 KAction *copyUrlAction = actionCollection()->addAction(
"transfer_copy_source_url");
322 copyUrlAction->setText(i18n(
"Copy URL to Clipboard"));
323 copyUrlAction->setIcon(KIcon(
"edit-copy"));
324 connect(copyUrlAction, SIGNAL(triggered()), SLOT(slotTransfersCopySourceUrl()));
326 KAction *transferHistoryAction = actionCollection()->addAction(
"transfer_history");
327 transferHistoryAction->setText(i18n(
"&Transfer History"));
328 transferHistoryAction->setIcon(KIcon(
"view-history"));
329 transferHistoryAction->setShortcuts(KShortcut(
"Ctrl+H"));
330 connect(transferHistoryAction, SIGNAL(triggered()), SLOT(slotTransferHistory()));
332 KAction *transferGroupSettingsAction = actionCollection()->addAction(
"transfer_group_settings");
333 transferGroupSettingsAction->setText(i18n(
"&Group Settings"));
334 transferGroupSettingsAction->setIcon(KIcon(
"preferences-system"));
335 transferGroupSettingsAction->setShortcuts(KShortcut(
"Ctrl+G"));
336 connect(transferGroupSettingsAction, SIGNAL(triggered()), SLOT(slotTransferGroupSettings()));
338 KAction *transferSettingsAction = actionCollection()->addAction(
"transfer_settings");
339 transferSettingsAction->setText(i18n(
"&Transfer Settings"));
340 transferSettingsAction->setIcon(KIcon(
"preferences-system"));
341 transferSettingsAction->setShortcuts(KShortcut(
"Ctrl+T"));
342 connect(transferSettingsAction, SIGNAL(triggered()), SLOT(slotTransferSettings()));
344 KAction *listLinksAction = actionCollection()->addAction(
"import_links");
345 listLinksAction->setText(i18n(
"Import &Links..."));
346 listLinksAction->setIcon(KIcon(
"view-list-text"));
347 listLinksAction->setShortcuts(KShortcut(
"Ctrl+L"));
348 connect(listLinksAction, SIGNAL(triggered()), SLOT(slotShowListLinks()));
351 KSelectAction *downloadFinishedActions =
new KSelectAction(i18n(
"After downloads finished action"),
this);
352 actionCollection()->addAction(
"download_finished_actions", downloadFinishedActions);
353 downloadFinishedActions->setHelpText(i18n(
"Choose an action that is executed after all downloads have been finished."));
355 KAction *noAction = downloadFinishedActions->addAction(i18n(
"No Action"));
356 connect(noAction, SIGNAL(triggered()), SLOT(slotDownloadFinishedActions()));
357 downloadFinishedActions->addAction(noAction);
359 KAction *quitAction = downloadFinishedActions->addAction(i18n(
"Quit KGet"));
361 connect(quitAction, SIGNAL(triggered()), SLOT(slotDownloadFinishedActions()));
362 downloadFinishedActions->addAction(quitAction);
364 #ifdef HAVE_KWORKSPACE
365 KAction *shutdownAction = downloadFinishedActions->addAction(i18n(
"Turn Off Computer"));
367 connect(shutdownAction, SIGNAL(triggered()), SLOT(slotDownloadFinishedActions()));
368 downloadFinishedActions->addAction(shutdownAction);
370 KAction *hibernateAction = downloadFinishedActions->addAction(i18n(
"Hibernate Computer"));
372 connect(hibernateAction, SIGNAL(triggered()), SLOT(slotDownloadFinishedActions()));
373 downloadFinishedActions->addAction(hibernateAction);
375 KAction *suspendAction = downloadFinishedActions->addAction(i18n(
"Suspend Computer"));
377 connect(suspendAction, SIGNAL(triggered()), SLOT(slotDownloadFinishedActions()));
378 downloadFinishedActions->addAction(suspendAction);
384 downloadFinishedActions->setCurrentItem(0);
388 void MainWindow::slotDownloadFinishedActions()
390 KAction *action =
static_cast<KAction*
>(QObject::sender());
392 const int type = action->data().toInt(&ok);
406 KGet::load( KStandardDirs::locateLocal(
"appdata",
"transfers.kgt") );
409 m_dock =
new Tray(
this);
413 setAcceptDrops(
true);
416 setStandardToolBarMenuEnabled(
true);
419 connect(kapp, SIGNAL(saveYourself()), SLOT(slotSaveMyself()));
422 KConfig cfg(
"kioslaverc", KConfig::NoGlobals);
423 cfg.group(QString()).writeEntry(
"AutoResume",
true);
430 if (KMessageBox::questionYesNoCancel(
this ,i18n(
"This is the first time you have run KGet.\n"
431 "Would you like to enable KGet as the download manager for Konqueror?"),
432 i18n(
"Konqueror Integration"), KGuiItem(i18n(
"Enable")),
433 KGuiItem(i18n(
"Do Not Enable")))
434 == KMessageBox::Yes) {
437 slotKonquerorIntegration(
true);
450 lastClipboard = QApplication::clipboard()->text( QClipboard::Clipboard ).trimmed();
451 clipboardTimer =
new QTimer(
this);
452 connect(clipboardTimer, SIGNAL(timeout()), SLOT(slotCheckClipboard()));
454 clipboardTimer->start(1000);
472 connect(
KGet::model(), SIGNAL(transfersChangedEvent(QMap<TransferHandler*,Transfer::ChangesFlags>)),
473 SLOT(slotTransfersChanged(QMap<TransferHandler*,Transfer::ChangesFlags>)));
474 connect(
KGet::model(), SIGNAL(groupsChangedEvent(QMap<TransferGroupHandler*,TransferGroup::ChangesFlags>)),
475 SLOT(slotGroupsChanged(QMap<TransferGroupHandler*,TransferGroup::ChangesFlags>)));
482 QTest::qExec(&unitTest);
487 void MainWindow::slotToggleDropTarget()
492 void MainWindow::slotNewTransfer()
497 void MainWindow::slotImportTransfers()
499 QString filename = KFileDialog::getOpenFileName(KUrl(),
500 "*.kgt *.metalink *.meta4 *.torrent|" + i18n(
"All Openable Files") +
501 " (*.kgt *.metalink *.meta4 *.torrent)",
this, i18n(
"Open File"));
503 if(filename.endsWith(QLatin1String(
".kgt")))
509 if(!filename.isEmpty())
515 int percent = transfersPercent();
517 setPlainCaption(i18nc(
"window title including overall download progress in percent",
"KGet - %1%", percent));
519 setPlainCaption(i18n(
"KGet"));
523 void MainWindow::slotTransfersChanged(QMap<TransferHandler*, Transfer::ChangesFlags> transfers)
525 QMapIterator<TransferHandler*, Transfer::ChangesFlags> it(transfers);
530 while (it.hasNext()) {
548 void MainWindow::slotGroupsChanged(QMap<TransferGroupHandler*, TransferGroup::ChangesFlags> groups)
566 if (KMessageBox::warningYesNo(
this,
567 i18n(
"Some transfers are still running.\n"
568 "Are you sure you want to close KGet?"),
569 i18n(
"Confirm Quit"),
570 KStandardGuiItem::quit(), KStandardGuiItem::cancel(),
571 "ExitWithActiveTransfers") != KMessageBox::Yes)
579 void MainWindow::slotPreferences()
583 dialog->setAttribute(Qt::WA_DeleteOnClose);
586 connect( dialog, SIGNAL(settingsChanged(QString)),
587 this, SLOT(slotNewConfig()) );
592 void MainWindow::slotExportTransfers()
594 const QString filename = KFileDialog::getSaveFileName
596 "*.kgt|" + i18n(
"KGet Transfer List") +
" (*.kgt)\n*.txt|" + i18n(
"Text File") +
" (*.txt)",
598 i18n(
"Export Transfers")
601 if (!filename.isEmpty()) {
602 const bool plain = !filename.endsWith(
"kgt");
607 void MainWindow::slotCreateMetalink()
610 dialog->setAttribute(Qt::WA_DeleteOnClose);
614 void MainWindow::slotDeleteGroup()
622 void MainWindow::slotRenameGroup()
629 groupName = KInputDialog::getText(i18n(
"Enter Group Name"),
630 i18n(
"Group name:"), it->
name(), &ok,
this);
636 void MainWindow::slotSetIconGroup()
638 KIconDialog dialog(
this);
639 QString iconName = dialog.getIcon();
642 QModelIndexList indexList = selModel->selectedRows();
644 if (!iconName.isEmpty())
654 void MainWindow::slotStartDownload()
657 slotStartAllDownload();
659 slotStartSelectedDownload();
663 void MainWindow::slotStartAllDownload()
668 void MainWindow::slotStartSelectedDownload()
680 void MainWindow::slotStopDownload()
683 slotStopAllDownload();
685 slotStopSelectedDownload();
689 void MainWindow::slotStopAllDownload()
699 void MainWindow::slotStopSelectedDownload()
711 void MainWindow::slotDeleteSelected()
716 if (KMessageBox::warningYesNo(
this,
717 i18np(
"Are you sure you want to delete the selected transfer?",
719 i18n(
"Confirm transfer delete"),
720 KStandardGuiItem::remove(), KStandardGuiItem::cancel()) == KMessageBox::No)
729 if (!selectedTransfers.isEmpty()) {
740 void MainWindow::slotDeleteSelectedIncludingFiles()
744 if (!selectedTransfers.isEmpty()) {
745 if (KMessageBox::warningYesNo(
this,
746 i18np(
"Are you sure you want to delete the selected transfer including files?",
747 "Are you sure you want to delete the selected transfers including files?", selectedTransfers.count()),
748 i18n(
"Confirm transfer delete"),
749 KStandardGuiItem::remove(), KStandardGuiItem::cancel()) == KMessageBox::No) {
762 void MainWindow::slotRedownloadSelected()
770 void MainWindow::slotPriorityTop()
781 if (!group || (group != transfer->
group())) {
783 group = transfer->
group();
790 void MainWindow::slotPriorityBottom()
793 QList<TransferHandler*> groupTransfers;
802 if (!group || (group != transfer->
group())) {
803 group = transfer->
group();
805 if (groupTransfers.isEmpty()) {
808 after = groupTransfers.last();
817 void MainWindow::slotPriorityUp()
820 QList<TransferHandler*> groupTransfers;
830 if (!group || (group != transfer->
group())) {
831 group = transfer->
group();
836 if (!groupTransfers.isEmpty()) {
837 int index = groupTransfers.indexOf(transfer);
842 if ((index - 1) != newIndex) {
843 newIndex = index - 1;
844 if (newIndex - 1 >= 0) {
845 after = groupTransfers[newIndex - 1];
849 groupTransfers.move(index, newIndex);
862 void MainWindow::slotPriorityDown()
865 QList<TransferHandler*> groupTransfers;
868 for (
int i = selected.count() - 1; i >= 0; --i) {
875 if (!group || (group != transfer->
group())) {
876 group = transfer->
group();
880 if (!groupTransfers.isEmpty()) {
881 int index = groupTransfers.indexOf(transfer);
884 if ((index != -1) && (index + 1 < groupTransfers.count())) {
886 if ((index + 1) != newIndex) {
887 newIndex = index + 1;
892 groupTransfers.move(index, newIndex);
905 void MainWindow::slotTransfersOpenDest()
907 QStringList openedDirs;
910 QString directory = it->
dest().directory();
911 if( !openedDirs.contains( directory ) )
913 new KRun(directory,
this, 0,
true,
false);
914 openedDirs.append( directory );
919 void MainWindow::slotTransfersOpenFile()
923 new KRun(it->
dest(),
this, 0,
true,
false);
927 void MainWindow::slotTransfersShowDetails()
935 void MainWindow::slotTransfersCopySourceUrl()
939 QString sourceurl = it->
source().url();
940 QClipboard *cb = QApplication::clipboard();
941 cb->setText(sourceurl, QClipboard::Selection);
942 cb->setText(sourceurl, QClipboard::Clipboard);
946 void MainWindow::slotDeleteFinished()
954 void MainWindow::slotConfigureNotifications()
956 KNotifyConfigWidget::configure(
this);
960 void MainWindow::slotSaveMyself()
968 void MainWindow::slotNewToolbarConfig()
973 void MainWindow::slotNewConfig()
983 m_dock =
new Tray(
this);
993 if (clipboardTimer) {
995 clipboardTimer->start(1000);
997 clipboardTimer->stop();
1004 delete m_webinterface;
1006 }
else if (m_webinterface) {
1024 void MainWindow::slotToggleAutoPaste()
1030 clipboardTimer->start(1000);
1032 clipboardTimer->stop();
1033 m_autoPasteAction->setChecked(autoPaste);
1036 void MainWindow::slotCheckClipboard()
1038 const QString clipData = QApplication::clipboard()->text( QClipboard::Clipboard ).trimmed();
1040 if (clipData != lastClipboard) {
1041 lastClipboard = clipData;
1042 if (lastClipboard.isEmpty())
1045 const KUrl url = KUrl(lastClipboard);
1046 if (url.isValid() && !url.protocol().isEmpty() && url.hasPath() && url.hasHost() && !url.isLocalFile()) {
1048 const QString urlString = url.url();
1055 for (
int i = 0; i < types.count(); ++i) {
1056 const QRegExp::PatternSyntax syntax = (syntaxes[i] ==
AutoPasteModel::Wildcard ? QRegExp::Wildcard : QRegExp::RegExp2);
1057 QRegExp rx(patterns[i], cs, syntax);
1058 if (rx.exactMatch(urlString)) {
1071 void MainWindow::slotTrayKonquerorIntegration(
bool enable)
1073 slotKonquerorIntegration(enable);
1077 i18n(
"KGet has been temporarily disabled as download manager for Konqueror. "
1078 "If you want to disable it forever, go to Settings->Advanced and disable \"Use "
1079 "as download manager for Konqueror\"."),
1090 void MainWindow::slotKonquerorIntegration(
bool konquerorIntegration)
1092 KConfig cfgKonqueror(
"konquerorrc", KConfig::NoGlobals);
1093 cfgKonqueror.group(
"HTML Settings").writeEntry(
"DownloadManager",
1094 QString(konquerorIntegration ?
"kget" : QString()));
1095 cfgKonqueror.sync();
1098 void MainWindow::slotShowMenubar()
1100 if (m_menubarAction->isChecked())
1114 void MainWindow::slotTransferHistory()
1120 void MainWindow::slotTransferGroupSettings()
1132 void MainWindow::slotTransferSettings()
1145 void MainWindow::slotShowListLinks()
1164 if(e->spontaneous()) {
1185 event->setAccepted(KUrl::List::canDecode(event->mimeData())
1186 || event->mimeData()->hasText());
1191 KUrl::List list = KUrl::List::fromMimeData(event->mimeData());
1193 if (!list.isEmpty())
1195 if (list.count() == 1 && list.first().url().endsWith(QLatin1String(
".kgt")))
1197 int msgBoxResult = KMessageBox::questionYesNoCancel(
this, i18n(
"The dropped file is a KGet Transfer List"),
"KGet",
1198 KGuiItem(i18n(
"&Download"), KIcon(
"document-save")),
1199 KGuiItem(i18n(
"&Load transfer list"), KIcon(
"list-add")), KStandardGuiItem::cancel());
1201 if (msgBoxResult == 3)
1203 if (msgBoxResult == 4)
1208 if (list.count() == 1)
1220 #include "mainwindow.moc"
static void redownloadTransfer(TransferHandler *transfer)
Redownload a transfer.
Job::Status status() const
static TransferHandler * addTransfer(KUrl srcUrl, QString destDir=QString(), QString suggestedFileName=QString(), QString groupName=QString(), bool start=false)
Adds a new transfer to the KGet.
virtual void dropEvent(QDropEvent *)
static bool autoPaste()
Get AutoPaste.
virtual void hideEvent(QHideEvent *)
The job is stopped, but this also indicates that it stopped because an error occurred.
void closeTransferDetails(TransferHandler *transfer)
static void setKonquerorIntegration(bool v)
Set KonquerorIntegration.
virtual void start()
These are all Job-related functions.
void start()
These are all JobQueue-related functions.
static void settingsChanged()
This will be called when the settings have been changed.
static QList< TransferGroupHandler * > selectedTransferGroups()
static bool showMain()
Get ShowMain.
The job exited from its Running state successfully.
static QList< int > autoPastePatternSyntaxes()
Get AutoPastePatternSyntaxes.
static int globalUploadLimit()
Get GlobalUploadLimit.
static bool delTransfers(const QList< TransferHandler * > &transfers, DeleteMode mode=AutoDelete)
Removes multiple transfers from the KGet.
static void setGlobalDownloadLimit(int limit)
Sets the global download limit.
static bool konquerorIntegration()
Get KonquerorIntegration.
static void setAfterFinishAction(int v)
Set AfterFinishAction.
static QList< int > autoPasteTypes()
Get AutoPasteTypes.
virtual void dragEnterEvent(QDragEnterEvent *)
static bool speedLimit()
Get SpeedLimit.
static QPoint mainPosition()
Get MainPosition.
virtual QSize sizeHint() const
This class implements the main tray icon for kget.
static bool autoPasteCaseSensitive()
Get AutoPasteCaseSensitive.
void showTransferDetails(TransferHandler *transfer)
virtual void closeEvent(QCloseEvent *)
widget events
static bool afterFinishActionEnabled()
Get AfterFinishActionEnabled.
void setDropTargetVisible(bool shown, bool internal=true)
static QList< TransferGroupHandler * > allTransferGroups()
Gets all transfer-groups.
static QStringList autoPastePatterns()
Get AutoPastePatterns.
static QList< TransferHandler * > allTransfers()
Gets all transfers.
static void setFirstRun(bool v)
Set FirstRun.
MainWindow(bool showMainwindow=true, bool startWithoutAnimation=false, bool doTesting=false, QWidget *parent=0)
void setDownloading(bool downloading)
static void setGlobalUploadLimit(int limit)
Sets the global upload limit.
const KUrl & dest() const
static void save(QString filename=QString(), bool plain=false)
Exports all the transfers and groups to the given file.
static TransferTreeModel * model()
static TransferTreeSelectionModel * selectionModel()
void slotUpdateTitlePercent()
static QList< TransferHandler * > finishedTransfers()
const KUrl & source() const
static void setSuspendScheduler(bool isSuspended)
true suspends the scheduler, any events that would result in a reschedule are ignored false wakes up ...
static void setAutoPaste(bool v)
Set AutoPaste.
static void load(QString filename=QString())
Imports the transfers and groups included in the provided xml file.
void setName(const QString &name)
Set the group name.
void importUrl(const QString &url=QString())
static void setMainPosition(const QPoint &v)
Set MainPosition.
static bool enableSystemTray()
Get EnableSystemTray.
TransferGroupHandler * group() const
static int globalDownloadLimit()
Get GlobalDownloadLimit.
virtual void setSystemTrayDownloading(bool running)
static QList< TransferHandler * > selectedTransfers()
static void setShowMain(bool v)
Set ShowMain.
static void delGroups(QList< TransferGroupHandler * > groups, bool askUser=true)
Removes specific groups from the KGet.
static void showNewTransferDialog(const KUrl &url=KUrl())
void slotImportUrl(const QString &url)
void moveTransfer(Transfer *transfer, TransferGroup *destGroup, Transfer *after=0)
void setIconName(const QString &name)
Set the group's icon.
static void setAfterFinishActionEnabled(bool v)
Set AfterFinishActionEnabled.
static bool webinterfaceEnabled()
Get WebinterfaceEnabled.
const QList< TransferHandler * > transfers()
static KGet * self(MainWindow *mainWindow=0)
This is our KGet class.
static int afterFinishAction()
Get AfterFinishAction.
static bool showDropTarget()
Get ShowDropTarget.
static KNotification * showNotification(QWidget *parent, const QString &eventType, const QString &text, const QString &icon=QString("dialog-error"), const QString &title=i18n("KGet"), const KNotification::NotificationFlags &flags=KNotification::CloseOnTimeout)
Shows a knotification.
static bool firstRun()
Get FirstRun.
static void setSchedulerRunning(bool running=true)
if running == true starts the scheduler if running == false stops the scheduler
static bool schedulerRunning()
Returns true if the scheduler has running jobs.
virtual void showEvent(QShowEvent *)