mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06:00
Coding style for many files
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -24,120 +24,121 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "proptabbar.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QKeySequence>
|
||||
#include <QPushButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "proptabbar.h"
|
||||
#include "guiiconprovider.h"
|
||||
|
||||
PropTabBar::PropTabBar(QWidget *parent) :
|
||||
QHBoxLayout(parent), m_currentIndex(-1)
|
||||
PropTabBar::PropTabBar(QWidget *parent)
|
||||
: QHBoxLayout(parent)
|
||||
, m_currentIndex(-1)
|
||||
{
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignCenter);
|
||||
setSpacing(3);
|
||||
m_btnGroup = new QButtonGroup(this);
|
||||
// General tab
|
||||
QPushButton *main_infos_button = new QPushButton(
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignCenter);
|
||||
setSpacing(3);
|
||||
m_btnGroup = new QButtonGroup(this);
|
||||
// General tab
|
||||
QPushButton *mainInfosButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("document-properties"),
|
||||
GuiIconProvider::instance()->getIcon("document-properties"),
|
||||
#endif
|
||||
tr("General"), parent);
|
||||
main_infos_button->setShortcut(Qt::ALT + Qt::Key_G);
|
||||
addWidget(main_infos_button);
|
||||
m_btnGroup->addButton(main_infos_button, MAIN_TAB);
|
||||
// Trackers tab
|
||||
QPushButton *trackers_button = new QPushButton(
|
||||
tr("General"), parent);
|
||||
mainInfosButton->setShortcut(Qt::ALT + Qt::Key_G);
|
||||
addWidget(mainInfosButton);
|
||||
m_btnGroup->addButton(mainInfosButton, MainTab);
|
||||
// Trackers tab
|
||||
QPushButton *trackersButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("network-server"),
|
||||
GuiIconProvider::instance()->getIcon("network-server"),
|
||||
#endif
|
||||
tr("Trackers"), parent);
|
||||
trackers_button->setShortcut(Qt::ALT + Qt::Key_C);
|
||||
addWidget(trackers_button);
|
||||
m_btnGroup->addButton(trackers_button, TRACKERS_TAB);
|
||||
// Peers tab
|
||||
QPushButton *peers_button = new QPushButton(
|
||||
tr("Trackers"), parent);
|
||||
trackersButton->setShortcut(Qt::ALT + Qt::Key_C);
|
||||
addWidget(trackersButton);
|
||||
m_btnGroup->addButton(trackersButton, TrackersTab);
|
||||
// Peers tab
|
||||
QPushButton *peersButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("edit-find-user"),
|
||||
GuiIconProvider::instance()->getIcon("edit-find-user"),
|
||||
#endif
|
||||
tr("Peers"), parent);
|
||||
peers_button->setShortcut(Qt::ALT + Qt::Key_R);
|
||||
addWidget(peers_button);
|
||||
m_btnGroup->addButton(peers_button, PEERS_TAB);
|
||||
// URL seeds tab
|
||||
QPushButton *urlseeds_button = new QPushButton(
|
||||
tr("Peers"), parent);
|
||||
peersButton->setShortcut(Qt::ALT + Qt::Key_R);
|
||||
addWidget(peersButton);
|
||||
m_btnGroup->addButton(peersButton, PeersTab);
|
||||
// URL seeds tab
|
||||
QPushButton *URLSeedsButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("network-server"),
|
||||
GuiIconProvider::instance()->getIcon("network-server"),
|
||||
#endif
|
||||
tr("HTTP Sources"), parent);
|
||||
urlseeds_button->setShortcut(Qt::ALT + Qt::Key_B);
|
||||
addWidget(urlseeds_button);
|
||||
m_btnGroup->addButton(urlseeds_button, URLSEEDS_TAB);
|
||||
// Files tab
|
||||
QPushButton *files_button = new QPushButton(
|
||||
tr("HTTP Sources"), parent);
|
||||
URLSeedsButton->setShortcut(Qt::ALT + Qt::Key_B);
|
||||
addWidget(URLSeedsButton);
|
||||
m_btnGroup->addButton(URLSeedsButton, URLSeedsTab);
|
||||
// Files tab
|
||||
QPushButton *filesButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("inode-directory"),
|
||||
GuiIconProvider::instance()->getIcon("inode-directory"),
|
||||
#endif
|
||||
tr("Content"), parent);
|
||||
files_button->setShortcut(Qt::ALT + Qt::Key_Z);
|
||||
addWidget(files_button);
|
||||
m_btnGroup->addButton(files_button, FILES_TAB);
|
||||
// Spacer
|
||||
addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
// Speed tab
|
||||
QPushButton *speed_button = new QPushButton(
|
||||
tr("Content"), parent);
|
||||
filesButton->setShortcut(Qt::ALT + Qt::Key_Z);
|
||||
addWidget(filesButton);
|
||||
m_btnGroup->addButton(filesButton, FilesTab);
|
||||
// Spacer
|
||||
addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
// Speed tab
|
||||
QPushButton *speedButton = new QPushButton(
|
||||
#ifndef Q_OS_MAC
|
||||
GuiIconProvider::instance()->getIcon("office-chart-line"),
|
||||
GuiIconProvider::instance()->getIcon("office-chart-line"),
|
||||
#endif
|
||||
tr("Speed"), parent);
|
||||
speed_button->setShortcut(Qt::ALT + Qt::Key_D);
|
||||
addWidget(speed_button);
|
||||
m_btnGroup->addButton(speed_button, SPEED_TAB);
|
||||
// SIGNAL/SLOT
|
||||
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
|
||||
// Disable buttons focus
|
||||
foreach (QAbstractButton *btn, m_btnGroup->buttons()) {
|
||||
btn->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
tr("Speed"), parent);
|
||||
speedButton->setShortcut(Qt::ALT + Qt::Key_D);
|
||||
addWidget(speedButton);
|
||||
m_btnGroup->addButton(speedButton, SpeedTab);
|
||||
// SIGNAL/SLOT
|
||||
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
|
||||
// Disable buttons focus
|
||||
foreach (QAbstractButton *btn, m_btnGroup->buttons())
|
||||
btn->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
PropTabBar::~PropTabBar() {
|
||||
delete m_btnGroup;
|
||||
PropTabBar::~PropTabBar()
|
||||
{
|
||||
delete m_btnGroup;
|
||||
}
|
||||
|
||||
int PropTabBar::currentIndex() const
|
||||
{
|
||||
return m_currentIndex;
|
||||
return m_currentIndex;
|
||||
}
|
||||
|
||||
void PropTabBar::setCurrentIndex(int index)
|
||||
{
|
||||
if (index >= m_btnGroup->buttons().size())
|
||||
if (index >= m_btnGroup->buttons().size())
|
||||
index = 0;
|
||||
// If asked to hide or if the currently selected tab is clicked
|
||||
if (index < 0 || m_currentIndex == index) {
|
||||
if (m_currentIndex >= 0) {
|
||||
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||||
m_currentIndex = -1;
|
||||
emit visibilityToggled(false);
|
||||
// If asked to hide or if the currently selected tab is clicked
|
||||
if (index < 0 || m_currentIndex == index) {
|
||||
if (m_currentIndex >= 0) {
|
||||
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||||
m_currentIndex = -1;
|
||||
emit visibilityToggled(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Unselect previous tab
|
||||
if (m_currentIndex >= 0) {
|
||||
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||||
} else {
|
||||
// Nothing was selected, show!
|
||||
emit visibilityToggled(true);
|
||||
}
|
||||
// Select the new button
|
||||
m_btnGroup->button(index)->setDown(true);
|
||||
m_currentIndex = index;
|
||||
// Emit the signal
|
||||
emit tabChanged(index);
|
||||
// Unselect previous tab
|
||||
if (m_currentIndex >= 0) {
|
||||
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||||
}
|
||||
else {
|
||||
// Nothing was selected, show!
|
||||
emit visibilityToggled(true);
|
||||
}
|
||||
// Select the new button
|
||||
m_btnGroup->button(index)->setDown(true);
|
||||
m_currentIndex = index;
|
||||
// Emit the signal
|
||||
emit tabChanged(index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user