Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 7c4422fe rédigé par Kubat's avatar Kubat
Parcourir les fichiers

UI: Small tweaks on the ASS line display

parent 88c99aba
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!7Add the ASS sub document and the ASS tree
...@@ -68,25 +68,9 @@ AssLinesModel::data(const QModelIndex &index, int role) const noexcept ...@@ -68,25 +68,9 @@ AssLinesModel::data(const QModelIndex &index, int role) const noexcept
const Item *line = static_cast<const Item *>(index.internalPointer()); const Item *line = static_cast<const Item *>(index.internalPointer());
const Item::Field column = static_cast<Item::Field>(index.column()); const Item::Field column = static_cast<Item::Field>(index.column());
// Check state only for the IsComment
if (role == Qt::CheckStateRole && column == Item::Field::IsComment) {
return line->getIsComment() ? Qt::Checked : Qt::Unchecked;
}
// Is comment is centered
else if (role == Qt::TextAlignmentRole && column == Item::Field::IsComment) {
return Qt::AlignCenter;
}
// Display role // Display role
else if (Qt::DisplayRole == role) { if (Qt::DisplayRole == role) {
switch (column) { switch (column) {
case Item::Field::Style:
return line->getLineStyle();
case Item::Field::IsComment:
return QVariant();
case Item::Field::Text: case Item::Field::Text:
return line->getLineText(); return line->getLineText();
......
...@@ -20,8 +20,6 @@ private: ...@@ -20,8 +20,6 @@ private:
~Item() noexcept = default; ~Item() noexcept = default;
enum class Field : int { enum class Field : int {
IsComment,
Style,
Text, Text,
// Last, the count // Last, the count
...@@ -37,7 +35,7 @@ private: ...@@ -37,7 +35,7 @@ private:
Ass::LineWeakPtr line; Ass::LineWeakPtr line;
}; };
static inline const QStringList headers{ "", "Actor", "Text" }; static inline const QStringList headers{ "", "Style", "Text" };
public: public:
explicit AssLinesModel(const QVector<Ass::LinePtr> &) noexcept; explicit AssLinesModel(const QVector<Ass::LinePtr> &) noexcept;
......
...@@ -8,10 +8,13 @@ using namespace Vivy; ...@@ -8,10 +8,13 @@ using namespace Vivy;
AssLinesView::AssLinesView(QAbstractItemModel *model, QWidget *parent) noexcept AssLinesView::AssLinesView(QAbstractItemModel *model, QWidget *parent) noexcept
: QTableView(parent) : QTableView(parent)
, delegate(new Delegate(this)) , delegate(new Delegate(this))
{
// Force the 9pt font size for now
{ {
QFont f = font(); QFont f = font();
f.setPointSize(9); // Force the 9pt for now f.setPointSize(9);
setFont(f); setFont(f);
}
setMouseTracking(true); setMouseTracking(true);
setItemDelegate(delegate); setItemDelegate(delegate);
...@@ -21,10 +24,38 @@ AssLinesView::AssLinesView(QAbstractItemModel *model, QWidget *parent) noexcept ...@@ -21,10 +24,38 @@ AssLinesView::AssLinesView(QAbstractItemModel *model, QWidget *parent) noexcept
horizontalHeader()->setHighlightSections(false); horizontalHeader()->setHighlightSections(false);
horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
horizontalHeader()->setStretchLastSection(true); horizontalHeader()->setStretchLastSection(true);
horizontalHeader()->hide();
verticalHeader()->setVisible(true); verticalHeader()->setVisible(true);
setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionBehavior(QAbstractItemView::SelectRows);
setShowGrid(false);
// Also set the 9pt font size for the headers
{
QFont f = horizontalHeader()->font();
f.setPointSize(9);
horizontalHeader()->setFont(f);
verticalHeader()->setFont(f);
}
static const QString style = "QTableView::item:selected {"
" border-top:1px solid #1394B4;"
" border-bottom:1px solid #1394B4;"
" border-right:1px solid #1394B4;"
" border-left:1px solid #1394B4;"
" background-color: #002B36;"
"}"
"QTableView::item {"
" border: 1px solid #474747;"
"};"
"QTableView::item:last:selected {"
" border-top:1px solid #1394B4;"
" border-bottom:1px solid #1394B4;"
" border-right:1px solid #1394B4;"
" border-left:1px solid #1394B4;"
" background-color: #002B36;"
"}";
setStyleSheet(style);
setModel(model); setModel(model);
} }
...@@ -92,9 +123,4 @@ AssLinesView::Delegate::initStyleOption(QStyleOptionViewItem *option, ...@@ -92,9 +123,4 @@ AssLinesView::Delegate::initStyleOption(QStyleOptionViewItem *option,
const QModelIndex &index) const noexcept const QModelIndex &index) const noexcept
{ {
QStyledItemDelegate::initStyleOption(option, index); QStyledItemDelegate::initStyleOption(option, index);
// The first column is the IsComment column
// XXX This is hardcoded
if (index.column() == 0)
option->displayAlignment = Qt::AlignCenter;
} }
...@@ -11,7 +11,10 @@ VivyApplication::VivyApplication(int argc, char **argv) ...@@ -11,7 +11,10 @@ VivyApplication::VivyApplication(int argc, char **argv)
int int
VivyApplication::exec() noexcept VivyApplication::exec() noexcept
{ {
// Show the main window
MainWindow mainWindow; MainWindow mainWindow;
mainWindow.show(); mainWindow.show();
// Main loop
return QApplication::exec(); return QApplication::exec();
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter