]> granicus.if.org Git - transmission/commitdiff
(trunk qt) hack on the main window layout
authorCharles Kerr <charles@transmissionbt.com>
Wed, 15 Apr 2009 01:59:54 +0000 (01:59 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Wed, 15 Apr 2009 01:59:54 +0000 (01:59 +0000)
qt/icons/info-options.png [new file with mode: 0644]
qt/mainwin.cc
qt/mainwin.h
qt/mainwin.ui
qt/qtr.pro
qt/triconpushbutton.cc [new file with mode: 0644]
qt/triconpushbutton.h [new file with mode: 0644]

diff --git a/qt/icons/info-options.png b/qt/icons/info-options.png
new file mode 100644 (file)
index 0000000..476aa9f
Binary files /dev/null and b/qt/icons/info-options.png differ
index 35174cdd7bd3f16ce1910362e36131b634deddff..1ba468922349f505ebc053e96e9cd3b4c7135178 100644 (file)
@@ -28,6 +28,7 @@
 #include "about.h"
 #include "details.h"
 #include "filters.h"
+#include "hig.h"
 #include "mainwin.h"
 #include "make-dialog.h"
 #include "options.h"
@@ -40,6 +41,7 @@
 #include "torrent-delegate-min.h"
 #include "torrent-filter.h"
 #include "torrent-model.h"
+#include "triconpushbutton.h"
 #include "ui_mainwin.h"
 #include "utils.h"
 #include "qticonloader.h"
@@ -70,17 +72,6 @@ namespace
         QSize sz = fm.size( Qt::TextShowMnemonic, s );
         return button->style()->sizeFromContents( QStyle::CT_PushButton, &opt, sz, button ).expandedTo( QApplication::globalStrut( ) );
     }
-
-    void setTextButtonSizeHint( QPushButton * button )
-    {
-        /* this is kind of a hack, possibly coming from my being new to Qt.
-         * Qt 4.4's sizeHint calculations for QPushButton have it include
-         * space for an icon, even if no icon is used.  because of this,
-         * default pushbuttons look way too wide in the filterbar...
-         * so this routine recalculates the sizeHint without icons.
-         * If there's a Right Way to do this that I've missed, let me know */
-        button->setMaximumSize( calculateTextButtonSizeHint( button ) );
-    }
 }
 
 
@@ -136,11 +127,6 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     ui.action_Preferences->setIcon( getStockIcon( "preferences-system" ) );
     ui.action_Contents->setIcon( getStockIcon( "help-contents", QStyle::SP_DialogHelpButton ) );
     ui.action_About->setIcon( getStockIcon( "help-about" ) );
-    ui.statusbarStatsButton->setIcon( getStockIcon( "view-refresh", QStyle::SP_BrowserReload ) );
-    ui.downloadIconLabel->setPixmap( getStockIcon( "go-down", QStyle::SP_ArrowDown ).pixmap( smallIconSize ) );
-    ui.uploadIconLabel->setPixmap( getStockIcon( "go-up", QStyle::SP_ArrowUp ).pixmap( smallIconSize ) );
-    ui.filterEntryModeButton->setIcon( getStockIcon( "edit-find", QStyle::SP_ArrowForward ) );
-    ui.filterEntryClearButton->setIcon( getStockIcon( "edit-clear", QStyle::SP_DialogCloseButton ) );
 
     // ui signals
     connect( ui.action_Toolbar, SIGNAL(toggled(bool)), this, SLOT(setToolbarVisible(bool)));
@@ -192,21 +178,8 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     setContextMenuPolicy( Qt::ActionsContextMenu );
 
     // signals
-    connect( ui.speedLimitModeButton, SIGNAL(clicked()), this, SLOT(toggleSpeedMode()));
-    connect( ui.filterAll, SIGNAL(clicked()), this, SLOT(showAll()));
-    connect( ui.filterActive, SIGNAL(clicked()), this, SLOT(showActive()));
-    connect( ui.filterDownloading, SIGNAL(clicked()), this, SLOT(showDownloading()));
-    connect( ui.filterSeeding, SIGNAL(clicked()), this, SLOT(showSeeding()));
-    connect( ui.filterPaused, SIGNAL(clicked()), this, SLOT(showPaused()));
-    connect( ui.filterEntryClearButton, SIGNAL(clicked()), ui.filterEntry, SLOT(clear()));
-    connect( ui.filterEntry, SIGNAL(textChanged(QString)), &myFilterModel, SLOT(setText(QString)));
     connect( ui.action_SelectAll, SIGNAL(triggered()), ui.listView, SLOT(selectAll()));
     connect( ui.action_DeselectAll, SIGNAL(triggered()), ui.listView, SLOT(clearSelection()));
-    setTextButtonSizeHint( ui.filterAll );
-    setTextButtonSizeHint( ui.filterActive );
-    setTextButtonSizeHint( ui.filterDownloading );
-    setTextButtonSizeHint( ui.filterSeeding );
-    setTextButtonSizeHint( ui.filterPaused );
 
     connect( &myFilterModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(refreshVisibleCount()));
     connect( &myFilterModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(refreshVisibleCount()));
@@ -221,36 +194,6 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     connect( ui.listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)), this, SLOT(refreshActionSensitivity()));
 
     QActionGroup * actionGroup = new QActionGroup( this );
-    actionGroup->addAction( ui.action_FilterByName );
-    actionGroup->addAction( ui.action_FilterByFiles );
-    actionGroup->addAction( ui.action_FilterByTracker );
-    QMenu * menu = new QMenu( );
-    menu->addAction( ui.action_FilterByName );
-    menu->addAction( ui.action_FilterByFiles );
-    menu->addAction( ui.action_FilterByTracker );
-    ui.filterEntryModeButton->setMenu( menu );
-    connect( ui.action_FilterByName, SIGNAL(triggered()), this, SLOT(filterByName()));
-    connect( ui.action_FilterByFiles, SIGNAL(triggered()), this, SLOT(filterByFiles()));
-    connect( ui.action_FilterByTracker, SIGNAL(triggered()), this, SLOT(filterByTracker()));
-    ui.action_FilterByName->setChecked( true );
-
-    actionGroup = new QActionGroup( this );
-    actionGroup->addAction( ui.action_TotalRatio );
-    actionGroup->addAction( ui.action_TotalTransfer );
-    actionGroup->addAction( ui.action_SessionRatio );
-    actionGroup->addAction( ui.action_SessionTransfer );
-    menu = new QMenu( );
-    menu->addAction( ui.action_TotalRatio );
-    menu->addAction( ui.action_TotalTransfer );
-    menu->addAction( ui.action_SessionRatio );
-    menu->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()));
-    ui.statusbarStatsButton->setMenu( menu );
-
-    actionGroup = new QActionGroup( this );
     actionGroup->addAction( ui.action_SortByActivity );
     actionGroup->addAction( ui.action_SortByAge );
     actionGroup->addAction( ui.action_SortByETA );
@@ -261,7 +204,7 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     actionGroup->addAction( ui.action_SortByState );
     actionGroup->addAction( ui.action_SortByTracker );
 
-    menu = new QMenu( );
+    QMenu * menu = new QMenu( );
     menu->addAction( ui.action_Add );
     menu->addSeparator( );
     menu->addAction( ui.action_ShowMainWindow );
@@ -275,8 +218,6 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     myTrayIcon.setContextMenu( menu );
     myTrayIcon.setIcon( QApplication::windowIcon( ) );
 
