mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:46:41 +00:00
UI: Options: Traffic Graph: Add "Reset to defaults" button
This commit is contained in:
parent
3f7c5844d0
commit
63fc8a386f
@ -102,69 +102,83 @@ public:
|
||||
bool progPurgeOnStart() const { return valueBool("prog/purgeOnStart"); }
|
||||
void setProgPurgeOnStart(bool v) { setValue("prog/purgeOnStart", v); }
|
||||
|
||||
constexpr bool graphWindowAlwaysOnTopDefault() const { return true; }
|
||||
bool graphWindowAlwaysOnTop() const { return valueBool("graphWindow/alwaysOnTop", true); }
|
||||
void setGraphWindowAlwaysOnTop(bool on) { setValue("graphWindow/alwaysOnTop", on); }
|
||||
|
||||
constexpr bool graphWindowFramelessDefault() const { return false; }
|
||||
bool graphWindowFrameless() const { return valueBool("graphWindow/frameless"); }
|
||||
void setGraphWindowFrameless(bool on) { setValue("graphWindow/frameless", on); }
|
||||
|
||||
constexpr bool graphWindowClickThroughDefault() const { return false; }
|
||||
bool graphWindowClickThrough() const { return valueBool("graphWindow/clickThrough"); }
|
||||
void setGraphWindowClickThrough(bool on) { setValue("graphWindow/clickThrough", on); }
|
||||
|
||||
constexpr bool graphWindowHideOnHoverDefault() const { return false; }
|
||||
bool graphWindowHideOnHover() const { return valueBool("graphWindow/hideOnHover"); }
|
||||
void setGraphWindowHideOnHover(bool on) { setValue("graphWindow/hideOnHover", on); }
|
||||
|
||||
constexpr int graphWindowOpacityDefault() const { return 90; }
|
||||
int graphWindowOpacity() const { return valueInt("graphWindow/opacity", 90); }
|
||||
void setGraphWindowOpacity(int v) { setValue("graphWindow/opacity", v); }
|
||||
|
||||
constexpr int graphWindowHoverOpacityDefault() const { return 95; }
|
||||
int graphWindowHoverOpacity() const { return valueInt("graphWindow/hoverOpacity", 95); }
|
||||
void setGraphWindowHoverOpacity(int v) { setValue("graphWindow/hoverOpacity", v); }
|
||||
|
||||
constexpr int graphWindowMaxSecondsDefault() const { return 500; }
|
||||
int graphWindowMaxSeconds() const { return valueInt("graphWindow/maxSeconds", 500); }
|
||||
void setGraphWindowMaxSeconds(int v) { setValue("graphWindow/maxSeconds", v); }
|
||||
|
||||
constexpr QColor graphWindowColorDefault() const { return QColor(255, 255, 255); }
|
||||
QColor graphWindowColor() const
|
||||
{
|
||||
return valueColor("graphWindow/color", QColor(255, 255, 255));
|
||||
return valueColor("graphWindow/color", graphWindowColorDefault());
|
||||
}
|
||||
void setGraphWindowColor(const QColor &v) { setColor("graphWindow/color", v); }
|
||||
|
||||
constexpr QColor graphWindowColorInDefault() const { return QColor(52, 196, 84); }
|
||||
QColor graphWindowColorIn() const
|
||||
{
|
||||
return valueColor("graphWindow/colorIn", QColor(52, 196, 84));
|
||||
return valueColor("graphWindow/colorIn", graphWindowColorInDefault());
|
||||
}
|
||||
void setGraphWindowColorIn(const QColor &v) { setColor("graphWindow/colorIn", v); }
|
||||
|
||||
constexpr QColor graphWindowColorOutDefault() const { return QColor(235, 71, 63); }
|
||||
QColor graphWindowColorOut() const
|
||||
{
|
||||
return valueColor("graphWindow/colorOut", QColor(235, 71, 63));
|
||||
return valueColor("graphWindow/colorOut", graphWindowColorOutDefault());
|
||||
}
|
||||
void setGraphWindowColorOut(const QColor &v) { setColor("graphWindow/colorOut", v); }
|
||||
|
||||
constexpr QColor graphWindowAxisColorDefault() const { return QColor(0, 0, 0); }
|
||||
QColor graphWindowAxisColor() const
|
||||
{
|
||||
return valueColor("graphWindow/axisColor", QColor(0, 0, 0));
|
||||
return valueColor("graphWindow/axisColor", graphWindowAxisColorDefault());
|
||||
}
|
||||
void setGraphWindowAxisColor(const QColor &v) { setColor("graphWindow/axisColor", v); }
|
||||
|
||||
constexpr QColor graphWindowTickLabelColorDefault() const { return QColor(0, 0, 0); }
|
||||
QColor graphWindowTickLabelColor() const
|
||||
{
|
||||
return valueColor("graphWindow/tickLabelColor", QColor(0, 0, 0));
|
||||
return valueColor("graphWindow/tickLabelColor", graphWindowTickLabelColorDefault());
|
||||
}
|
||||
void setGraphWindowTickLabelColor(const QColor &v)
|
||||
{
|
||||
setColor("graphWindow/tickLabelColor", v);
|
||||
}
|
||||
|
||||
constexpr QColor graphWindowLabelColorDefault() const { return QColor(0, 0, 0); }
|
||||
QColor graphWindowLabelColor() const
|
||||
{
|
||||
return valueColor("graphWindow/labelColor", QColor(0, 0, 0));
|
||||
return valueColor("graphWindow/labelColor", graphWindowLabelColorDefault());
|
||||
}
|
||||
void setGraphWindowLabelColor(const QColor &v) { setColor("graphWindow/labelColor", v); }
|
||||
|
||||
constexpr QColor graphWindowGridColorDefault() const { return QColor(200, 200, 200); }
|
||||
QColor graphWindowGridColor() const
|
||||
{
|
||||
return valueColor("graphWindow/gridColor", QColor(200, 200, 200));
|
||||
return valueColor("graphWindow/gridColor", graphWindowGridColorDefault());
|
||||
}
|
||||
void setGraphWindowGridColor(const QColor &v) { setColor("graphWindow/gridColor", v); }
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@ -21,7 +22,10 @@ GraphPage::GraphPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctr
|
||||
|
||||
void GraphPage::onRetranslateUi()
|
||||
{
|
||||
m_gbGraph->setTitle(tr("Graph"));
|
||||
m_btResetToDefaults->setText(tr("Reset to defaults"));
|
||||
|
||||
m_gbGraph->setTitle(tr("Window"));
|
||||
m_gbColors->setTitle(tr("Colors"));
|
||||
|
||||
m_cbGraphAlwaysOnTop->setText(tr("Always on top"));
|
||||
m_cbGraphFrameless->setText(tr("Frameless"));
|
||||
@ -30,6 +34,7 @@ void GraphPage::onRetranslateUi()
|
||||
m_graphOpacity->label()->setText(tr("Opacity:"));
|
||||
m_graphHoverOpacity->label()->setText(tr("Hover opacity:"));
|
||||
m_graphMaxSeconds->label()->setText(tr("Max seconds:"));
|
||||
|
||||
m_graphColor->label()->setText(tr("Background:"));
|
||||
m_graphColorIn->label()->setText(tr("Download:"));
|
||||
m_graphColorOut->label()->setText(tr("Upload:"));
|
||||
@ -40,6 +45,49 @@ void GraphPage::onRetranslateUi()
|
||||
}
|
||||
|
||||
void GraphPage::setupUi()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
|
||||
// Header
|
||||
auto header = setupHeader();
|
||||
layout->addLayout(header);
|
||||
|
||||
// Columns
|
||||
auto colLayout = setupColumns();
|
||||
layout->addLayout(colLayout, 1);
|
||||
|
||||
this->setLayout(layout);
|
||||
}
|
||||
|
||||
QLayout *GraphPage::setupHeader()
|
||||
{
|
||||
auto layout = new QHBoxLayout();
|
||||
|
||||
m_btResetToDefaults = ControlUtil::createButton(":/icons/arrow_refresh_small.png", [&] {
|
||||
m_cbGraphAlwaysOnTop->setChecked(ini()->graphWindowAlwaysOnTopDefault());
|
||||
m_cbGraphFrameless->setChecked(ini()->graphWindowFramelessDefault());
|
||||
m_cbGraphClickThrough->setChecked(ini()->graphWindowClickThroughDefault());
|
||||
m_cbGraphHideOnHover->setChecked(ini()->graphWindowHideOnHoverDefault());
|
||||
m_graphOpacity->spinBox()->setValue(ini()->graphWindowOpacityDefault());
|
||||
m_graphHoverOpacity->spinBox()->setValue(ini()->graphWindowHoverOpacityDefault());
|
||||
m_graphMaxSeconds->spinBox()->setValue(ini()->graphWindowMaxSecondsDefault());
|
||||
|
||||
m_graphColor->setColor(ini()->graphWindowColorDefault());
|
||||
m_graphColorIn->setColor(ini()->graphWindowColorInDefault());
|
||||
m_graphColorOut->setColor(ini()->graphWindowColorOutDefault());
|
||||
m_graphAxisColor->setColor(ini()->graphWindowAxisColorDefault());
|
||||
m_graphTickLabelColor->setColor(ini()->graphWindowTickLabelColorDefault());
|
||||
m_graphLabelColor->setColor(ini()->graphWindowLabelColorDefault());
|
||||
m_graphGridColor->setColor(ini()->graphWindowGridColorDefault());
|
||||
});
|
||||
|
||||
layout->addStretch();
|
||||
layout->addWidget(m_btResetToDefaults);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
QLayout *GraphPage::setupColumns()
|
||||
{
|
||||
// Column #1
|
||||
auto colLayout1 = setupColumn1();
|
||||
@ -54,7 +102,7 @@ void GraphPage::setupUi()
|
||||
layout->addLayout(colLayout2);
|
||||
layout->addStretch();
|
||||
|
||||
this->setLayout(layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
QLayout *GraphPage::setupColumn1()
|
||||
@ -71,35 +119,14 @@ QLayout *GraphPage::setupColumn1()
|
||||
return layout;
|
||||
}
|
||||
|
||||
QLayout *GraphPage::setupColumn2()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setSpacing(10);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void GraphPage::setupGraphBox()
|
||||
{
|
||||
setupGraphCheckboxes();
|
||||
setupGraphOptions();
|
||||
setupGraphColors();
|
||||
|
||||
// Layout
|
||||
auto colLayout1 = ControlUtil::createLayoutByWidgets({ m_cbGraphAlwaysOnTop, m_cbGraphFrameless,
|
||||
auto layout = ControlUtil::createLayoutByWidgets({ m_cbGraphAlwaysOnTop, m_cbGraphFrameless,
|
||||
m_cbGraphClickThrough, m_cbGraphHideOnHover, ControlUtil::createSeparator(),
|
||||
m_graphOpacity, m_graphHoverOpacity, m_graphMaxSeconds, nullptr });
|
||||
|
||||
auto colLayout2 =
|
||||
ControlUtil::createLayoutByWidgets({ m_graphColor, m_graphColorIn, m_graphColorOut,
|
||||
m_graphAxisColor, m_graphTickLabelColor, m_graphLabelColor, m_graphGridColor });
|
||||
|
||||
auto layout = new QHBoxLayout();
|
||||
layout->addLayout(colLayout1);
|
||||
layout->addWidget(ControlUtil::createSeparator(Qt::Vertical));
|
||||
layout->addLayout(colLayout2);
|
||||
m_graphOpacity, m_graphHoverOpacity, m_graphMaxSeconds });
|
||||
|
||||
m_gbGraph = new QGroupBox();
|
||||
m_gbGraph->setLayout(layout);
|
||||
@ -163,6 +190,32 @@ void GraphPage::setupGraphOptions()
|
||||
});
|
||||
}
|
||||
|
||||
QLayout *GraphPage::setupColumn2()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setSpacing(10);
|
||||
|
||||
// Graph Colors Group Box
|
||||
setupColorsBox();
|
||||
layout->addWidget(m_gbColors);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void GraphPage::setupColorsBox()
|
||||
{
|
||||
setupGraphColors();
|
||||
|
||||
auto layout =
|
||||
ControlUtil::createLayoutByWidgets({ m_graphColor, m_graphColorIn, m_graphColorOut,
|
||||
m_graphAxisColor, m_graphTickLabelColor, m_graphLabelColor, m_graphGridColor });
|
||||
|
||||
m_gbColors = new QGroupBox();
|
||||
m_gbColors->setLayout(layout);
|
||||
}
|
||||
|
||||
void GraphPage::setupGraphColors()
|
||||
{
|
||||
m_graphColor = ControlUtil::createLabelColor(ini()->graphWindowColor(), [&](const QColor &v) {
|
||||
|
@ -18,15 +18,22 @@ protected slots:
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
QLayout *setupHeader();
|
||||
QLayout *setupColumns();
|
||||
QLayout *setupColumn1();
|
||||
void setupGraphBox();
|
||||
void setupGraphCheckboxes();
|
||||
void setupGraphOptions();
|
||||
void setupGraphColors();
|
||||
QLayout *setupColumn2();
|
||||
void setupColorsBox();
|
||||
void setupGraphColors();
|
||||
|
||||
private:
|
||||
QGroupBox *m_gbGraph = nullptr;
|
||||
QGroupBox *m_gbColors = nullptr;
|
||||
|
||||
QPushButton *m_btResetToDefaults = nullptr;
|
||||
|
||||
QCheckBox *m_cbGraphAlwaysOnTop = nullptr;
|
||||
QCheckBox *m_cbGraphFrameless = nullptr;
|
||||
QCheckBox *m_cbGraphClickThrough = nullptr;
|
||||
@ -34,6 +41,7 @@ private:
|
||||
LabelSpin *m_graphOpacity = nullptr;
|
||||
LabelSpin *m_graphHoverOpacity = nullptr;
|
||||
LabelSpin *m_graphMaxSeconds = nullptr;
|
||||
|
||||
LabelColor *m_graphColor = nullptr;
|
||||
LabelColor *m_graphColorIn = nullptr;
|
||||
LabelColor *m_graphColorOut = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user