Skip to content

Commit

Permalink
Save/Restore Overview column widths
Browse files Browse the repository at this point in the history
Fixes #4007.
  • Loading branch information
liversedge committed Aug 15, 2021
1 parent 2ea3080 commit 5fd1a08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Charts/Overview.cpp
Expand Up @@ -104,6 +104,20 @@ OverviewWindow::getConfiguration() const

// setup
config = "{\n \"version\":\"2.0\",\n";
config += " \"widths\":[";

// column widths
bool first=true;
foreach(int n, space->columnWidths()) {

// last one doesn't have a comma
if (!first) config += ",";
else first=false;

config += QString(" %1").arg(n);
}
config += " ],\n";

config += " \"CHARTS\":[\n";

// do cards
Expand Down Expand Up @@ -290,6 +304,15 @@ OverviewWindow::setConfiguration(QString config)
goto defaultsetup;
}

// does it contain widths (we added this later)
if (root.contains("widths")) {

QVector<int> widths;
QJsonArray w = root["widths"].toArray();
foreach(const QJsonValue width, w) widths << width.toInt();
space->setColumnWidths(widths);
}

// cards
QJsonArray CHARTS = root["CHARTS"].toArray();
foreach(const QJsonValue val, CHARTS) {
Expand Down
4 changes: 4 additions & 0 deletions src/Gui/ChartSpace.h
Expand Up @@ -197,6 +197,10 @@ class ChartSpace : public QWidget
void dateRangeChanged(DateRange);
void filterChanged();

// column sizing
QVector<int> columnWidths() { return columns; }
void setColumnWidths(QVector<int> x) { columns =x; updateGeometry(); }

// for smooth scrolling
void setViewY(int x) { if (_viewY != x) {_viewY =x; updateView();} }
int getViewY() const { return _viewY; }
Expand Down

0 comments on commit 5fd1a08

Please sign in to comment.