Commit b4f313b5 authored by Silvio Heinrich's avatar Silvio Heinrich

Replaced the QSlider in the zoom popup with a KisSliderSpinBox.

Also fixed crash when clicking the "back" button in the
file system browser and the history is empty.
parent 89b46d34
......@@ -7,12 +7,9 @@
<x>0</x>
<y>0</y>
<width>340</width>
<height>63</height>
<height>59</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
......@@ -100,61 +97,18 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="zoomSpinBox">
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="zoomSlider">
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="tracking">
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
</widget>
</item>
</layout>
<widget class="KisSliderSpinBox" name="zoomSlider" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KisSliderSpinBox</class>
<extends>QWidget</extends>
<header location="global">kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -10,9 +10,6 @@
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
......
......@@ -184,11 +184,14 @@ ImageDockerDock::ImageDockerDock():
m_ui->bnPopup->setIcon(QIcon::fromTheme("zoom-original"));
m_ui->bnPopup->setPopupWidget(m_popupUi);
m_popupUi->zoomSlider->setRange(5, 500);
m_popupUi->zoomSlider->setValue(100);
m_zoomButtons->addButton(m_popupUi->bnZoomFit , KisImageView::VIEW_MODE_FIT);
m_zoomButtons->addButton(m_popupUi->bnZoomAdjust, KisImageView::VIEW_MODE_ADJUST);
m_zoomButtons->addButton(m_popupUi->bnZoom25 , 25);
m_zoomButtons->addButton(m_popupUi->bnZoom50 , 50);
m_zoomButtons->addButton(m_popupUi->bnZoom75 , 70);
m_zoomButtons->addButton(m_popupUi->bnZoom75 , 75);
m_zoomButtons->addButton(m_popupUi->bnZoom100 , 100);
m_model->setRootPath(QDir::rootPath());
......@@ -207,7 +210,6 @@ ImageDockerDock::ImageDockerDock():
connect(m_ui->imgView , SIGNAL(sigColorSelected(const QColor&)) , SLOT(slotColorSelected(const QColor)));
connect(m_ui->imgView , SIGNAL(sigViewModeChanged(int, qreal)) , SLOT(slotViewModeChanged(int, qreal)));
connect(m_popupUi->zoomSlider , SIGNAL(valueChanged(int)) , SLOT(slotZoomChanged(int)));
connect(m_popupUi->zoomSpinBox , SIGNAL(valueChanged(int)) , SLOT(slotZoomChanged(int)));
connect(m_zoomButtons , SIGNAL(buttonClicked(int)) , SLOT(slotZoomChanged(int)));
connect(m_zoomButtons , SIGNAL(buttonClicked(int)) , SLOT(slotCloseZoomPopup()));
connect(this , SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), SLOT(slotDockLocationChanged(Qt::DockWidgetArea)));
......@@ -242,6 +244,7 @@ void ImageDockerDock::addCurrentPathToHistory()
void ImageDockerDock::updatePath(const QString& path)
{
m_ui->cmbPath->lineEdit()->setText(path);
m_ui->bnBack->setDisabled(m_history.empty());
m_thumbModel->setCurrentDirectory(path);
}
......@@ -292,9 +295,6 @@ void ImageDockerDock::setZoom(const ImageInfo& info)
m_popupUi->zoomSlider->blockSignals(true);
m_popupUi->zoomSlider->setValue(zoom);
m_popupUi->zoomSlider->blockSignals(false);
m_popupUi->zoomSpinBox->blockSignals(true);
m_popupUi->zoomSpinBox->setValue(zoom);
m_popupUi->zoomSpinBox->blockSignals(false);
}
......@@ -316,11 +316,13 @@ void ImageDockerDock::slotItemDoubleClicked(const QModelIndex& index)
void ImageDockerDock::slotBackButtonClicked()
{
QString path = m_history.last();
QModelIndex index = m_proxyModel->mapFromSource(m_model->index(path));
m_ui->treeView->setRootIndex(index);
m_history.pop_back();
updatePath(path);
if(!m_history.empty()) {
QString path = m_history.last();
QModelIndex index = m_proxyModel->mapFromSource(m_model->index(path));
m_ui->treeView->setRootIndex(index);
m_history.pop_back();
updatePath(path);
}
}
void ImageDockerDock::slotHomeButtonClicked()
......@@ -475,9 +477,6 @@ void ImageDockerDock::slotViewModeChanged(int viewMode, qreal scale)
m_popupUi->zoomSlider->blockSignals(true);
m_popupUi->zoomSlider->setValue(zoom);
m_popupUi->zoomSlider->blockSignals(false);
m_popupUi->zoomSpinBox->blockSignals(true);
m_popupUi->zoomSpinBox->setValue(zoom);
m_popupUi->zoomSpinBox->blockSignals(false);
}
}
......
......@@ -24,6 +24,7 @@
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
#include <QMutexLocker>
#include <QIcon>
/////////////////////////////////////////////////////////////////////////////////////////////
// ------------- KisImageLoader ---------------------------------------------------------- //
......@@ -70,13 +71,27 @@ void KisImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opti
if(m_loader->isImageLoaded(this)) {
QImage image = m_loader->getImage(this);
QPointF offset((m_size-image.width()) / 2.0, (m_size-image.height()) / 2.0);
painter->drawImage(offset, image);
if(!image.isNull()) {
QPointF offset((m_size-image.width()) / 2.0, (m_size-image.height()) / 2.0);
painter->drawImage(offset, image);
}
else {
QIcon icon = QIcon::fromTheme("image-missing");
QRect rect = boundingRect().toRect();
QPixmap img = icon.pixmap(rect.size());
painter->drawPixmap(rect, img, img.rect());
}
}
else {
QIcon icon = QIcon::fromTheme("image-loading");
QRect rect = boundingRect().toRect();
QPixmap img = icon.pixmap(rect.size());
painter->drawPixmap(rect, img, img.rect());
}
if(isSelected()) {
if(isSelected())
painter->fillRect(boundingRect(), Qt::Dense5Pattern);
}
painter->drawRect(boundingRect());
}
......
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