Browse Source

Better Mac integration

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
0d4b55ca32
  1. 6
      src/GUI.cpp
  2. 19
      src/main.cpp
  3. 56
      src/qmacapplication.cpp
  4. 55
      src/qmacapplication.h
  5. 23
      src/src.pro

6
src/GUI.cpp

@ -65,6 +65,9 @@
#include "transferlistfilterswidget.h" #include "transferlistfilterswidget.h"
#include "propertieswidget.h" #include "propertieswidget.h"
#include "statusbar.h" #include "statusbar.h"
#ifdef Q_WS_MAC
#include "qmacapplication.h"
#endif
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#include <windows.h> #include <windows.h>
@ -129,6 +132,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString))); connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
connect(BTSession, SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool))); connect(BTSession, SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
connect(BTSession, SIGNAL(recursiveTorrentDownloadPossible(QTorrentHandle&)), this, SLOT(askRecursiveTorrentDownloadConfirmation(QTorrentHandle&))); connect(BTSession, SIGNAL(recursiveTorrentDownloadPossible(QTorrentHandle&)), this, SLOT(askRecursiveTorrentDownloadConfirmation(QTorrentHandle&)));
#ifdef Q_WS_MAC
connect(static_cast<QMacApplication*>(qApp), SIGNAL(newFileOpenMacEvent(QStringList)), this, SLOT(processParams(QStringList)));
#endif
qDebug("create tabWidget"); qDebug("create tabWidget");
tabs = new QTabWidget(); tabs = new QTabWidget();

19
src/main.cpp

@ -39,6 +39,9 @@
#include <QStyle> #include <QStyle>
#include <QSplashScreen> #include <QSplashScreen>
#include <QPushButton> #include <QPushButton>
#ifdef Q_WS_MAC
#include "qmacapplication.h"
#endif
#include "GUI.h" #include "GUI.h"
#include "ico.h" #include "ico.h"
#else #else
@ -70,7 +73,11 @@ const int UNLEN = 256;
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
QCoreApplication *app; QCoreApplication *app;
#else #else
#ifndef Q_WS_MAC
QApplication *app; QApplication *app;
#else
QMacApplication *app;
#endif
#endif #endif
class UsageDisplay: public QObject { class UsageDisplay: public QObject {
@ -170,11 +177,15 @@ void useStyle(QApplication *app, QString style){
// Main // Main
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
// Create Application // Create Application
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
app = new QCoreApplication(argc, argv); app = new QCoreApplication(argc, argv);
#else #else
#ifndef Q_WS_MAC
app = new QApplication(argc, argv); app = new QApplication(argc, argv);
#endif #else
app = new QMacApplication(argc, argv);
#endif
#endif
QString locale; QString locale;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
@ -353,6 +364,6 @@ int main(int argc, char *argv[]){
#endif #endif
qDebug("App was deleted! All good."); qDebug("App was deleted! All good.");
return ret; return ret;
} }

56
src/qmacapplication.cpp

@ -0,0 +1,56 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifdef Q_WS_MAC
#include <QFileOpenEvent>
#include "qmacapplication.h"
QMacApplication::QMacApplication(int &argc, char** argv) :
QApplication(argc, argv)
{
}
bool QMacApplication::event(QEvent * event) {
switch (event->type()) {
case QEvent::FileOpen:
{
QStringList paths;
paths << static_cast<QFileOpenEvent *>(event)->file();
emit newFileOpenMacEvent(paths);
return true;
}
default:
return QApplication::event(event);
}
}
#endif

55
src/qmacapplication.h

@ -0,0 +1,55 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef QMACAPPLICATION_H
#define QMACAPPLICATION_H
#ifdef Q_WS_MAC
#include <QApplication>
#include <QStringList>
class QMacApplication : public QApplication
{
Q_OBJECT
public:
explicit QMacApplication(int &argc, char** argv);
signals:
void newFileOpenMacEvent(QStringList paths);
protected:
bool event(QEvent *);
};
#endif
#endif // QMACAPPLICATION_H

23
src/src.pro

@ -270,8 +270,10 @@ HEADERS += misc.h \
bandwidthscheduler.h \ bandwidthscheduler.h \
scannedfoldersmodel.h scannedfoldersmodel.h
contains(DEFINES, DISABLE_GUI):HEADERS += headlessloader.h contains(DEFINES, DISABLE_GUI) {
else:HEADERS += GUI.h \ HEADERS += headlessloader.h
} else {
HEADERS += GUI.h \
feedList.h \ feedList.h \
supportedengines.h \ supportedengines.h \
transferlistwidget.h \ transferlistwidget.h \
@ -312,8 +314,13 @@ else:HEADERS += GUI.h \
pieceavailabilitybar.h \ pieceavailabilitybar.h \
advancedsettings.h \ advancedsettings.h \
cookiesdlg.h cookiesdlg.h
macx {
HEADERS += qmacapplication.h
}
}
!contains(DEFINES, DISABLE_GUI):FORMS += ui/mainwindow.ui \ !contains(DEFINES, DISABLE_GUI) {
FORMS += ui/mainwindow.ui \
ui/options.ui \ ui/options.ui \
ui/about.ui \ ui/about.ui \
ui/createtorrent.ui \ ui/createtorrent.ui \
@ -333,6 +340,7 @@ else:HEADERS += GUI.h \
ui/peer.ui \ ui/peer.ui \
ui/confirmdeletiondlg.ui \ ui/confirmdeletiondlg.ui \
ui/cookiesdlg.ui ui/cookiesdlg.ui
}
SOURCES += main.cpp \ SOURCES += main.cpp \
bittorrent.cpp \ bittorrent.cpp \
@ -346,7 +354,8 @@ SOURCES += main.cpp \
scannedfoldersmodel.cpp \ scannedfoldersmodel.cpp \
misc.cpp misc.cpp
!contains(DEFINES, DISABLE_GUI):SOURCES += GUI.cpp \ !contains(DEFINES, DISABLE_GUI) {
SOURCES += GUI.cpp \
options_imp.cpp \ options_imp.cpp \
createtorrent_imp.cpp \ createtorrent_imp.cpp \
searchengine.cpp \ searchengine.cpp \
@ -361,5 +370,9 @@ SOURCES += main.cpp \
cookiesdlg.cpp \ cookiesdlg.cpp \
trackerlist.cpp trackerlist.cpp
DESTDIR = . macx {
HEADERS += qmacapplication.cpp
}
}
DESTDIR = .

Loading…
Cancel
Save