make label dialog assume one label per page if label is too big for page
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 18 Sep 2008 15:24:33 +0000 (15:24 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 18 Sep 2008 15:24:33 +0000 (15:24 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@176 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/labeldlg.cpp
src/labeldlg.h

index 41dcca0..5eb12ab 100644 (file)
@@ -71,24 +71,29 @@ MLabelDialog::MLabelDialog(QWidget*par,QPrinter* pn,int nl,QSizeF ls)
        setLayout(vl=new QVBoxLayout);
        vl->addLayout(gl=new QGridLayout,0);
        
-       gl->addWidget(new QLabel(tr("Label offset:")),0,0);
-       gl->addWidget(offx=new QLineEdit(QString::number(ox)),0,1);
+       int ln=0;
+       gl->addWidget(new QLabel(tr("Label offset:")),ln,0);
+       gl->addWidget(offx=new QLineEdit(QString::number(ox)),ln,1);
        offx->setValidator(new QDoubleValidator(0.0,1000.0,2,this));
-       gl->addWidget(new QLabel("x"),0,2);
-       gl->addWidget(offy=new QLineEdit(QString::number(oy)),0,3);
+       gl->addWidget(new QLabel("x"),ln,2);
+       gl->addWidget(offy=new QLineEdit(QString::number(oy)),ln,3);
        offy->setValidator(new QDoubleValidator(0.0,1000.0,2,this));
-       gl->addWidget(new QLabel(tr("Label size:")),1,0);
-       gl->addWidget(sizex=new QLineEdit(QString::number(lsx)),1,1);
+       gl->addWidget(new QLabel(tr("Label size:")),++ln,0);
+       gl->addWidget(sizex=new QLineEdit(QString::number(lsx)),ln,1);
        sizex->setValidator(new QDoubleValidator(0.0,1000.0,2,this));
-       gl->addWidget(new QLabel("x"),1,2);
-       gl->addWidget(sizey=new QLineEdit(QString::number(lsy)),1,3);
+       gl->addWidget(new QLabel("x"),ln,2);
+       gl->addWidget(sizey=new QLineEdit(QString::number(lsy)),ln,3);
        sizey->setValidator(new QDoubleValidator(0.0,1000.0,2,this));
-       gl->addWidget(new QLabel(tr("Unit:")),2,0);
-       gl->addWidget(metric=new QComboBox,2,1,1,3);
+       gl->addWidget(new QLabel(tr("Unit:")),++ln,0);
+       gl->addWidget(metric=new QComboBox,ln,1,1,3);
        metric->addItem(tr("Millimeter"),"mm");
        metric->addItem(tr("Centimeter"),"cm");
        metric->addItem(tr("Inch"),"in");
-       gl->setColumnStretch(4,10);
+       gl->addWidget(warning=new QLabel(""),++ln,0,1,4);
+       QPalette pal=warning->palette();
+       pal.setColor(QPalette::WindowText,Qt::red);
+       warning->setPalette(pal);
+       gl->setColumnStretch(++ln,10);
        
        vl->addSpacing(10);
        vl->addWidget(new QLabel(tr("Page usage:")),0);
@@ -268,13 +273,22 @@ void MLabelDialog::updatePage()
                ly*=printer->logicalDpiY()/25.4;
        }
        
+       bool dowarn=false;
        if(ly>0.0){
                maxrows=pr.height()/ly;
                if(maxrows>ROWS)maxrows=ROWS;
+               if(maxrows<1){
+                       maxrows=1;
+                       dowarn=true;
+               }
        }else maxrows=ROWS;
        if(lx>0.0){
                maxcols=pr.width()/lx;
                if(maxcols>COLS)maxcols=COLS;
+               if(maxcols<1){
+                       maxcols=1;
+                       dowarn=true;
+               }
        }else maxcols=COLS;
        //update
        oldpage=page->itemData(page->currentIndex()).toInt();
@@ -285,6 +299,10 @@ void MLabelDialog::updatePage()
                        checks[i]->setChecked(b && checked[oldpage][i]);
                        checks[i]->setEnabled(b);
                }
+       if(dowarn)
+               warning->setText(tr("Warning: the label may not fit on the page!"));
+       else
+               warning->setText("");
 }
 
 void MLabelDialog::saveSettings()
index 17ea5ec..2b22aae 100644 (file)
@@ -22,6 +22,7 @@ class QCheckBox;
 class QComboBox;
 class QLineEdit;
 class QPrinter;
+class QLabel;
 
 class MLabelDialog:public QDialog
 {
@@ -54,6 +55,7 @@ class MLabelDialog:public QDialog
                
        private:
                QLineEdit *offx,*offy,*sizex,*sizey;
+               QLabel *warning;
                QSizeF labelsize;
                QComboBox *metric,*page;
                QList<QCheckBox*>checks;