mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
Some Win32 improvements
This commit is contained in:
parent
bb606e0b2f
commit
5c4450f3cd
5 changed files with 47 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
|||
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
Normal file
BIN
src/qbittorrent.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
1
src/qbittorrent.rc
Normal file
1
src/qbittorrent.rc
Normal file
|
@ -0,0 +1 @@
|
|||
IDI_ICON1 ICON DISCARDABLE "qbittorrent.ico"
|
|
@ -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…
Reference in a new issue