追加“设置打印页”对话框
This commit is contained in:
parent
cb6a3e1696
commit
b16ac1f407
150
logPlus/SetPageMeg.ui
Normal file
150
logPlus/SetPageMeg.ui
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageMeg</class>
|
||||
<widget class="QDialog" name="PageMeg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SetPageMeg</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>130</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>100</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>左边距</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>顶边距</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>40</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>360</x>
|
||||
<y>130</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>100</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>右边距</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>200</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>240</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>底边距</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>80</y>
|
||||
<width>161</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>300</y>
|
||||
<width>112</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>300</y>
|
||||
<width>112</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>放弃</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
49
logPlus/SetPageMegDlg.cpp
Normal file
49
logPlus/SetPageMegDlg.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#pragma warning( push , 0 )
|
||||
#include <QList>
|
||||
#include <QDialog>
|
||||
#include "SetPageMegDlg.h"
|
||||
#include "geometryutils.h"
|
||||
#pragma warning( pop )
|
||||
|
||||
|
||||
double FIXED_LOGLeft_MARGIN_CM = 0;
|
||||
double FIXED_LOGRight_MARGIN_CM = 0;
|
||||
double FIXED_LOGHead_MARGIN_CM = 0;
|
||||
double FIXED_LOGBottom_MARGIN_CM = 0;
|
||||
|
||||
CSetPageMegDlg::CSetPageMegDlg()
|
||||
:m_pDialog( NULL )
|
||||
{
|
||||
m_pDialog=new Ui_PageMeg;
|
||||
m_pDialog->setupUi(this);
|
||||
connect( m_pDialog->pushButton,SIGNAL(clicked()),this,SLOT(slotOnOkBtnClicked()) );
|
||||
connect( m_pDialog->pushButton_2,SIGNAL(clicked()),this,SLOT(slotOnCancelBtnClicked()));
|
||||
}
|
||||
void CSetPageMegDlg::Init()
|
||||
{
|
||||
m_pDialog->lineEdit->setText(toString(FIXED_LOGLeft_MARGIN_CM));
|
||||
m_pDialog->lineEdit->setValidator(new QDoubleValidator(0,999999,6,this));
|
||||
m_pDialog->lineEdit_2->setText(toString(FIXED_LOGHead_MARGIN_CM));
|
||||
m_pDialog->lineEdit_2->setValidator(new QDoubleValidator(0,999999,6,this));
|
||||
m_pDialog->lineEdit_3->setText(toString(FIXED_LOGRight_MARGIN_CM));
|
||||
m_pDialog->lineEdit_3->setValidator(new QDoubleValidator(0,999999,6,this));
|
||||
m_pDialog->lineEdit_4->setText(toString(FIXED_LOGBottom_MARGIN_CM));
|
||||
m_pDialog->lineEdit_4->setValidator(new QDoubleValidator(0,999999,6,this));
|
||||
}
|
||||
CSetPageMegDlg::~CSetPageMegDlg()
|
||||
{
|
||||
|
||||
}
|
||||
void CSetPageMegDlg::slotOnOkBtnClicked()
|
||||
{
|
||||
FIXED_LOGLeft_MARGIN_CM=m_pDialog->lineEdit->text().toFloat();
|
||||
FIXED_LOGHead_MARGIN_CM=m_pDialog->lineEdit_2->text().toFloat();
|
||||
FIXED_LOGRight_MARGIN_CM=m_pDialog->lineEdit_3->text().toFloat();
|
||||
FIXED_LOGBottom_MARGIN_CM=m_pDialog->lineEdit_4->text().toFloat();
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void CSetPageMegDlg::slotOnCancelBtnClicked()
|
||||
{
|
||||
this->reject();
|
||||
}
|
||||
27
logPlus/SetPageMegDlg.h
Normal file
27
logPlus/SetPageMegDlg.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* @file SetPageMegDlg.h
|
||||
* @brief 创建图头表格属性配置对话框
|
||||
* @date 2015-03
|
||||
* @author: lxl
|
||||
*/
|
||||
#pragma warning( push , 0 )
|
||||
#include "ui_SetPageMeg.h"
|
||||
#include <QStandardItemModel>
|
||||
#pragma warning( pop )
|
||||
|
||||
|
||||
class CSetPageMegDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CSetPageMegDlg();
|
||||
~CSetPageMegDlg();
|
||||
void Init();
|
||||
public:
|
||||
private slots:
|
||||
void slotOnOkBtnClicked();
|
||||
void slotOnCancelBtnClicked();
|
||||
private:
|
||||
Ui_PageMeg* m_pDialog;
|
||||
public:
|
||||
};
|
||||
|
|
@ -44,6 +44,7 @@ SOURCES += \
|
|||
PropertyWidget.cpp \
|
||||
QCPSizeHandle.cpp \
|
||||
QCPSizeHandleManager.cpp \
|
||||
SetPageMegDlg.cpp \
|
||||
TransparentDraggableCorePhysics.cpp \
|
||||
TransparentDraggableFac.cpp \
|
||||
TransparentDraggableGeoLith.cpp \
|
||||
|
|
@ -117,6 +118,7 @@ HEADERS += \
|
|||
PropertyWidget.h \
|
||||
QCPSizeHandle.h \
|
||||
QCPSizeHandleManager.h \
|
||||
SetPageMegDlg.h \
|
||||
TransparentDraggableCorePhysics.h \
|
||||
TransparentDraggableFac.h \
|
||||
TransparentDraggableGeoLith.h \
|
||||
|
|
@ -172,6 +174,7 @@ HEADERS += \
|
|||
|
||||
FORMS += \
|
||||
InDefTable.ui \
|
||||
SetPageMeg.ui \
|
||||
formdraw.ui \
|
||||
formhead.ui \
|
||||
formimage.ui \
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "DepthProgress.h"
|
||||
#include "wellheader.h"
|
||||
#include <QPageSetupDialog>
|
||||
#include "SetPageMegDlg.h"
|
||||
|
||||
//主窗口,为了方便获取tab当前页
|
||||
extern MainWindow *g_mainWindow;
|
||||
|
|
@ -64,6 +65,12 @@ int g_iLoadingJson = 0;
|
|||
extern QString g_strSlfName;
|
||||
extern QString g_strWellName;
|
||||
|
||||
//设置打印页
|
||||
extern double FIXED_LOGLeft_MARGIN_CM;
|
||||
extern double FIXED_LOGRight_MARGIN_CM;
|
||||
extern double FIXED_LOGHead_MARGIN_CM;
|
||||
extern double FIXED_LOGBottom_MARGIN_CM;
|
||||
|
||||
MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindowCurve)
|
||||
|
|
@ -260,6 +267,9 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
|||
isScale[3]=m_isPrint;
|
||||
isScale[4]=m_isBMP;
|
||||
|
||||
// double dMargin = 0.5 * g_dPixelPerCm;//每厘米像素数
|
||||
// ui->centralwidget->layout()->setContentsMargins(dMargin, dMargin, dMargin, dMargin);
|
||||
|
||||
QTimer::singleShot(200, this, [=]() {
|
||||
QRect rect = this->geometry();
|
||||
this->resize(rect.width(), rect.height()+1); // 设置初始大小
|
||||
|
|
@ -740,7 +750,7 @@ void MainWindowCurve::initMainToolBar()
|
|||
m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this);
|
||||
m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this);
|
||||
m_PrintAc = new QAction(PrintIcon, "打印", this);
|
||||
m_PrintSetupAc = new QAction(PrintSetupIcon, "打印设置", this);
|
||||
m_PrintSetupAc = new QAction(PrintSetupIcon, "设置打印页", this);
|
||||
m_PrintPreviewAc = new QAction(PrintPreviewIcon, "打印预览", this);
|
||||
m_blackAc = new QAction(blackIcon, "黑白图", this);
|
||||
m_doubleHeadAc = new QAction(doubleHeadIcon, "单曲线头", this);
|
||||
|
|
@ -3716,7 +3726,7 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName,
|
|||
{
|
||||
iHight += ui->tableWidget_2->rowHeight(i);
|
||||
}
|
||||
iHight += top + (ui->tableWidget_2->rowCount()+1);//上margin + 边框n+1
|
||||
iHight += top + bottom + (ui->tableWidget_2->rowCount()+1);//上margin + 边框n+1
|
||||
//宽度
|
||||
for(int j=0; j<ui->tableWidget_2->columnCount(); j++)
|
||||
{
|
||||
|
|
@ -4181,14 +4191,39 @@ void MainWindowCurve::s_PrintSetup()
|
|||
// qDebug() << "Paper size:" << printer.paperSize();
|
||||
// }
|
||||
|
||||
int left, top, right, bottom;
|
||||
int left=0, top=0, right=0, bottom=0;
|
||||
if (ui->centralwidget->layout())
|
||||
{
|
||||
ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom);
|
||||
|
||||
ui->centralwidget->layout()->setContentsMargins(left+10, top+10, right+10, bottom+10);
|
||||
}
|
||||
|
||||
// 创建对话框
|
||||
CSetPageMegDlg *dlg = new CSetPageMegDlg();
|
||||
FIXED_LOGLeft_MARGIN_CM = (double)left/g_dPixelPerCm;//每厘米像素数;
|
||||
FIXED_LOGRight_MARGIN_CM = (double)right/g_dPixelPerCm;//每厘米像素数;
|
||||
FIXED_LOGHead_MARGIN_CM = (double)top/g_dPixelPerCm;//每厘米像素数;
|
||||
FIXED_LOGBottom_MARGIN_CM = (double)bottom/g_dPixelPerCm;//每厘米像素数;
|
||||
dlg->Init();
|
||||
//
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
||||
int result = dlg->exec();//模态对话框
|
||||
if (result == QDialog::Accepted) {
|
||||
// 处理用户点击了确定按钮的逻辑
|
||||
qDebug() << "Accepted=";
|
||||
left = FIXED_LOGLeft_MARGIN_CM * g_dPixelPerCm;//每厘米像素数;
|
||||
right = FIXED_LOGRight_MARGIN_CM * g_dPixelPerCm;//每厘米像素数;
|
||||
top = FIXED_LOGHead_MARGIN_CM * g_dPixelPerCm;//每厘米像素数;
|
||||
bottom = FIXED_LOGBottom_MARGIN_CM * g_dPixelPerCm;//每厘米像素数;
|
||||
ui->centralwidget->layout()->setContentsMargins(left, top, right, bottom);
|
||||
}
|
||||
else if (result == QDialog::Rejected) {
|
||||
// 处理用户点击了取消按钮的逻辑
|
||||
qDebug() << "Rejected=";
|
||||
}
|
||||
else {
|
||||
// 处理其他情况的逻辑
|
||||
qDebug() << "other=";
|
||||
}
|
||||
|
||||
QMessageBox::information(NULL,"提示","打印设置完成!",QMessageBox::Ok);
|
||||
//居中
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user