diff --git a/src/main.cpp b/src/main.cpp index e1d53d355..9d73589f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,6 @@ #include #include #include -#include "qgnomelook.h" #include "GUI.h" #include "ico.h" #else @@ -163,11 +162,6 @@ void useStyle(QApplication *app, QString style){ if(!style.isEmpty()) { QApplication::setStyle(QStyleFactory::create(style)); } - if(app->style()->objectName() == "cleanlooks") { - // Force our own cleanlooks style - qDebug("Forcing our own cleanlooks style"); - app->setStyle(new QGnomeLookStyle()); - } Preferences::setStyle(app->style()->objectName()); } #endif diff --git a/src/options_imp.cpp b/src/options_imp.cpp index a2f049f47..e27b72538 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -34,7 +34,6 @@ #include #include #include -#include "qgnomelook.h" #include #include #include @@ -310,11 +309,6 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous void options_imp::useStyle() { QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex()))); - if(QApplication::style()->objectName() == "cleanlooks") { - // Force our own cleanlooks style - qDebug("Forcing our own cleanlooks style"); - QApplication::setStyle(new QGnomeLookStyle()); - } } void options_imp::loadWindowState() { diff --git a/src/peerlistdelegate.h b/src/peerlistdelegate.h index 92ba1886e..1bd32dc1b 100644 --- a/src/peerlistdelegate.h +++ b/src/peerlistdelegate.h @@ -32,6 +32,7 @@ #define PEERLISTDELEGATE_H #include +#include #include "misc.h" enum PeerListColumns {IP, CLIENT, PROGRESS, DOWN_SPEED, UP_SPEED, TOT_DOWN, TOT_UP, IP_HIDDEN}; @@ -45,30 +46,32 @@ public: ~PeerListDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ + painter->save(); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); switch(index.column()){ - case TOT_DOWN: - case TOT_UP: + case TOT_DOWN: + case TOT_UP: QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); break; - case DOWN_SPEED: - case UP_SPEED:{ - QItemDelegate::drawBackground(painter, opt, index); - double speed = index.data().toDouble(); - if (speed > 0.0) - QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)")); - break; - } - case PROGRESS:{ - QItemDelegate::drawBackground(painter, opt, index); - double progress = index.data().toDouble(); - QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%"); - break; - } - default: - QItemDelegate::paint(painter, option, index); - } + case DOWN_SPEED: + case UP_SPEED:{ + QItemDelegate::drawBackground(painter, opt, index); + double speed = index.data().toDouble(); + if (speed > 0.0) + QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)")); + break; + } + case PROGRESS:{ + QItemDelegate::drawBackground(painter, opt, index); + double progress = index.data().toDouble(); + QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%"); + break; + } + default: + QItemDelegate::paint(painter, option, index); + } + painter->restore(); } QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { diff --git a/src/previewlistdelegate.h b/src/previewlistdelegate.h index fb3f7dbb7..223a5c757 100644 --- a/src/previewlistdelegate.h +++ b/src/previewlistdelegate.h @@ -54,6 +54,7 @@ class PreviewListDelegate: public QItemDelegate { ~PreviewListDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ + painter->save(); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); switch(index.column()){ @@ -77,6 +78,7 @@ class PreviewListDelegate: public QItemDelegate { default: QItemDelegate::paint(painter, option, index); } + painter->restore(); } QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { diff --git a/src/proplistdelegate.h b/src/proplistdelegate.h index 0f034c8e3..cc53a186d 100644 --- a/src/proplistdelegate.h +++ b/src/proplistdelegate.h @@ -62,6 +62,7 @@ public: ~PropListDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ + painter->save(); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); switch(index.column()){ case SIZE: @@ -105,6 +106,7 @@ public: QItemDelegate::paint(painter, option, index); break; } + painter->restore(); } QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{ diff --git a/src/qgnomelook.h b/src/qgnomelook.h deleted file mode 100644 index b53a8762b..000000000 --- a/src/qgnomelook.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 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 - */ - -#ifndef QGNOMELOOK -#define QGNOMELOOK - -#include -#include -#include -#include -#include -#include - -class QGnomeLookStyle : public QCleanlooksStyle { - public: - QGnomeLookStyle() : QCleanlooksStyle() {} - - void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { - switch(element) { - case CE_ProgressBarLabel: - if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { - bool vertical = false; - if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast(option)) { - vertical = (pb2->orientation == Qt::Vertical); - } - if (!vertical) { - QPalette::ColorRole textRole = QPalette::WindowText;/* - if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible - && ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) { - textRole = QPalette::HighlightedText; - //Draw text shadow, This will increase readability when the background of same color - QRect shadowRect(pb->rect); - shadowRect.translate(1,1); - QColor shadowColor = (pb->palette.color(textRole).value() <= 128) ? QColor(255,255,255,160) : QColor(0,0,0,160); - QPalette shadowPalette = pb->palette; - shadowPalette.setColor(textRole, shadowColor); - drawItemText(painter, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette, pb->state, pb->text, textRole); - } - QPalette shadowPalette = pb->palette; - shadowPalette.setColor(textRole, QColor(0,0,0,160));*/ - drawItemText(painter, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, pb->state, pb->text, textRole); - } - } - break; - default: - QCleanlooksStyle::drawControl(element, option, painter, widget); - } - } - - QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget=0) const - { - QRect rect; - switch (element) { -#ifndef QT_NO_PROGRESSBAR - case SE_ProgressBarLabel: - case SE_ProgressBarContents: - case SE_ProgressBarGroove: - return option->rect; -#endif // QT_NO_PROGRESSBAR - default: - return QCleanlooksStyle::subElementRect(element, option, widget); - } - - return visualRect(option->direction, option->rect, rect); - } - -}; - -#endif diff --git a/src/searchlistdelegate.h b/src/searchlistdelegate.h index 694f9aed7..e61c69009 100644 --- a/src/searchlistdelegate.h +++ b/src/searchlistdelegate.h @@ -55,6 +55,7 @@ class SearchListDelegate: public QItemDelegate { ~SearchListDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ + painter->save(); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); switch(index.column()){ case SIZE: @@ -64,6 +65,7 @@ class SearchListDelegate: public QItemDelegate { default: QItemDelegate::paint(painter, option, index); } + painter->restore(); } QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { diff --git a/src/src.pro b/src/src.pro index 0ad4b3dec..4cbca9c9a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -240,7 +240,6 @@ else:HEADERS += GUI.h \ ico.h \ engineselectdlg.h \ pluginsource.h \ - qgnomelook.h \ searchEngine.h \ rss.h \ rss_imp.h \ diff --git a/src/transferlistdelegate.h b/src/transferlistdelegate.h index 69d7c5f6c..b94ab4734 100644 --- a/src/transferlistdelegate.h +++ b/src/transferlistdelegate.h @@ -55,6 +55,7 @@ public: void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); + painter->save(); switch(index.column()){ case TR_SIZE:{ QItemDelegate::drawBackground(painter, opt, index); @@ -172,6 +173,7 @@ public: default: QItemDelegate::paint(painter, option, index); } + painter->restore(); } QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {