mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
plot: only select a color on double click
otherwise we will get some random globalcolor from qt
This commit is contained in:
@@ -1564,14 +1564,13 @@ void MainWindow::on_treePlotColumns_itemChanged(QTreeWidgetItem *changeitem, int
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(column == PlotColumnY)
|
||||
{
|
||||
if(changeitem->checkState(column) == Qt::Checked)
|
||||
{
|
||||
QColorDialog colordialog(this);
|
||||
// get a default color
|
||||
QColor curbkcolor = changeitem->backgroundColor(column);
|
||||
QColor precolor = !curbkcolor.isValid() ? (Qt::GlobalColor)(qrand() % 13 + 5) : curbkcolor;
|
||||
QColor color = colordialog.getColor(precolor, this, tr("Choose a axis color"));
|
||||
QColor color = !curbkcolor.isValid() ? (Qt::GlobalColor)(qrand() % 13 + 5) : curbkcolor;
|
||||
if(color.isValid())
|
||||
{
|
||||
changeitem->setBackgroundColor(column, color);
|
||||
@@ -1589,6 +1588,36 @@ void MainWindow::on_treePlotColumns_itemChanged(QTreeWidgetItem *changeitem, int
|
||||
updatePlot(m_currentPlotModel, false);
|
||||
}
|
||||
|
||||
void MainWindow::on_treePlotColumns_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
// disable change updates, or we get unwanted redrawing and weird behavior
|
||||
disconnect(ui->treePlotColumns, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
|
||||
this,SLOT(on_treePlotColumns_itemChanged(QTreeWidgetItem*,int)));
|
||||
|
||||
if(column == PlotColumnY)
|
||||
{
|
||||
// On double click open the colordialog
|
||||
QColorDialog colordialog(this);
|
||||
QColor curbkcolor = item->backgroundColor(column);
|
||||
QColor precolor = !curbkcolor.isValid() ? (Qt::GlobalColor)(qrand() % 13 + 5) : curbkcolor;
|
||||
QColor color = colordialog.getColor(precolor, this, tr("Choose a axis color"));
|
||||
if(color.isValid())
|
||||
{
|
||||
item->setCheckState(column, Qt::Checked);
|
||||
item->setBackgroundColor(column, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setCheckState(column, Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
connect(ui->treePlotColumns, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
|
||||
this,SLOT(on_treePlotColumns_itemChanged(QTreeWidgetItem*,int)));
|
||||
|
||||
updatePlot(m_currentPlotModel, false);
|
||||
}
|
||||
|
||||
void MainWindow::on_butSavePlot_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
|
||||
@@ -168,6 +168,7 @@ private slots:
|
||||
virtual void httpresponse(QNetworkReply* reply);
|
||||
virtual void updatePlot(SqliteTableModel* model, bool update = true);
|
||||
void on_treePlotColumns_itemChanged(QTreeWidgetItem *item, int column);
|
||||
void on_treePlotColumns_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void on_butSavePlot_clicked();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user