• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.14
  • kdenetwork
  • kget
  • ui
tray.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2009 by Fabian Henze <flyser42 AT gmx DOT de>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 */
10 #include "ui/tray.h"
11 #include "mainwindow.h"
12 #include "ui/newtransferdialog.h"
13 #include <kaboutdata.h>
14 #include <kactioncollection.h>
15 #include <kapplication.h>
16 #include <kmenu.h>
17 #include <kdebug.h>
18 
19 #include <QClipboard>
20 
24 Tray::Tray(MainWindow * parent)
25  : KStatusNotifierItem(parent)
26 {
27  // set up the context menu
28  KMenu * cm = contextMenu();
29  cm->addAction( parent->actionCollection()->action("new_download") );
30  cm->addAction( parent->actionCollection()->action("import_links") );
31  cm->addSeparator();
32  cm->addAction( parent->actionCollection()->action("start_all_download") );
33  cm->addAction( parent->actionCollection()->action("stop_all_download") );
34  cm->addSeparator();
35  cm->addAction( parent->actionCollection()->action("konqueror_integration") );
36  cm->addAction( parent->actionCollection()->action("options_configure") );
37 
38  // Set up basic tray parameters
39  setCategory(ApplicationStatus);
40  setIconByName("kget");
41  setTitle(i18n("KGet"));
42  setContextMenu(cm);
43  setAssociatedWidget(parent);
44  setToolTipIconByName("kget");
45  setToolTipTitle(i18n("Download Manager"));
46  // Not of much use atm, but maybe we want to set this later?
47  // setToolTipSubTitle("[..]");
48 
49  // filter middle mouse clicks to ask scheduler to paste URL
50  connect( this, SIGNAL(secondaryActivateRequested(QPoint)),
51  this, SLOT(slotActivated()) );
52 }
53 
54 
55 // filter middle mouse clicks to ask scheduler to paste URL
56 void Tray::slotActivated()
57 {
58  // Here we paste the transfer
59  QString newtransfer = QApplication::clipboard()->text();
60  newtransfer = newtransfer.trimmed();
61 
62  if(!newtransfer.isEmpty())
63  NewTransferDialogHandler::showNewTransferDialog(KUrl(newtransfer));
64 }
65 
66 // display a play icon when downloading and
67 // switch between Active or Passive state
68 void Tray::setDownloading( bool downloading )
69 {
70  kDebug(5001) << "Tray::setDownloading";
71 
72  if (downloading)
73  {
74  if (status() == KStatusNotifierItem::Active)
75  return;
76  setStatus(KStatusNotifierItem::Active);
77  setOverlayIconByName("media-playback-start");
78  }
79  else
80  {
81  if (status() == KStatusNotifierItem::Passive)
82  return;
83  setStatus(KStatusNotifierItem::Passive);
84  setOverlayIconByName(QString());
85  }
86 }
87 
88 bool Tray::isDownloading()
89 {
90  // KStatusNotifierItem::NeedsAttention is not handled here,
91  // as we do not use it.
92  return (status() == KStatusNotifierItem::Active);
93 }
94 
95 #include "tray.moc"
Tray::Tray
Tray(MainWindow *parent)
class Tray Reimplementation of the KStatusNotifierItem class
Definition: tray.cpp:24
QPoint
Tray::setDownloading
void setDownloading(bool downloading)
Definition: tray.cpp:68
QApplication::clipboard
QClipboard * clipboard()
QString::isEmpty
bool isEmpty() const
QString::trimmed
QString trimmed() const
mainwindow.h
newtransferdialog.h
QString
tray.h
QClipboard::text
QString text(Mode mode) const
NewTransferDialogHandler::showNewTransferDialog
static void showNewTransferDialog(const KUrl &url=KUrl())
Definition: newtransferdialog.cpp:493
KStatusNotifierItem
Tray::isDownloading
bool isDownloading()
Definition: tray.cpp:88
MainWindow
The main window of KGet.
Definition: mainwindow.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:28:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal