]> granicus.if.org Git - transmission/commitdiff
Move status bar creation to mainwin.ui
authorMike Gelfand <mikedld@mikedld.com>
Thu, 18 Dec 2014 01:30:50 +0000 (01:30 +0000)
committerMike Gelfand <mikedld@mikedld.com>
Thu, 18 Dec 2014 01:30:50 +0000 (01:30 +0000)
Among other things,
* fix turtle icons size (20x14 -> 16x16)
* use QIcon states instead of changing the turtle icon ourselves each
  time (unchecked - off, checked - on)
* make speed limit action in tray menu checkable
* simplify status bar buttons drawing and use QToolButton instead of
  QPushButton

qt/CMakeLists.txt
qt/icons/turtle-blue.png
qt/icons/turtle-grey.png
qt/mainwin.cc
qt/mainwin.h
qt/mainwin.ui
qt/qtr.pro
qt/triconpushbutton.cc [deleted file]
qt/triconpushbutton.h [deleted file]
qt/tricontoolbutton.cc [new file with mode: 0644]
qt/tricontoolbutton.h [new file with mode: 0644]

index 11870504eaf0548de0c3887e30fb0bcadeebfead..54edceff2eb6640adcd0cf0c661eca9a0f961636 100644 (file)
@@ -56,7 +56,7 @@ set(${PROJECT_NAME}_SOURCES
     tracker-delegate.cc
     tracker-model-filter.cc
     tracker-model.cc
-    triconpushbutton.cc
+    tricontoolbutton.cc
     utils.cc
     watchdir.cc
 )
