Some work about adaptive color scheme for Web UI (PR #19901)
http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.0 KiB
110 lines
4.0 KiB
14 years ago
|
/*
|
||
|
* 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
|
||
|
*/
|
||
|
|
||
|
#include <QButtonGroup>
|
||
|
#include <QPushButton>
|
||
|
#include <QSpacerItem>
|
||
|
#include <QKeySequence>
|
||
|
|
||
|
#include "proptabbar.h"
|
||
14 years ago
|
#include "iconprovider.h"
|
||
14 years ago
|
|
||
|
PropTabBar::PropTabBar(QWidget *parent) :
|
||
|
QHBoxLayout(parent), m_currentIndex(-1)
|
||
|
{
|
||
13 years ago
|
setSpacing(2);
|
||
14 years ago
|
m_btnGroup = new QButtonGroup(this);
|
||
|
// General tab
|
||
14 years ago
|
QPushButton *main_infos_button = new QPushButton(IconProvider::instance()->getIcon("document-properties"), tr("General"), parent);
|
||
14 years ago
|
main_infos_button->setShortcut(QKeySequence(QString::fromUtf8("Alt+P")));
|
||
|
addWidget(main_infos_button);
|
||
|
m_btnGroup->addButton(main_infos_button, MAIN_TAB);
|
||
|
// Trackers tab
|
||
14 years ago
|
QPushButton *trackers_button = new QPushButton(IconProvider::instance()->getIcon("network-server"), tr("Trackers"), parent);
|
||
14 years ago
|
addWidget(trackers_button);
|
||
|
m_btnGroup->addButton(trackers_button, TRACKERS_TAB);
|
||
|
// Peers tab
|
||
14 years ago
|
QPushButton *peers_button = new QPushButton(IconProvider::instance()->getIcon("edit-find-user"), tr("Peers"), parent);
|
||
14 years ago
|
addWidget(peers_button);
|
||
|
m_btnGroup->addButton(peers_button, PEERS_TAB);
|
||
|
// URL seeds tab
|
||
14 years ago
|
QPushButton *urlseeds_button = new QPushButton(IconProvider::instance()->getIcon("network-server"), tr("HTTP Sources"), parent);
|
||
14 years ago
|
addWidget(urlseeds_button);
|
||
|
m_btnGroup->addButton(urlseeds_button, URLSEEDS_TAB);
|
||
|
// Files tab
|
||
14 years ago
|
QPushButton *files_button = new QPushButton(IconProvider::instance()->getIcon("inode-directory"), tr("Content"), parent);
|
||
14 years ago
|
addWidget(files_button);
|
||
|
m_btnGroup->addButton(files_button, FILES_TAB);
|
||
|
// Spacer
|
||
|
addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||
|
// SIGNAL/SLOT
|
||
|
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
|
||
14 years ago
|
// Disable buttons focus
|
||
13 years ago
|
foreach (QAbstractButton *btn, m_btnGroup->buttons()) {
|
||
14 years ago
|
btn->setFocusPolicy(Qt::NoFocus);
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
PropTabBar::~PropTabBar() {
|
||
|
delete m_btnGroup;
|
||
|
}
|
||
|
|
||
|
int PropTabBar::currentIndex() const
|
||
|
{
|
||
|
return m_currentIndex;
|
||
|
}
|
||
|
|
||
|
void PropTabBar::setCurrentIndex(int index)
|
||
|
{
|
||
13 years ago
|
if (index >= m_btnGroup->buttons().size())
|
||
14 years ago
|
index = 0;
|
||
14 years ago
|
// If asked to hide or if the currently selected tab is clicked
|
||
13 years ago
|
if (index < 0 || m_currentIndex == index) {
|
||
|
if (m_currentIndex >= 0) {
|
||
13 years ago
|
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||
14 years ago
|
m_currentIndex = -1;
|
||
|
emit visibilityToggled(false);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
// Unselect previous tab
|
||
13 years ago
|
if (m_currentIndex >= 0) {
|
||
13 years ago
|
m_btnGroup->button(m_currentIndex)->setDown(false);
|
||
14 years ago
|
} else {
|
||
|
// Nothing was selected, show!
|
||
|
emit visibilityToggled(true);
|
||
|
}
|
||
|
// Select the new button
|
||
13 years ago
|
m_btnGroup->button(index)->setDown(true);
|
||
14 years ago
|
m_currentIndex = index;
|
||
|
// Emit the signal
|
||
|
emit tabChanged(index);
|
||
|
}
|