mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
added new xProgressBar, thanks to xesk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@338 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b7abbda1fb
commit
81fcc83bdc
@ -68,6 +68,7 @@ HEADERS += rshare.h \
|
||||
gui/StatisticDialog.h \
|
||||
gui/HelpDialog.h \
|
||||
gui/LogoBar.h \
|
||||
gui/xprogressbar.h \
|
||||
lang/languagesupport.h \
|
||||
util/process.h \
|
||||
util/registry.h \
|
||||
@ -218,6 +219,7 @@ SOURCES += main.cpp \
|
||||
gui/MessagesDialog.cpp \
|
||||
gui/HelpDialog.cpp \
|
||||
gui/LogoBar.cpp \
|
||||
gui/xprogressbar.cpp \
|
||||
lang/languagesupport.cpp \
|
||||
util/process.cpp \
|
||||
util/registry.cpp \
|
||||
|
@ -145,25 +145,17 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case PROGRESS:
|
||||
{
|
||||
progress = index.data().toDouble();
|
||||
temp.clear();
|
||||
temp.sprintf("%.2f", progress);
|
||||
temp += "%";
|
||||
newopt.rect = opt.rect;
|
||||
//newopt.text = temp;
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
newopt.progress = (int)progress;
|
||||
newopt.state |= QStyle::State_Enabled;
|
||||
newopt.textVisible = false;
|
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
|
||||
painter);
|
||||
//We prefer to display text manually to control color/font/boldness
|
||||
if (option.state & QStyle::State_Selected){
|
||||
opt.palette.setColor(QPalette::Text, QColor("grey"));
|
||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||
// create a xProgressBar
|
||||
xProgressBar progressBar(option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||
progressBar.setDisplayText(false); // should display % text?
|
||||
progressBar.setValue(progress); // set the progress value
|
||||
progressBar.setVerticalSpan(1);
|
||||
progressBar.paint(); // paint the progress bar
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case NAME:
|
||||
// decoration
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006,2007 crypton
|
||||
* Copyright (C) 2006,2007,2008 crypton
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -23,6 +23,8 @@
|
||||
#define DLLISTDELEGATE_H
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include "xprogressbar.h"
|
||||
|
||||
|
||||
// Defines for download list list columns
|
||||
#define NAME 0
|
||||
|
@ -10,9 +10,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -501,10 +499,22 @@
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
@ -517,10 +527,22 @@
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="2" >
|
||||
@ -541,12 +563,12 @@
|
||||
<property name="html" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://retroshare.wiki.sourceforge.net/help_tab"><span style=" text-decoration: underline; color:#0000ff;">This Page in the retroshare Wiki</span></a><br /><br />The About/Help Tab is regularly updated from the Wiki page.<br /><br />External Links to more information:<br /></p>
|
||||
<ul style="-qt-list-indent: 1;"><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://retroshare.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Webpage</span></a></li>
|
||||
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://retroshare.wiki.sourceforge.net/"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Wiki</span></a></li>
|
||||
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sourceforge.net/projects/retroshare/"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Project Page</span></a></li>
|
||||
<li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.lunamutt.com"><span style=" text-decoration: underline; color:#0000ff;">Lunamutt Homepage.</span></a></li></ul></body></html></string>
|
||||
<ul style="-qt-list-indent: 1;"><li style="" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://retroshare.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Webpage</span></a></li>
|
||||
<li style="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://retroshare.wiki.sourceforge.net/"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Wiki</span></a></li>
|
||||
<li style="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sourceforge.net/projects/retroshare/"><span style=" text-decoration: underline; color:#0000ff;">Retroshare Project Page</span></a></li>
|
||||
<li style="" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.lunamutt.com"><span style=" text-decoration: underline; color:#0000ff;">Lunamutt Homepage.</span></a></li></ul></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks" >
|
||||
<bool>true</bool>
|
||||
@ -581,12 +603,21 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Authors</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="authors" >
|
||||
<property name="undoRedoEnabled" >
|
||||
@ -601,7 +632,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="html" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><span style=" font-size:19pt; font-weight:600; color:#0000ff;">The RetroShare Team:</span><br /> <br /><span style=" font-size:9pt; color:#0000ff;">defnax</span>: Lead GUI developer <br /><span style=" font-size:9pt; color:#0000ff;">drbob7</span>: Lead Core developer. <br /> <br /><span style=" font-size:9pt; color:#0000ff;">bmeck</span> : Our new web-developer. Joined retroshare a couple <br />of weeks ago, and already starting on an exciting new <br />design for the web-page. <br /> <br /><span style=" font-size:9pt; color:#0000ff;">noragen</span> : Developer from the SIM-IM project. Working on a retroshare plugin to SIM-IM. <br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt; color:#0000ff;">kernelpanix</span> : Gui and skin developer</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
@ -618,7 +649,7 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<enum>Qt::TextBrowserInteraction</enum>
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -629,12 +660,21 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Thanks to</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="thanks" >
|
||||
<property name="undoRedoEnabled" >
|
||||
@ -646,11 +686,20 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:10pt; font-weight:600;">xEsk</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"> xProgressBar: A custom progress bar for Qt 4.</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"> xEsk (Xesc &amp; Technology 2008)</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"> ProgressBar</p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<enum>Qt::TextBrowserInteraction</enum>
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -661,12 +710,21 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Translation</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="translation" >
|
||||
<property name="undoRedoEnabled" >
|
||||
@ -678,7 +736,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="html" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Translators:</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">French</span>:Temet</p>
|
||||
@ -690,7 +748,7 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<enum>Qt::TextSelectableByMouse</enum>
|
||||
<set>Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -701,12 +759,21 @@ p, li { white-space: pre-wrap; }
|
||||
<string>License Agreement</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="license" >
|
||||
<property name="undoRedoEnabled" >
|
||||
@ -719,7 +786,7 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<enum>Qt::TextBrowserInteraction</enum>
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -729,10 +796,22 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
@ -750,10 +829,22 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
|
200
retroshare-gui/src/gui/xprogressbar.cpp
Normal file
200
retroshare-gui/src/gui/xprogressbar.cpp
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* xProgressBar: A custom progress bar for Qt 4.
|
||||
* Author: xEsk (Xesc & Technology 2008)
|
||||
*
|
||||
* Changelog:
|
||||
*
|
||||
* v1.0:
|
||||
* -----
|
||||
* - First release
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#include "xprogressbar.h"
|
||||
|
||||
xProgressBar::xProgressBar(QRect rect, QPainter *painter, int schemaIndex)
|
||||
{
|
||||
// assign internal data
|
||||
this->schemaIndex = schemaIndex;
|
||||
this->rect = rect;
|
||||
this->painter = painter;
|
||||
this->progressValue = 0.00;
|
||||
// set the progress bar colors
|
||||
setColor();
|
||||
// configure span
|
||||
vSpan = 0;
|
||||
hSpan = 0;
|
||||
// text color
|
||||
textColor = QColor("white");
|
||||
}
|
||||
|
||||
void xProgressBar::setColor()
|
||||
{
|
||||
/* TEMPORAL SCHEMA DEFINITION */
|
||||
|
||||
switch (schemaIndex)
|
||||
{
|
||||
/* blue schema */
|
||||
case 0:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(143, 180, 219);
|
||||
backgroundColor.setRgb(198, 209, 221);
|
||||
// progress
|
||||
gradBorderColor.setRgb(35, 96, 167);
|
||||
gradColor1.setRgb(100, 136, 252);
|
||||
gradColor2.setRgb(165, 183, 240);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* green schema */
|
||||
case 1:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(3, 194, 26);
|
||||
backgroundColor.setRgb(76, 214, 93);
|
||||
// progress
|
||||
gradBorderColor.setRgb(8, 77, 16);
|
||||
gradColor1.setRgb(0, 137, 16);
|
||||
gradColor2.setRgb(78, 194, 81);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* red schema */
|
||||
case 2:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(255, 62, 62);
|
||||
backgroundColor.setRgb(248, 175, 175);
|
||||
// progress
|
||||
gradBorderColor.setRgb(151, 0, 0);
|
||||
gradColor1.setRgb(251, 54, 54);
|
||||
gradColor2.setRgb(246, 118, 118);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* gray schema */
|
||||
case 3:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(116, 177, 160);
|
||||
backgroundColor.setRgb(178, 215, 205);
|
||||
// progress
|
||||
gradBorderColor.setRgb(106, 106, 106);
|
||||
gradColor1.setRgb(168, 168, 168);
|
||||
gradColor2.setRgb(197, 197, 197);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* yellow schema */
|
||||
case 4:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(227, 204, 79);
|
||||
backgroundColor.setRgb(255, 236, 130);
|
||||
// progress
|
||||
gradBorderColor.setRgb(215, 182, 0);
|
||||
gradColor1.setRgb(233, 197, 0);
|
||||
gradColor2.setRgb(255, 236, 130);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* black schema */
|
||||
case 5:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(99, 99, 99);
|
||||
backgroundColor.setRgb(134, 134, 134);
|
||||
// progress
|
||||
gradBorderColor.setRgb(0, 0, 0);
|
||||
gradColor1.setRgb(38, 38, 38);
|
||||
gradColor2.setRgb(113, 113, 113);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* purple schema */
|
||||
case 6:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(234, 127, 223);
|
||||
backgroundColor.setRgb(255, 164, 246);
|
||||
// progress
|
||||
gradBorderColor.setRgb(150, 0, 134);
|
||||
gradColor1.setRgb(218, 0, 195);
|
||||
gradColor2.setRgb(255, 121, 241);
|
||||
// ok
|
||||
break;
|
||||
|
||||
/* maroon schema */
|
||||
case 7:
|
||||
// background
|
||||
backgroundBorderColor.setRgb(255, 174, 49);
|
||||
backgroundColor.setRgb(255, 204, 132);
|
||||
// progress
|
||||
gradBorderColor.setRgb(159, 94, 0);
|
||||
gradColor1.setRgb(223, 134, 6);
|
||||
gradColor2.setRgb(248, 170, 59);
|
||||
// ok
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void xProgressBar::paint()
|
||||
{
|
||||
// paint the progressBar background
|
||||
painter->setBrush(backgroundColor);
|
||||
painter->setPen(backgroundBorderColor);
|
||||
painter->drawRect(rect.x() + hSpan, rect.y() + vSpan, rect.width() - 1 - hSpan, rect.height() - 1 - vSpan * 2);
|
||||
|
||||
// define gradient
|
||||
QLinearGradient linearGrad(rect.x(), rect.y(), rect.x(), rect.y() + rect.height() - 1);
|
||||
|
||||
linearGrad.setColorAt(0.00, gradColor1);
|
||||
linearGrad.setColorAt(0.16, gradColor2);
|
||||
linearGrad.setColorAt(1.00, gradColor1);
|
||||
painter->setPen(gradBorderColor);
|
||||
|
||||
// calculate progress value
|
||||
int preWidth = static_cast<int>((rect.width() - 1 - hSpan)*(progressValue/100));
|
||||
int progressWidth = rect.width() - preWidth;
|
||||
if (progressWidth == rect.width() - hSpan) return;
|
||||
|
||||
// paint the progress
|
||||
painter->setBrush(linearGrad);
|
||||
painter->drawRect(rect.x() + hSpan, rect.y() + vSpan, rect.width() - progressWidth - hSpan, rect.height() - 1 - vSpan * 2);
|
||||
|
||||
// paint text?
|
||||
if (displayText)
|
||||
{
|
||||
QLocale locale;
|
||||
painter->setPen(textColor);
|
||||
painter->drawText(rect, Qt::AlignCenter, locale.toString(progressValue, 'f', 2) + "%");
|
||||
}
|
||||
}
|
||||
|
||||
void xProgressBar::setValue(const float value)
|
||||
{
|
||||
progressValue = value < 0 ? 0 : value > 100 ? 100 : value;
|
||||
}
|
||||
|
||||
void xProgressBar::setDisplayText(const bool display)
|
||||
{
|
||||
displayText = display;
|
||||
}
|
||||
|
||||
void xProgressBar::setVerticalSpan(const int value)
|
||||
{
|
||||
vSpan = value;
|
||||
}
|
||||
|
||||
void xProgressBar::setHorizontalSpan(const int value)
|
||||
{
|
||||
hSpan = value;
|
||||
}
|
67
retroshare-gui/src/gui/xprogressbar.h
Normal file
67
retroshare-gui/src/gui/xprogressbar.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* xProgressBar: A custom progress bar for Qt 4.
|
||||
* Author: xEsk (Xesc & Technology 2008)
|
||||
*
|
||||
* Changelog:
|
||||
*
|
||||
* v1.0:
|
||||
* -----
|
||||
* - First release
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef XPROGRESSBAR_H
|
||||
#define XPROGRESSBAR_H
|
||||
//
|
||||
#include <QRect>
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QLinearGradient>
|
||||
#include <QLocale>
|
||||
//
|
||||
class xProgressBar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
// progress vlues
|
||||
float progressValue;
|
||||
int schemaIndex;
|
||||
bool displayText;
|
||||
int vSpan;
|
||||
int hSpan;
|
||||
// painter config
|
||||
QRect rect;
|
||||
QPainter *painter;
|
||||
// text color
|
||||
QColor textColor;
|
||||
// progress colors
|
||||
QColor backgroundBorderColor;
|
||||
QColor backgroundColor;
|
||||
QColor gradBorderColor;
|
||||
QColor gradColor1;
|
||||
QColor gradColor2;
|
||||
// configure the color
|
||||
void setColor();
|
||||
public:
|
||||
xProgressBar(QRect rect, QPainter *painter, int schemaIndex = 0);
|
||||
void paint();
|
||||
void setValue(const float value);
|
||||
void setDisplayText(const bool display);
|
||||
void setVerticalSpan(const int value);
|
||||
void setHorizontalSpan(const int value);
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user