mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-29 22:39:59 +01:00
Element editor : alignment of text field can be edited
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5362 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -19,30 +19,29 @@
|
||||
#include "ui_alignmenttextdialog.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
|
||||
AlignmentTextDialog::AlignmentTextDialog(DynamicElementTextItem *text, QWidget *parent) :
|
||||
AlignmentTextDialog::AlignmentTextDialog(Qt::Alignment alignment, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AlignmentTextDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
Qt::Alignment align = text->alignment();
|
||||
if(align == (Qt::AlignTop|Qt::AlignLeft))
|
||||
if(alignment == (Qt::AlignTop|Qt::AlignLeft))
|
||||
ui->top_left->setChecked(true);
|
||||
else if(align == (Qt::AlignTop|Qt::AlignHCenter))
|
||||
else if(alignment == (Qt::AlignTop|Qt::AlignHCenter))
|
||||
ui->top->setChecked(true);
|
||||
else if(align == (Qt::AlignTop|Qt::AlignRight))
|
||||
else if(alignment == (Qt::AlignTop|Qt::AlignRight))
|
||||
ui->top_right->setChecked(true);
|
||||
else if(align == (Qt::AlignVCenter|Qt::AlignLeft))
|
||||
else if(alignment == (Qt::AlignVCenter|Qt::AlignLeft))
|
||||
ui->left->setChecked(true);
|
||||
else if(align == Qt::AlignCenter)
|
||||
else if(alignment == Qt::AlignCenter)
|
||||
ui->center->setChecked(true);
|
||||
else if(align == (Qt::AlignVCenter|Qt::AlignRight))
|
||||
else if(alignment == (Qt::AlignVCenter|Qt::AlignRight))
|
||||
ui->right->setChecked(true);
|
||||
else if(align == (Qt::AlignBottom|Qt::AlignLeft))
|
||||
else if(alignment == (Qt::AlignBottom|Qt::AlignLeft))
|
||||
ui->bottom_left->setChecked(true);
|
||||
else if(align == (Qt::AlignBottom|Qt::AlignHCenter))
|
||||
else if(alignment == (Qt::AlignBottom|Qt::AlignHCenter))
|
||||
ui->bottom->setChecked(true);
|
||||
else if(align == (Qt::AlignBottom|Qt::AlignRight))
|
||||
else if(alignment == (Qt::AlignBottom|Qt::AlignRight))
|
||||
ui->bottom_right->setChecked(true);
|
||||
}
|
||||
|
||||
@@ -81,7 +80,7 @@ Qt::Alignment AlignmentTextDialog::alignment() const
|
||||
|
||||
bool AlignmentTextDialog::event(QEvent *event)
|
||||
{
|
||||
//Little hack to set focus to a radio button
|
||||
//Little hack when this dialog is called from a QAbstractItemModel, to set focus to a radio button
|
||||
//if we not do that, when the user click on the title bar (for move the dialog) or try to resize the dialog,
|
||||
//the dialog lose focus and close.
|
||||
if(event->type() == QEvent::Show && m_first_show)
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class DynamicElementTextItem;
|
||||
|
||||
namespace Ui {
|
||||
class AlignmentTextDialog;
|
||||
}
|
||||
@@ -31,7 +29,7 @@ class AlignmentTextDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlignmentTextDialog(DynamicElementTextItem *text, QWidget *parent = nullptr);
|
||||
explicit AlignmentTextDialog(Qt::Alignment alignment, QWidget *parent = nullptr);
|
||||
~AlignmentTextDialog();
|
||||
|
||||
Qt::Alignment alignment() const;
|
||||
|
||||
@@ -1406,7 +1406,7 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
||||
if(!deti)
|
||||
break;
|
||||
|
||||
AlignmentTextDialog *atd = new AlignmentTextDialog(deti, parent);
|
||||
AlignmentTextDialog *atd = new AlignmentTextDialog(deti->alignment(), parent);
|
||||
atd->setObjectName("alignment_text");
|
||||
return atd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user