[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/videocatcher
From: Jonas Emanuel Müller <zanoi () zanoi ! net>
Date: 2010-05-20 0:18:40
Message-ID: 20100520001840.B04BCAC8BB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1128689 by jonasemuller:
made notification area (KStatusNotifierItem) dependent on KDE version
M +1 -1 CHANGELOG
M +2 -0 src/main.cpp
M +30 -2 src/mainwindowkde.cpp
M +3 -0 src/mainwindowkde.h
--- trunk/playground/pim/videocatcher/CHANGELOG #1128688:1128689
@@ -1,5 +1,5 @@
0.1.4 Now somewhere else in KDE SVN!
-- Notification area (a.k.a. system tray) now supported
+- Notification area (a.k.a. system tray) now supported (only in KDE 4.4 and above)
- OPML import now possible
- Automatically detect already downloaded episodes when adding new channel
- Current download speed shown in notification area
--- trunk/playground/pim/videocatcher/src/main.cpp #1128688:1128689
@@ -91,9 +91,11 @@
window->show();
int result = app.exec();
+#if KDE_IS_VERSION(4,4,0)
//need to delete window manually since WA_DeleteOnClose is set to false
//and all database objects need to be destroyed before program exits
delete window;
+#endif
return result;
}
--- trunk/playground/pim/videocatcher/src/mainwindowkde.cpp #1128688:1128689
@@ -45,9 +45,12 @@
#include <KGlobal>
#include <KComponentData>
#include <KMenu>
-#include <KStatusNotifierItem>
#include <KFileDialog>
+#if KDE_IS_VERSION(4,4,0)
+#include <KStatusNotifierItem>
+#endif
+
#include <QSqlRelationalDelegate>
#include <QSqlError>
#include <QHeaderView>
@@ -96,6 +99,7 @@
connect(episodeView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showEpisodeViewContextMenu(const QPoint&)));
+#if KDE_IS_VERSION(4,4,0)
qApp->setQuitOnLastWindowClosed(false);
this->setAttribute(Qt::WA_DeleteOnClose, false);
@@ -113,6 +117,7 @@
cm->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Quit)));
statusNotifier->setToolTip("videocatcher", "Videocatcher", "Not downloading");
+#endif
//workaround for Qt SQLite bug
while (originalEpisodeModel->canFetchMore()) {
@@ -129,7 +134,11 @@
void MainWindow::setupActions()
{
//TODO: add status tips
+#if KDE_IS_VERSION(4,4,0)
KStandardAction::quit(this, SLOT(quit()), actionCollection());
+#else
+ KStandardAction::quit(this, SLOT(close()), actionCollection());
+#endif
KStandardAction::preferences(this, SLOT(configure()), actionCollection());
KAction *importChannelsAction = new KAction(i18n("&Import from File"), this);
@@ -589,7 +598,9 @@
++i;
}
int downloadSpeed = (sum/1024.0)+0.5; //change to kilobytes and round it
+#if KDE_IS_VERSION(4,4,0)
statusNotifier->setToolTip("videocatcher", "Videocatcher", QString("Download \
speed %1 KiB/s").arg(downloadSpeed)); +#endif
}
void MainWindow::downloadEpisodeResult(KJob *job)
@@ -610,12 +621,14 @@
originalEpisodeModel->setStatus(index, Episode_Status_Downloaded);
}
+#if KDE_IS_VERSION(4,4,0)
//remove from download speed statistic
downloadSpeeds->remove(job);
if(downloadSpeeds->isEmpty()) {
kDebug() << "downloadSpeeds is empty";
statusNotifier->setToolTip("videocatcher", "Videocatcher", "Not \
downloading"); }
+#endif
jobs->remove(job);
@@ -641,11 +654,13 @@
KJob* job;
job = jobs->key(url);
if(job) { //does download exist?
+#if KDE_IS_VERSION(4,4,0)
//remove from download speed statistic
downloadSpeeds->remove(job);
if(downloadSpeeds->isEmpty()) {
statusNotifier->setToolTip("videocatcher", "Videocatcher", "Not \
downloading"); }
+#endif
job->kill();
jobs->remove(job);
@@ -847,15 +862,29 @@
void MainWindow::closeEvent(QCloseEvent *event)
{
+#if KDE_IS_VERSION(4,4,0)
// if the event comes from out the application (close event) we hide the \
application window
// if the event comes from the application (system shutdown) we say goodbye
if(event->spontaneous()) {
event->ignore();
hide();
}
+#else
+ QModelIndexList downloading = originalEpisodeModel->findDownloadingEpisodes();
+ if(!downloading.empty()) {
+ int r = KMessageBox::warningYesNo(this, i18n("All currently active downloads \
will be canceled. Are you sure you want to quit Videocatcher?"), i18n("Confirm \
Quit"), KStandardGuiItem::quit(), KStandardGuiItem::cancel()); + if( r == \
KMessageBox::Yes) { + cancelAllEpisodeDownloads();
+ event->accept();
+ } else if (r == KMessageBox::No) {
+ event->ignore();
}
+ }
+#endif
+}
+// is only used if KDE version is 4.4 or greater (see definition of quit action)
void MainWindow::quit()
{
QModelIndexList downloading = originalEpisodeModel->findDownloadingEpisodes();
@@ -869,7 +898,6 @@
}
}
- //Settings::self()->writeConfig();
qApp->quit();
}
--- trunk/playground/pim/videocatcher/src/mainwindowkde.h #1128688:1128689
@@ -49,6 +49,7 @@
#include <KXmlGuiWindow>
#include <KLineEdit>
+#include <kdeversion.h>
#include <QList>
#include <QMap>
@@ -120,7 +121,9 @@
QLabel *episodeLabel;
QMap<KJob *, QString> *jobs;
Ui::ConfigureWidget configureWidget;
+#if KDE_IS_VERSION(4,4,0)
KStatusNotifierItem *statusNotifier;
+#endif
QMap<KJob *, unsigned long> *downloadSpeeds;
// The search bar
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic