HGGitLab

Commit 70de9c6c authored by luoliangyi's avatar luoliangyi

UI微调

parent f3abd9b7
...@@ -51,6 +51,10 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) : ...@@ -51,6 +51,10 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok")); ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel")); 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 //Temporarily hide some functions
ui->cbtn_subFolderByBlank->setVisible(false); ui->cbtn_subFolderByBlank->setVisible(false);
ui->cbtn_subFolderByColor->setVisible(false); ui->cbtn_subFolderByColor->setVisible(false);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>442</width> <width>554</width>
<height>360</height> <height>525</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>462</width> <width>16777215</width>
<height>360</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "ui_dialog_imageeditor.h" #include "ui_dialog_imageeditor.h"
#include "graphicsscene.h" #include "graphicsscene.h"
#include <QColorDialog> #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_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 }; 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 }; 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) ...@@ -19,6 +21,12 @@ Dialog_ImageEditor::Dialog_ImageEditor(QWidget *parent)
ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]); ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]);
ui->graphicsView->setScene(m_scene); ui->graphicsView->setScene(m_scene);
ui->btn_color->setStyleSheet("QPushButton{background-color:red;border:1px solid red;}"); 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() Dialog_ImageEditor::~Dialog_ImageEditor()
...@@ -154,7 +162,9 @@ void Dialog_ImageEditor::on_btn_undo_clicked() ...@@ -154,7 +162,9 @@ void Dialog_ImageEditor::on_btn_undo_clicked()
void Dialog_ImageEditor::on_btn_ok_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(); accept();
} }
......
#include "dialog_imgproc_adjust.h" #include "dialog_imgproc_adjust.h"
#include "ui_dialog_imgproc_adjust.h" #include "ui_dialog_imgproc_adjust.h"
#include "imgproc/HGImgProc.h" #include "imgproc/HGImgProc.h"
#include "app_cfg.h"
Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) : Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
QDialog(parent), QDialog(parent),
...@@ -8,23 +9,32 @@ Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) : ...@@ -8,23 +9,32 @@ Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
{ {
ui->setupUi(this); 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_before->addImage(img);
ui->view_after->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_before->setVisible(ui->cbtn_preview->isChecked());
ui->gbox_after->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::Ok)->setText(tr("ok"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel")); ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("restore default")); 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() Dialog_ImgProc_Adjust::~Dialog_ImgProc_Adjust()
...@@ -49,18 +59,23 @@ HGImage Dialog_ImgProc_Adjust::getAfterImage() ...@@ -49,18 +59,23 @@ HGImage Dialog_ImgProc_Adjust::getAfterImage()
void Dialog_ImgProc_Adjust::on_brightness_change(int value) void Dialog_ImgProc_Adjust::on_brightness_change(int value)
{ {
m_brightness = value; m_brightness = value;
saveCfgValue("adjust", "brightness", m_brightness);
process(); process();
} }
void Dialog_ImgProc_Adjust::on_contrast_change(int value) void Dialog_ImgProc_Adjust::on_contrast_change(int value)
{ {
m_contrast = value; m_contrast = value;
saveCfgValue("adjust", "contrast", m_contrast);
process(); process();
} }
void Dialog_ImgProc_Adjust::on_gamma_change(double value) void Dialog_ImgProc_Adjust::on_gamma_change(double value)
{ {
m_gamma = value; m_gamma = value;
char gamma[32];
sprintf(gamma, "%f", m_gamma);
saveCfgValue("adjust", "gamma", QString(gamma));
process(); process();
} }
...@@ -69,6 +84,7 @@ void Dialog_ImgProc_Adjust::on_cbtn_preview_toggled(bool checked) ...@@ -69,6 +84,7 @@ void Dialog_ImgProc_Adjust::on_cbtn_preview_toggled(bool checked)
reinterpret_cast<QVBoxLayout*>(this->layout())->setStretch(1, checked ? 1 : 0); reinterpret_cast<QVBoxLayout*>(this->layout())->setStretch(1, checked ? 1 : 0);
ui->gbox_before->setVisible(checked); ui->gbox_before->setVisible(checked);
ui->gbox_after->setVisible(checked); ui->gbox_after->setVisible(checked);
saveCfgValue("adjust", "preview", checked);
} }
void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool 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) ...@@ -80,6 +96,7 @@ void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool checked)
ui->view_before->getImage(&img); ui->view_before->getImage(&img);
assert(nullptr != img); assert(nullptr != img);
emit applyToImage(img); emit applyToImage(img);
saveCfgValue("adjust", "applyImg", checked);
} }
void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button) void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button)
...@@ -90,6 +107,13 @@ 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_brightness = 0;
m_contrast = 0; m_contrast = 0;
m_gamma = 1.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(); process();
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QPushButton> #include <QPushButton>
#include <QMouseEvent> #include <QMouseEvent>
#include <QDebug> #include <QDebug>
#include "app_cfg.h"
Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent) Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
: QDialog(parent) : QDialog(parent)
...@@ -14,8 +15,8 @@ Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent) ...@@ -14,8 +15,8 @@ Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
, m_isCrop(false) , m_isCrop(false)
, m_isDeskew(false) , m_isDeskew(false)
, m_isFillBlank(false) , m_isFillBlank(false)
, m_isConvex(false) , m_isConvex(true)
, m_isAutoColor(false) , m_isAutoColor(true)
, m_isUseAdvancedParam(false) , m_isUseAdvancedParam(false)
, m_threshold(40) , m_threshold(40)
, m_noise(8) , m_noise(8)
...@@ -28,15 +29,23 @@ Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent) ...@@ -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_autoColor);
m_btnGroup_backgroundColor.addButton(ui->rbtn_defaultColor); m_btnGroup_backgroundColor.addButton(ui->rbtn_defaultColor);
ui->cbtn_crop->setChecked(false); ui->cbtn_crop->setChecked(getCfgValue("autoCrop", "crop", false));
ui->cbtn_corrSkew->setChecked(false); ui->cbtn_corrSkew->setChecked(getCfgValue("autoCrop", "deskew", false));
ui->gbox_fillBlank->setChecked(false); ui->gbox_fillBlank->setChecked(getCfgValue("autoCrop", "fillBlank", false));
ui->rbtn_convex->setChecked(true); bool convex = getCfgValue("autoCrop", "convex", true);
ui->rbtn_autoColor->setChecked(true); if (convex)
ui->gbox_param->setChecked(false); ui->rbtn_convex->setChecked(true);
ui->spin_threshold->setValue(40); else
ui->spin_noise->setValue(8); ui->rbtn_concave->setChecked(true);
ui->spin_indent->setValue(5); bool autoColor = getCfgValue("autoCrop", "autoColor", true);
if (autoColor)
ui->rbtn_autoColor->setChecked(true);
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_imgBefore->setPixmap(QPixmap::fromImage(QImage()));
ui->lab_arrow->setPixmap(QPixmap::fromImage(QImage())); ui->lab_arrow->setPixmap(QPixmap::fromImage(QImage()));
...@@ -108,14 +117,23 @@ void Dialog_ImgProc_AutoCrop::on_buttonBox_clicked(QAbstractButton *button) ...@@ -108,14 +117,23 @@ void Dialog_ImgProc_AutoCrop::on_buttonBox_clicked(QAbstractButton *button)
void Dialog_ImgProc_AutoCrop::on_buttonBox_accepted() void Dialog_ImgProc_AutoCrop::on_buttonBox_accepted()
{ {
m_isCrop = ui->cbtn_crop->isChecked(); m_isCrop = ui->cbtn_crop->isChecked();
saveCfgValue("autoCrop", "crop", m_isCrop);
m_isDeskew = ui->cbtn_corrSkew->isChecked(); m_isDeskew = ui->cbtn_corrSkew->isChecked();
saveCfgValue("autoCrop", "deskew", m_isDeskew);
m_isFillBlank = ui->gbox_fillBlank->isChecked(); m_isFillBlank = ui->gbox_fillBlank->isChecked();
saveCfgValue("autoCrop", "fillBlank", m_isFillBlank);
m_isConvex = ui->rbtn_convex->isChecked(); m_isConvex = ui->rbtn_convex->isChecked();
saveCfgValue("autoCrop", "convex", m_isConvex);
m_isAutoColor = ui->rbtn_autoColor->isChecked(); m_isAutoColor = ui->rbtn_autoColor->isChecked();
saveCfgValue("autoCrop", "autoColor", m_isAutoColor);
m_isUseAdvancedParam = ui->gbox_param->isChecked(); m_isUseAdvancedParam = ui->gbox_param->isChecked();
saveCfgValue("autoCrop", "useAdvancedParam", m_isUseAdvancedParam);
m_threshold = ui->spin_threshold->value(); m_threshold = ui->spin_threshold->value();
saveCfgValue("autoCrop", "threshold", m_threshold);
m_noise = ui->spin_noise->value(); m_noise = ui->spin_noise->value();
saveCfgValue("autoCrop", "noise", m_noise);
m_indent = ui->spin_indent->value(); m_indent = ui->spin_indent->value();
saveCfgValue("autoCrop", "indent", m_indent);
} }
void Dialog_ImgProc_AutoCrop::updateExample(int example) void Dialog_ImgProc_AutoCrop::updateExample(int example)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>600</width>
<height>406</height> <height>408</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
<widget class="QSpinBox" name="spin_threshold"> <widget class="QSpinBox" name="spin_threshold">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>16777215</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<widget class="QSpinBox" name="spin_noise"> <widget class="QSpinBox" name="spin_noise">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>16777215</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
<widget class="QSpinBox" name="spin_indent"> <widget class="QSpinBox" name="spin_indent">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>16777215</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>226</width> <width>316</width>
<height>102</height> <height>127</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -26,7 +26,14 @@ ...@@ -26,7 +26,14 @@
</widget> </widget>
</item> </item>
<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> </item>
</layout> </layout>
</item> </item>
......
...@@ -17,6 +17,21 @@ Widget_Imgproc_Base::~Widget_Imgproc_Base() ...@@ -17,6 +17,21 @@ Widget_Imgproc_Base::~Widget_Imgproc_Base()
delete ui; 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() void Widget_Imgproc_Base::setDefault()
{ {
ui->spin_brightness->setValue(0); ui->spin_brightness->setValue(0);
......
...@@ -15,6 +15,9 @@ public: ...@@ -15,6 +15,9 @@ public:
explicit Widget_Imgproc_Base(QWidget *parent = nullptr); explicit Widget_Imgproc_Base(QWidget *parent = nullptr);
~Widget_Imgproc_Base(); ~Widget_Imgproc_Base();
void setBrightness(int brightness);
void setContrast(int contrast);
void setGamma(double gamma);
void setDefault(); void setDefault();
signals: 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