@@ -94,7 +94,7 @@ set(${PROJECT_NAME}_HEADERS
     tracker-delegate.h
     tracker-model-filter.h
     tracker-model.h
-    triconpushbutton.h
+    tricontoolbutton.h
     types.h
     utils.h
     watchdir.h
index fa7fe15b5ecd382e1911fe9a21f593ed048bc132..51e84de556d6c1d9ebf8cdf0116ddb8ed8b3e1a1 100644 (file)
Binary files a/qt/icons/turtle-blue.png and b/qt/icons/turtle-blue.png differ
index edfaa300e3cebfe510a72c202631dfdc783f94a5..c03f5a7f69336a005ae4b77975a61139bcfc71a2 100644 (file)
Binary files a/qt/icons/turtle-grey.png and b/qt/icons/turtle-grey.png differ
index 899921ef77e0b5055cfafb1229b6adca48c0f9cf..490254bc6853835cc871d57c4a2a3dee0012186f 100644 (file)
@@ -43,8 +43,6 @@
 #include "torrent-delegate-min.h"
 #include "torrent-filter.h"
 #include "torrent-model.h"
-#include "triconpushbutton.h"
-#include "ui_mainwin.h"
 
 #define PREFS_KEY "prefs-key";
 
@@ -94,8 +92,6 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
   mySession (session),
   myPrefs (prefs),
   myModel (model),
-  mySpeedModeOffIcon (":/icons/alt-limit-off.png"),
-  mySpeedModeOnIcon (":/icons/alt-limit-on.png"),
   myLastSendTime (0),
   myLastReadTime (0),
   myNetworkTimer (this),
@@ -216,7 +212,8 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
   actionGroup->addAction (ui.action_SortByState);
 
   myAltSpeedAction = new QAction (tr ("Speed Limits"), this);
-  myAltSpeedAction->setIcon (myPrefs.get<bool> (Prefs::ALT_SPEED_LIMIT_ENABLED) ? mySpeedModeOnIcon : mySpeedModeOffIcon);
+  myAltSpeedAction->setIcon (ui.altSpeedButton->icon ());
+  myAltSpeedAction->setCheckable (true);
   connect (myAltSpeedAction, SIGNAL (triggered ()), this, SLOT (toggleSpeedMode ()));
 
   QMenu * menu = new QMenu (this);
@@ -243,7 +240,7 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
   toggleWindows (!minimized);
   ui.action_TrayIcon->setChecked (minimized || prefs.getBool (Prefs::SHOW_TRAY_ICON));
 
-  ui.verticalLayout->addWidget (createStatusBar ());
+  initStatusBar ();
   ui.verticalLayout->insertWidget (0, myFilterBar = new FilterBar (myPrefs, myModel, myFilterModel));
 
   QList<int> initKeys;
@@ -276,7 +273,7 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
 
   if (mySession.isServer ())
     {
-      myNetworkLabel->hide ();
+      ui.networkLabel->hide ();
     }
   else
     {
@@ -341,82 +338,18 @@ TrMainWindow::onSetPrefs (bool isChecked)
 
 #define SHOW_KEY "show-mode"
 
-QWidget *
-TrMainWindow::createStatusBar ()
+void
+TrMainWindow::initStatusBar ()
 {
-  QMenu * m;
-  QLabel * l;
-  QHBoxLayout * h;
-  QPushButton * p;
-  QActionGroup * a;
-  const int i = style ()->pixelMetric (QStyle::PM_SmallIconSize, 0, this);
-  const QSize smallIconSize (i, i);
+  ui.optionsButton->setMenu (createOptionsMenu ());
+
+  const int minimumSpeedWidth = ui.downloadSpeedLabel->fontMetrics ().width (Formatter::uploadSpeedToString (Speed::fromKBps (999.99)));
+  ui.downloadSpeedLabel->setMinimumWidth (minimumSpeedWidth);
+  ui.uploadSpeedLabel->setMinimumWidth (minimumSpeedWidth);
 
-  QWidget * top = myStatusBar = new QWidget;
-  h = new QHBoxLayout (top);
-  h->setContentsMargins (HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL);
-  h->setSpacing (HIG::PAD_SMALL);
-
-    p = myOptionsButton = new TrIconPushButton (this);
-    p->setIcon (QIcon (":/icons/utilities.png"));
-    p->setIconSize (QPixmap (":/icons/utilities.png").size ());
-    p->setFlat (true);
-    p->setMenu (createOptionsMenu ());
-    h->addWidget (p);
-
-    p = myAltSpeedButton = new QPushButton (this);
-    p->setIcon (myPrefs.get<bool> (Prefs::ALT_SPEED_LIMIT_ENABLED) ? mySpeedModeOnIcon : mySpeedModeOffIcon);
-    p->setIconSize (QPixmap (":/icons/alt-limit-on.png").size ());
-    p->setCheckable (true);
-    p->setFixedWidth (p->height ());
-    p->setFlat (true);
-    h->addWidget (p);
-    connect (p, SIGNAL (clicked ()), this, SLOT (toggleSpeedMode ()));
-
-    l = myNetworkLabel = new QLabel;
-    h->addWidget (l);
-
-  h->addStretch (1);
-
-    l = myDownloadSpeedLabel = new QLabel (this);
-    const int minimumSpeedWidth = l->fontMetrics ().width (Formatter::uploadSpeedToString (Speed::fromKBps (999.99)));
-    l->setMinimumWidth (minimumSpeedWidth);
-    l->setAlignment (Qt::AlignRight|Qt::AlignVCenter);
-    h->addWidget (l);
-
-  h->addSpacing (HIG::PAD);
-
-    l = myUploadSpeedLabel = new QLabel;
-    l->setMinimumWidth (minimumSpeedWidth);
-    l->setAlignment (Qt::AlignRight|Qt::AlignVCenter);
-    h->addWidget (l);
-
-  h->addSpacing (HIG::PAD);
-
-    l = myStatsLabel = new QLabel (this);
-    h->addWidget (l);
-    a = new QActionGroup (this);
-    a->addAction (ui.action_TotalRatio);
-    a->addAction (ui.action_TotalTransfer);
-    a->addAction (ui.action_SessionRatio);
-    a->addAction (ui.action_SessionTransfer);
-    m = new QMenu (this);
-    m->addAction (ui.action_TotalRatio);
-    m->addAction (ui.action_TotalTransfer);
-    m->addAction (ui.action_SessionRatio);
-    m->addAction (ui.action_SessionTransfer);
-    connect (ui.action_TotalRatio, SIGNAL (triggered ()), this, SLOT (showTotalRatio ()));
-    connect (ui.action_TotalTransfer, SIGNAL (triggered ()), this, SLOT (showTotalTransfer ()));
-    connect (ui.action_SessionRatio, SIGNAL (triggered ()), this, SLOT (showSessionRatio ()));
-    connect (ui.action_SessionTransfer, SIGNAL (triggered ()), this, SLOT (showSessionTransfer ()));
-    p = myStatsModeButton = new TrIconPushButton (this);
-    p->setIcon (QIcon (":/icons/ratio.png"));
-    p->setIconSize (QPixmap (":/icons/ratio.png").size ());
-    p->setFlat (true);
-    p->setMenu (m);
-    h->addWidget (p);
-
-  return top;
+  ui.statsModeButton->setMenu (createStatsModeMenu ());
+
+  connect (ui.altSpeedButton, SIGNAL (clicked ()), this, SLOT (toggleSpeedMode ()));
 }
 
 QMenu *
@@ -503,6 +436,29 @@ TrMainWindow::createOptionsMenu ()
   return menu;
 }
 
+QMenu *
+TrMainWindow::createStatsModeMenu ()
+{
+  QActionGroup * a = new QActionGroup (this);
+  a->addAction (ui.action_TotalRatio);
+  a->addAction (ui.action_TotalTransfer);
+  a->addAction (ui.action_SessionRatio);
+  a->addAction (ui.action_SessionTransfer);
+
+  QMenu * m = new QMenu (this);
+  m->addAction (ui.action_TotalRatio);
+  m->addAction (ui.action_TotalTransfer);
+  m->addAction (ui.action_SessionRatio);
+  m->addAction (ui.action_SessionTransfer);
+
+  connect (ui.action_TotalRatio, SIGNAL (triggered ()), this, SLOT (showTotalRatio ()));
+  connect (ui.action_TotalTransfer, SIGNAL (triggered ()), this, SLOT (showTotalTransfer ()));
+  connect (ui.action_SessionRatio, SIGNAL (triggered ()), this, SLOT (showSessionRatio ()));
+  connect (ui.action_SessionTransfer, SIGNAL (triggered ()), this, SLOT (showSessionTransfer ()));
+
+  return m;
+}
+
 /****
 *****
 ****/
@@ -731,12 +687,12 @@ TrMainWindow::refreshStatusBar ()
   size_t upCount, downCount;
   myModel.getTransferSpeed (upSpeed, upCount, downSpeed, downCount);
 
-  myUploadSpeedLabel->setText (Formatter::uploadSpeedToString(upSpeed));
-  myUploadSpeedLabel->setVisible (downCount || upCount);
-  myDownloadSpeedLabel->setText (Formatter::downloadSpeedToString(downSpeed));
-  myDownloadSpeedLabel->setVisible (downCount);
+  ui.uploadSpeedLabel->setText (Formatter::uploadSpeedToString (upSpeed));
+  ui.uploadSpeedLabel->setVisible (downCount || upCount);
+  ui.downloadSpeedLabel->setText (Formatter::downloadSpeedToString (downSpeed));
+  ui.downloadSpeedLabel->setVisible (downCount);
 
-  myNetworkLabel->setVisible (!mySession.isServer ());
+  ui.networkLabel->setVisible (!mySession.isServer ());
 
   const QString mode (myPrefs.getString (Prefs::STATUSBAR_STATS));
   QString str;
@@ -762,7 +718,7 @@ TrMainWindow::refreshStatusBar ()
       str = tr ("Ratio: %1").arg (Formatter:: ratioToString (mySession.getCumulativeStats ().ratio));
     }
 
