change: change code style to Linux style except indent.
This commit is contained in:
@@ -22,32 +22,33 @@
|
||||
|
||||
#include "ui/colorcoding.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ColorCodingComboBox::ColorCodingComboBox(QWidget *parent) :
|
||||
QComboBox(parent)
|
||||
namespace olive
|
||||
{
|
||||
SetColor(0);
|
||||
|
||||
ColorCodingComboBox::ColorCodingComboBox(QWidget *parent)
|
||||
: QComboBox(parent)
|
||||
{
|
||||
SetColor(0);
|
||||
}
|
||||
|
||||
void ColorCodingComboBox::showPopup()
|
||||
{
|
||||
ColorLabelMenu menu(this);
|
||||
ColorLabelMenu menu(this);
|
||||
|
||||
menu.setMinimumWidth(width());
|
||||
menu.setMinimumWidth(width());
|
||||
|
||||
QAction* a = menu.exec(parentWidget()->mapToGlobal(pos()));
|
||||
QAction *a = menu.exec(parentWidget()->mapToGlobal(pos()));
|
||||
|
||||
if (a) {
|
||||
SetColor(a->data().toInt());
|
||||
}
|
||||
if (a) {
|
||||
SetColor(a->data().toInt());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorCodingComboBox::SetColor(int index)
|
||||
{
|
||||
clear();
|
||||
addItem(ColorCoding::GetColorName(index));
|
||||
index_ = index;
|
||||
clear();
|
||||
addItem(ColorCoding::GetColorName(index));
|
||||
index_ = index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,26 +25,25 @@
|
||||
|
||||
#include "widget/colorlabelmenu/colorlabelmenu.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ColorCodingComboBox : public QComboBox
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ColorCodingComboBox : public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorCodingComboBox(QWidget* parent = nullptr);
|
||||
ColorCodingComboBox(QWidget *parent = nullptr);
|
||||
|
||||
virtual void showPopup() override;
|
||||
virtual void showPopup() override;
|
||||
|
||||
void SetColor(int index);
|
||||
void SetColor(int index);
|
||||
|
||||
int GetSelectedColor() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
int GetSelectedColor() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
private:
|
||||
int index_;
|
||||
|
||||
int index_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,54 +27,57 @@
|
||||
#include "common/qtutils.h"
|
||||
#include "ui/colorcoding.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ColorLabelMenu::ColorLabelMenu(QWidget *parent) :
|
||||
Menu(parent)
|
||||
namespace olive
|
||||
{
|
||||
// Used for size calculations
|
||||
int box_size = fontMetrics().height();
|
||||
|
||||
color_items_.resize(ColorCoding::standard_colors().size());
|
||||
for (int i=0; i<ColorCoding::standard_colors().size(); i++) {
|
||||
QPixmap p(box_size, box_size);
|
||||
ColorLabelMenu::ColorLabelMenu(QWidget *parent)
|
||||
: Menu(parent)
|
||||
{
|
||||
// Used for size calculations
|
||||
int box_size = fontMetrics().height();
|
||||
|
||||
QPainter painter(&p);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(QtUtils::toQColor(ColorCoding::standard_colors().at(i)));
|
||||
painter.drawRect(p.rect().adjusted(0, 0, -1, -1));
|
||||
color_items_.resize(ColorCoding::standard_colors().size());
|
||||
for (int i = 0; i < ColorCoding::standard_colors().size(); i++) {
|
||||
QPixmap p(box_size, box_size);
|
||||
|
||||
QAction *a = AddItem(QStringLiteral("colorlabel%1").arg(i), this, &ColorLabelMenu::ActionTriggered);
|
||||
a->setIcon(p);
|
||||
a->setData(i);
|
||||
color_items_.replace(i, a);
|
||||
}
|
||||
QPainter painter(&p);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(
|
||||
QtUtils::toQColor(ColorCoding::standard_colors().at(i)));
|
||||
painter.drawRect(p.rect().adjusted(0, 0, -1, -1));
|
||||
|
||||
Retranslate();
|
||||
QAction *a = AddItem(QStringLiteral("colorlabel%1").arg(i), this,
|
||||
&ColorLabelMenu::ActionTriggered);
|
||||
a->setIcon(p);
|
||||
a->setData(i);
|
||||
color_items_.replace(i, a);
|
||||
}
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void ColorLabelMenu::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
}
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
Menu::changeEvent(event);
|
||||
Menu::changeEvent(event);
|
||||
}
|
||||
|
||||
void ColorLabelMenu::Retranslate()
|
||||
{
|
||||
this->setTitle(tr("Color"));
|
||||
this->setTitle(tr("Color"));
|
||||
|
||||
for (int i=0; i<color_items_.size(); i++) {
|
||||
color_items_.at(i)->setText(ColorCoding::GetColorName(i));
|
||||
}
|
||||
for (int i = 0; i < color_items_.size(); i++) {
|
||||
color_items_.at(i)->setText(ColorCoding::GetColorName(i));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorLabelMenu::ActionTriggered()
|
||||
{
|
||||
QAction* a = static_cast<QAction*>(sender());
|
||||
emit ColorSelected(a->data().toInt());
|
||||
QAction *a = static_cast<QAction *>(sender());
|
||||
emit ColorSelected(a->data().toInt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,27 +23,26 @@
|
||||
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ColorLabelMenu : public Menu
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorLabelMenu(QWidget* parent = nullptr);
|
||||
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
class ColorLabelMenu : public Menu {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorLabelMenu(QWidget *parent = nullptr);
|
||||
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
signals:
|
||||
void ColorSelected(int i);
|
||||
void ColorSelected(int i);
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void Retranslate();
|
||||
|
||||
QVector<QAction*> color_items_;
|
||||
QVector<QAction *> color_items_;
|
||||
|
||||
private slots:
|
||||
void ActionTriggered();
|
||||
|
||||
void ActionTriggered();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user