Permalink
Browse files

Transparent background & theme-able container added

  • Loading branch information...
1 parent 6fe6fb0 commit dae56f1c9a3606ab8b91e295ab268ec1dfe5b6cd @kuzmas kuzmas committed Oct 31, 2012
@@ -43,11 +43,18 @@ EXPORT_RAZOR_PANEL_PLUGIN_CPP(RazorSysStat)
RazorSysStat::RazorSysStat(const RazorPanelPluginStartInfo *startInfo, QWidget *parent):
RazorPanelPlugin(startInfo, parent),
- content(new RazorSysStatContent(*this, this))
+ mContent(new RazorSysStatContent(*this, this))
{
setObjectName("SysStat");
- addWidget(content);
+ QWidget *border = new QWidget(this);
+
+ QVBoxLayout *borderLayout = new QVBoxLayout(border);
+ borderLayout->setContentsMargins(0, 0, 0, 0);
+ borderLayout->setSpacing(0);
+ borderLayout->addWidget(mContent);
+
+ addWidget(border);
this->layout()->setContentsMargins(0, 0, 0, 0);
this->layout()->setSpacing(0);
@@ -62,7 +69,7 @@ RazorSysStat::~RazorSysStat()
void RazorSysStat::settingsChanged()
{
- content->updateSettings(settings());
+ mContent->updateSettings(settings());
}
void RazorSysStat::showConfigureDialog()
@@ -99,12 +106,11 @@ void RazorSysStatContent::updateSettings(const QSettings &settings)
{
QString old_dataType = dataType;
- bgColour = QColor(settings.value("graph/bgColour", "0x000000").toString().toInt(NULL, 0) | 0xff000000);
updateInterval = settings.value("graph/updateInterval", 1.0).toDouble();
historyLength = settings.value("graph/historyLength", 30).toInt();
gridLines = settings.value("grid/lines", 1).toInt();
- gridColour = QColor(settings.value("grid/colour", "0xc0c0c0").toString().toInt(NULL, 0) | 0xff000000);
+ gridColour = QColor(settings.value("grid/colour", "#c0c0c0").toString());
titleLabel = settings.value("title/label", QString()).toString();
QFont defaultFont(QApplication::font());
@@ -113,26 +119,26 @@ void RazorSysStatContent::updateSettings(const QSettings &settings)
settings.value("title/font/pointSize", defaultFont.pointSize()).toInt(),
settings.value("title/font/weight", defaultFont.weight()).toInt(),
settings.value("title/font/italic", defaultFont.italic()).toBool() );
- titleColour = QColor(settings.value("title/colour", "0xffffff").toString().toInt(NULL, 0) | 0xff000000);
+ titleColour = QColor(settings.value("title/colour", "#ffffff").toString());
dataType = settings.value("data/type", QString("CPU")).toString();
dataSource = settings.value("data/source", QString()).toString();
- cpuSystemColour = QColor(settings.value("cpu/systemColour", "0x800000").toString().toInt(NULL, 0) | 0xff000000);
- cpuUserColour = QColor(settings.value("cpu/userColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000);
- cpuNiceColour = QColor(settings.value("cpu/niceColour", "0x008000").toString().toInt(NULL, 0) | 0xff000000);
- cpuOtherColour = QColor(settings.value("cpu/otherColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000);
+ cpuSystemColour = QColor(settings.value("cpu/systemColour", "#800000").toString());
+ cpuUserColour = QColor(settings.value("cpu/userColour", "#000080").toString());
+ cpuNiceColour = QColor(settings.value("cpu/niceColour", "#008000").toString());
+ cpuOtherColour = QColor(settings.value("cpu/otherColour", "#808000").toString());
useFrequency = settings.value("cpu/useFrequency", true).toBool();
- frequencyColour = QColor(settings.value("cpu/frequencyColour", "0x60c0c0").toString().toInt(NULL, 0) | 0xff000000);
+ frequencyColour = QColor(settings.value("cpu/frequencyColour", "#60c0c0").toString());
- memAppsColour = QColor(settings.value("mem/appsColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000);
- memBuffersColour = QColor(settings.value("mem/buffersColour", "0x008000").toString().toInt(NULL, 0) | 0xff000000);
- memCachedColour = QColor(settings.value("mem/cachedColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000);
- swapUsedColour = QColor(settings.value("mem/swapColour", "0x800000").toString().toInt(NULL, 0) | 0xff000000);
+ memAppsColour = QColor(settings.value("mem/appsColour", "#000080").toString());
+ memBuffersColour = QColor(settings.value("mem/buffersColour", "#008000").toString());
+ memCachedColour = QColor(settings.value("mem/cachedColour", "#808000").toString());
+ swapUsedColour = QColor(settings.value("mem/swapColour", "#800000").toString());
- netReceivedColour = QColor(settings.value("net/receivedColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000);
- netTransmittedColour = QColor(settings.value("net/transmittedColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000);
+ netReceivedColour = QColor(settings.value("net/receivedColour", "#000080").toString());
+ netTransmittedColour = QColor(settings.value("net/transmittedColour", "#808000").toString());
netMaximumSpeed = PluginSysStat::netSpeedFromString(settings.value("net/maximumSpeed", "1 MB/s").toString());
logarithmicScale = settings.value("net/logarithmicScale", true).toBool();
@@ -224,14 +230,14 @@ void RazorSysStatContent::reset(void)
setMinimumSize(plugin.panel()->isHorizontal() ? historyLength : 0, plugin.panel()->isHorizontal() ? 0 : historyLength);
historyOffset = 0;
- historyImage[0] = QImage(historyLength, height(), QImage::Format_RGB32);
- historyImage[1] = QImage(historyLength, height(), QImage::Format_RGB32);
+ historyImage[0] = QImage(historyLength, height(), QImage::Format_ARGB32);
+ historyImage[1] = QImage(historyLength, height(), QImage::Format_ARGB32);
#if QT_VERSION < 0x040800
- historyImage[0].fill(bgColour.rgba());
- historyImage[1].fill(bgColour.rgba());
+ historyImage[0].fill(QColor(Qt::transparent).rgba());
+ historyImage[1].fill(QColor(Qt::transparent).rgba());
#else
- historyImage[0].fill(bgColour);
- historyImage[1].fill(bgColour);
+ historyImage[0].fill(Qt::transparent);
+ historyImage[1].fill(Qt::transparent);
#endif
update();
@@ -256,7 +262,6 @@ void RazorSysStatContent::cpuUpdate(float user, float nice, float system, float
int y_other = y_nice - height * other * frequencyRate + 0.5;
int y_freq = height - height * frequencyRate + 0.5;
- drawLine(imageIndex, x, 0, y_freq, bgColour);
drawLine(imageIndex, x, y_freq, y_other, frequencyColour);
drawLine(imageIndex, x, y_other, y_nice, cpuOtherColour);
drawLine(imageIndex, x, y_nice, y_user, cpuNiceColour);
@@ -266,6 +271,8 @@ void RazorSysStatContent::cpuUpdate(float user, float nice, float system, float
++historyOffset;
if (historyOffset == historyLength * 2)
historyOffset = 0;
+ if (!(historyOffset % historyLength))
+ historyImage[1 - imageIndex].fill(Qt::transparent);
update();
}
@@ -282,7 +289,6 @@ void RazorSysStatContent::cpuUpdate(float user, float nice, float system, float
int y_nice = y_user - height * nice + 0.5;
int y_other = y_nice - height * other + 0.5;
- drawLine(imageIndex, x, 0, y_other, bgColour);
drawLine(imageIndex, x, y_other, y_nice, cpuOtherColour);
drawLine(imageIndex, x, y_nice, y_user, cpuNiceColour);
drawLine(imageIndex, x, y_user, y_system, cpuUserColour);
@@ -291,6 +297,8 @@ void RazorSysStatContent::cpuUpdate(float user, float nice, float system, float
++historyOffset;
if (historyOffset == historyLength * 2)
historyOffset = 0;
+ if (!(historyOffset % historyLength))
+ historyImage[1 - imageIndex].fill(Qt::transparent);
update();
}
@@ -306,14 +314,15 @@ void RazorSysStatContent::memoryUpdate(float apps, float buffers, float cached)
int y_buffers = y_apps - height * buffers + 0.5;
int y_cached = y_buffers - height * cached + 0.5;
- drawLine(imageIndex, x, 0, y_cached, bgColour);
drawLine(imageIndex, x, y_cached, y_buffers, memCachedColour);
drawLine(imageIndex, x, y_buffers, y_apps, memBuffersColour);
drawLine(imageIndex, x, y_apps, height, memAppsColour);
++historyOffset;
if (historyOffset == historyLength * 2)
historyOffset = 0;
+ if (!(historyOffset % historyLength))
+ historyImage[1 - imageIndex].fill(Qt::transparent);
update();
}
@@ -327,12 +336,13 @@ void RazorSysStatContent::swapUpdate(float used)
int height = historyImage[imageIndex].height() - titleFontPixelHeight;
int y_used = height - height * used + 0.5;
- drawLine(imageIndex, x, 0, y_used, bgColour);
drawLine(imageIndex, x, y_used, height, swapUsedColour);
++historyOffset;
if (historyOffset == historyLength * 2)
historyOffset = 0;
+ if (!(historyOffset % historyLength))
+ historyImage[1 - imageIndex].fill(Qt::transparent);
update();
}
@@ -355,13 +365,14 @@ void RazorSysStatContent::networkUpdate(unsigned received, unsigned transmitted)
int y_max = height - height * max_value + 0.5;
QColor maxColor = (received > transmitted) ? netReceivedColour : netTransmittedColour;
- drawLine(imageIndex, x, 0, y_max, bgColour);
drawLine(imageIndex, x, y_max, y_min, maxColor);
drawLine(imageIndex, x, y_min, height, netBothColour);
++historyOffset;
if (historyOffset == historyLength * 2)
historyOffset = 0;
+ if (!(historyOffset % historyLength))
+ historyImage[1 - imageIndex].fill(Qt::transparent);
update();
@@ -382,8 +393,6 @@ void RazorSysStatContent::paintEvent(QPaintEvent *)
graphHeight -= graphTop;
}
- p.fillRect(rect(), bgColour);
-
if (!titleLabel.isEmpty())
{
p.setPen(titleColour);
@@ -52,7 +52,7 @@ protected slots:
virtual void showConfigureDialog();
private:
- RazorSysStatContent *content;
+ RazorSysStatContent *mContent;
};
class RazorSysStatContent : public QWidget
@@ -59,7 +59,6 @@ RazorSysStatConfiguration::RazorSysStatConfiguration(QSettings &settings, QWidge
connect(ui->buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(dialogButtonsAction(QAbstractButton*)));
- CONNECT_SELECT_COLOUR(bgColour)
CONNECT_SELECT_COLOUR(gridColour)
CONNECT_SELECT_COLOUR(titleColour)
CONNECT_SELECT_COLOUR(cpuSystem)
@@ -96,12 +95,11 @@ void RazorSysStatConfiguration::loadSettings()
{
lockSaving = true;
- applyColor(ui->bgColourF, QColor(mSettings.value("graph/bgColour", "0x000000").toString().toInt(NULL, 0) | 0xff000000));
ui->intervalSB->setValue(mSettings.value("graph/updateInterval", 1.0).toDouble());
ui->sizeSB->setValue(mSettings.value("graph/historyLength", 30).toInt());
ui->linesSB->setValue(mSettings.value("grid/lines", 1).toInt());
- applyColor(ui->gridColourF, QColor(mSettings.value("grid/colour", "0x808080").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->gridColourF, QColor(mSettings.value("grid/colour", "#808080").toString()));
ui->labelLE->setText(mSettings.value("title/label", QString()).toString());
QFont defaultFont(QApplication::font());
@@ -111,7 +109,7 @@ void RazorSysStatConfiguration::loadSettings()
mSettings.value("title/font/weight", defaultFont.weight()).toInt(),
mSettings.value("title/font/italic", defaultFont.italic()).toBool() );
ui->fontValueL->setText(constructFontDescription(titleFont));
- applyColor(ui->titleColourF, QColor(mSettings.value("title/colour", "0xffffff").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->titleColourF, QColor(mSettings.value("title/colour", "#ffffff").toString()));
int typeIndex = ui->typeCOB->findText(mSettings.value("data/type", QString("CPU")).toString());
ui->typeCOB->setCurrentIndex((typeIndex >= 0) ? typeIndex : 0);
@@ -120,20 +118,20 @@ void RazorSysStatConfiguration::loadSettings()
int sourceIndex = ui->sourceCOB->findText(mSettings.value("data/source", QString()).toString());
ui->sourceCOB->setCurrentIndex((sourceIndex >= 0) ? sourceIndex : 0);
- applyColor(ui->cpuSystemF, QColor(mSettings.value("cpu/systemColour", "0x800000").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->cpuUserF, QColor(mSettings.value("cpu/userColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->cpuNiceF, QColor(mSettings.value("cpu/niceColour", "0x008000").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->cpuOtherF, QColor(mSettings.value("cpu/otherColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->cpuSystemF, QColor(mSettings.value("cpu/systemColour", "#800000").toString()));
+ applyColor(ui->cpuUserF, QColor(mSettings.value("cpu/userColour", "#000080").toString()));
+ applyColor(ui->cpuNiceF, QColor(mSettings.value("cpu/niceColour", "#008000").toString()));
+ applyColor(ui->cpuOtherF, QColor(mSettings.value("cpu/otherColour", "#808000").toString()));
ui->useFrequencyCB->setChecked(mSettings.value("cpu/useFrequency", true).toBool());
- applyColor(ui->frequencyF, QColor(mSettings.value("cpu/frequencyColour", "0x202020").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->frequencyF, QColor(mSettings.value("cpu/frequencyColour", "#202020").toString()));
- applyColor(ui->memAppsF, QColor(mSettings.value("mem/appsColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->memBuffersF, QColor(mSettings.value("mem/buffersColour", "0x008000").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->memCachedF, QColor(mSettings.value("mem/cachedColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->swapUsedF, QColor(mSettings.value("mem/swapColour", "0x800000").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->memAppsF, QColor(mSettings.value("mem/appsColour", "#000080").toString()));
+ applyColor(ui->memBuffersF, QColor(mSettings.value("mem/buffersColour", "#008000").toString()));
+ applyColor(ui->memCachedF, QColor(mSettings.value("mem/cachedColour", "#808000").toString()));
+ applyColor(ui->swapUsedF, QColor(mSettings.value("mem/swapColour", "#800000").toString()));
- applyColor(ui->netReceivedF, QColor(mSettings.value("net/receivedColour", "0x000080").toString().toInt(NULL, 0) | 0xff000000));
- applyColor(ui->netTransmittedF, QColor(mSettings.value("net/transmittedColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000));
+ applyColor(ui->netReceivedF, QColor(mSettings.value("net/receivedColour", "#000080").toString()));
+ applyColor(ui->netTransmittedF, QColor(mSettings.value("net/transmittedColour", "#808000").toString()));
ui->maximumHS->setValue(PluginSysStat::netSpeedFromString(mSettings.value("net/maximumSpeed", "1 MB/s").toString()));
on_maximumHS_valueChanged(ui->maximumHS->value());
ui->logarithmicCB->setChecked(mSettings.value("net/logarithmicScale", true).toBool());
@@ -147,37 +145,36 @@ void RazorSysStatConfiguration::saveSettings()
if (lockSaving)
return;
- mSettings.setValue("graph/bgColour", QString("0x%1").arg(ui->bgColourF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
mSettings.setValue("graph/updateInterval", ui->intervalSB->value());
mSettings.setValue("graph/historyLength", ui->sizeSB->value());
mSettings.setValue("grid/lines", ui->linesSB->value());
- mSettings.setValue("grid/colour", QString("0x%1").arg(ui->gridColourF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("grid/colour", ui->gridColourF->palette().color(QPalette::Window).name());
mSettings.setValue("title/label", ui->labelLE->text());
mSettings.setValue("title/font/family", titleFont.family());
mSettings.setValue("title/font/pointSize", titleFont.pointSize());
mSettings.setValue("title/font/weight", titleFont.weight());
mSettings.setValue("title/font/italic", titleFont.italic());
- mSettings.setValue("title/colour", QString("0x%1").arg(ui->titleColourF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("title/colour", ui->titleColourF->palette().color(QPalette::Window).name());
mSettings.setValue("data/type", ui->typeCOB->currentText());
mSettings.setValue("data/source", ui->sourceCOB->currentText());
- mSettings.setValue("cpu/systemColour", QString("0x%1").arg(ui->cpuSystemF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("cpu/userColour", QString("0x%1").arg(ui->cpuUserF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("cpu/niceColour", QString("0x%1").arg(ui->cpuNiceF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("cpu/otherColour", QString("0x%1").arg(ui->cpuOtherF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("cpu/systemColour", ui->cpuSystemF->palette().color(QPalette::Window).name());
+ mSettings.setValue("cpu/userColour", ui->cpuUserF ->palette().color(QPalette::Window).name());
+ mSettings.setValue("cpu/niceColour", ui->cpuNiceF ->palette().color(QPalette::Window).name());
+ mSettings.setValue("cpu/otherColour", ui->cpuOtherF ->palette().color(QPalette::Window).name());
mSettings.setValue("cpu/useFrequency", ui->useFrequencyCB->isChecked());
- mSettings.setValue("cpu/frequencyColour", QString("0x%1").arg(ui->frequencyF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("cpu/frequencyColour", ui->frequencyF->palette().color(QPalette::Window).name());
- mSettings.setValue("mem/appsColour", QString("0x%1").arg(ui->memAppsF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("mem/buffersColour", QString("0x%1").arg(ui->memBuffersF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("mem/cachedColour", QString("0x%1").arg(ui->memCachedF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("mem/swapColour", QString("0x%1").arg(ui->swapUsedF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("mem/appsColour", ui->memAppsF ->palette().color(QPalette::Window).name());
+ mSettings.setValue("mem/buffersColour", ui->memBuffersF->palette().color(QPalette::Window).name());
+ mSettings.setValue("mem/cachedColour", ui->memCachedF ->palette().color(QPalette::Window).name());
+ mSettings.setValue("mem/swapColour", ui->swapUsedF ->palette().color(QPalette::Window).name());
- mSettings.setValue("net/receivedColour", QString("0x%1").arg(ui->netReceivedF ->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
- mSettings.setValue("net/transmittedColour", QString("0x%1").arg(ui->netTransmittedF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
+ mSettings.setValue("net/receivedColour", ui->netReceivedF ->palette().color(QPalette::Window).name());
+ mSettings.setValue("net/transmittedColour", ui->netTransmittedF->palette().color(QPalette::Window).name());
mSettings.setValue("net/maximumSpeed", PluginSysStat::netSpeedToString(ui->maximumHS->value()));
mSettings.setValue("net/logarithmicScale", ui->logarithmicCB->isChecked());
mSettings.setValue("net/logarithmicScaleSteps", ui->logScaleSB->value());
Oops, something went wrong.

0 comments on commit dae56f1

Please sign in to comment.