-  myStatsLabel->setText (str);
+  ui.statsLabel->setText (str);
 }
 
 
@@ -951,7 +907,7 @@ TrMainWindow::toggleSpeedMode ()
 {
   myPrefs.toggleBool (Prefs::ALT_SPEED_LIMIT_ENABLED);
   const bool mode = myPrefs.get<bool> (Prefs::ALT_SPEED_LIMIT_ENABLED);
-  myAltSpeedAction->setIcon (mode ? mySpeedModeOnIcon : mySpeedModeOffIcon);
+  myAltSpeedAction->setChecked (mode);
 }
 void
 TrMainWindow::setToolbarVisible (bool visible)
@@ -1071,7 +1027,7 @@ TrMainWindow::refreshPref (int key)
 
       case Prefs::STATUSBAR:
         b = myPrefs.getBool (key);
-        myStatusBar->setVisible (b);
+        ui.statusBar->setVisible (b);
         ui.action_Statusbar->setChecked (b);
         break;
 
@@ -1118,14 +1074,14 @@ TrMainWindow::refreshPref (int key)
       case Prefs::ALT_SPEED_LIMIT_DOWN:
         {
           b = myPrefs.getBool (Prefs::ALT_SPEED_LIMIT_ENABLED);
-          myAltSpeedButton->setChecked (b);
-          myAltSpeedButton->setIcon (b ? mySpeedModeOnIcon : mySpeedModeOffIcon);
+          myAltSpeedAction->setChecked (b);
+          ui.altSpeedButton->setChecked (b);
           const QString fmt = b ? tr ("Click to disable Temporary Speed Limits\n (%1 down, %2 up)")
                                 : tr ("Click to enable Temporary Speed Limits\n (%1 down, %2 up)");
           const Speed d = Speed::fromKBps (myPrefs.getInt (Prefs::ALT_SPEED_LIMIT_DOWN));
           const Speed u = Speed::fromKBps (myPrefs.getInt (Prefs::ALT_SPEED_LIMIT_UP));
-          myAltSpeedButton->setToolTip (fmt.arg (Formatter::speedToString (d))
-                                           .arg (Formatter::speedToString (u)));
+          ui.altSpeedButton->setToolTip (fmt.arg (Formatter::speedToString (d))
+                                            .arg (Formatter::speedToString (u)));
           break;
         }
 
