Git commit d5f62e2e075be875e18ba5b776e702541070475b by Sven Langkamp. Committed on 30/06/2013 at 21:04. Pushed by langkamp into branch 'master'. removed delete button in the preset strip as that triggered accidential del= ete operations for many users BUG:319852 M +0 -59 krita/ui/widgets/kis_preset_selector_strip.cpp M +1 -29 krita/ui/widgets/kis_preset_selector_strip.h http://commits.kde.org/calligra/d5f62e2e075be875e18ba5b776e702541070475b diff --git a/krita/ui/widgets/kis_preset_selector_strip.cpp b/krita/ui/widg= ets/kis_preset_selector_strip.cpp index 4eddfc4..1953d91 100644 --- a/krita/ui/widgets/kis_preset_selector_strip.cpp +++ b/krita/ui/widgets/kis_preset_selector_strip.cpp @@ -27,7 +27,6 @@ = #include #include -#include = KisPresetSelectorStrip::KisPresetSelectorStrip(QWidget* parent) : QWidget(parent) @@ -38,69 +37,19 @@ KisPresetSelectorStrip::KisPresetSelectorStrip(QWidget*= parent) m_resourceItemView =3D smallPresetChooser->itemChooser()->itemView(); m_resourceItemView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf= f); m_resourceItemView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - m_refresher =3D new QTimer(this); - m_refresher->setSingleShot(true); = /* This is an heuristic to fill smallPresetChooser with only the prese= ts * for the paintop that comes selected by default: Pixel Brush. */ const QString PIXEL_BRUSH_ID =3D "paintbrush"; = - deletePresetBtn->setIcon(koIcon("trash-empty")); - deletePresetBtn->setVisible(true); - connect(smallPresetChooser, SIGNAL(resourceSelected(KoResource*)), this, SLOT(prepareDeleteButton())); connect(smallPresetChooser, SIGNAL(resourceSelected(KoResource*)), this, SLOT(startRefreshingTimer())); - connect(m_refresher, SIGNAL(timeout()), this, SLOT(repaintDeleteButton= ())); } = KisPresetSelectorStrip::~KisPresetSelectorStrip() { - delete m_refresher; -} - -void KisPresetSelectorStrip::showEvent(QShowEvent* event) -{ - deletePresetBtn->hide(); - QWidget::showEvent(event); -} - -void KisPresetSelectorStrip::currentPaintopChanged(QString paintOpID) -{ - deletePresetBtn->hide(); -} - -void KisPresetSelectorStrip::startRefreshingTimer() -{ - // Estimated time it takes for the ResourceView to scroll when a widget - // that is only partially visible becomes visible - m_refresher->start(450); -} - -void KisPresetSelectorStrip::repaintDeleteButton() -{ - if (deletePresetBtn->isVisible()) { - prepareDeleteButton(); - } -} - -void KisPresetSelectorStrip::prepareDeleteButton() -{ - const quint8 HEURISTIC_OFFSET =3D 7; // This number is just conjured = out of the nether to make - // things look good - quint16 buttonWidth =3D deletePresetBtn->width(); - quint16 buttonHeight =3D deletePresetBtn->height(); - quint16 columnWidth =3D m_resourceItemView->columnWidth(0); // Al= l columns assumed equal in width - quint16 currentColumn =3D m_resourceItemView->currentIndex().column(= ); - quint16 rowHeight =3D m_resourceItemView->rowHeight(0); // Th= ere is only 1 row in this widget - quint16 yPos =3D rowHeight - deletePresetBtn->height() + HE= URISTIC_OFFSET; - quint16 xPos =3D m_resourceItemView->columnViewportPosition= (currentColumn) - + columnWidth + HEURISTIC_OFFSET - buttonWid= th; - = - deletePresetBtn->setGeometry(xPos, yPos, buttonWidth, buttonHeight); - deletePresetBtn->setVisible(true); } = void KisPresetSelectorStrip::on_leftScrollBtn_pressed() @@ -121,12 +70,4 @@ void KisPresetSelectorStrip::on_rightScrollBtn_pressed() deletePresetBtn->setVisible(false); } = -void KisPresetSelectorStrip::on_deletePresetBtn_clicked() -{ - KoResourceItemChooser* itemChooser =3D smallPresetChooser->itemChooser= (); - itemChooser->slotButtonClicked(KoResourceItemChooser::Button_Remove); - deletePresetBtn->hide(); - smallPresetChooser->updateViewSettings(); -} - #include "kis_preset_selector_strip.moc" diff --git a/krita/ui/widgets/kis_preset_selector_strip.h b/krita/ui/widget= s/kis_preset_selector_strip.h index 1a92270..580a9cc 100644 --- a/krita/ui/widgets/kis_preset_selector_strip.h +++ b/krita/ui/widgets/kis_preset_selector_strip.h @@ -45,47 +45,19 @@ public: KisPresetSelectorStrip(QWidget *parent); virtual ~KisPresetSelectorStrip(); = - virtual void showEvent(QShowEvent *event); - = -public slots: - /// Updates the contents of the strip item view, show only presets for= @param paintOpID - void currentPaintopChanged(QString paintOpID); - = - /** - * startRefreshingTimer() and repaintDeleteButton() are heuristics - * to reposition the delete button when the strip auto-scrolls = - * to show a selected item that's partly outside the item view - */ - void startRefreshingTimer(); - void repaintDeleteButton(); - private slots: - /** - * Properly position the delete button on the bottom right corner of th= e currently - * selected preset item - */ - void prepareDeleteButton(); - = /// Scrolls the strip's item view to the left void on_leftScrollBtn_pressed(); = /// Scrolls the strip's item view to the right void on_rightScrollBtn_pressed(); - = - /** - * This small button will hover over a preset when it is selected; - * and will remove the preset when clicked - */ - void on_deletePresetBtn_clicked(); - = + private: /** * This is a workaround to access members of KisPresetChooser using the= QObject tree * instead of class methods */ KoResourceItemView* m_resourceItemView; - = - QTimer* m_refresher; }; = =20