-    ui.optionsButton->setMenu( createOptionsMenu( ) );
-
     connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)) );
     connect( ui.action_ShowMainWindow, SIGNAL(toggled(bool)), this, SLOT(toggleWindows()));
     connect( &myTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
@@ -285,6 +226,9 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     ui.action_ShowMainWindow->setChecked( !minimized );
     ui.action_TrayIcon->setChecked( minimized || prefs.getBool( Prefs::SHOW_TRAY_ICON ) );
 
+    ui.verticalLayout->addWidget( createStatusBar( ) );
+    ui.verticalLayout->insertWidget( 0, createFilterBar( ) );
+
     QList<int> initKeys;
     initKeys << Prefs :: MAIN_WINDOW_X
              << Prefs :: SHOW_TRAY_ICON
@@ -311,7 +255,7 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
     connect( &mySession, SIGNAL(dataSendProgress()), this, SLOT(dataSendProgress()) );
 
     if( mySession.isServer( ) )
-        ui.networkLabel->hide( );
+        myNetworkLabel->hide( );
     else {
         connect( &myNetworkTimer, SIGNAL(timeout()), this, SLOT(onNetworkTimer()));
         myNetworkTimer.start( 1000 );
@@ -348,6 +292,155 @@ TrMainWindow :: onSetPrefs( bool isChecked )
         onSetPrefs( );
 }
 
+#define SHOW_KEY "show-mode"
+
+void
+TrMainWindow :: onShowModeClicked( )
+{
+    setShowMode( sender()->property(SHOW_KEY).toInt() );
+}
+
+QWidget *
+TrMainWindow :: createFilterBar( )
+{
+    int i;
+    QMenu * m;
+    QLineEdit * e;
+    QPushButton * p;
+    QHBoxLayout * h;
+    QActionGroup * a;
+    const int smallSize = style( )->pixelMetric( QStyle::PM_SmallIconSize, 0, this );
+    const QSize smallIconSize( smallSize, smallSize );
+
+    QWidget * top = myFilterBar = 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 );
+
+        QList<QString> titles;
+        titles << tr( "A&ll" ) << tr( "&Active" ) << tr( "&Downloading" ) << tr( "&Seeding" ) << tr( "&Paused" );
+        for( i=0; i<titles.size(); ++i ) {
+            p = myFilterButtons[i] = new QPushButton( titles[i] );
+            p->setProperty( SHOW_KEY, i );
+            p->setFlat( true );
+            p->setCheckable( true );
+            p->setMaximumSize( calculateTextButtonSizeHint( p ) );
+            connect( p, SIGNAL(clicked()), this, SLOT(onShowModeClicked()));
+            h->addWidget( p );
+        }
+
+    h->addStretch( 1 );
+
+        a = new QActionGroup( this );
+        a->addAction( ui.action_FilterByName );
+        a->addAction( ui.action_FilterByFiles );
+        a->addAction( ui.action_FilterByTracker );
+        m = new QMenu( );
+        m->addAction( ui.action_FilterByName );
+        m->addAction( ui.action_FilterByFiles );
+        m->addAction( ui.action_FilterByTracker );
+        connect( ui.action_FilterByName, SIGNAL(triggered()), this, SLOT(filterByName()));
+        connect( ui.action_FilterByFiles, SIGNAL(triggered()), this, SLOT(filterByFiles()));
+        connect( ui.action_FilterByTracker, SIGNAL(triggered()), this, SLOT(filterByTracker()));
+        ui.action_FilterByName->setChecked( true );
+        p = myFilterTextButton = new TrIconPushButton;
+        p->setIcon( getStockIcon( "edit-find", QStyle::SP_ArrowForward ) );
+        p->setFlat( true );
+        p->setMenu( m );
+        h->addWidget( p );
+
+        e = myFilterTextLineEdit = new QLineEdit;
+        connect( e, SIGNAL(textChanged(QString)), &myFilterModel, SLOT(setText(QString)));
+        h->addWidget( e );
+
+        p = myFilterTextButton = new TrIconPushButton;
+        p->setIcon( getStockIcon( "edit-clear", QStyle::SP_DialogCloseButton ) );
+        p->setFlat( true );
+        connect( p, SIGNAL(clicked()), myFilterTextLineEdit, SLOT(clear()));
+        h->addWidget( p );
+
+    return top;
+}
+
+QWidget *
+TrMainWindow :: createStatusBar( )
+{
+    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 );
+
+    QWidget * top = myStatusBar = new QWidget;
+    h = new QHBoxLayout( top );
+    h->setContentsMargins( HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL );
+
+        p = myOptionsButton = new TrIconPushButton( this );
+        p->setIcon( QIcon( ":/icons/options.png" ) );
+        p->setFlat( true );
+        p->setMenu( createOptionsMenu( ) );
+        h->addWidget( p );
+
+        p = myAltSpeedButton = new TrIconPushButton( this );
+        p->setIcon( myPrefs.get<bool>(Prefs::ALT_SPEED_LIMIT_ENABLED) ? mySpeedModeOnIcon : mySpeedModeOffIcon );
+        p->setFlat( true );
+        h->addWidget( p );
+        connect( p, SIGNAL(clicked()), this, SLOT(toggleSpeedMode()));
+
+        l = myNetworkLabel = new QLabel;
+        h->addWidget( l );
+
+    h->addStretch( 1 );
+
+        l = myVisibleCountLabel = new QLabel( this );
+        h->addWidget( l );
+
+    h->addStretch( 1 );
+  
+        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( );
+        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( getStockIcon( "view-refresh", QStyle::SP_BrowserReload ) );
+        p->setFlat( true );
+        p->setMenu( m );
+        h->addWidget( p );  
+        h->addSpacing( HIG :: PAD_SMALL );
+        l = myStatsLabel = new QLabel( this );
+        h->addWidget( l );  
+   
+    h->addStretch( 1 );
+
+        l = new QLabel( this );
+        l->setPixmap( getStockIcon( "go-down", QStyle::SP_ArrowDown ).pixmap( smallIconSize ) );
+        h->addWidget( l );
+        l = myDownloadSpeedLabel = new QLabel( this );
+        h->addWidget( l );
+
+    h->addSpacing( HIG :: PAD_BIG );
+
+        l = new QLabel;
+        l->setPixmap( getStockIcon( "go-up", QStyle::SP_ArrowUp ).pixmap( smallIconSize ) );
+        h->addWidget( l );
+        l = myUploadSpeedLabel = new QLabel;
+        h->addWidget( l );
+
+    return top;
+}
+
 QMenu *
 TrMainWindow :: createOptionsMenu( )
 {
@@ -496,7 +589,7 @@ TrMainWindow :: refreshVisibleCount( )
         str = tr( "%Ln Torrent(s)", 0, totalCount );
     else
         str = tr( "%L1 of %Ln Torrent(s)", 0, totalCount ).arg( visibleCount );
-    ui.visibleCountLabel->setText( str );
+    myVisibleCountLabel->setText( str );
 }
 
 void
