1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-05-11 03:24:57 +02:00
* FWWindowPrint.cpp (FWWindow::tableResolutionSettingChanged):
Using slider widget to set table scaling factor; now user can
choose any scaling factor between 1 and 200%. This fixes bug
#2789903: "Table scaling when printing in 3.0.4"
This commit is contained in:
Vadim Kurland
2009-05-12 21:59:46 +00:00
parent 0f9d29d492
commit dbe1c90354
6 changed files with 231 additions and 216 deletions

View File

@@ -1 +1 @@
#define BUILD_NUM 888
#define BUILD_NUM 926

View File

@@ -1,3 +1,10 @@
2009-05-12 vadim <vadim@vk.crocodile.org>
* FWWindowPrint.cpp (FWWindow::tableResolutionSettingChanged):
Using slider widget to set table scaling factor; now user can
choose any scaling factor between 1 and 200%. This fixes bug
#2789903: "Table scaling when printing in 3.0.4"
2009-05-06 vadim <vadim@vk.crocodile.org>
* FirewallInstallerCisco.cpp (FirewallInstallerCisco::activatePolicy):

View File

@@ -169,6 +169,8 @@ FWWindow::FWWindow() : QMainWindow(), // QMainWindow(NULL, Qt::Desktop),
m_mainWindow = new Ui::FWBMainWindow_q();
m_mainWindow->setupUi(dynamic_cast<QMainWindow*>(this));
psd = NULL;
prepareFileOpenRecentMenu();
m_space = new QMdiArea(this);

View File

