Browse Source

Make QtDBus dependency optional

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
b6c3189fe3
  1. 1
      Changelog
  2. 43
      configure
  3. 2
      qbittorrent.qc
  4. 31
      qcm/qt-dbus.qcm
  5. 24
      src/mainwindow.cpp
  6. 4
      src/misc.cpp
  7. 8
      src/powermanagement/powermanagement.cpp
  8. 22
      src/powermanagement/powermanagement.h
  9. 6
      src/powermanagement/powermanagement.pri
  10. 7
      src/preferences/options_imp.cpp
  11. 2
      unixconf.pri

1
Changelog

@ -8,6 +8,7 @@
- FEATURE: Added option to disable program exit confirmation - FEATURE: Added option to disable program exit confirmation
- FEATURE: Added per-torrent ratio limiting (Christian Kandeler) - FEATURE: Added per-torrent ratio limiting (Christian Kandeler)
- BUGFIX: Fix compilation with namespaced Qt (Christian Kandeler) - BUGFIX: Fix compilation with namespaced Qt (Christian Kandeler)
- OTHER: Make QtDBus dependency optional (X11)
* Sun Jan 9 2011 - Christophe Dumez <chris@qbittorrent.org> - v2.6.0 * Sun Jan 9 2011 - Christophe Dumez <chris@qbittorrent.org> - v2.6.0
- FEATURE: Use system icons (Linux, Qt >= 4.6) - FEATURE: Use system icons (Linux, Qt >= 4.6)

43
configure vendored

@ -22,6 +22,7 @@ Dependency options:
--disable-gui Disable qBittorrent --disable-gui Disable qBittorrent
Graphical user interface for Graphical user interface for
headless running headless running
--disable-qt-dbus Disable use of qt-dbus
--with-libboost-inc=[path] Path to libboost include --with-libboost-inc=[path] Path to libboost include
files files
--with-libboost-lib=[path] Path to libboost library --with-libboost-lib=[path] Path to libboost library
@ -162,6 +163,11 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
--disable-qt-dbus)
QC_DISABLE_qt_dbus="Y"
shift
;;
--with-libboost-inc=*) --with-libboost-inc=*)
QC_WITH_LIBBOOST_INC=$optarg QC_WITH_LIBBOOST_INC=$optarg
shift shift
@ -215,6 +221,7 @@ echo DATADIR=$DATADIR
echo EX_QTDIR=$EX_QTDIR echo EX_QTDIR=$EX_QTDIR
echo QC_ENABLE_DEBUG=$QC_ENABLE_DEBUG echo QC_ENABLE_DEBUG=$QC_ENABLE_DEBUG
echo QC_DISABLE_GUI=$QC_DISABLE_GUI echo QC_DISABLE_GUI=$QC_DISABLE_GUI
echo QC_DISABLE_qt_dbus=$QC_DISABLE_qt_dbus
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
echo QC_WITH_LIBBOOST_LIB=$QC_WITH_LIBBOOST_LIB echo QC_WITH_LIBBOOST_LIB=$QC_WITH_LIBBOOST_LIB
echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify
@ -355,6 +362,38 @@ public:
return(QT_VERSION >= 0x040500); return(QT_VERSION >= 0x040500);
} }
}; };
#line 1 "qt-dbus.qcm"
/*
-----BEGIN QCMOD-----
name: qt-dbus
-----END QCMOD-----
*/
// see Conf::findPkgConfig
class qc_qt_dbus : public ConfObj
{
public:
qc_qt_dbus(Conf *c) : ConfObj(c) {}
QString name() const { return "QtDBus >= 4.5"; }
QString shortname() const { return "qt-dbus"; }
QString checkString() const {
if(!conf->getenv("QC_DISABLE_qt_dbus").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty())
return "";
return ConfObj::checkString();
}
bool exec(){
if(!conf->getenv("QC_DISABLE_qt_dbus").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty())
return false;
QStringList incs;
QString req_ver = "4.5.0";
QString version, libs, other;
VersionMode mode = VersionMin;
if(conf->findPkgConfig("QtDBus", mode, req_ver, &version, &incs, &libs, &other)) {
conf->addExtra("CONFIG += dbus");
return true;
}
return false;
}
};
#line 1 "pkg-config.qcm" #line 1 "pkg-config.qcm"
/* /*
-----BEGIN QCMOD----- -----BEGIN QCMOD-----
@ -645,6 +684,9 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_qt4(conf); o = new qc_qt4(conf);
o->required = true; o->required = true;
o->disabled = false; o->disabled = false;
o = new qc_qt_dbus(conf);
o->required = false;
o->disabled = false;
o = new qc_pkg_config(conf); o = new qc_pkg_config(conf);
o->required = true; o->required = true;
o->disabled = false; o->disabled = false;
@ -1610,6 +1652,7 @@ export DATADIR
export EX_QTDIR export EX_QTDIR
export QC_ENABLE_DEBUG export QC_ENABLE_DEBUG
export QC_DISABLE_GUI export QC_DISABLE_GUI
export QC_DISABLE_qt_dbus
export QC_WITH_LIBBOOST_INC export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBBOOST_LIB export QC_WITH_LIBBOOST_LIB
export QC_DISABLE_libnotify export QC_DISABLE_libnotify

2
qbittorrent.qc

@ -6,6 +6,8 @@
<dep type='qt4'> <dep type='qt4'>
<required/> <required/>
</dep> </dep>
<dep type='qt-dbus'>
</dep>
<dep type='pkg-config'> <dep type='pkg-config'>
<required/> <required/>
</dep> </dep>

31
qcm/qt-dbus.qcm

@ -0,0 +1,31 @@
/*
-----BEGIN QCMOD-----
name: qt-dbus
-----END QCMOD-----
*/
// see Conf::findPkgConfig
class qc_qt_dbus : public ConfObj
{
public:
qc_qt_dbus(Conf *c) : ConfObj(c) {}
QString name() const { return "QtDBus >= 4.5"; }
QString shortname() const { return "qt-dbus"; }
QString checkString() const {
if(!conf->getenv("QC_DISABLE_qt_dbus").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty())
return "";
return ConfObj::checkString();
}
bool exec(){
if(!conf->getenv("QC_DISABLE_qt_dbus").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty())
return false;
QStringList incs;
QString req_ver = "4.5.0";
QString version, libs, other;
VersionMode mode = VersionMin;
if(conf->findPkgConfig("QtDBus", mode, req_ver, &version, &incs, &libs, &other)) {
conf->addExtra("CONFIG += dbus");
return true;
}
return false;
}
};