@@ -504,8 +597,8 @@ TrMainWindow :: refreshStatusBar( )
 {
     const Speed up( myModel.getUploadSpeed( ) );
     const Speed down( myModel.getDownloadSpeed( ) );
-    ui.uploadTextLabel->setText( Utils :: speedToString( up ) );
-    ui.downloadTextLabel->setText( Utils :: speedToString( down ) );
+    myUploadSpeedLabel->setText( Utils :: speedToString( up ) );
+    myDownloadSpeedLabel->setText( Utils :: speedToString( down ) );
     const QString mode( myPrefs.getString( Prefs::STATUSBAR_STATS ) );
     QString str;
 
@@ -530,7 +623,7 @@ TrMainWindow :: refreshStatusBar( )
         str = tr( "Ratio: %1" ).arg( Utils :: ratioToString( mySession.getCumulativeStats().ratio ) );
     }
 
-    ui.statusbarStatsLabel->setText( str );
+    myStatsLabel->setText( str );
 }
 
 void
@@ -778,22 +871,19 @@ TrMainWindow :: refreshPref( int key )
 
         case Prefs::FILTER_MODE:
             i = myPrefs.get<FilterMode>(key).mode( );
-            ui.filterAll->setChecked         ( i == FilterMode::SHOW_ALL );
-            ui.filterActive->setChecked      ( i == FilterMode::SHOW_ACTIVE );
-            ui.filterDownloading->setChecked ( i == FilterMode::SHOW_DOWNLOADING );
-            ui.filterSeeding->setChecked     ( i == FilterMode::SHOW_SEEDING );
-            ui.filterPaused->setChecked      ( i == FilterMode::SHOW_PAUSED );
+            for( int j=0; j<FilterMode::NUM_MODES; ++j )
+                myFilterButtons[j]->setChecked( i==j );
             break;
 
         case Prefs::FILTERBAR:
             b = myPrefs.getBool( key );
