implemented all field UIs
This commit is contained in:
@@ -138,8 +138,8 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
|
||||
outline_enable(false);
|
||||
shadow_enable(false);
|
||||
|
||||
connect(shadow_bool, SIGNAL(toggled(bool)), this, SLOT(shadow_enable(bool)));
|
||||
connect(outline_bool, SIGNAL(toggled(bool)), this, SLOT(outline_enable(bool)));
|
||||
connect(shadow_bool, SIGNAL(Toggled(bool)), this, SLOT(shadow_enable(bool)));
|
||||
connect(outline_bool, SIGNAL(Toggled(bool)), this, SLOT(outline_enable(bool)));
|
||||
|
||||
vertPath = "common.vert";
|
||||
fragPath = "dropshadow.frag";
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
class TextEffect : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextEffect(Clip* c, const EffectMeta *em);
|
||||
TextEffect(Clip* c, const EffectMeta *em);
|
||||
void redraw(double timecode);
|
||||
|
||||
StringField* text_val;
|
||||
|
||||
@@ -256,7 +256,22 @@ void VSTHost::processAudio(long numFrames) {
|
||||
plugin->processReplacing(plugin, inputs, outputs, numFrames);
|
||||
}
|
||||
|
||||
VSTHost::VSTHost(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
void VSTHost::CreateDialogIfNull()
|
||||
{
|
||||
if (dialog == nullptr) {
|
||||
dialog = new QDialog(olive::MainWindow);
|
||||
dialog->setWindowTitle(tr("VST Plugin"));
|
||||
dialog->setAttribute(Qt::WA_NativeWindow, true);
|
||||
dialog->setWindowFlags(dialog->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
|
||||
connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button()));
|
||||
}
|
||||
}
|
||||
|
||||
VSTHost::VSTHost(Clip* c, const EffectMeta *em) :
|
||||
Effect(c, em),
|
||||
plugin(nullptr),
|
||||
dialog(nullptr)
|
||||
{
|
||||
plugin = nullptr;
|
||||
|
||||
inputs = new float* [CHANNEL_COUNT];
|
||||
@@ -268,21 +283,14 @@ VSTHost::VSTHost(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
|
||||
EffectRow* file_row = new EffectRow(this, tr("Plugin"), true, false);
|
||||
file_field = new FileField(file_row, "filename");
|
||||
connect(file_field, SIGNAL(changed()), this, SLOT(change_plugin()));
|
||||
connect(file_field, SIGNAL(Changed()), this, SLOT(change_plugin()));
|
||||
|
||||
EffectRow* interface_row = new EffectRow(this, tr("Interface"), false, false);
|
||||
|
||||
|
||||
show_interface_btn = new ButtonField(interface_row, tr("Show"));
|
||||
show_interface_btn->SetCheckable(true);
|
||||
show_interface_btn->SetEnabled(false);
|
||||
connect(show_interface_btn, SIGNAL(toggled(bool)), this, SLOT(show_interface(bool)));
|
||||
|
||||
dialog = new QDialog(olive::MainWindow);
|
||||
dialog->setWindowTitle(tr("VST Plugin"));
|
||||
dialog->setAttribute(Qt::WA_NativeWindow, true);
|
||||
dialog->setWindowFlags(dialog->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
|
||||
connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button()));
|
||||
connect(show_interface_btn, SIGNAL(Toggled(bool)), this, SLOT(show_interface(bool)));
|
||||
}
|
||||
|
||||
VSTHost::~VSTHost() {
|
||||
@@ -294,9 +302,6 @@ VSTHost::~VSTHost() {
|
||||
delete [] inputs;
|
||||
|
||||
freePlugin();
|
||||
|
||||
delete show_interface_btn;
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void VSTHost::process_audio(double, double, quint8* samples, int nb_bytes, int) {
|
||||
@@ -358,6 +363,7 @@ void VSTHost::save(QXmlStreamWriter &stream) {
|
||||
}
|
||||
|
||||
void VSTHost::show_interface(bool show) {
|
||||
CreateDialogIfNull();
|
||||
dialog->setVisible(show);
|
||||
|
||||
if (show) {
|
||||
@@ -383,9 +389,13 @@ void VSTHost::change_plugin() {
|
||||
if (plugin != nullptr) {
|
||||
if (configurePluginCallbacks()) {
|
||||
startPlugin();
|
||||
|
||||
VSTRect* eRect = nullptr;
|
||||
plugin->dispatcher(plugin, effEditGetRect, 0, 0, &eRect, 0);
|
||||
|
||||
CreateDialogIfNull();
|
||||
dialog->setFixedSize(eRect->right - eRect->left, eRect->bottom - eRect->top);
|
||||
|
||||
} else {
|
||||
#ifdef __APPLE__
|
||||
CFBundleUnloadExecutable(bundle);
|
||||
|
||||
@@ -62,6 +62,7 @@ private:
|
||||
void suspendPlugin();
|
||||
bool canPluginDo(char *canDoString);
|
||||
void processAudio(long numFrames);
|
||||
void CreateDialogIfNull();
|
||||
float** inputs;
|
||||
float** outputs;
|
||||
QDialog* dialog;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "buttonfield.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
ButtonField::ButtonField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI)
|
||||
{
|
||||
SetValueAt(0, string);
|
||||
}
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
button_text_(string)
|
||||
{}
|
||||
|
||||
void ButtonField::SetCheckable(bool c)
|
||||
{
|
||||
@@ -16,3 +17,20 @@ void ButtonField::SetChecked(bool c)
|
||||
checked_ = c;
|
||||
emit CheckedChanged(c);
|
||||
}
|
||||
|
||||
QWidget *ButtonField::CreateWidget()
|
||||
{
|
||||
QPushButton* button = new QPushButton();
|
||||
|
||||
button->setCheckable(checkable_);
|
||||
button->setEnabled(IsEnabled());
|
||||
button->setText(button_text_);
|
||||
|
||||
connect(this, SIGNAL(CheckedChanged(bool)), button, SLOT(setChecked(bool)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), button, SLOT(setEnabled(bool)));
|
||||
connect(button, SIGNAL(clicked(bool)), this, SIGNAL(Clicked()));
|
||||
connect(button, SIGNAL(toggled(bool)), this, SLOT(SetChecked(bool)));
|
||||
connect(button, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,20 @@ public:
|
||||
ButtonField(EffectRow* parent, const QString& string);
|
||||
|
||||
void SetCheckable(bool c);
|
||||
virtual QWidget* CreateWidget() override;
|
||||
|
||||
public slots:
|
||||
void SetChecked(bool c);
|
||||
|
||||
signals:
|
||||
void CheckedChanged(bool);
|
||||
void Toggled(bool);
|
||||
|
||||
private:
|
||||
bool checkable_;
|
||||
bool checked_;
|
||||
|
||||
QString button_text_;
|
||||
};
|
||||
|
||||
#endif // BUTTONFIELD_H
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include "ui/colorbutton.h"
|
||||
|
||||
ColorField::ColorField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_COLOR)
|
||||
{}
|
||||
@@ -11,6 +13,16 @@ QColor ColorField::GetColorAt(double timecode)
|
||||
return GetValueAt(timecode).value<QColor>();
|
||||
}
|
||||
|
||||
QWidget *ColorField::CreateWidget()
|
||||
{
|
||||
ColorButton* cb = new ColorButton();
|
||||
|
||||
connect(cb, SIGNAL(color_changed(const QColor &)), this, SLOT(UpdateFromWidget(const QColor &)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
QVariant ColorField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return QColor(s);
|
||||
@@ -20,3 +32,8 @@ QString ColorField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.value<QColor>().name();
|
||||
}
|
||||
|
||||
void ColorField::UpdateFromWidget(const QColor& c)
|
||||
{
|
||||
SetValueAt(Now(), c);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,12 @@ public:
|
||||
|
||||
QColor GetColorAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QColor &c);
|
||||
};
|
||||
|
||||
#endif // COLORFIELD_H
|
||||
|
||||
@@ -25,6 +25,7 @@ QWidget *ComboField::CreateWidget()
|
||||
}
|
||||
|
||||
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ QWidget *DoubleField::CreateWidget()
|
||||
ls->set_display_type(display_type_);
|
||||
ls->set_frame_rate(frame_rate_);
|
||||
|
||||
ls->setEnabled(IsEnabled());
|
||||
|
||||
connect(ls, SIGNAL(valueChanged(double)), this, SLOT(UpdateFromWidget(double)));
|
||||
connect(ls, SIGNAL(clicked()), this, SIGNAL(Clicked()));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), ls, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -85,6 +85,7 @@ private:
|
||||
signals:
|
||||
void Changed();
|
||||
void Clicked();
|
||||
|
||||
void EnabledChanged(bool);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "filefield.h"
|
||||
|
||||
#include "ui/embeddedfilechooser.h"
|
||||
|
||||
FileField::FileField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FILE)
|
||||
{
|
||||
@@ -10,3 +12,18 @@ QString FileField::GetFileAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QWidget *FileField::CreateWidget()
|
||||
{
|
||||
EmbeddedFileChooser* efc = new EmbeddedFileChooser();
|
||||
|
||||
connect(efc, SIGNAL(changed(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), efc, SLOT(setEnabled(bool)));
|
||||
|
||||
return efc;
|
||||
}
|
||||
|
||||
void FileField::UpdateFromWidget(const QString &s)
|
||||
{
|
||||
SetValueAt(Now(), s);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ public:
|
||||
FileField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetFileAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString &s);
|
||||
};
|
||||
|
||||
#endif // FILEFIELD_H
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
#include "fontfield.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFontDatabase>
|
||||
|
||||
FontField::FontField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FONT)
|
||||
{
|
||||
font_list = QFontDatabase().families();
|
||||
|
||||
SetValueAt(0, font_list.first());
|
||||
}
|
||||
|
||||
QString FontField::GetFontAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QWidget *FontField::CreateWidget()
|
||||
{
|
||||
QComboBox* fcb = new QComboBox();
|
||||
|
||||
fcb->addItems(font_list);
|
||||
|
||||
connect(fcb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(UpdateFromWidget(const QString &)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), fcb, SLOT(setEnabled(bool)));
|
||||
|
||||
return fcb;
|
||||
}
|
||||
|
||||
void FontField::UpdateFromWidget(const QString& s)
|
||||
{
|
||||
SetValueAt(Now(), s);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ public:
|
||||
FontField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetFontAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
private:
|
||||
QStringList font_list;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString& index);
|
||||
};
|
||||
|
||||
#endif // FONTFIELD_H
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
#include "labelfield.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
LabelField::LabelField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI)
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
label_text_(string)
|
||||
{}
|
||||
|
||||
QWidget *LabelField::CreateWidget()
|
||||
{
|
||||
SetValueAt(0, string);
|
||||
QLabel* label = new QLabel(label_text_);
|
||||
|
||||
label->setEnabled(IsEnabled());
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ class LabelField : public EffectField
|
||||
Q_OBJECT
|
||||
public:
|
||||
LabelField(EffectRow* parent, const QString& string);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
private:
|
||||
QString label_text_;
|
||||
};
|
||||
|
||||
#endif // LABELFIELD_H
|
||||
|
||||
@@ -20,6 +20,7 @@ QWidget *StringField::CreateWidget()
|
||||
{
|
||||
TextEditEx* text_edit = new TextEditEx();
|
||||
|
||||
text_edit->setEnabled(IsEnabled());
|
||||
text_edit->setUndoRedoEnabled(true);
|
||||
|
||||
// the "2" looks like a magic number, but it's just one pixel on the top and the bottom
|
||||
@@ -28,6 +29,7 @@ QWidget *StringField::CreateWidget()
|
||||
+ text_edit->document()->documentMargin() + 2));
|
||||
|
||||
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
|
||||
|
||||
return text_edit;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,6 @@ AddEffectCommand::AddEffectCommand(Clip* c, EffectPtr e, const EffectMeta *m, in
|
||||
ref = e;
|
||||
meta = m;
|
||||
pos = insert_pos;
|
||||
done = false;
|
||||
}
|
||||
|
||||
void AddEffectCommand::doUndo() {
|
||||
@@ -207,7 +206,6 @@ void AddEffectCommand::doUndo() {
|
||||
} else {
|
||||
clip->effects.removeAt(pos);
|
||||
}
|
||||
done = false;
|
||||
}
|
||||
|
||||
void AddEffectCommand::doRedo() {
|
||||
@@ -219,7 +217,6 @@ void AddEffectCommand::doRedo() {
|
||||
} else {
|
||||
clip->effects.insert(pos, ref);
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
|
||||
AddTransitionCommand::AddTransitionCommand(Clip* iopen,
|
||||
|
||||
+20
-20
@@ -25,47 +25,47 @@
|
||||
#include <QColorDialog>
|
||||
|
||||
ColorButton::ColorButton(QWidget *parent)
|
||||
: QPushButton(parent), color(Qt::white) {
|
||||
set_button_color();
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(open_dialog()));
|
||||
: QPushButton(parent), color(Qt::white) {
|
||||
set_button_color();
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(open_dialog()));
|
||||
}
|
||||
|
||||
QColor ColorButton::get_color() {
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
void ColorButton::set_color(QColor c) {
|
||||
previousColor = color;
|
||||
color = c;
|
||||
set_button_color();
|
||||
previousColor = color;
|
||||
color = c;
|
||||
set_button_color();
|
||||
}
|
||||
|
||||
const QColor &ColorButton::getPreviousValue() {
|
||||
return previousColor;
|
||||
return previousColor;
|
||||
}
|
||||
|
||||
void ColorButton::set_button_color() {
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
setPalette(pal);
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
setPalette(pal);
|
||||
}
|
||||
|
||||
void ColorButton::open_dialog() {
|
||||
QColor new_color = QColorDialog::getColor(color, nullptr, tr("Set Color"));
|
||||
if (new_color.isValid() && color != new_color) {
|
||||
set_color(new_color);
|
||||
set_button_color();
|
||||
emit color_changed();
|
||||
}
|
||||
QColor new_color = QColorDialog::getColor(color, nullptr, tr("Set Color"));
|
||||
if (new_color.isValid() && color != new_color) {
|
||||
set_color(new_color);
|
||||
set_button_color();
|
||||
emit color_changed(color);
|
||||
}
|
||||
}
|
||||
|
||||
ColorCommand::ColorCommand(ColorButton* s, QColor o, QColor n)
|
||||
: sender(s), old_color(o), new_color(n) {}
|
||||
: sender(s), old_color(o), new_color(n) {}
|
||||
|
||||
void ColorCommand::undo() {
|
||||
sender->set_color(old_color);
|
||||
sender->set_color(old_color);
|
||||
}
|
||||
|
||||
void ColorCommand::redo() {
|
||||
sender->set_color(new_color);
|
||||
sender->set_color(new_color);
|
||||
}
|
||||
|
||||
+16
-16
@@ -26,31 +26,31 @@
|
||||
#include <QUndoCommand>
|
||||
|
||||
class ColorButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorButton(QWidget* parent = 0);
|
||||
QColor get_color();
|
||||
void set_color(QColor c);
|
||||
const QColor& getPreviousValue();
|
||||
ColorButton(QWidget* parent = nullptr);
|
||||
QColor get_color();
|
||||
void set_color(QColor c);
|
||||
const QColor& getPreviousValue();
|
||||
private:
|
||||
QColor color;
|
||||
QColor previousColor;
|
||||
void set_button_color();
|
||||
QColor color;
|
||||
QColor previousColor;
|
||||
void set_button_color();
|
||||
signals:
|
||||
void color_changed();
|
||||
void color_changed(const QColor& c);
|
||||
private slots:
|
||||
void open_dialog();
|
||||
void open_dialog();
|
||||
};
|
||||
|
||||
class ColorCommand : public QUndoCommand {
|
||||
public:
|
||||
ColorCommand(ColorButton* s, QColor o, QColor n);
|
||||
void undo();
|
||||
void redo();
|
||||
ColorCommand(ColorButton* s, QColor o, QColor n);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
ColorButton* sender;
|
||||
QColor old_color;
|
||||
QColor new_color;
|
||||
ColorButton* sender;
|
||||
QColor old_color;
|
||||
QColor new_color;
|
||||
};
|
||||
|
||||
#endif // COLORBUTTON_H
|
||||
|
||||
+9
-9
@@ -25,18 +25,18 @@
|
||||
#include <QDebug>
|
||||
|
||||
class ComboBoxEx : public QComboBox {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
ComboBoxEx(QWidget* parent = 0);
|
||||
void setCurrentIndexEx(int i);
|
||||
void setCurrentTextEx(const QString &text);
|
||||
int getPreviousIndex();
|
||||
ComboBoxEx(QWidget* parent = 0);
|
||||
void setCurrentIndexEx(int i);
|
||||
void setCurrentTextEx(const QString &text);
|
||||
int getPreviousIndex();
|
||||
private slots:
|
||||
void index_changed(int);
|
||||
void index_changed(int);
|
||||
private:
|
||||
int index;
|
||||
int previousIndex;
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
int index;
|
||||
int previousIndex;
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
};
|
||||
|
||||
#endif // COMBOBOXEX_H
|
||||
|
||||
+35
-35
@@ -27,54 +27,54 @@
|
||||
#include <QFileDialog>
|
||||
|
||||
EmbeddedFileChooser::EmbeddedFileChooser(QWidget* parent) : QWidget(parent) {
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
file_label = new QLabel(this);
|
||||
update_label();
|
||||
layout->addWidget(file_label);
|
||||
QPushButton* browse_button = new QPushButton("...", this);
|
||||
browse_button->setFixedWidth(25);
|
||||
layout->addWidget(browse_button);
|
||||
connect(browse_button, SIGNAL(clicked(bool)), this, SLOT(browse()));
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
file_label = new QLabel(this);
|
||||
update_label();
|
||||
layout->addWidget(file_label);
|
||||
QPushButton* browse_button = new QPushButton("...", this);
|
||||
browse_button->setFixedWidth(25);
|
||||
layout->addWidget(browse_button);
|
||||
connect(browse_button, SIGNAL(clicked(bool)), this, SLOT(browse()));
|
||||
}
|
||||
|
||||
const QString &EmbeddedFileChooser::getFilename() {
|
||||
return filename;
|
||||
return filename;
|
||||
}
|
||||
|
||||
const QString &EmbeddedFileChooser::getPreviousValue() {
|
||||
return old_filename;
|
||||
return old_filename;
|
||||
}
|
||||
|
||||
void EmbeddedFileChooser::setFilename(const QString &s) {
|
||||
old_filename = filename;
|
||||
filename = s;
|
||||
update_label();
|
||||
emit changed();
|
||||
old_filename = filename;
|
||||
filename = s;
|
||||
update_label();
|
||||
emit changed(filename);
|
||||
}
|
||||
|
||||
void EmbeddedFileChooser::update_label() {
|
||||
QString l = "<html>" + tr("File:") + " ";
|
||||
if (filename.isEmpty()) {
|
||||
l += "(none)";
|
||||
} else {
|
||||
bool file_exists = QFileInfo::exists(filename);
|
||||
if (!file_exists) l += "<font color='red'>";
|
||||
QString short_fn = filename.mid(filename.lastIndexOf('/')+1);
|
||||
if (short_fn.size() > 20) {
|
||||
l += "..." + short_fn.right(20);
|
||||
} else {
|
||||
l += short_fn;
|
||||
}
|
||||
if (!file_exists) l += "</font>";
|
||||
}
|
||||
l += "</html>";
|
||||
file_label->setText(l);
|
||||
QString l = "<html>" + tr("File:") + " ";
|
||||
if (filename.isEmpty()) {
|
||||
l += "(none)";
|
||||
} else {
|
||||
bool file_exists = QFileInfo::exists(filename);
|
||||
if (!file_exists) l += "<font color='red'>";
|
||||
QString short_fn = filename.mid(filename.lastIndexOf('/')+1);
|
||||
if (short_fn.size() > 20) {
|
||||
l += "..." + short_fn.right(20);
|
||||
} else {
|
||||
l += short_fn;
|
||||
}
|
||||
if (!file_exists) l += "</font>";
|
||||
}
|
||||
l += "</html>";
|
||||
file_label->setText(l);
|
||||
}
|
||||
|
||||
void EmbeddedFileChooser::browse() {
|
||||
QString fn = QFileDialog::getOpenFileName(this);
|
||||
if (!fn.isEmpty()) {
|
||||
setFilename(fn);
|
||||
}
|
||||
QString fn = QFileDialog::getOpenFileName(this);
|
||||
if (!fn.isEmpty()) {
|
||||
setFilename(fn);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -26,22 +26,22 @@
|
||||
class QLabel;
|
||||
|
||||
class EmbeddedFileChooser : public QWidget {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
EmbeddedFileChooser(QWidget* parent = 0);
|
||||
EmbeddedFileChooser(QWidget* parent = 0);
|
||||
|
||||
const QString& getFilename();
|
||||
const QString& getPreviousValue();
|
||||
void setFilename(const QString& s);
|
||||
const QString& getFilename();
|
||||
const QString& getPreviousValue();
|
||||
void setFilename(const QString& s);
|
||||
signals:
|
||||
void changed();
|
||||
void changed(const QString& s);
|
||||
private:
|
||||
QLabel* file_label;
|
||||
QString filename;
|
||||
QString old_filename;
|
||||
void update_label();
|
||||
QLabel* file_label;
|
||||
QString filename;
|
||||
QString old_filename;
|
||||
void update_label();
|
||||
private slots:
|
||||
void browse();
|
||||
void browse();
|
||||
};
|
||||
|
||||
#endif // EMBEDDEDFILECHOOSER_H
|
||||
|
||||
+7
-7
@@ -22,19 +22,19 @@
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
FontCombobox::FontCombobox(QWidget* parent) : ComboBoxEx(parent) {
|
||||
addItems(QFontDatabase().families());
|
||||
FontCombobox::FontCombobox(QWidget* parent) : QComboBox(parent) {
|
||||
addItems(QFontDatabase().families());
|
||||
|
||||
value = currentText();
|
||||
value = currentText();
|
||||
|
||||
connect(this, SIGNAL(currentTextChanged(QString)), this, SLOT(updateInternals()));
|
||||
connect(this, SIGNAL(currentTextChanged(QString)), this, SLOT(updateInternals()));
|
||||
}
|
||||
|
||||
const QString& FontCombobox::getPreviousValue() {
|
||||
return previousValue;
|
||||
return previousValue;
|
||||
}
|
||||
|
||||
void FontCombobox::updateInternals() {
|
||||
previousValue = value;
|
||||
value = currentText();
|
||||
previousValue = value;
|
||||
value = currentText();
|
||||
}
|
||||
|
||||
+8
-8
@@ -21,18 +21,18 @@
|
||||
#ifndef FONTCOMBOBOX_H
|
||||
#define FONTCOMBOBOX_H
|
||||
|
||||
#include "comboboxex.h"
|
||||
#include <QComboBox>
|
||||
|
||||
class FontCombobox : public ComboBoxEx {
|
||||
Q_OBJECT
|
||||
class FontCombobox : public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontCombobox(QWidget* parent = 0);
|
||||
const QString &getPreviousValue();
|
||||
FontCombobox(QWidget* parent = 0);
|
||||
const QString &getPreviousValue();
|
||||
private slots:
|
||||
void updateInternals();
|
||||
void updateInternals();
|
||||
private:
|
||||
QString previousValue;
|
||||
QString value;
|
||||
QString previousValue;
|
||||
QString value;
|
||||
};
|
||||
|
||||
#endif // FONTCOMBOBOX_H
|
||||
|
||||
Reference in New Issue
Block a user