@@ -1366,8 +1322,8 @@ TrMainWindow::updateNetworkIcon ()
   else
     tip = tr ("%1 is not responding").arg (url);
 
-  myNetworkLabel->setPixmap (pixmap);
-  myNetworkLabel->setToolTip (tip);
+  ui.networkLabel->setPixmap (pixmap);
+  ui.networkLabel->setToolTip (tip);
 }
 
 void
index d5a81cf5bb2f433834794f10aa7141e8968c05e5..da51f58593fe8b646d7d02ccad683310cae501a0 100644 (file)
@@ -69,8 +69,6 @@ class TrMainWindow: public QMainWindow
     Prefs& myPrefs;
     TorrentModel& myModel;
     Ui_MainWindow ui;
-    QIcon mySpeedModeOffIcon;
-    QIcon mySpeedModeOnIcon;
     time_t myLastSendTime;
     time_t myLastReadTime;
     QTimer myNetworkTimer;
@@ -146,16 +144,10 @@ class TrMainWindow: public QMainWindow
 
   private:
     QMenu * createOptionsMenu ();
-    QWidget * createStatusBar ();
-    QWidget * myStatusBar;
-    QPushButton * myAltSpeedButton;
+    QMenu * createStatsModeMenu ();
+    void initStatusBar ();
+
     QAction * myAltSpeedAction;
-    QPushButton * myOptionsButton;
-    QPushButton * myStatsModeButton;
-    QLabel * myStatsLabel;
-    QLabel * myDownloadSpeedLabel;
-    QLabel * myUploadSpeedLabel;
-    QLabel * myNetworkLabel;
     QString myErrorMessage;
 
   public slots:
index e8f97499caad48651a4d02c27d31ddb8264f9ab5..d27abb47569a9ecc366a0351ab7a9cc87e16feaf 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>792</width>
-    <height>390</height>
+    <width>472</width>
+    <height>427</height>
    </rect>
   </property>
   <property name="windowTitle">
       </property>
      </widget>
     </item>
