Browse Source

Some Win32 improvements

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
5c4450f3cd
  1. 9
      src/GUI.cpp
  2. 36
      src/preferences.h
  3. BIN
      src/qbittorrent.ico
  4. 1
      src/qbittorrent.rc
  5. 1
      src/src.pro

9
src/GUI.cpp

@ -218,6 +218,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis @@ -218,6 +218,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
qDebug("GUI Built");
#ifdef Q_WS_WIN
if(!Preferences::isFileAssocOk()) {
if(QMessageBox::question(0, tr("Torrent file association"),
tr("qBittorrent is not the default application to open torrent files.\nDo you want to associate qBittorrent to torrent files?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
Preferences::setFileAssoc();
}
}
#endif
}
// Destructor

36
src/preferences.h

@ -37,6 +37,12 @@ @@ -37,6 +37,12 @@
#include <QDir>
#include <QTime>
#ifndef DISABLE_GUI
#include <QApplication>
#else
#include <QCoreApplication>
#endif
#define QBT_REALM "Web UI Access"
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
@ -993,6 +999,36 @@ public: @@ -993,6 +999,36 @@ public:
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Win32/PythonPath"), "").toString();
}
static bool isFileAssocOk() {
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
if(settings.value(".torrent/Default").toString() != "qBittorrent") {
qDebug(".torrent != qBittorrent");
return false;
}
qDebug("Checking shell command");
QString shell_command = settings.value("qBittorrent/shell/open/command/Default", "").toString();
qDebug("Shell command is: %s", qPrintable(shell_command));
QRegExp exe_reg("\"([^\"]+)\".*");
if(exe_reg.indexIn(shell_command) < 0)
return false;
QString assoc_exe = exe_reg.cap(1);
qDebug("exe: %s", qPrintable(assoc_exe));
return (assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) == 0);
}
static void setFileAssoc() {
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
settings.setValue(".torrent/Default", "qBittorrent");
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
settings.setValue("qBittorrent/shell/Default", "open");
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
settings.setValue("qBittorrent/shell/open/command/Default", command_str);
settings.setValue("qBittorrent/Content Type/Default", "application/x-bittorrent");
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",0";
settings.setValue("qBittorrent/DefaultIcon/Default", icon_str);
}
#endif
};

BIN
src/qbittorrent.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

1
src/qbittorrent.rc

@ -0,0 +1 @@ @@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "qbittorrent.ico"

1
src/src.pro

@ -133,6 +133,7 @@ DEFINES += QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS @@ -133,6 +133,7 @@ DEFINES += QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS
# win32:LIBS += -ltorrent -lboost_system
# win32:LIBS += -lz ?
win32 {
RC_FILE = qbittorrent.rc
# Adapt these paths on Windows
LIBS += C:/qbittorrent/libs/libtorrent.lib \

Loading…
Cancel
Save