HGGitLab

Commit 70de9c6c authored by luoliangyi's avatar luoliangyi

UI微调

parent f3abd9b7
......@@ -51,6 +51,10 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
this->setFixedHeight(380);
ui->spin_index->setFixedWidth(160);
ui->cbox_digit->setFixedWidth(80);
//Temporarily hide some functions
ui->cbtn_subFolderByBlank->setVisible(false);
ui->cbtn_subFolderByColor->setVisible(false);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>442</width>
<height>360</height>
<width>554</width>
<height>525</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -18,8 +18,8 @@
</property>
<property name="maximumSize">
<size>
<width>462</width>
<height>360</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
......
......@@ -2,6 +2,8 @@
#include "ui_dialog_imageeditor.h"
#include "graphicsscene.h"
#include <QColorDialog>
#include <app_cfg.h>
int m_textSize[] = { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 28, 72 };
int m_lineWidth[] = { 1, 3, 5, 8 };
float m_scaled[] = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 2.0f, 2.5f, 4.0f, 6.0f };
......@@ -19,6 +21,12 @@ Dialog_ImageEditor::Dialog_ImageEditor(QWidget *parent)
ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]);
ui->graphicsView->setScene(m_scene);
ui->btn_color->setStyleSheet("QPushButton{background-color:red;border:1px solid red;}");
ui->comboBox_lineWidth->setCurrentIndex(getCfgValue("imageEditor", "lineWidth", 0));
ui->comboBox_textSize->setCurrentIndex(getCfgValue("imageEditor", "textSize", 0));
ui->comboBox_textSize->setFixedWidth(80);
ui->comboBox_lineWidth->setFixedWidth(120);
}
Dialog_ImageEditor::~Dialog_ImageEditor()
......@@ -154,7 +162,9 @@ void Dialog_ImageEditor::on_btn_undo_clicked()
void Dialog_ImageEditor::on_btn_ok_clicked()
{
//exportImage().save("2.jpg");
saveCfgValue("imageEditor", "lineWidth", ui->comboBox_lineWidth->currentIndex());
saveCfgValue("imageEditor", "textSize", ui->comboBox_textSize->currentIndex());
accept();
}
......
#include "dialog_imgproc_adjust.h"
#include "ui_dialog_imgproc_adjust.h"
#include "imgproc/HGImgProc.h"
#include "app_cfg.h"
Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
QDialog(parent),
......@@ -8,23 +9,32 @@ Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
{
ui->setupUi(this);
m_base_widget = new Widget_Imgproc_Base(this);
reinterpret_cast<QVBoxLayout*>(this->layout())->insertWidget(2, m_base_widget);
connect(m_base_widget, SIGNAL(brightness_change(int)), this, SLOT(on_brightness_change(int)));
connect(m_base_widget, SIGNAL(contrast_change(int)), this, SLOT(on_contrast_change(int)));
connect(m_base_widget, SIGNAL(gamma_change(double)), this, SLOT(on_gamma_change(double)));
ui->view_before->addImage(img);
ui->view_after->addImage(img);
m_brightness = getCfgValue("adjust", "brightness", 0);
m_base_widget->setBrightness(m_brightness);
m_contrast = getCfgValue("adjust", "contrast", 0);
m_base_widget->setContrast(m_contrast);
QString gamma = getCfgValue("adjust", "gamma", QString("1.0"));
m_gamma = atof(gamma.toStdString().c_str());
m_base_widget->setGamma(m_gamma);
ui->cbtn_preview->setChecked(getCfgValue("adjust", "preview", false));
ui->cbtn_applyImg->setChecked(getCfgValue("adjust", "applyImg", false));
ui->gbox_before->setVisible(ui->cbtn_preview->isChecked());
ui->gbox_after->setVisible(ui->cbtn_preview->isChecked());
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("restore default"));
m_base_widget = new Widget_Imgproc_Base(this);
reinterpret_cast<QVBoxLayout*>(this->layout())->insertWidget(2, m_base_widget);
connect(m_base_widget, SIGNAL(brightness_change(int)), this, SLOT(on_brightness_change(int)));
connect(m_base_widget, SIGNAL(contrast_change(int)), this, SLOT(on_contrast_change(int)));
connect(m_base_widget, SIGNAL(gamma_change(double)), this, SLOT(on_gamma_change(double)));
m_brightness = 0;
m_contrast = 0;
m_gamma = 1.0;
}
Dialog_ImgProc_Adjust::~Dialog_ImgProc_Adjust()
......@@ -49,18 +59,23 @@ HGImage Dialog_ImgProc_Adjust::getAfterImage()
void Dialog_ImgProc_Adjust::on_brightness_change(int value)
{
m_brightness = value;
saveCfgValue("adjust", "brightness", m_brightness);
process();
}
void Dialog_ImgProc_Adjust::on_contrast_change(int value)
{
m_contrast = value;
saveCfgValue("adjust", "contrast", m_contrast);
process();
}
void Dialog_ImgProc_Adjust::on_gamma_change(double value)
{
m_gamma = value;
char gamma[32];
sprintf(gamma, "%f", m_gamma);
saveCfgValue("adjust", "gamma", QString(gamma));
process();
}
......@@ -69,6 +84,7 @@ void Dialog_ImgProc_Adjust::on_cbtn_preview_toggled(bool checked)
reinterpret_cast<QVBoxLayout*>(this->layout())->setStretch(1, checked ? 1 : 0);
ui->gbox_before->setVisible(checked);
ui->gbox_after->setVisible(checked);
saveCfgValue("adjust", "preview", checked);
}
void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool checked)
......@@ -80,6 +96,7 @@ void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool checked)
ui->view_before->getImage(&img);
assert(nullptr != img);
emit applyToImage(img);
saveCfgValue("adjust", "applyImg", checked);
}
void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button)
......@@ -90,6 +107,13 @@ void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button)
m_brightness = 0;
m_contrast = 0;
m_gamma = 1.0;
saveCfgValue("adjust", "brightness", m_brightness);
saveCfgValue("adjust", "contrast", m_contrast);
char gamma[32];
sprintf(gamma, "%f", m_gamma);
saveCfgValue("adjust", "gamma", QString(gamma));
process();
}
}
......
......@@ -4,6 +4,7 @@
#include <QPushButton>
#include <QMouseEvent>
#include <QDebug>
#include "app_cfg.h"
Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
: QDialog(parent)
......@@ -14,8 +15,8 @@ Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
, m_isCrop(false)
, m_isDeskew(false)
, m_isFillBlank(false)
, m_isConvex(false)
, m_isAutoColor(false)
, m_isConvex(true)
, m_isAutoColor(true)
, m_isUseAdvancedParam(false)
, m_threshold(40)
, m_noise(8)
......@@ -28,15 +29,23 @@ Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
m_btnGroup_backgroundColor.addButton(ui->rbtn_autoColor);
m_btnGroup_backgroundColor.addButton(ui->rbtn_defaultColor);
ui->cbtn_crop->setChecked(false);
ui->cbtn_corrSkew->setChecked(false);
ui->gbox_fillBlank->setChecked(false);
ui->cbtn_crop->setChecked(getCfgValue("autoCrop", "crop", false));
ui->cbtn_corrSkew->setChecked(getCfgValue("autoCrop", "deskew", false));
ui->gbox_fillBlank->setChecked(getCfgValue("autoCrop", "fillBlank", false));
bool convex = getCfgValue("autoCrop", "convex", true);
if (convex)
ui->rbtn_convex->setChecked(true);
else
ui->rbtn_concave->setChecked(true);
bool autoColor = getCfgValue("autoCrop", "autoColor", true);
if (autoColor)
ui->rbtn_autoColor->setChecked(true);
ui->gbox_param->setChecked(false);
ui->spin_threshold->setValue(40);
ui->spin_noise->setValue(8);
ui->spin_indent->setValue(5);
else
ui->rbtn_defaultColor->setChecked(true);
ui->gbox_param->setChecked(getCfgValue("autoCrop", "useAdvancedParam", false));
ui->spin_threshold->setValue(getCfgValue("autoCrop", "threshold", 40));
ui->spin_noise->setValue(getCfgValue("autoCrop", "noise", 8));
ui->spin_indent->setValue(getCfgValue("autoCrop", "indent", 5));
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage()));
ui->lab_arrow->setPixmap(QPixmap::fromImage(QImage()));
......@@ -108,14 +117,23 @@ void Dialog_ImgProc_AutoCrop::on_buttonBox_clicked(QAbstractButton *button)
void Dialog_ImgProc_AutoCrop::on_buttonBox_accepted()
{
m_isCrop = ui->cbtn_crop->isChecked();
saveCfgValue("autoCrop", "crop", m_isCrop);
m_isDeskew = ui->cbtn_corrSkew->isChecked();
saveCfgValue("autoCrop", "deskew", m_isDeskew);
m_isFillBlank = ui->gbox_fillBlank->isChecked();
saveCfgValue("autoCrop", "fillBlank", m_isFillBlank);
m_isConvex = ui->rbtn_convex->isChecked();
saveCfgValue("autoCrop", "convex", m_isConvex);
m_isAutoColor = ui->rbtn_autoColor->isChecked();
saveCfgValue("autoCrop", "autoColor", m_isAutoColor);
m_isUseAdvancedParam = ui->gbox_param->isChecked();
saveCfgValue("autoCrop", "useAdvancedParam", m_isUseAdvancedParam);
m_threshold = ui->spin_threshold->value();
saveCfgValue("autoCrop", "threshold", m_threshold);
m_noise = ui->spin_noise->value();
saveCfgValue("autoCrop", "noise", m_noise);
m_indent = ui->spin_indent->value();
saveCfgValue("autoCrop", "indent", m_indent);
}
void Dialog_ImgProc_AutoCrop::updateExample(int example)
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>406</height>
<height>408</height>
</rect>
</property>
<property name="minimumSize">
......@@ -124,7 +124,7 @@
<widget class="QSpinBox" name="spin_threshold">
<property name="maximumSize">
<size>
<width>100</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
......@@ -151,7 +151,7 @@
<widget class="QSpinBox" name="spin_noise">
<property name="maximumSize">
<size>
<width>100</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
......@@ -178,7 +178,7 @@
<widget class="QSpinBox" name="spin_indent">
<property name="maximumSize">
<size>
<width>100</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>226</width>
<height>102</height>
<width>316</width>
<height>127</height>
</rect>
</property>
<property name="windowTitle">
......@@ -26,7 +26,14 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
......
......@@ -17,6 +17,21 @@ Widget_Imgproc_Base::~Widget_Imgproc_Base()
delete ui;
}
void Widget_Imgproc_Base::setBrightness(int brightness)
{
ui->spin_brightness->setValue(brightness);
}
void Widget_Imgproc_Base::setContrast(int contrast)
{
ui->spin_contrast->setValue(contrast);
}
void Widget_Imgproc_Base::setGamma(double gamma)
{
ui->dspin_gamma->setValue(gamma);
}
void Widget_Imgproc_Base::setDefault()
{
ui->spin_brightness->setValue(0);
......
......@@ -15,6 +15,9 @@ public:
explicit Widget_Imgproc_Base(QWidget *parent = nullptr);
~Widget_Imgproc_Base();
void setBrightness(int brightness);
void setContrast(int contrast);
void setGamma(double gamma);
void setDefault();
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment