Color highlight FITS header
This commit is contained in:
+10
-1
@@ -2,6 +2,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
QMap<QString, QColor> headerHighlight;
|
||||||
|
|
||||||
ImageInfo::ImageInfo(QWidget *parent) : QTreeWidget(parent)
|
ImageInfo::ImageInfo(QWidget *parent) : QTreeWidget(parent)
|
||||||
{
|
{
|
||||||
setColumnCount(3);
|
setColumnCount(3);
|
||||||
@@ -25,7 +27,14 @@ void ImageInfo::setInfo(const ImageInfoData &info)
|
|||||||
QTreeWidgetItem *fitsHeader = new QTreeWidgetItem({tr("FITS Header")});
|
QTreeWidgetItem *fitsHeader = new QTreeWidgetItem({tr("FITS Header")});
|
||||||
for(const FITSRecord &record : info.fitsHeader)
|
for(const FITSRecord &record : info.fitsHeader)
|
||||||
{
|
{
|
||||||
new QTreeWidgetItem(fitsHeader, {record.key, record.value.toString().left(1024), record.comment});
|
QTreeWidgetItem *item = new QTreeWidgetItem(fitsHeader, {record.key, record.value.toString().left(1024), record.comment});
|
||||||
|
if(headerHighlight.contains(record.key))
|
||||||
|
{
|
||||||
|
QColor color = headerHighlight[record.key];
|
||||||
|
item->setBackground(0, color);
|
||||||
|
item->setBackground(1, color);
|
||||||
|
item->setBackground(2, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addTopLevelItem(fitsHeader);
|
addTopLevelItem(fitsHeader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,15 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QColorDialog>
|
||||||
#include "rawimage.h"
|
#include "rawimage.h"
|
||||||
|
|
||||||
extern int DEFAULT_WIDTH;
|
extern int DEFAULT_WIDTH;
|
||||||
extern double SATURATION;
|
extern double SATURATION;
|
||||||
extern int FILTERING;
|
extern int FILTERING;
|
||||||
extern bool BESTFIT;
|
extern bool BESTFIT;
|
||||||
|
extern QMap<QString, QColor> headerHighlight;
|
||||||
|
|
||||||
class EvenNumber : public QSpinBox
|
class EvenNumber : public QSpinBox
|
||||||
{
|
{
|
||||||
@@ -87,6 +90,44 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
|
|||||||
m_bestFit->setChecked(BESTFIT);
|
m_bestFit->setChecked(BESTFIT);
|
||||||
|
|
||||||
|
|
||||||
|
m_headerHighlight = new QListWidget(this);
|
||||||
|
for(auto i = headerHighlight.begin(); i != headerHighlight.end(); i++)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(m_headerHighlight);
|
||||||
|
item->setText(i.key());
|
||||||
|
item->setBackground(i.value());
|
||||||
|
}
|
||||||
|
m_keyword = new QLineEdit(this);
|
||||||
|
QPushButton *color = new QPushButton(this);
|
||||||
|
QPixmap pix(16, 16);
|
||||||
|
pix.fill(m_color);
|
||||||
|
color->setIcon(pix);
|
||||||
|
connect(color, &QPushButton::clicked, [this, color](){
|
||||||
|
QColor rgb = QColorDialog::getColor(m_color, this);
|
||||||
|
if(rgb.isValid())
|
||||||
|
{
|
||||||
|
QPixmap pix(16, 16);
|
||||||
|
pix.fill(rgb);
|
||||||
|
color->setIcon(pix);
|
||||||
|
m_color = rgb;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QPushButton *add = new QPushButton(tr("Add keyword highlight"), this);
|
||||||
|
connect(add, &QPushButton::clicked, [this](){
|
||||||
|
auto list = m_headerHighlight->findItems(m_keyword->text(), Qt::MatchFixedString | Qt::MatchCaseSensitive);
|
||||||
|
if(list.size())return;
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(m_headerHighlight);
|
||||||
|
item->setText(m_keyword->text());
|
||||||
|
item->setBackground(m_color);
|
||||||
|
});
|
||||||
|
QPushButton *remove = new QPushButton(tr("Remove keyword highlight"), this);
|
||||||
|
connect(remove, &QPushButton::clicked, [this](){
|
||||||
|
auto list = m_headerHighlight->selectedItems();
|
||||||
|
for(auto item : list)
|
||||||
|
delete item;
|
||||||
|
});
|
||||||
|
|
||||||
layout->addRow(tr("Image preload count"), m_preloadImages);
|
layout->addRow(tr("Image preload count"), m_preloadImages);
|
||||||
layout->addRow(tr("Thumbnails size"), m_thumSize);
|
layout->addRow(tr("Thumbnails size"), m_thumSize);
|
||||||
layout->addRow(tr("Saturation"), m_saturation);
|
layout->addRow(tr("Saturation"), m_saturation);
|
||||||
@@ -95,6 +136,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
|
|||||||
layout->addRow(m_qualityThumbnail);
|
layout->addRow(m_qualityThumbnail);
|
||||||
layout->addRow(m_useNativeDialog);
|
layout->addRow(m_useNativeDialog);
|
||||||
layout->addRow(m_bestFit);
|
layout->addRow(m_bestFit);
|
||||||
|
layout->addRow(m_headerHighlight);
|
||||||
|
layout->addRow(m_keyword, color);
|
||||||
|
layout->addRow(add, remove);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN64
|
#ifdef Q_OS_WIN64
|
||||||
QPushButton *installThumbnailer = new QPushButton(tr("Install"), this);
|
QPushButton *installThumbnailer = new QPushButton(tr("Install"), this);
|
||||||
@@ -125,6 +169,11 @@ void SettingsDialog::loadSettings()
|
|||||||
FILTERING = settings.value("settings/filtering", FILTERING).toInt();
|
FILTERING = settings.value("settings/filtering", FILTERING).toInt();
|
||||||
QUALITY_RESIZE = settings.value("settings/qualitythumbnail", QUALITY_RESIZE).toBool();
|
QUALITY_RESIZE = settings.value("settings/qualitythumbnail", QUALITY_RESIZE).toBool();
|
||||||
BESTFIT = settings.value("settings/bestfit", BESTFIT).toBool();
|
BESTFIT = settings.value("settings/bestfit", BESTFIT).toBool();
|
||||||
|
QStringList keywords = settings.value("settings/headerhighlightkeywords").toStringList();
|
||||||
|
QStringList colors = settings.value("settings/headerhighlightcolors").toStringList();
|
||||||
|
for(int i = 0; i < std::min(keywords.size(), colors.size()); i++)
|
||||||
|
headerHighlight.insert(keywords[i], QColor::fromString(colors[i]));
|
||||||
|
|
||||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, settings.value("settings/dontusenativedialogs", false).toBool());
|
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, settings.value("settings/dontusenativedialogs", false).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,4 +224,15 @@ void SettingsDialog::saveSettings()
|
|||||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, m_useNativeDialog->isChecked());
|
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, m_useNativeDialog->isChecked());
|
||||||
if(DEFAULT_WIDTH != m_preloadImages->value())
|
if(DEFAULT_WIDTH != m_preloadImages->value())
|
||||||
emit preloadChanged(m_preloadImages->value());
|
emit preloadChanged(m_preloadImages->value());
|
||||||
|
|
||||||
|
headerHighlight.clear();
|
||||||
|
QStringList colors;
|
||||||
|
for(int i = 0; i < m_headerHighlight->count(); i++)
|
||||||
|
{
|
||||||
|
auto item = m_headerHighlight->item(i);
|
||||||
|
colors.push_back(item->background().color().name());
|
||||||
|
headerHighlight[item->text()] = item->background().color();
|
||||||
|
}
|
||||||
|
settings.setValue("settings/headerhighlightkeywords", headerHighlight.keys());
|
||||||
|
settings.setValue("settings/headerhighlightcolors", colors);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
class SettingsDialog : public QDialog
|
class SettingsDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,9 @@ private:
|
|||||||
QCheckBox *m_qualityThumbnail;
|
QCheckBox *m_qualityThumbnail;
|
||||||
QComboBox *m_filtering;
|
QComboBox *m_filtering;
|
||||||
QCheckBox *m_bestFit;
|
QCheckBox *m_bestFit;
|
||||||
|
QListWidget *m_headerHighlight;
|
||||||
|
QColor m_color = Qt::yellow;
|
||||||
|
QLineEdit *m_keyword;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSDIALOG_H
|
#endif // SETTINGSDIALOG_H
|
||||||
|
|||||||
Reference in New Issue
Block a user