void TabularHeaderItem::setHasXAlignment(bool hasXAlignment) { m_hasXAlignment = hasXAlignment; if(!hasXAlignment && m_Alignment == AlignX) { slotAlignLeft(); } }
/* void DateTimeGrid::paintUserDefinedHeader( QPainter* painter, const QRectF& headerRect, const QRectF& exposedRect, qreal offset, const KGantt::DateTimeScaleFormatter* formatter, QWidget* widget) { const QStyle* const style = widget ? widget->style() : QApplication::style(); QDateTime dt = formatter->currentRangeBegin( mapToDateTime( offset + exposedRect.left() ) ).toUTC(); qreal x = mapFromDateTime( dt ); while ( x < exposedRect.right() + offset ) { const QDateTime next = formatter->nextRangeBegin( dt ); const qreal nextx = mapFromDateTime( next ); QStyleOptionHeader opt; if ( widget ) opt.init( widget ); opt.rect = QRectF( x - offset+1, headerRect.top(), qMax( 1., nextx-x-1 ), headerRect.height() ).toAlignedRect(); //opt.state = QStyle::State_Raised | QStyle::State_Enabled; opt.textAlignment = formatter->alignment(); opt.text = formatter->text( dt ); // use white text on black background opt.palette.setColor(QPalette::Window, QColor("black")); opt.palette.setColor(QPalette::ButtonText, QColor("white")); style->drawControl( QStyle::CE_Header, &opt, painter, widget ); dt = next; x = nextx; } } */ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ), m_model( new ProjectModel( this ) ), m_view( new KGantt::View ) { m_view->setModel( m_model ); m_view->setSelectionModel( new QItemSelectionModel(m_model)); // slotToolsNewItem(); m_view->leftView()->setItemDelegateForColumn( 1, new MyItemDelegate( this ) ); m_view->leftView()->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_view->graphicsView()->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_view->setGrid(new DateTimeGrid(this)); //QItemEditorCreatorBase *creator = new QItemEditorCreator<ItemTypeComboBox>("itemType"); //QItemEditorFactory* factory = new QItemEditorFactory; //factory->registerEditor( QVariant( KGantt::TypeTask ).type(), creator ); //m_view->itemDelegate()->setItemEditorFactory( factory ); setCentralWidget( m_view ); QMenuBar* mb = menuBar(); QMenu* fileMenu = new QMenu( tr( "&File" ) ); #ifndef QT_NO_PRINTER fileMenu->addAction( tr( "&Save as PDF..." ), this, SLOT( slotFileSavePdf() ) ); fileMenu->addAction( tr( "&Print..." ), this, SLOT( slotFilePrint() ) ); #endif fileMenu->addSeparator(); fileMenu->addAction( tr( "&Quit" ), this, SLOT( slotFileQuit() ) ); mb->addMenu( fileMenu ); QMenu* toolsMenu = new QMenu( tr( "&Tools" ) ); toolsMenu->addAction( tr( "&New Item" ), this, SLOT( slotToolsNewItem() ) ); toolsMenu->addAction( tr( "&Add Item" ), this, SLOT( slotToolsAppendItem() ) ); toolsMenu->addSeparator(); QMenu *alignMenu = toolsMenu->addMenu( tr( "Ali&gn" ) ); alignMenu->addAction( tr( "&Left" ), this, SLOT( slotAlignLeft() ) ); alignMenu->addAction( tr( "&Center" ), this, SLOT( slotAlignCenter() ) ); alignMenu->addAction( tr( "&Right" ), this, SLOT( slotAlignRight() ) ); alignMenu->addAction( tr( "&Hidden" ), this, SLOT( slotAlignHidden() ) ); toolsMenu->addSeparator(); toolsMenu->addAction( tr( "&Collapse All" ), this, SLOT( slotCollapseAll() ) ); toolsMenu->addAction( tr( "&Expand All" ), this, SLOT( slotExpandAll() ) ); mb->addMenu( toolsMenu ); /* slotToolsNewItem(); slotToolsNewItem(); slotToolsNewItem(); for (int i = 0; i < 3; ++i) { m_model->setData(m_model->index(i,2,QModelIndex()), qVariantFromValue(QDateTime::currentDateTime().addDays(i)), KGantt::StartTimeRole); m_model->setData(m_model->index(i,3,QModelIndex()), qVariantFromValue(QDateTime::currentDateTime().addDays(i+1)), KGantt::EndTimeRole); } m_view->setConstraintModel(new KGantt::ConstraintModel(m_view)); m_view->constraintModel()->addConstraint(KGantt::Constraint(m_model->index(0,0,QModelIndex()),m_model->index(1,0,QModelIndex()))); m_view->constraintModel()->addConstraint(KGantt::Constraint(m_model->index(1,0,QModelIndex()),m_model->index(2,0,QModelIndex()))); */ }
Geometryval::Geometryval(const MltVideoProfile profile, QPoint frame_size, QWidget* parent) : QWidget(parent), m_profile(profile), m_paramRect(NULL), m_geom(NULL), m_path(NULL), m_fixedMode(false), m_frameSize(frame_size) { m_ui.setupUi(this); QVBoxLayout* vbox = new QVBoxLayout(m_ui.widget); QGraphicsView *view = new QGraphicsView(this); view->setBackgroundBrush(QBrush(Qt::black)); vbox->addWidget(view); vbox->setContentsMargins(0, 0, 0, 0); QVBoxLayout* vbox2 = new QVBoxLayout(m_ui.keyframeWidget); m_helper = new KeyframeHelper(this); vbox2->addWidget(m_helper); vbox2->setContentsMargins(0, 0, 0, 0); connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int))); m_scene = new GraphicsSceneRectMove(this); m_scene->setTool(TITLE_SELECT); view->setScene(m_scene); QGraphicsRectItem *m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, profile.width, profile.height)); m_frameBorder->setZValue(-1100); m_frameBorder->setBrush(QColor(255, 255, 0, 30)); m_frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine)); m_scene->addItem(m_frameBorder); m_ui.buttonNext->setIcon(KIcon("media-skip-forward")); m_ui.buttonNext->setToolTip(i18n("Go to next keyframe")); m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward")); m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe")); m_ui.buttonAdd->setIcon(KIcon("document-new")); m_ui.buttonAdd->setToolTip(i18n("Add keyframe")); m_ui.buttonDelete->setIcon(KIcon("edit-delete")); m_ui.buttonDelete->setToolTip(i18n("Delete keyframe")); QMenu *configMenu = new QMenu(i18n("Misc..."), this); m_ui.buttonMenu->setIcon(KIcon("system-run")); m_ui.buttonMenu->setMenu(configMenu); m_ui.buttonMenu->setPopupMode(QToolButton::QToolButton::InstantPopup); configMenu->addAction(i18n("Geometry"), this, SLOT(slotGeometry())); m_scaleMenu = new QMenu(i18n("Resize..."), this); configMenu->addMenu(m_scaleMenu); m_scaleMenu->addAction(i18n("50%"), this, SLOT(slotResize50())); m_scaleMenu->addAction(i18n("100%"), this, SLOT(slotResize100())); m_scaleMenu->addAction(i18n("200%"), this, SLOT(slotResize200())); m_scaleMenu->addAction(i18n("Original size"), this, SLOT(slotResizeOriginal())); m_scaleMenu->addAction(i18n("Custom"), this, SLOT(slotResizeCustom())); m_alignMenu = new QMenu(i18n("Align..."), this); configMenu->addMenu(m_alignMenu); m_alignMenu->addAction(i18n("Center"), this, SLOT(slotAlignCenter())); m_alignMenu->addAction(i18n("Hor. Center"), this, SLOT(slotAlignHCenter())); m_alignMenu->addAction(i18n("Vert. Center"), this, SLOT(slotAlignVCenter())); m_alignMenu->addAction(i18n("Right"), this, SLOT(slotAlignRight())); m_alignMenu->addAction(i18n("Left"), this, SLOT(slotAlignLeft())); m_alignMenu->addAction(i18n("Top"), this, SLOT(slotAlignTop())); m_alignMenu->addAction(i18n("Bottom"), this, SLOT(slotAlignBottom())); m_syncAction = configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor())); m_syncAction->setCheckable(true); m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor()); //scene->setSceneRect(0, 0, profile.width * 2, profile.height * 2); //view->fitInView(m_frameBorder, Qt::KeepAspectRatio); const double sc = 100.0 / profile.height * 0.8; QRectF srect = view->sceneRect(); view->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10); m_scene->setZoom(sc); view->centerOn(m_frameBorder); connect(m_ui.buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame())); connect(m_ui.buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame())); connect(m_ui.buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame())); connect(m_ui.buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame())); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties())); connect(m_scene, SIGNAL(doubleClickEvent()), this, SLOT(slotGeometry())); }
TabularHeaderItem::TabularHeaderItem(QWidget *parent) : QObject(parent), QTableWidgetItem(QIcon::fromTheme("format-justify-left"), "l"), m_Alignment(Qt::AlignLeft), m_InsertBefore(false), m_InsertAfter(false), m_SuppressSpace(false), m_DontSuppressSpace(false), m_hasXAlignment(false) { m_Popup = new QMenu(parent); m_Popup->addAction(QIcon::fromTheme("format-justify-left"), i18n("Align Left"), this, SLOT(slotAlignLeft())); m_Popup->addAction(QIcon::fromTheme("format-justify-center"), i18n("Align Center"), this, SLOT(slotAlignCenter())); m_Popup->addAction(QIcon::fromTheme("format-justify-right"), i18n("Align Right"), this, SLOT(slotAlignRight())); m_Popup->addAction(i18n("p{w} Alignment"), this, SLOT(slotAlignP())); m_Popup->addAction(i18n("b{w} Alignment"), this, SLOT(slotAlignB())); m_Popup->addAction(i18n("m{w} Alignment"), this, SLOT(slotAlignM())); m_acXAlignment = m_Popup->addAction(i18n("X Alignment"), this, SLOT(slotAlignX())); m_Popup->addSeparator(); m_acDeclPre = m_Popup->addAction(i18n("Insert Before Declaration"), this, SLOT(slotDeclPre())); m_acDeclPost = m_Popup->addAction(i18n("Insert After Declaration"), this, SLOT(slotDeclPost())); m_acDeclAt = m_Popup->addAction(i18n("Suppress Space"), this, SLOT(slotDeclAt())); m_acDeclBang = m_Popup->addAction(i18n("Do not Suppress Space"), this, SLOT(slotDeclBang())); m_acDeclPre->setCheckable(true); m_acDeclPost->setCheckable(true); m_acDeclAt->setCheckable(true); m_acDeclBang->setCheckable(true); }
Geometryval::Geometryval(const Mlt::Profile *profile, const Timecode &t, const QPoint &frame_size, int startPoint, QWidget* parent) : QWidget(parent), m_profile(profile), m_paramRect(NULL), m_geom(NULL), m_path(NULL), m_fixedMode(false), m_frameSize(frame_size), m_startPoint(startPoint), m_timePos(t) { setupUi(this); toolbarlayout->addWidget(&m_timePos); toolbarlayout->insertStretch(-1); QVBoxLayout* vbox = new QVBoxLayout(widget); m_sceneview = new QGraphicsView(this); m_sceneview->setBackgroundBrush(QBrush(Qt::black)); vbox->addWidget(m_sceneview); vbox->setContentsMargins(0, 0, 0, 0); QVBoxLayout* vbox2 = new QVBoxLayout(keyframeWidget); m_helper = new KeyframeHelper(this); vbox2->addWidget(m_helper); vbox2->setContentsMargins(0, 0, 0, 0); connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int))); connect(m_helper, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int))); connect(m_helper, SIGNAL(addKeyframe(int)), this, SLOT(slotAddFrame(int))); connect(m_helper, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteFrame(int))); m_scene = new GraphicsSceneRectMove(this); m_scene->setTool(TITLE_SELECT); m_sceneview->setScene(m_scene); m_dar = (m_profile->height() * m_profile->dar()) / (double) m_profile->width(); m_realWidth = (int)(profile->height() * profile->dar() + 0.5); QGraphicsRectItem *frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_realWidth, profile->height())); frameBorder->setZValue(-1100); frameBorder->setBrush(QColor(255, 255, 0, 30)); frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine)); m_scene->addItem(frameBorder); buttonNext->setIcon(QIcon::fromTheme("media-skip-forward")); buttonNext->setToolTip(i18n("Go to next keyframe")); buttonPrevious->setIcon(QIcon::fromTheme("media-skip-backward")); buttonPrevious->setToolTip(i18n("Go to previous keyframe")); buttonAdd->setIcon(QIcon::fromTheme("document-new")); buttonAdd->setToolTip(i18n("Add keyframe")); buttonDelete->setIcon(QIcon::fromTheme("edit-delete")); buttonDelete->setToolTip(i18n("Delete keyframe")); m_configMenu = new QMenu(i18n("Misc..."), this); buttonMenu->setMenu(m_configMenu); buttonMenu->setPopupMode(QToolButton::MenuButtonPopup); m_editOptions = m_configMenu->addAction(QIcon::fromTheme("system-run"), i18n("Show/Hide options")); m_editOptions->setCheckable(true); buttonMenu->setDefaultAction(m_editOptions); connect(m_editOptions, SIGNAL(triggered()), this, SLOT(slotSwitchOptions())); slotSwitchOptions(); m_reset = m_configMenu->addAction(QIcon::fromTheme("view-refresh"), i18n("Reset"), this, SLOT(slotResetPosition())); m_syncAction = m_configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor())); m_syncAction->setCheckable(true); m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor()); //scene->setSceneRect(0, 0, profile->width * 2, profile->height * 2); //view->fitInView(m_frameBorder, Qt::KeepAspectRatio); const double sc = 100.0 / profile->height() * 0.8; QRectF srect = m_sceneview->sceneRect(); m_sceneview->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10); m_scene->setZoom(sc); m_sceneview->centerOn(frameBorder); m_sceneview->setMouseTracking(true); connect(buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame())); connect(buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame())); connect(buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame())); connect(buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame())); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties())); buttonhcenter->setIcon(QIcon::fromTheme("kdenlive-align-hor")); buttonhcenter->setToolTip(i18n("Align item horizontally")); buttonvcenter->setIcon(QIcon::fromTheme("kdenlive-align-vert")); buttonvcenter->setToolTip(i18n("Align item vertically")); buttontop->setIcon(QIcon::fromTheme("kdenlive-align-top")); buttontop->setToolTip(i18n("Align item to top")); buttonbottom->setIcon(QIcon::fromTheme("kdenlive-align-bottom")); buttonbottom->setToolTip(i18n("Align item to bottom")); buttonright->setIcon(QIcon::fromTheme("kdenlive-align-right")); buttonright->setToolTip(i18n("Align item to right")); buttonleft->setIcon(QIcon::fromTheme("kdenlive-align-left")); buttonleft->setToolTip(i18n("Align item to left")); connect(buttonhcenter, SIGNAL(clicked()), this, SLOT(slotAlignHCenter())); connect(buttonvcenter, SIGNAL(clicked()), this, SLOT(slotAlignVCenter())); connect(buttontop, SIGNAL(clicked()), this, SLOT(slotAlignTop())); connect(buttonbottom, SIGNAL(clicked()), this, SLOT(slotAlignBottom())); connect(buttonright, SIGNAL(clicked()), this, SLOT(slotAlignRight())); connect(buttonleft, SIGNAL(clicked()), this, SLOT(slotAlignLeft())); connect(spinX, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryX(int))); connect(spinY, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryY(int))); connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryWidth(int))); connect(spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryHeight(int))); connect(spinResize, SIGNAL(editingFinished()), this, SLOT(slotResizeCustom())); connect(buttonResize, SIGNAL(clicked()), this, SLOT(slotResizeOriginal())); connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateGeometry())); }