24
src/mainwindow.cpp

@ -43,9 +43,6 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QShortcut> #include <QShortcut>
#include <QScrollBar> #include <QScrollBar>
#ifdef Q_WS_X11
#include <QDBusInterface>
#endif
#include "mainwindow.h" #include "mainwindow.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
@ -235,11 +232,14 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo
autoShutdownGroup->setExclusive(true); autoShutdownGroup->setExclusive(true);
autoShutdownGroup->addAction(actionAutoShutdown_Disabled); autoShutdownGroup->addAction(actionAutoShutdown_Disabled);
autoShutdownGroup->addAction(actionAutoExit_qBittorrent); autoShutdownGroup->addAction(actionAutoExit_qBittorrent);
#if !defined(Q_WS_X11) || defined(QT_DBUS_LIB)
autoShutdownGroup->addAction(actionAutoShutdown_system); autoShutdownGroup->addAction(actionAutoShutdown_system);
autoShutdownGroup->addAction(actionAutoSuspend_system); autoShutdownGroup->addAction(actionAutoSuspend_system);
actionAutoExit_qBittorrent->setChecked(pref.shutdownqBTWhenDownloadsComplete());
actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete()); actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete());
actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete()); actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete());
#endif
actionAutoExit_qBittorrent->setChecked(pref.shutdownqBTWhenDownloadsComplete());
if(!autoShutdownGroup->checkedAction()) if(!autoShutdownGroup->checkedAction())
actionAutoShutdown_Disabled->setChecked(true); actionAutoShutdown_Disabled->setChecked(true);
@ -997,12 +997,12 @@ void MainWindow::loadPreferences(bool configure_session) {
if(pref.preventFromSuspend()) if(pref.preventFromSuspend())
{ {
preventTimer->start(PREVENT_SUSPEND_INTERVAL); preventTimer->start(PREVENT_SUSPEND_INTERVAL);
} }
else else
{ {
preventTimer->stop(); preventTimer->stop();
m_pwr->setActivityState(false); m_pwr->setActivityState(false);
} }
const uint new_refreshInterval = pref.getRefreshInterval(); const uint new_refreshInterval = pref.getRefreshInterval();
@ -1336,9 +1336,9 @@ void MainWindow::on_actionAutoShutdown_system_toggled(bool enabled)
void MainWindow::checkForActiveTorrents() void MainWindow::checkForActiveTorrents()
{ {
const TorrentStatusReport report = transferList->getSourceModel()->getTorrentStatusReport(); const TorrentStatusReport report = transferList->getSourceModel()->getTorrentStatusReport();
if(report.nb_active > 0) // Active torrents are present; prevent system from suspend if(report.nb_active > 0) // Active torrents are present; prevent system from suspend
m_pwr->setActivityState(true); m_pwr->setActivityState(true);
else else
m_pwr->setActivityState(false); m_pwr->setActivityState(false);
} }

4
src/misc.cpp

@ -71,7 +71,7 @@ const int UNLEN = 256;
#endif #endif
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusMessage> #include <QDBusMessage>
#endif #endif
@ -206,7 +206,7 @@ long long misc::freeDiskSpaceOnPath(QString path) {
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
void misc::shutdownComputer(bool sleep) { void misc::shutdownComputer(bool sleep) {
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
// Use dbus to power off the system // Use dbus to power off the system
// dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown // dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus()); QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());

8
src/powermanagement/powermanagement.cpp

@ -30,7 +30,7 @@
#include <QtGlobal> #include <QtGlobal>
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
#include "powermanagement_x11.h" #include "powermanagement_x11.h"
#endif #endif
#include "powermanagement.h" #include "powermanagement.h"
@ -45,7 +45,7 @@
PowerManagement::PowerManagement(QObject *parent) : QObject(parent), m_busy(false) PowerManagement::PowerManagement(QObject *parent) : QObject(parent), m_busy(false)
{ {
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
m_inhibitor = new PowerManagementInhibitor(this); m_inhibitor = new PowerManagementInhibitor(this);
#endif #endif
} }
@ -67,7 +67,7 @@ void PowerManagement::setBusy()
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#elif defined(Q_WS_X11) #elif defined(Q_WS_X11) && defined(QT_DBUS_LIB)
m_inhibitor->RequestBusy(); m_inhibitor->RequestBusy();
#elif defined(Q_WS_MAC) #elif defined(Q_WS_MAC)
IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID); IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID);
@ -82,7 +82,7 @@ void PowerManagement::setIdle()
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
SetThreadExecutionState(ES_CONTINUOUS); SetThreadExecutionState(ES_CONTINUOUS);
#elif defined(Q_WS_X11) #elif defined(Q_WS_X11) && defined(QT_DBUS_LIB)
m_inhibitor->RequestIdle(); m_inhibitor->RequestIdle();
#elif defined(Q_WS_MAC) #elif defined(Q_WS_MAC)
IOPMAssertionRelease(m_assertionID); IOPMAssertionRelease(m_assertionID);

22
src/powermanagement/powermanagement.h

@ -38,32 +38,32 @@
#include <IOKit/pwr_mgt/IOPMLib.h> #include <IOKit/pwr_mgt/IOPMLib.h>
#endif #endif
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
// Require DBus // Require DBus
class PowerManagementInhibitor; class PowerManagementInhibitor;
#endif #endif
class PowerManagement : public QObject class PowerManagement : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
PowerManagement(QObject *parent = 0); PowerManagement(QObject *parent = 0);
virtual ~PowerManagement(); virtual ~PowerManagement();
void setActivityState(bool busy); void setActivityState(bool busy);
private: private:
bool m_busy; bool m_busy;
void setBusy(); void setBusy();
void setIdle(); void setIdle();
#ifdef Q_WS_X11 #if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
PowerManagementInhibitor *m_inhibitor; PowerManagementInhibitor *m_inhibitor;
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
IOPMAssertionID m_assertionID; IOPMAssertionID m_assertionID;
#endif #endif
}; };