@@ -28,6 +28,8 @@
#define __FWWINDOW_H_
#include <ui_FWBMainWindow_q.h>
#include <ui_pagesetupdialog_q.h>
#include "RCS.h"
#include "ObjectEditor.h"
#include "HttpGet.h"
@@ -69,6 +71,8 @@ class FWWindow : public QMainWindow {
Q_OBJECT
Ui::pageSetupDialog_q *psd;
QMdiArea *m_space;
QWidget *instd;
HttpGet *current_version_http_getter;
@@ -185,6 +189,8 @@ public slots:
virtual void checkForUpgrade(const QString&);
virtual void projectWindowClosed();
void tableResolutionSettingChanged(int );
public:
Ui::FWBMainWindow_q *m_mainWindow;

View File

@@ -38,8 +38,6 @@
#include "fwbuilder/Firewall.h"
#include "fwbuilder/RuleSet.h"
#include <ui_pagesetupdialog_q.h>
#include <qglobal.h>
#include <QPrintDialog>
@@ -100,43 +98,47 @@ void FWWindow::filePrint()
print_objects = st->getBool("PrintSetup/printObjects");
if (!st->getStr("PrintSetup/tableResolution").isEmpty())
{
tableResolution = st->getInt("PrintSetup/tableResolution");
// for backwards compatibility, convert resolutino from an index
// in a table to float 0..1.0
// Previously values were from the following list:
// 50%, 75%, 100%, 150%, 200%, default 100%
float old_res[] = {50, 75, 100, 150, 200 };
if (tableResolution <= 4 )
tableResolution = old_res[int(tableResolution)];
}
Ui::pageSetupDialog_q psd;
QDialog dlg;
psd.setupUi(&dlg);
psd = new Ui::pageSetupDialog_q();
psd->setupUi(&dlg);
connect(psd->tableResolution, SIGNAL(valueChanged(int)),
this, SLOT(tableResolutionSettingChanged(int)));
psd.newPageForSection->setChecked(newPageForSection);
psd.printHeader->setChecked(print_header);
psd.printLegend->setChecked(print_legend);
psd.printObjects->setChecked(print_objects);
psd.tableResolution->setCurrentIndex(tableResolution);
psd->newPageForSection->setChecked(newPageForSection);
psd->printHeader->setChecked(print_header);
psd->printLegend->setChecked(print_legend);
psd->printObjects->setChecked(print_objects);
psd->tableResolution->setValue(tableResolution);
if ( dlg.exec() == QDialog::Accepted )
{
newPageForSection = psd.newPageForSection->isChecked();
print_header = psd.printHeader->isChecked();
print_legend = psd.printLegend->isChecked();
print_objects = psd.printObjects->isChecked();
tableResolution = psd.tableResolution->currentIndex();
newPageForSection = psd->newPageForSection->isChecked();
print_header = psd->printHeader->isChecked();
print_legend = psd->printLegend->isChecked();
print_objects = psd->printObjects->isChecked();
tableResolution = psd->tableResolution->value();
st->setBool("PrintSetup/newPageForSection",newPageForSection);
st->setBool("PrintSetup/printHeader", print_header );
st->setBool("PrintSetup/printLegend", print_legend );
st->setBool("PrintSetup/printObjects", print_objects );
st->setInt("PrintSetup/tableResolution", tableResolution );
st->setBool("PrintSetup/newPageForSection", newPageForSection);
st->setBool("PrintSetup/printHeader", print_header);
st->setBool("PrintSetup/printLegend", print_legend);
st->setBool("PrintSetup/printObjects", print_objects);
st->setInt("PrintSetup/tableResolution", tableResolution);
st->getPrinterOptions(printer, pageWidth, pageHeight);
switch (tableResolution)
{
case 0: table_scaling = 0.5; break;
case 1: table_scaling = 0.75; break;
case 2: table_scaling = 1.0; break;
case 3: table_scaling = 1.5; break;
case 4: table_scaling = 2.0; break;
}
table_scaling = float(tableResolution) / 100;
//printer->setResolution(resolution);
printer->setFullPage(fullPage);
@@ -212,8 +214,18 @@ void FWWindow::filePrint()
st->setPrinterOptions(printer,pageWidth,pageHeight);
}
delete psd;
psd = NULL;
}
void FWWindow::tableResolutionSettingChanged(int )
{
if (psd)
{
QString res_lbl = QString("%1 %").arg(psd->tableResolution->value());
psd->tableResolutionLabel->setText(res_lbl);
}
}
void FWWindow::printFirewallFromFile(QString fileName,
QString firewallName,
@@ -266,14 +278,7 @@ void FWWindow::printFirewallFromFile(QString fileName,
if (!st->getStr("PrintSetup/tableResolution").isEmpty())
tableResolution = st->getInt("PrintSetup/tableResolution");
switch (tableResolution)
{
case 0: table_scaling = 0.5; break;
case 1: table_scaling = 0.75; break;
case 2: table_scaling = 1.0; break;
case 3: table_scaling = 1.5; break;
case 4: table_scaling = 2.0; break;
}
table_scaling = float(tableResolution) / 100;
st->getPrinterOptions(printer,pageWidth,pageHeight);

View File

@@ -1,182 +1,177 @@
<ui version="4.0" stdsetdef="1" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>pageSetupDialog_q</class>
<widget class="QDialog" name="pageSetupDialog_q" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>248</width>
<height>199</height>
</rect>
</property>
<property name="windowTitle" >
<string>Page Setup</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="newPageForSection" >
<property name="text" >
<string>start each section on a new page</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="printHeader" >
<property name="text" >
<string>print header on every page</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="printLegend" >
<property name="text" >
<string>print legend</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="printObjects" >
<property name="text" >
<string>print objects used in rules</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<item>
<spacer name="spacer9" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="sizeType" >
<enum>Expanding</enum>
</property>
<property name="orientation" >
<enum>Horizontal</enum>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Scale tables: </string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="tableResolution" >
<item>
<property name="text" >
<string>50%</string>
</property>
</item>
<item>
<property name="text" >
<string>75%</string>
</property>
</item>
<item>
<property name="text" >
<string>100%</string>
</property>
</item>
<item>
<property name="text" >
<string>150%</string>
</property>
</item>
<item>
<property name="text" >
<string>200%</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="spacer10" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="sizeType" >
<enum>Expanding</enum>
</property>
<property name="orientation" >
<enum>Horizontal</enum>
</property>
</spacer>
</item>
</layout>
</item>
<ui version="4.0" >
<class>pageSetupDialog_q</class>
<widget class="QDialog" name="pageSetupDialog_q" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>316</width>
<height>235</height>
</rect>
</property>
<property name="windowTitle" >
<string>Page Setup</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="newPageForSection" >
<property name="text" >
<string>start each section on a new page</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QCheckBox" name="printHeader" >
<property name="text" >
<string>print header on every page</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<widget class="QCheckBox" name="printLegend" >
<property name="text" >
<string>print legend</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="printObjects" >
<property name="text" >
<string>print objects used in rules</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Scale tables: </string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QSlider" name="tableResolution" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>200</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QLabel" name="tableResolutionLabel" >
<property name="text" >
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="1" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>38</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<item>
<spacer name="spacer9" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>pageSetupDialog_q</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>pageSetupDialog_q</receiver>
<slot>reject()</slot>
</connection>
</connections>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<resources/>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>pageSetupDialog_q</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>pageSetupDialog_q</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>