-            ui.filterbar->setVisible( b );
+            myFilterBar->setVisible( b );
             ui.action_Filterbar->setChecked( b );
             break;
 
         case Prefs::STATUSBAR:
             b = myPrefs.getBool( key );
-            ui.statusbar->setVisible( b );
+            myStatusBar->setVisible( b );
             ui.action_Statusbar->setChecked( b );
             break;
 
@@ -828,10 +918,10 @@ TrMainWindow :: refreshPref( int key )
 
         case Prefs :: ALT_SPEED_LIMIT_ENABLED:
             b = myPrefs.getBool( key );
-            ui.speedLimitModeButton->setChecked( b );
-            ui.speedLimitModeButton->setIcon( b ? mySpeedModeOnIcon : mySpeedModeOffIcon );
-            ui.speedLimitModeButton->setToolTip( b ? tr( "Click to disable Speed Limit Mode" )
-                                                   : tr( "Click to enable Speed Limit Mode" ) );
+            myAltSpeedButton->setChecked( b );
+            myAltSpeedButton->setIcon( b ? mySpeedModeOnIcon : mySpeedModeOffIcon );
+            myAltSpeedButton->setToolTip( b ? tr( "Click to disable Speed Limit Mode" )
+                                            : tr( "Click to enable Speed Limit Mode" ) );
             break;
 
         default:
@@ -918,8 +1008,8 @@ TrMainWindow :: updateNetworkIcon( )
 
     QIcon icon = getStockIcon( key, QStyle::SP_DriveNetIcon );
     QPixmap pixmap = icon.pixmap ( 16, 16 );
-    ui.networkLabel->setPixmap( pixmap );
-    ui.networkLabel->setToolTip( isSending || isReading
+    myNetworkLabel->setPixmap( pixmap );
+    myNetworkLabel->setToolTip( isSending || isReading
         ? tr( "Transmission server is responding" )
         : tr( "Last response from server was %1 ago" ).arg( Utils::timeToString( now-std::max(myLastReadTime,myLastSendTime))));
 }
index 8c8565a47c2c896a570f526ca737cc9448f8a50d..08cd3332b1c0646a88c624d02cb66eabf7b8683a 100644 (file)
 #include <ctime>
 #include <QCheckBox>
 #include <QFileDialog>
+#include <QLineEdit>
 #include <QIcon>
 #include <QMainWindow>
+#include <QMap>
 #include <QSet>
 #include <QSystemTrayIcon>
 #include <QTimer>
@@ -27,6 +29,7 @@ extern "C" {
     struct tr_benc;
 };
 
+#include "filters.h"
 #include "torrent-filter.h"
 #include "ui_mainwin.h"
 
@@ -37,6 +40,7 @@ class TorrentDelegate;
 class TorrentDelegateMin;
 class TorrentModel;
 class QAction;
+class QLabel;
 class QMenu;
 class QModelIndex;
 class QSortFilterProxyModel;
@@ -82,6 +86,7 @@ class TrMainWindow: public QMainWindow
         QWidgetList myHidden;
 
     private slots:
+        void onShowModeClicked( );
         void showAll( );
         void showActive( );
         void showDownloading( );
@@ -125,7 +130,24 @@ class TrMainWindow: public QMainWindow
         void onSortByTrackerToggled  ( bool );
 
     private:
-        QMenu* createOptionsMenu( void );
+        QWidget * createFilterBar( void );
+        QWidget * myFilterBar;
+        QPushButton * myFilterButtons[FilterMode::NUM_MODES];
+        QPushButton * myFilterTextButton;
+        QLineEdit * myFilterTextLineEdit;
+
+    private:
+        QMenu * createOptionsMenu( void );
+        QWidget * createStatusBar( void );
+        QWidget * myStatusBar;
+        QPushButton * myAltSpeedButton;
+        QPushButton * myOptionsButton;
+        QLabel * myVisibleCountLabel;
+        QPushButton * myStatsModeButton;
+        QLabel * myStatsLabel;
+        QLabel * myDownloadSpeedLabel;
+        QLabel * myUploadSpeedLabel;
+        QLabel * myNetworkLabel;
 
     public slots:
         void startAll( );
index c7489d87a5c55ecf4ab8fef10704008196914bfd..b4e8434484005e1fa0d0d942adb9292eea929eb3 100644 (file)
     <property name="margin">
      <number>0</number>
     </property>
-    <item>
-     <widget class="QWidget" name="filterbar" native="true">
-      <property name="sizePolicy">
-       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-        <horstretch>0</horstretch>
-        <verstretch>0</verstretch>
-       </sizepolicy>
-      </property>
-      <layout class="QHBoxLayout" name="horizontalLayout_2">
-       <property name="spacing">
-        <number>3</number>
-       </property>
-       <property name="sizeConstraint">
-        <enum>QLayout::SetDefaultConstraint</enum>
-       </property>
-       <property name="margin">
-        <number>2</number>
-       </property>
-       <item>
-        <widget class="QPushButton" name="filterAll">
-         <property name="toolTip">
-          <string>Show all torrents</string>
-         </property>
-         <property name="text">
-          <string>A&amp;ll</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterActive">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip">
-          <string>Show active torrents</string>
-         </property>
-         <property name="text">
-          <string>&amp;Active</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterDownloading">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="baseSize">
-          <size>
-           <width>0</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="toolTip">
-          <string>Show torrents being downloaded</string>
-         </property>
-         <property name="text">
-          <string>&amp;Downloading</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterSeeding">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip">
-          <string>Show torrents being seeded</string>
-         </property>
-         <property name="text">
-          <string>&amp;Seeding</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterPaused">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip">
-          <string>Show paused torrents</string>
-         </property>
-         <property name="text">
-          <string>&amp;Paused</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QWidget" name="filterBarSpacer" native="true">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-           <horstretch>1</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterEntryModeButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip">
-          <string>Set text filter mode</string>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLineEdit" name="filterEntry">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>3</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip">
-          <string>Show torrents matching this text</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="filterEntryClearButton">
-         <property name="toolTip">
-          <string>Clear the filter text</string>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-      </layout>
-      <zorder>filterAll</zorder>
-      <zorder>filterActive</zorder>
-      <zorder>filterDownloading</zorder>
-      <zorder>filterSeeding</zorder>
-      <zorder>filterPaused</zorder>
-      <zorder>filterBarSpacer</zorder>
-      <zorder>filterEntry</zorder>
-      <zorder>filterEntryClearButton</zorder>
-      <zorder>filterEntryModeButton</zorder>
-     </widget>
-    </item>
     <item>
      <widget class="QListView" name="listView">
       <property name="sizePolicy">
       </property>
      </widget>
     </item>