6
src/powermanagement/powermanagement.pri

@ -3,7 +3,7 @@ INCLUDEPATH += $$PWD
HEADERS += $$PWD/powermanagement.h HEADERS += $$PWD/powermanagement.h
SOURCES += $$PWD/powermanagement.cpp SOURCES += $$PWD/powermanagement.cpp
unix:!macx { unix:!macx:dbus {
HEADERS += $$PWD/powermanagement_x11.h HEADERS += $$PWD/powermanagement_x11.h
SOURCES += $$PWD/powermanagement_x11.cpp SOURCES += $$PWD/powermanagement_x11.cpp
} }

7
src/preferences/options_imp.cpp

@ -132,6 +132,9 @@ options_imp::options_imp(QWidget *parent):
connect(checkShowSplash, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkShowSplash, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkProgramExitConfirm, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkProgramExitConfirm, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkPreventFromSuspend, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkPreventFromSuspend, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#if defined(Q_WS_X11) && !defined(QT_DBUS_LIB)
checkPreventFromSuspend->setDisabled(true);
#endif
// Downloads tab // Downloads tab
connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textTempPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
@ -231,7 +234,7 @@ void options_imp::initializeLanguageCombo()
QLocale locale(localeStr); QLocale locale(localeStr);
const QString country = locale.name().split("_").last().toLower(); const QString country = locale.name().split("_").last().toLower();
QString language_name = languageToLocalizedString(locale.language(), country); QString language_name = languageToLocalizedString(locale.language(), country);
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name()); comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name());
qDebug() << "Supported locale:" << locale.name(); qDebug() << "Supported locale:" << locale.name();
} }
} }
@ -917,7 +920,7 @@ bool options_imp::isSlashScreenDisabled() const {
} }
bool options_imp::preventFromSuspend() const { bool options_imp::preventFromSuspend() const {
return checkPreventFromSuspend->isChecked(); return checkPreventFromSuspend->isChecked();
} }
bool options_imp::preAllocateAllFiles() const { bool options_imp::preAllocateAllFiles() const {

2
unixconf.pri

@ -2,7 +2,7 @@
include(conf.pri) include(conf.pri)
# COMPILATION SPECIFIC # COMPILATION SPECIFIC
!nox { !nox:dbus {
QT += dbus QT += dbus
} }
QMAKE_LFLAGS_APP += -rdynamic QMAKE_LFLAGS_APP += -rdynamic

Loading…
Cancel
Save