Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f0f0534bb9
Fetching contributors…

Cannot retrieve contributors at this time

file 46 lines (37 sloc) 1.302 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/* This file is (c) 2012 Tvangeste <i.4m.l33t@yandex.ru>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#include "gdappstyle.hh"
#include "dictionarybar.hh"

#include <QWidget>
#include <QToolButton>
#include <QDebug>

GdAppStyle::GdAppStyle(QProxyStyle * parent) : QProxyStyle(parent) {}

int GdAppStyle::pixelMetric ( PixelMetric metric, const QStyleOption * option, const QWidget * widget) const
{
  int defaultVal = QProxyStyle::pixelMetric(metric, option, widget);

  if ( dictionaryBarButton( widget ) )
  {
    if ( metric == QStyle::PM_ButtonShiftVertical || metric == QStyle::PM_ButtonShiftHorizontal )
    {
      if (option ->state & State_Sunken ) {
        return defaultVal;
      }

      if ( option ->state & State_On ) {
        // No shift for for the checked tool buttons on the dictionary bar,
        // that's why the whole thing with QProxyStyle is neded, to achieve this.
        return 0;
      }
    }
  }

  return defaultVal;
}

bool GdAppStyle::dictionaryBarButton(const QWidget * widget) const {
  if (widget) {
    const QWidget * parent = widget->parentWidget();
    if ( parent &&
         qobject_cast<const DictionaryBar *>( parent ) &&
         qobject_cast<const QToolButton *>( widget ) )
      return true;
  }

  return false;
}
Something went wrong with that request. Please try again.