Commit 6d6f154a authored by Moritz Molch's avatar Moritz Molch

Move labels into sliders in the main UI, make them DPI dependent for

high res screens

REVIEW:122946
parent c20483b6
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <QPixmap> #include <QPixmap>
#include <QList> #include <QList>
#include <QVector> #include <QVector>
#include <QLabel>
#include <kis_debug.h> #include <kis_debug.h>
#include <kmenu.h> #include <kmenu.h>
...@@ -120,6 +121,8 @@ KisLayerBox::KisLayerBox() ...@@ -120,6 +121,8 @@ KisLayerBox::KisLayerBox()
, m_canvas(0) , m_canvas(0)
, m_wdgLayerBox(new Ui_WdgLayerBox) , m_wdgLayerBox(new Ui_WdgLayerBox)
{ {
KisConfig cfg;
setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QWidget* mainWidget = new QWidget(this); QWidget* mainWidget = new QWidget(this);
...@@ -222,6 +225,10 @@ KisLayerBox::KisLayerBox() ...@@ -222,6 +225,10 @@ KisLayerBox::KisLayerBox()
connect(m_wdgLayerBox->bnLower, SIGNAL(clicked()), SLOT(slotRaiseClicked())); connect(m_wdgLayerBox->bnLower, SIGNAL(clicked()), SLOT(slotRaiseClicked()));
// END NOTE // END NOTE
if (cfg.sliderLabels()) {
m_wdgLayerBox->opacityLabel->hide();
m_wdgLayerBox->doubleOpacity->setPrefix(QString("%1: ").arg(i18n("Opacity")));
}
m_wdgLayerBox->doubleOpacity->setRange(0, 100, 0); m_wdgLayerBox->doubleOpacity->setRange(0, 100, 0);
m_wdgLayerBox->doubleOpacity->setSuffix("%"); m_wdgLayerBox->doubleOpacity->setSuffix("%");
...@@ -261,7 +268,6 @@ KisLayerBox::KisLayerBox() ...@@ -261,7 +268,6 @@ KisLayerBox::KisLayerBox()
connect(showGlobalSelectionMask, SIGNAL(triggered(bool)), SLOT(slotEditGlobalSelection(bool))); connect(showGlobalSelectionMask, SIGNAL(triggered(bool)), SLOT(slotEditGlobalSelection(bool)));
m_actions.append(showGlobalSelectionMask); m_actions.append(showGlobalSelectionMask);
KisConfig cfg;
showGlobalSelectionMask->setChecked(cfg.showGlobalSelection()); showGlobalSelectionMask->setChecked(cfg.showGlobalSelection());
m_wdgLayerBox->listLayers->setModel(m_nodeModel); m_wdgLayerBox->listLayers->setModel(m_nodeModel);
......
...@@ -1212,6 +1212,16 @@ void KisConfig::setToolbarSlider(int sliderNumber, const QString &slider) ...@@ -1212,6 +1212,16 @@ void KisConfig::setToolbarSlider(int sliderNumber, const QString &slider)
m_cfg.writeEntry(QString("toolbarslider_%1").arg(sliderNumber), slider); m_cfg.writeEntry(QString("toolbarslider_%1").arg(sliderNumber), slider);
} }
bool KisConfig::sliderLabels() const
{
return m_cfg.readEntry("sliderLabels", true);
}
void KisConfig::setSliderLabels(bool enabled)
{
m_cfg.writeEntry("sliderLabels", enabled);
}
QString KisConfig::currentInputProfile() const QString KisConfig::currentInputProfile() const
{ {
return m_cfg.readEntry("currentInputProfile", QString()); return m_cfg.readEntry("currentInputProfile", QString());
......
...@@ -370,6 +370,9 @@ public: ...@@ -370,6 +370,9 @@ public:
QString toolbarSlider(int sliderNumber); QString toolbarSlider(int sliderNumber);
void setToolbarSlider(int sliderNumber, const QString &slider); void setToolbarSlider(int sliderNumber, const QString &slider);
bool sliderLabels() const;
void setSliderLabels(bool enabled);
QString currentInputProfile() const; QString currentInputProfile() const;
void setCurrentInputProfile(const QString& name); void setCurrentInputProfile(const QString& name);
......
...@@ -175,40 +175,58 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char * ...@@ -175,40 +175,58 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
vMirrorButton->setDefaultAction(m_vMirrorAction); vMirrorButton->setDefaultAction(m_vMirrorAction);
m_viewManager->actionCollection()->addAction("vmirror_action", m_vMirrorAction); m_viewManager->actionCollection()->addAction("vmirror_action", m_vMirrorAction);
const bool sliderLabels = cfg.sliderLabels();
int sliderWidth;
if (sliderLabels) {
sliderWidth = 150 * logicalDpiX() / 96;
}
else {
sliderWidth = 120 * logicalDpiX() / 96;
}
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
m_sliderChooser[i] = new KisWidgetChooser(i + 1); m_sliderChooser[i] = new KisWidgetChooser(i + 1);
KisDoubleSliderSpinBox* slOpacity = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("opacity", i18n("Opacity:")); KisDoubleSliderSpinBox* slOpacity;
KisDoubleSliderSpinBox* slFlow = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("flow" , i18n("Flow:")); KisDoubleSliderSpinBox* slFlow;
KisDoubleSliderSpinBox* slSize = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("size" , i18n("Size:")); KisDoubleSliderSpinBox* slSize;
if (sliderLabels) {
slOpacity = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("opacity");
slFlow = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("flow");
slSize = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("size");
slOpacity->setPrefix(QString("%1 ").arg(i18n("Opacity:")));
slFlow->setPrefix(QString("%1 ").arg(i18n("Flow:")));
slSize->setPrefix(QString("%1 ").arg(i18n("Size:")));
}
else {
slOpacity = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("opacity", i18n("Opacity:"));
slFlow = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("flow", i18n("Flow:"));
slSize = m_sliderChooser[i]->addWidget<KisDoubleSliderSpinBox>("size", i18n("Size:"));
}
slOpacity->setRange(0.0, 1.0, 2); slOpacity->setRange(0.0, 1.0, 2);
slOpacity->setValue(1.0); slOpacity->setValue(1.0);
slOpacity->setSingleStep(0.05); slOpacity->setSingleStep(0.05);
slOpacity->setMinimumWidth(120); slOpacity->setMinimumWidth(sliderWidth);
slFlow->setRange(0.0, 1.0, 2); slFlow->setRange(0.0, 1.0, 2);
slFlow->setValue(1.0); slFlow->setValue(1.0);
slFlow->setSingleStep(0.05); slFlow->setSingleStep(0.05);
slFlow->setMinimumWidth(120); slFlow->setMinimumWidth(sliderWidth);
slSize->setRange(0, 1000, 2); slSize->setRange(0, 1000, 2);
slSize->setValue(100); slSize->setValue(100);
slSize->setSingleStep(1); slSize->setSingleStep(1);
slSize->setExponentRatio(3.0); slSize->setExponentRatio(3.0);
slSize->setMinimumWidth(120); slSize->setMinimumWidth(sliderWidth);
slSize->setSuffix(" px"); slSize->setSuffix(" px");
m_sliderChooser[i]->chooseWidget(cfg.toolbarSlider(i + 1)); m_sliderChooser[i]->chooseWidget(cfg.toolbarSlider(i + 1));
} }
QLabel* labelMode = new QLabel(i18n("Mode: "), this);
labelMode->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
m_cmbCompositeOp = new KisCompositeOpComboBox(); m_cmbCompositeOp = new KisCompositeOpComboBox();
m_cmbCompositeOp->setFixedHeight(30); m_cmbCompositeOp->setFixedHeight(32);
foreach(KAction * a, m_cmbCompositeOp->blendmodeActions()) { foreach(KAction * a, m_cmbCompositeOp->blendmodeActions()) {
m_viewManager->actionCollection()->addAction(a->text(), a); m_viewManager->actionCollection()->addAction(a->text(), a);
} }
...@@ -231,12 +249,11 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char * ...@@ -231,12 +249,11 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
QWidget* compositeActions = new QWidget(this); QWidget* compositeActions = new QWidget(this);
QHBoxLayout* compositeLayout = new QHBoxLayout(compositeActions); QHBoxLayout* compositeLayout = new QHBoxLayout(compositeActions);
compositeLayout->addWidget(labelMode);
compositeLayout->addWidget(m_cmbCompositeOp); compositeLayout->addWidget(m_cmbCompositeOp);
compositeLayout->addWidget(m_eraseModeButton); compositeLayout->addWidget(m_eraseModeButton);
compositeLayout->addWidget(m_alphaLockButton); compositeLayout->addWidget(m_alphaLockButton);
compositeLayout->setContentsMargins(8, 0, 0, 0); compositeLayout->setContentsMargins(3, 0, 0, 0);
compositeLayout->addWidget(m_reloadButton); compositeLayout->addWidget(m_reloadButton);
......
...@@ -67,6 +67,8 @@ KisCompositeOpComboBox::KisCompositeOpComboBox(QWidget* parent): ...@@ -67,6 +67,8 @@ KisCompositeOpComboBox::KisCompositeOpComboBox(QWidget* parent):
setSizeAdjustPolicy(AdjustToContents); setSizeAdjustPolicy(AdjustToContents);
m_view->setResizeMode(QListView::Adjust); m_view->setResizeMode(QListView::Adjust);
setToolTip(i18n("Blending Mode"));
setModel(m_model); setModel(m_model);
setView(m_view); setView(m_view);
setItemDelegate(new KisCategorizedItemDelegate(true, this)); setItemDelegate(new KisCategorizedItemDelegate(true, this));
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
qreal slowFactor; qreal slowFactor;
qreal shiftPercent; qreal shiftPercent;
bool shiftMode; bool shiftMode;
QString prefix;
QString suffix; QString suffix;
qreal exponentRatio; qreal exponentRatio;
int value; int value;
...@@ -305,9 +306,12 @@ QSize KisAbstractSliderSpinBox::sizeHint() const ...@@ -305,9 +306,12 @@ QSize KisAbstractSliderSpinBox::sizeHint() const
const Q_D(KisAbstractSliderSpinBox); const Q_D(KisAbstractSliderSpinBox);
QStyleOptionSpinBox spinOpts = spinBoxOptions(); QStyleOptionSpinBox spinOpts = spinBoxOptions();
QFontMetrics fm(font()); QFont ft(font());
// The plastique style uses bold font in progressbars
ft.setBold(true);
QFontMetrics fm(ft);
//We need at least 50 pixels or things start to look bad //We need at least 50 pixels or things start to look bad
int w = qMax(fm.width(QString::number(d->maximum)), 50); int w = qMax(fm.width(d->prefix + QString::number(d->maximum) + d->suffix)+qRound(0.2*logicalDpiX()), 50);
QSize hint(w, d->edit->sizeHint().height() + 3); QSize hint(w, d->edit->sizeHint().height() + 3);
//Getting the size of the buttons is a pain as the calcs require a rect //Getting the size of the buttons is a pain as the calcs require a rect
...@@ -380,7 +384,7 @@ QStyleOptionProgressBar KisAbstractSliderSpinBox::progressBarOptions() const ...@@ -380,7 +384,7 @@ QStyleOptionProgressBar KisAbstractSliderSpinBox::progressBarOptions() const
qreal dValues = (d->maximum - minDbl); qreal dValues = (d->maximum - minDbl);
progressOpts.progress = dValues * pow((d->value - minDbl) / dValues, 1.0 / d->exponentRatio) + minDbl; progressOpts.progress = dValues * pow((d->value - minDbl) / dValues, 1.0 / d->exponentRatio) + minDbl;
progressOpts.text = valueString() + d->suffix; progressOpts.text = d->prefix + valueString() + d->suffix;
progressOpts.textAlignment = Qt::AlignCenter; progressOpts.textAlignment = Qt::AlignCenter;
progressOpts.textVisible = !(d->edit->isVisible()); progressOpts.textVisible = !(d->edit->isVisible());
...@@ -447,6 +451,12 @@ int KisAbstractSliderSpinBox::valueForX(int x, Qt::KeyboardModifiers modifiers) ...@@ -447,6 +451,12 @@ int KisAbstractSliderSpinBox::valueForX(int x, Qt::KeyboardModifiers modifiers)
return int(realvalue); return int(realvalue);
} }
void KisAbstractSliderSpinBox::setPrefix(const QString& prefix)
{
Q_D(KisAbstractSliderSpinBox);
d->prefix = prefix;
}
void KisAbstractSliderSpinBox::setSuffix(const QString& suffix) void KisAbstractSliderSpinBox::setSuffix(const QString& suffix)
{ {
Q_D(KisAbstractSliderSpinBox); Q_D(KisAbstractSliderSpinBox);
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
void showEdit(); void showEdit();
void hideEdit(); void hideEdit();
void setPrefix(const QString& prefix);
void setSuffix(const QString& suffix); void setSuffix(const QString& suffix);
void setExponentRatio(qreal dbl); void setExponentRatio(qreal dbl);
......
...@@ -46,6 +46,7 @@ KisWidgetChooser::KisWidgetChooser(int id, QWidget* parent) ...@@ -46,6 +46,7 @@ KisWidgetChooser::KisWidgetChooser(int id, QWidget* parent)
m_popup->setFrameStyle(QFrame::Panel|QFrame::Raised); m_popup->setFrameStyle(QFrame::Panel|QFrame::Raised);
m_arrowButton->setIcon(arrowIcon()); m_arrowButton->setIcon(arrowIcon());
m_arrowButton->setFixedWidth(m_arrowButton->sizeHint().height()/2);
m_arrowButton->setAutoRaise(true); m_arrowButton->setAutoRaise(true);
connect(m_arrowButton, SIGNAL(clicked(bool)), SLOT(slotButtonPressed())); connect(m_arrowButton, SIGNAL(clicked(bool)), SLOT(slotButtonPressed()));
...@@ -84,7 +85,13 @@ void KisWidgetChooser::addWidget(const QString& id, const QString& label, QWidge ...@@ -84,7 +85,13 @@ void KisWidgetChooser::addWidget(const QString& id, const QString& label, QWidge
} }
removeWidget(id); removeWidget(id);
m_widgets.push_back(Data(id, widget, new QLabel(label)));
if (label.isEmpty()) {
m_widgets.push_back(Data(id, widget, 0));
}
else {
m_widgets.push_back(Data(id, widget, new QLabel(label)));
}
delete m_popup->layout(); delete m_popup->layout();
m_popup->setLayout(createPopupLayout()); m_popup->setLayout(createPopupLayout());
...@@ -97,12 +104,14 @@ void KisWidgetChooser::addWidget(const QString& id, const QString& label, QWidge ...@@ -97,12 +104,14 @@ void KisWidgetChooser::addWidget(const QString& id, const QString& label, QWidge
QLayout* KisWidgetChooser::createLayout() QLayout* KisWidgetChooser::createLayout()
{ {
QHBoxLayout* layout = new QHBoxLayout(); QHBoxLayout* layout = new QHBoxLayout();
layout->setContentsMargins(2, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0); layout->setSpacing(0);
for(Iterator i=m_widgets.begin(); i!=m_widgets.end(); ++i) { for(Iterator i=m_widgets.begin(); i!=m_widgets.end(); ++i) {
if(i->choosen) { if(i->choosen) {
layout->addWidget(i->label); if (i->label) {
layout->addWidget(i->label);
}
layout->addWidget(i->widget); layout->addWidget(i->widget);
break; break;
} }
...@@ -117,8 +126,8 @@ QLayout* KisWidgetChooser::createPopupLayout() ...@@ -117,8 +126,8 @@ QLayout* KisWidgetChooser::createPopupLayout()
QGridLayout* layout = new QGridLayout(); QGridLayout* layout = new QGridLayout();
int row = 0; int row = 0;
int idx = 0; int idx = 0;
layout->setContentsMargins(2, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0); layout->setSpacing(0);
QButtonGroup* group = new QButtonGroup(); QButtonGroup* group = new QButtonGroup();
...@@ -133,9 +142,15 @@ QLayout* KisWidgetChooser::createPopupLayout() ...@@ -133,9 +142,15 @@ QLayout* KisWidgetChooser::createPopupLayout()
buttons.push_back(bn); buttons.push_back(bn);
} }
layout->addWidget(i->label , row, 0); if (i->label) {
layout->addWidget(i->widget , row, 1); layout->addWidget(i->label , row, 0);
layout->addWidget(buttons[row], row, 2); layout->addWidget(i->widget , row, 1);
layout->addWidget(buttons[row], row, 2);
}
else {
layout->addWidget(i->widget , row, 0);
layout->addWidget(buttons[row], row, 1);
}
group->addButton(buttons[row], idx); group->addButton(buttons[row], idx);
++row; ++row;
} }
...@@ -166,7 +181,9 @@ void KisWidgetChooser::removeWidget(const QString& id) ...@@ -166,7 +181,9 @@ void KisWidgetChooser::removeWidget(const QString& id)
} }
else delete QWidget::layout(); else delete QWidget::layout();
delete data->label; if (data->label) {
delete data->label;
}
delete data->widget; delete data->widget;
m_widgets.erase(data); m_widgets.erase(data);
} }
...@@ -210,7 +227,7 @@ QWidget* KisWidgetChooser::getWidget(const QString& id) const ...@@ -210,7 +227,7 @@ QWidget* KisWidgetChooser::getWidget(const QString& id) const
void KisWidgetChooser::showPopupWidget() void KisWidgetChooser::showPopupWidget()
{ {
QSize popSize = m_popup->size(); QSize popSize = m_popup->size();
QRect popupRect(QFrame::mapToGlobal(QPoint(0, QFrame::height())), popSize); QRect popupRect(QFrame::mapToGlobal(QPoint(-1, QFrame::height())), popSize);
// Get the available geometry of the screen which contains this KisPopupButton // Get the available geometry of the screen which contains this KisPopupButton
QRect screenRect = QApplication::desktop()->availableGeometry(this); QRect screenRect = QApplication::desktop()->availableGeometry(this);
......
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
QWidget* getWidget(const QString& id) const; QWidget* getWidget(const QString& id) const;
template<class TWidget> template<class TWidget>
TWidget* addWidget(const QString& id, const QString& label) { TWidget* addWidget(const QString& id, const QString& label = "") {
TWidget* widget = new TWidget(); TWidget* widget = new TWidget();
addWidget(id, label, widget); addWidget(id, label, widget);
return widget; return widget;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment