[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/traverso/widgets TransportConsoleW...
From: |
Nicola Doebelin |
Subject: |
[Traverso-commit] traverso/src/traverso/widgets TransportConsoleW... |
Date: |
Fri, 23 May 2008 08:48:11 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 08/05/23 08:48:11
Modified files:
src/traverso/widgets: TransportConsoleWidget.cpp
TransportConsoleWidget.h
Log message:
* Transport console was converted into a toolbar
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/widgets/TransportConsoleWidget.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/widgets/TransportConsoleWidget.h?cvsroot=traverso&r1=1.3&r2=1.4
Patches:
Index: TransportConsoleWidget.cpp
===================================================================
RCS file:
/sources/traverso/traverso/src/traverso/widgets/TransportConsoleWidget.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- TransportConsoleWidget.cpp 18 May 2008 20:55:33 -0000 1.5
+++ TransportConsoleWidget.cpp 23 May 2008 08:48:10 -0000 1.6
@@ -38,117 +38,30 @@
static const int HEIGHT_THRESHOLD = 90;
static const float FONT_HEIGHT = 0.8;
-TimeLabel::TimeLabel(QWidget* parent)
- : QFrame(parent)
-{
- font = QApplication::font();
- setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
- setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding));
- calc_font_size();
-}
-
-void TimeLabel::set_time(QString s)
-{
- time = s;
- update();
-}
-
-void TimeLabel::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- p.setFont(font);
- p.drawText(0, 0, width(), height(), Qt::AlignCenter, time);
- p.end();
-}
-
-void TimeLabel::resizeEvent(QResizeEvent *)
-{
- calc_font_size();
- update();
-}
-
-void TimeLabel::calc_font_size()
-{
- font.setPixelSize(int(FONT_HEIGHT * height()));
-
- QFontMetrics fm(font);
- int w = fm.width(time);
-
- if (w >= width())
- {
- font.setPixelSize(int((FONT_HEIGHT * height() * width()) / w));
- }
-}
-
-
TransportConsoleWidget::TransportConsoleWidget(QWidget* parent)
- : QWidget(parent)
+ : QToolBar(parent)
{
setEnabled(false);
- m_layout = new QGridLayout(this);
- m_label = new TimeLabel(this);
- m_label->setMinimumWidth(80);
-
- QToolButton* buttonToStart = new QToolButton(this);
- QToolButton* buttonToLeft = new QToolButton(this);
- QToolButton* buttonRec = new QToolButton(this);
- QToolButton* buttonPlay = new QToolButton(this);
- QToolButton* buttonToRight = new QToolButton(this);
- QToolButton* buttonToEnd = new QToolButton(this);
-
- buttonToStart->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
- buttonToLeft->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
- buttonRec->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
- buttonPlay->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
- buttonToRight->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
- buttonToEnd->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred));
-
- m_toStartAction = new QAction(this);
- m_toLeftAction = new QAction(this);
- m_recAction = new QAction(this);
- m_playAction = new QAction(this);
- m_toEndAction = new QAction(this);
- m_toRightAction = new QAction(this);
+ m_timeLabel = new QLineEdit(this);
+ m_timeLabel->setReadOnly(true);
+ m_timeLabel->setAlignment(Qt::AlignCenter);
+ m_timeLabel->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
+ m_timeLabel->setFont(themer()->get_font("Playhead:fontscale:info"));
+
+ m_toStartAction = addAction(QIcon(":/skipleft"), tr("Skip to Start"),
this, SLOT(to_start()));
+ m_toLeftAction = addAction(QIcon(":/seekleft"), tr("Previous Snap
Position"), this, SLOT(to_left()));
+ m_recAction = addAction(QIcon(":/record"), tr("Record"), this,
SLOT(rec_toggled()));
+ m_playAction = addAction(QIcon(":/playstart"), tr("Play / Stop"), this,
SLOT(play_toggled()));
+ m_toRightAction = addAction(QIcon(":/seekright"), tr("Skip to End"),
this, SLOT(to_right()));
+ m_toEndAction = addAction(QIcon(":/skipright"), tr("Next Snap
Position"), this, SLOT(to_end()));
+
+ addWidget(m_timeLabel);
m_recAction->setCheckable(true);
m_playAction->setCheckable(true);
- m_toStartAction->setIcon(QIcon(":/skipleft"));
- m_toLeftAction->setIcon(QIcon(":/seekleft"));
- m_recAction->setIcon(QIcon(":/record"));
- m_playAction->setIcon(QIcon(":/playstart"));
- m_toEndAction->setIcon(QIcon(":/skipright"));
- m_toRightAction->setIcon(QIcon(":/seekright"));
-
- connect(m_toStartAction, SIGNAL(triggered()), this, SLOT(to_start()));
- connect(m_toLeftAction, SIGNAL(triggered()), this, SLOT(to_left()));
- connect(m_recAction, SIGNAL(triggered()), this, SLOT(rec_toggled()));
- connect(m_playAction, SIGNAL(triggered()), this, SLOT(play_toggled()));
- connect(m_toEndAction, SIGNAL(triggered()), this, SLOT(to_end()));
- connect(m_toRightAction, SIGNAL(triggered()), this, SLOT(to_right()));
-
- buttonToStart->setDefaultAction(m_toStartAction);
- buttonToLeft->setDefaultAction(m_toLeftAction);
- buttonRec->setDefaultAction(m_recAction);
- buttonPlay->setDefaultAction(m_playAction);
- buttonToEnd->setDefaultAction(m_toEndAction);
- buttonToRight->setDefaultAction(m_toRightAction);
-
- if (height() < HEIGHT_THRESHOLD)
- {
- m_layout->addWidget(m_label, 1, 6, 1, 1);
- } else {
- m_layout->addWidget(m_label, 0, 0, 1, 6);
- }
- m_layout->addWidget(buttonToStart, 1, 0, 1, 1);
- m_layout->addWidget(buttonToLeft, 1, 1, 1, 1);
- m_layout->addWidget(buttonRec, 1, 2, 1, 1);
- m_layout->addWidget(buttonPlay, 1, 3, 1, 1);
- m_layout->addWidget(buttonToRight, 1, 4, 1, 1);
- m_layout->addWidget(buttonToEnd, 1, 5, 1, 1);
-
- m_lastSnapPosition = TimeRef(0.0);
+ m_lastSnapPosition = TimeRef();
m_skipTimer.setSingleShot(true);
connect(&pm(), SIGNAL(projectLoaded(Project*)), this,
SLOT(set_project(Project*)));
@@ -289,32 +202,6 @@
}
}
-void TransportConsoleWidget::resizeEvent(QResizeEvent * e)
-{
- // position the text label depending on the widget size
- if ((e->oldSize().height() >= HEIGHT_THRESHOLD) && (e->size().height()
< HEIGHT_THRESHOLD))
- {
- place_label();
- }
-
- if ((e->oldSize().height() < HEIGHT_THRESHOLD) && (e->size().height()
>= HEIGHT_THRESHOLD))
- {
- place_label();
- }
-}
-
-void TransportConsoleWidget::place_label()
-{
- if (height() < HEIGHT_THRESHOLD)
- {
- m_layout->removeWidget(m_label);
- m_layout->addWidget(m_label, 1, 6, 1, 1);
- } else {
- m_layout->removeWidget(m_label);
- m_layout->addWidget(m_label, 0, 0, 1, 6);
- }
-}
-
void TransportConsoleWidget::update_label()
{
QString currentTime;
@@ -324,7 +211,7 @@
} else {
currentTime =
timeref_to_ms_2(m_sheet->get_transport_location());
}
- m_label->set_time(currentTime);
+ m_timeLabel->setText(currentTime);
}
//eof
Index: TransportConsoleWidget.h
===================================================================
RCS file:
/sources/traverso/traverso/src/traverso/widgets/TransportConsoleWidget.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- TransportConsoleWidget.h 18 May 2008 20:55:33 -0000 1.3
+++ TransportConsoleWidget.h 23 May 2008 08:48:10 -0000 1.4
@@ -23,8 +23,8 @@
#define TRANSPORTCONSOLEWIDGET_H
#include <QWidget>
-#include <QGridLayout>
-#include <QFrame>
+#include <QToolBar>
+#include <QLineEdit>
#include <QTimer>
#include <QEvent>
#include <QFont>
@@ -35,42 +35,15 @@
class Project;
class Sheet;
-
-class TimeLabel : public QFrame
-{
-Q_OBJECT
-
-public:
- TimeLabel(QWidget* parent = 0);
- ~TimeLabel() {};
-
-public slots:
- void set_time(QString);
-
-protected:
- void paintEvent(QPaintEvent *);
- void resizeEvent(QResizeEvent *);
-
-private:
- QFont font;
- QString time;
-
- void calc_font_size();
-};
-
-
-class TransportConsoleWidget : public QWidget
+class TransportConsoleWidget : public QToolBar
{
Q_OBJECT
public:
TransportConsoleWidget(QWidget* parent);
-protected:
- void resizeEvent(QResizeEvent*);
-
private:
- QGridLayout* m_layout;
+ QLineEdit* m_timeLabel;
Project* m_project;
Sheet* m_sheet;
QAction* m_toStartAction;
@@ -79,13 +52,10 @@
QAction* m_playAction;
QAction* m_toEndAction;
QAction* m_toRightAction;
- TimeLabel* m_label;
QTimer m_updateTimer;
QTimer m_skipTimer;
TimeRef m_lastSnapPosition;
- void place_label();
-
protected slots:
void set_project(Project*);
void set_sheet(Sheet*);