mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-12 15:57:57 +00:00
Merge pull request #2046 from pmzqla/toolbar-menu
Allow minor toolbar customizations
This commit is contained in:
commit
d888d4e897
@ -124,6 +124,8 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine): QMai
|
|||||||
#endif
|
#endif
|
||||||
setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")));
|
setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")));
|
||||||
|
|
||||||
|
addToolbarContextMenu();
|
||||||
|
|
||||||
actionOpen->setIcon(IconProvider::instance()->getIcon("list-add"));
|
actionOpen->setIcon(IconProvider::instance()->getIcon("list-add"));
|
||||||
actionDownload_from_URL->setIcon(IconProvider::instance()->getIcon("insert-link"));
|
actionDownload_from_URL->setIcon(IconProvider::instance()->getIcon("insert-link"));
|
||||||
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
||||||
@ -356,6 +358,97 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine): QMai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addToolbarContextMenu()
|
||||||
|
{
|
||||||
|
const Preferences* const pref = Preferences::instance();
|
||||||
|
toolbarMenu = new QMenu(this);
|
||||||
|
|
||||||
|
toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(toolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(toolbarMenuRequested(QPoint)));
|
||||||
|
|
||||||
|
QAction *iconsOnly = new QAction(tr("Icons Only"), toolbarMenu);
|
||||||
|
connect(iconsOnly, SIGNAL(triggered()), this, SLOT(toolbarIconsOnly()));
|
||||||
|
QAction *textOnly = new QAction(tr("Text Only"), toolbarMenu);
|
||||||
|
connect(textOnly, SIGNAL(triggered()), this, SLOT(toolbarTextOnly()));
|
||||||
|
QAction *textBesideIcons = new QAction(tr("Text Alongside Icons"), toolbarMenu);
|
||||||
|
connect(textBesideIcons, SIGNAL(triggered()), this, SLOT(toolbarTextBeside()));
|
||||||
|
QAction *textUnderIcons = new QAction(tr("Text Under Icons"), toolbarMenu);
|
||||||
|
connect(textUnderIcons, SIGNAL(triggered()), this, SLOT(toolbarTextUnder()));
|
||||||
|
QAction *followSystemStyle = new QAction(tr("Follow System Style"), toolbarMenu);
|
||||||
|
connect(followSystemStyle, SIGNAL(triggered()), this, SLOT(toolbarFollowSystem()));
|
||||||
|
toolbarMenu->addAction(iconsOnly);
|
||||||
|
toolbarMenu->addAction(textOnly);
|
||||||
|
toolbarMenu->addAction(textBesideIcons);
|
||||||
|
toolbarMenu->addAction(textUnderIcons);
|
||||||
|
toolbarMenu->addAction(followSystemStyle);
|
||||||
|
QActionGroup *textPositionGroup = new QActionGroup(toolbarMenu);
|
||||||
|
textPositionGroup->addAction(iconsOnly);
|
||||||
|
iconsOnly->setCheckable(true);
|
||||||
|
textPositionGroup->addAction(textOnly);
|
||||||
|
textOnly->setCheckable(true);
|
||||||
|
textPositionGroup->addAction(textBesideIcons);
|
||||||
|
textBesideIcons->setCheckable(true);
|
||||||
|
textPositionGroup->addAction(textUnderIcons);
|
||||||
|
textUnderIcons->setCheckable(true);
|
||||||
|
textPositionGroup->addAction(followSystemStyle);
|
||||||
|
followSystemStyle->setCheckable(true);
|
||||||
|
|
||||||
|
const Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(pref->getToolbarTextPosition());
|
||||||
|
if (buttonStyle >= Qt::ToolButtonIconOnly && buttonStyle <= Qt::ToolButtonFollowStyle)
|
||||||
|
toolBar->setToolButtonStyle(buttonStyle);
|
||||||
|
switch (buttonStyle) {
|
||||||
|
case Qt::ToolButtonIconOnly:
|
||||||
|
iconsOnly->setChecked(true);
|
||||||
|
break;
|
||||||
|
case Qt::ToolButtonTextOnly:
|
||||||
|
textOnly->setChecked(true);
|
||||||
|
break;
|
||||||
|
case Qt::ToolButtonTextBesideIcon:
|
||||||
|
textBesideIcons->setChecked(true);
|
||||||
|
break;
|
||||||
|
case Qt::ToolButtonTextUnderIcon:
|
||||||
|
textUnderIcons->setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
followSystemStyle->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarMenuRequested(QPoint point)
|
||||||
|
{
|
||||||
|
toolbarMenu->exec(toolBar->mapToGlobal(point));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarIconsOnly()
|
||||||
|
{
|
||||||
|
toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||||
|
Preferences::instance()->setToolbarTextPosition(Qt::ToolButtonIconOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarTextOnly()
|
||||||
|
{
|
||||||
|
toolBar->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
||||||
|
Preferences::instance()->setToolbarTextPosition(Qt::ToolButtonTextOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarTextBeside()
|
||||||
|
{
|
||||||
|
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
|
Preferences::instance()->setToolbarTextPosition(Qt::ToolButtonTextBesideIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarTextUnder()
|
||||||
|
{
|
||||||
|
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
|
Preferences::instance()->setToolbarTextPosition(Qt::ToolButtonTextUnderIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toolbarFollowSystem()
|
||||||
|
{
|
||||||
|
toolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||||
|
Preferences::instance()->setToolbarTextPosition(Qt::ToolButtonFollowStyle);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::shutdownCleanUp()
|
void MainWindow::shutdownCleanUp()
|
||||||
{
|
{
|
||||||
qDebug("GUI destruction");
|
qDebug("GUI destruction");
|
||||||
@ -410,6 +503,7 @@ void MainWindow::shutdownCleanUp()
|
|||||||
delete switchSearchShortcut2;
|
delete switchSearchShortcut2;
|
||||||
delete switchTransferShortcut;
|
delete switchTransferShortcut;
|
||||||
delete switchRSSShortcut;
|
delete switchRSSShortcut;
|
||||||
|
delete toolbarMenu;
|
||||||
IconProvider::drop();
|
IconProvider::drop();
|
||||||
Preferences::drop();
|
Preferences::drop();
|
||||||
qDebug("Finished GUI destruction");
|
qDebug("Finished GUI destruction");
|
||||||
|
@ -161,6 +161,7 @@ private slots:
|
|||||||
void pythonDownloadSuccess(QString url, QString file_path);
|
void pythonDownloadSuccess(QString url, QString file_path);
|
||||||
void pythonDownloadFailure(QString url, QString error);
|
void pythonDownloadFailure(QString url, QString error);
|
||||||
#endif
|
#endif
|
||||||
|
void addToolbarContextMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFileSystemWatcher *executable_watcher;
|
QFileSystemWatcher *executable_watcher;
|
||||||
@ -214,6 +215,7 @@ private:
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool has_python;
|
bool has_python;
|
||||||
#endif
|
#endif
|
||||||
|
QMenu* toolbarMenu;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionSearch_engine_triggered();
|
void on_actionSearch_engine_triggered();
|
||||||
@ -232,6 +234,12 @@ private slots:
|
|||||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||||
void checkProgramUpdate();
|
void checkProgramUpdate();
|
||||||
#endif
|
#endif
|
||||||
|
void toolbarMenuRequested(QPoint);
|
||||||
|
void toolbarIconsOnly();
|
||||||
|
void toolbarTextOnly();
|
||||||
|
void toolbarTextBeside();
|
||||||
|
void toolbarTextUnder();
|
||||||
|
void toolbarFollowSystem();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,6 +145,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Add torrent file...</string>
|
<string>&Add torrent file...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionExit">
|
<action name="actionExit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -158,6 +161,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Options...</string>
|
<string>&Options...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Options</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -168,16 +174,25 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Resume</string>
|
<string>&Resume</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Resume</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPause">
|
<action name="actionPause">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Pause</string>
|
<string>&Pause</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Pause</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDelete">
|
<action name="actionDelete">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Delete</string>
|
<string>&Delete</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Delete</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionWebsite">
|
<action name="actionWebsite">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@ -192,6 +207,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add &link to torrent...</string>
|
<string>Add &link to torrent...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Open URL</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionCreate_torrent">
|
<action name="actionCreate_torrent">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -316,6 +334,9 @@
|
|||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Lock qBittorrent</string>
|
<string>Lock qBittorrent</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Lock</string>
|
||||||
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string notr="true">Ctrl+L</string>
|
<string notr="true">Ctrl+L</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1952,6 +1952,14 @@ void Preferences::setRssFeedsAliases(const QStringList &rssAliases) {
|
|||||||
setValue("Rss/streamAlias", rssAliases);
|
setValue("Rss/streamAlias", rssAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Preferences::getToolbarTextPosition() const {
|
||||||
|
return value("Toolbar/textPosition", -1).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setToolbarTextPosition(const int position) {
|
||||||
|
setValue("Toolbar/textPosition", position);
|
||||||
|
}
|
||||||
|
|
||||||
QList<QByteArray> Preferences::getHostNameCookies(const QString &host_name) const {
|
QList<QByteArray> Preferences::getHostNameCookies(const QString &host_name) const {
|
||||||
QMap<QString, QVariant> hosts_table = value("Rss/hosts_cookies").toMap();
|
QMap<QString, QVariant> hosts_table = value("Rss/hosts_cookies").toMap();
|
||||||
if (!hosts_table.contains(host_name)) return QList<QByteArray>();
|
if (!hosts_table.contains(host_name)) return QList<QByteArray>();
|
||||||
|
@ -460,6 +460,8 @@ public:
|
|||||||
void setTransSelFilter(const int &index);
|
void setTransSelFilter(const int &index);
|
||||||
QByteArray getTransHeaderState() const;
|
QByteArray getTransHeaderState() const;
|
||||||
void setTransHeaderState(const QByteArray &state);
|
void setTransHeaderState(const QByteArray &state);
|
||||||
|
int getToolbarTextPosition() const;
|
||||||
|
void setToolbarTextPosition(const int position);
|
||||||
|
|
||||||
// Temp code.
|
// Temp code.
|
||||||
// See TorrentStatistics::loadStats() for details.
|
// See TorrentStatistics::loadStats() for details.
|
||||||
|
Loading…
Reference in New Issue
Block a user