+    <item>
+     <widget class="QWidget" name="statusBar" native="true">
+      <property name="styleSheet">
+       <string notr="true">QLabel { margin: 3px 0; }</string>
+      </property>
+      <layout class="QHBoxLayout" name="statusBarLayout">
+       <property name="spacing">
+        <number>3</number>
+       </property>
+       <property name="margin">
+        <number>3</number>
+       </property>
+       <item>
+        <widget class="TrIconToolButton" name="optionsButton">
+         <property name="icon">
+          <iconset resource="application.qrc">
+           <normaloff>:/icons/utilities.png</normaloff>:/icons/utilities.png</iconset>
+         </property>
+         <property name="popupMode">
+          <enum>QToolButton::InstantPopup</enum>
+         </property>
+         <property name="toolButtonStyle">
+          <enum>Qt::ToolButtonIconOnly</enum>
+         </property>
+         <property name="autoRaise">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QToolButton" name="altSpeedButton">
+         <property name="icon">
+          <iconset resource="application.qrc">
+           <normaloff>:/icons/alt-limit-off.png</normaloff>
+           <normalon>:/icons/alt-limit-on.png</normalon>:/icons/alt-limit-off.png</iconset>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="toolButtonStyle">
+          <enum>Qt::ToolButtonIconOnly</enum>
+         </property>
+         <property name="autoRaise">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="networkLabel"/>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>1</width>
+           <height>1</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QLabel" name="downloadSpeedLabel">
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="uploadSpeedLabel">
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="statsLabel"/>
+       </item>
+       <item>
+        <widget class="TrIconToolButton" name="statsModeButton">
+         <property name="icon">
+          <iconset resource="application.qrc">
+           <normaloff>:/icons/ratio.png</normaloff>:/icons/ratio.png</iconset>
+         </property>
+         <property name="popupMode">
+          <enum>QToolButton::InstantPopup</enum>
+         </property>
+         <property name="toolButtonStyle">
+          <enum>Qt::ToolButtonIconOnly</enum>
+         </property>
+         <property name="autoRaise">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </item>
    </layout>
   </widget>
   <widget class="QMenuBar" name="menubar">
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>792</width>
-     <height>20</height>
+     <width>472</width>
+     <height>24</height>
     </rect>
    </property>
    <property name="sizePolicy">
    </property>
   </action>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>TrIconToolButton</class>
+   <extends>QToolButton</extends>
+   <header>tricontoolbutton.h</header>
+  </customwidget>
+ </customwidgets>
  <resources>
   <include location="application.qrc"/>
  </resources>
index 66134e04b9b14d56369d6a4f0d51997747e5825d..043f671b6ae089dad6f45d582bd888bd609741db 100644 (file)
@@ -79,7 +79,7 @@ SOURCES += about.cc \
            tracker-delegate.cc \
            tracker-model.cc \
            tracker-model-filter.cc \
-           triconpushbutton.cc \
+           tricontoolbutton.cc \
            utils.cc \
            watchdir.cc
 HEADERS += $$replace(SOURCES, .cc, .h)
