Skip to content

Commit

Permalink
Move Download button to the left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Oct 29, 2020
1 parent ada27e4 commit 9a00834
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 79 deletions.
131 changes: 59 additions & 72 deletions src/tribler-gui/tribler_gui/qt_resources/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -495,57 +495,6 @@ background: none;</string>
</property>
</spacer>
</item>
<item>
<widget class="CircleButton" name="add_torrent_button">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>../images/add.png</normaloff>../images/add.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -638,7 +587,7 @@ color: #eee;</string>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>180</width>
<height>16777215</height>
</size>
</property>
Expand Down Expand Up @@ -679,6 +628,60 @@ color: white;
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="add_torrent_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>10000</width>
<height>32</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">QPushButton#add_torrent_button {
border-style: outset;
border-width: 2px;
border-radius: 15px;
border-color: grey;
padding-left: 5px;
margin-left: 17px;
margin-right: 30px;
font: bold;
}
QPushButton::menu-indicator{width:0px;}</string>
</property>
<property name="text">
<string>Add torrent</string>
</property>
<property name="icon">
<iconset>
<normaloff>../images/add.png</normaloff>../images/add.png</iconset>
</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="QPushButton" name="left_menu_button_discovered">
<property name="sizePolicy">
Expand Down Expand Up @@ -1377,8 +1380,8 @@ border-top: 1px solid #555;
<rect>
<x>0</x>
<y>0</y>
<width>854</width>
<height>710</height>
<width>300</width>
<height>498</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -3760,8 +3763,8 @@ color: white</string>
<rect>
<x>0</x>
<y>0</y>
<width>308</width>
<height>276</height>
<width>321</width>
<height>259</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_4">
Expand Down Expand Up @@ -5728,22 +5731,6 @@ margin: 10px 4px 2px 10px;</string>
</hint>
</hints>
</connection>
<connection>
<sender>add_torrent_button</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>on_add_torrent_button_click()</slot>
<hints>
<hint type="sourcelabel">
<x>1045</x>
<y>33</y>
</hint>
<hint type="destinationlabel">
<x>427</x>
<y>317</y>
</hint>
</hints>
</connection>
<connection>
<sender>left_menu_button_trust_graph</sender>
<signal>clicked()</signal>
Expand Down
12 changes: 5 additions & 7 deletions src/tribler-gui/tribler_gui/tribler_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
QLineEdit,
QListWidget,
QMainWindow,
QPushButton,
QShortcut,
QStyledItemDelegate,
QSystemTrayIcon,
Expand Down Expand Up @@ -318,6 +319,10 @@ def sigint_handler(*_):

self.add_to_channel_dialog = AddToChannelDialog(self.window())

self.add_torrent_menu = self.findChild(QPushButton, "add_torrent_button")
self.add_torrent_menu = self.create_add_torrent_menu()
self.add_torrent_button.setMenu(self.add_torrent_menu)

def update_tray_icon(self, use_monochrome_icon):
if not QSystemTrayIcon.isSystemTrayAvailable() or not self.tray_icon:
return
Expand Down Expand Up @@ -753,13 +758,6 @@ def on_create_torrent(self):
def on_create_torrent_updates(self, update_dict):
self.tray_show_message("Torrent updates", update_dict['msg'])

def on_add_torrent_button_click(self, _pos):
plus_btn_pos = self.add_torrent_button.pos()
plus_btn_geometry = self.add_torrent_button.geometry()
plus_btn_pos.setX(plus_btn_pos.x() - CONTEXT_MENU_WIDTH)
plus_btn_pos.setY(plus_btn_pos.y() + plus_btn_geometry.height())
self.create_add_torrent_menu().exec_(self.mapToParent(plus_btn_pos))

def on_add_torrent_browse_file(self):
filenames = QFileDialog.getOpenFileNames(
self, "Please select the .torrent file", QDir.homePath(), "Torrent files (*.torrent)"
Expand Down

0 comments on commit 9a00834

Please sign in to comment.