-    <item>
-     <widget class="QWidget" name="statusbar" native="true">
-      <property name="sizePolicy">
-       <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-        <horstretch>0</horstretch>
-        <verstretch>0</verstretch>
-       </sizepolicy>
-      </property>
-      <layout class="QHBoxLayout" name="horizontalLayout">
-       <property name="spacing">
-        <number>3</number>
-       </property>
-       <property name="margin">
-        <number>3</number>
-       </property>
-       <item>
-        <widget class="QPushButton" name="speedLimitModeButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>30</width>
-           <height>24</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>24</width>
-           <height>50</height>
-          </size>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="optionsButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>30</width>
-           <height>28</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>1000</width>
-           <height>1000</height>
-          </size>
-         </property>
-         <property name="text">
-          <string notr="true">Options</string>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer_4">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Expanding</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>1</width>
-           <height>1</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QLabel" name="visibleCountLabel">
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Expanding</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>1</width>
-           <height>1</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QPushButton" name="statusbarStatsButton">
-         <property name="text">
-          <string/>
-         </property>
-         <property name="iconSize">
-          <size>
-           <width>16</width>
-           <height>16</height>
-          </size>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="statusbarStatsLabel">
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer_3">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Fixed</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>0</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QLabel" name="downloadIconLabel">
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="downloadTextLabel">
-         <property name="toolTip">
-          <string>Overall download speed</string>
-         </property>
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer_2">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Fixed</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>0</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QLabel" name="uploadIconLabel">
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="uploadTextLabel">
-         <property name="toolTip">
-          <string>Overall upload speed</string>
-         </property>
-         <property name="text">
-          <string>TextLabel</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer_5">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Fixed</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>10</width>
-           <height>0</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QLabel" name="networkLabel">
-         <property name="minimumSize">
-          <size>
-           <width>16</width>
-           <height>16</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="textFormat">
-          <enum>Qt::PlainText</enum>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </widget>
-    </item>
    </layout>
-   <zorder>listView</zorder>
-   <zorder>statusbar</zorder>
-   <zorder>filterbar</zorder>
   </widget>
   <widget class="QMenuBar" name="menubar">
    <property name="geometry">
      <x>0</x>
      <y>0</y>
      <width>792</width>
-     <height>25</height>
+     <height>23</height>
     </rect>
    </property>
    <property name="sizePolicy">
index 9b356613e708e5a3533520073f5a6df802666f43..1c6a78e29e1ec5e54046e9c1b4d41030038f137e 100644 (file)
@@ -26,7 +26,8 @@ SOURCES += about.cc app.cc details.cc file-tree.cc filters.cc hig.cc \
            mainwin.cc make-dialog.cc options.cc prefs.cc prefs-dialog.cc \
            qticonloader.cc session.cc squeezelabel.cc stats-dialog.cc \
            torrent.cc torrent-delegate.cc torrent-delegate-min.cc \
-           torrent-filter.cc torrent-model.cc utils.cc watchdir.cc
+           torrent-filter.cc torrent-model.cc triconpushbutton.cc \
+           utils.cc watchdir.cc
 HEADERS += $$replace(SOURCES, .cc, .h)
 HEADERS += speed.h types.h
 
diff --git a/qt/triconpushbutton.cc b/qt/triconpushbutton.cc
new file mode 100644 (file)
index 0000000..937bbad
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
+ *
+ * This file is licensed by the GPL version 2.  Works owned by the
+ * Transmission project are granted a special exemption to clause 2(b)
+ * so that the bulk of its code can remain under the MIT license.
+ * This exemption does not extend to derived works not owned by
+ * the Transmission project.
+ *
+ * $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;
+    QIcon::State state = QIcon::Off;
+    if( opt.state & QStyle::State_On )
+        state = QIcon::On;
+    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
new file mode 100644 (file)
index 0000000..7afd071
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
+ *
+ * This file is licensed by the GPL version 2.  Works owned by the
+ * Transmission project are granted a special exemption to clause 2(b)
+ * so that the bulk of its code can remain under the MIT license.
+ * This exemption does not extend to derived works not owned by
+ * the Transmission project.
+ *
+ * $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