diff --git a/qt/triconpushbutton.cc b/qt/triconpushbutton.cc
deleted file mode 100644 (file)
index c79d0a0..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file Copyright (C) 2009-2014 Mnemosyne LLC
- *
- * It may be used under the GNU Public License v2 or v3 licenses,
- * or any future license endorsed by Mnemosyne LLC.
- *
- * $Id$
- */
-
-#include <iostream>
-#include <QIcon>
-#include <QStyleOption>
-#include <QStyleOptionButton>
-#include <QStylePainter>
-
-#include "hig.h"
-#include "triconpushbutton.h"
-
-TrIconPushButton::TrIconPushButton (QWidget * parent):
-  QPushButton (parent)
-{
-}
-
-TrIconPushButton::TrIconPushButton (const QIcon& icon, QWidget * parent):
-  QPushButton (parent)
-{
-  setIcon (icon);
-}
-
-QSize
-TrIconPushButton::sizeHint () const
-{
-  QSize s = iconSize ();
-  s.rwidth() += HIG::PAD_SMALL*2;
-  return s;
-}
-
-void
-TrIconPushButton::paintEvent (QPaintEvent *)
-{
-  QStylePainter p (this);
-  QStyleOptionButton opt;
-  initStyleOption (&opt);
-
-  QIcon::Mode mode = opt.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
-  if ((mode == QIcon::Normal) &&  (opt.state & QStyle::State_HasFocus))
-    mode = QIcon::Active;
-  QPixmap pixmap = opt.icon.pixmap (opt.iconSize, QIcon::Active, QIcon::On);
-  QRect iconRect (opt.rect.x() + HIG::PAD_SMALL,
-                  opt.rect.y() + (opt.rect.height() - pixmap.height())/2,
-                  pixmap.width(),
-                  pixmap.height());
-  if (opt.state &  (QStyle::State_On | QStyle::State_Sunken))
-    iconRect.translate (style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &opt, this),
-                        style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &opt, this));
-
-  p.drawPixmap(iconRect, pixmap);
-
-  if (opt.state & QStyle::State_HasFocus)
-    p.drawPrimitive (QStyle::PE_FrameFocusRect, opt);
-}
diff --git a/qt/triconpushbutton.h b/qt/triconpushbutton.h
deleted file mode 100644 (file)
index cd3f950..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file Copyright (C) 2009-2014 Mnemosyne LLC
- *
- * It may be used under the GNU GPL versions 2 or 3
- * or any future license endorsed by Mnemosyne LLC.
- *
- * $Id$
- */
-
-#ifndef QTR_IconPushButton_H
-#define QTR_IconPushButton_H
-
-#include <QPushButton>
-
-class QIcon;
-
-class TrIconPushButton: public QPushButton
-{
-    Q_OBJECT
-
-  public:
-    TrIconPushButton (QWidget * parent = 0);
-    TrIconPushButton (const QIcon&, QWidget * parent = 0);
-    virtual ~TrIconPushButton () {}
-    QSize sizeHint () const;
-
-  protected:
-    void paintEvent (QPaintEvent * event);
-};
-
-#endif // QTR_IconPushButton_H
diff --git a/qt/tricontoolbutton.cc b/qt/tricontoolbutton.cc
new file mode 100644 (file)
index 0000000..6ef9e75
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * This file Copyright (C) 2009-2014 Mnemosyne LLC
+ *
+ * It may be used under the GNU Public License v2 or v3 licenses,
+ * or any future license endorsed by Mnemosyne LLC.
+ *
+ * $Id$
+ */
+
+#include <QStyleOption>
+#include <QStyleOptionToolButton>
+#include <QStylePainter>
+
+#include "tricontoolbutton.h"
+
+TrIconToolButton::TrIconToolButton (QWidget * parent):
+  QToolButton (parent)
+{
+}
+
+void TrIconToolButton::paintEvent (QPaintEvent * /*event*/)
+{
+  QStylePainter painter(this);
+  QStyleOptionToolButton option;
+  initStyleOption (&option);
+  option.features &= ~QStyleOptionToolButton::HasMenu;
+  painter.drawComplexControl(QStyle::CC_ToolButton, option);
+}
diff --git a/qt/tricontoolbutton.h b/qt/tricontoolbutton.h
new file mode 100644 (file)
index 0000000..714cadd
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * This file Copyright (C) 2009-2014 Mnemosyne LLC
+ *
+ * It may be used under the GNU GPL versions 2 or 3
+ * or any future license endorsed by Mnemosyne LLC.
+ *
+ * $Id$
+ */
+
+#ifndef QTR_ICON_TOOL_BUTTON_H
+#define QTR_ICON_TOOL_BUTTON_H
+
+#include <QToolButton>
+
+class TrIconToolButton: public QToolButton
+{
+    Q_OBJECT
+
+  public:
+    TrIconToolButton (QWidget * parent = nullptr);
+
+  protected:
+    virtual void paintEvent (QPaintEvent * event);
+};
+
+#endif // QTR_ICON_TOOL_BUTTON_H