Browse Source

- Added priority buttons

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
ca118697e9
  1. 39
      src/GUI.cpp
  2. 2
      src/GUI.h
  3. 56
      src/MainWindow.ui
  4. 4
      src/bittorrent.cpp

39
src/GUI.cpp

@ -1227,6 +1227,45 @@ void GUI::on_actionPause_All_triggered() {
} }
} }
void GUI::on_actionIncreasePriority_triggered() {
bool inDownloadList = true;
if(tabs->currentIndex() > 1) return;
if(tabs->currentIndex() == 1)
inDownloadList = false;
if(!inDownloadList)
return;
QStringList hashes;
if(inDownloadList) {
hashes = downloadingTorrentTab->getSelectedTorrents();
} else {
hashes = finishedTorrentTab->getSelectedTorrents();
}
foreach(QString hash, hashes) {
BTSession->increaseDlTorrentPriority(hash);
downloadingTorrentTab->updateDlList();
}
}
void GUI::on_actionDecreasePriority_triggered() {
bool inDownloadList = true;
if(tabs->currentIndex() > 1) return;
if(tabs->currentIndex() == 1)
inDownloadList = false;
if(!inDownloadList)
return;
QStringList hashes;
if(inDownloadList) {
hashes = downloadingTorrentTab->getSelectedTorrents();
} else {
hashes = finishedTorrentTab->getSelectedTorrents();
}
QString hash;
foreach(QString hash, hashes) {
BTSession->decreaseDlTorrentPriority(hash);
downloadingTorrentTab->updateDlList();
}
}
// pause selected items in the list // pause selected items in the list
void GUI::on_actionPause_triggered() { void GUI::on_actionPause_triggered() {
bool inDownloadList = true; bool inDownloadList = true;

2
src/GUI.h

@ -162,6 +162,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void updateLists(); void updateLists();
bool initWebUi(QString username, QString password, int port); bool initWebUi(QString username, QString password, int port);
void pauseTorrent(QString hash); void pauseTorrent(QString hash);
void on_actionIncreasePriority_triggered();
void on_actionDecreasePriority_triggered();
// Options slots // Options slots
void on_actionOptions_triggered(); void on_actionOptions_triggered();
void OptionsSaved(QString info, bool deleteOptions); void OptionsSaved(QString info, bool deleteOptions);

56
src/MainWindow.ui

@ -5,7 +5,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>849</width> <width>914</width>
<height>563</height> <height>563</height>
</rect> </rect>
</property> </property>
@ -16,22 +16,14 @@
<string/> <string/>
</property> </property>
<widget class="QWidget" name="centralwidget" > <widget class="QWidget" name="centralwidget" >
<property name="geometry" > <layout class="QVBoxLayout" />
<rect>
<x>0</x>
<y>58</y>
<width>849</width>
<height>482</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vboxLayout" />
</widget> </widget>
<widget class="QMenuBar" name="menubar" > <widget class="QMenuBar" name="menubar" >
<property name="geometry" > <property name="geometry" >
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>849</width> <width>914</width>
<height>26</height> <height>26</height>
</rect> </rect>
</property> </property>
@ -83,14 +75,6 @@
<property name="enabled" > <property name="enabled" >
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="geometry" >
<rect>
<x>0</x>
<y>26</y>
<width>849</width>
<height>32</height>
</rect>
</property>
<property name="contextMenuPolicy" > <property name="contextMenuPolicy" >
<enum>Qt::NoContextMenu</enum> <enum>Qt::NoContextMenu</enum>
</property> </property>
@ -126,20 +110,14 @@
<addaction name="actionStart_All" /> <addaction name="actionStart_All" />
<addaction name="actionPause_All" /> <addaction name="actionPause_All" />
<addaction name="separator" /> <addaction name="separator" />
<addaction name="actionDecreasePriority" />
<addaction name="actionIncreasePriority" />
<addaction name="separator" />
<addaction name="actionOptions" /> <addaction name="actionOptions" />
<addaction name="actionExit" /> <addaction name="actionExit" />
<addaction name="separator" /> <addaction name="separator" />
</widget> </widget>
<widget class="QStatusBar" name="statusBar" > <widget class="QStatusBar" name="statusBar" />
<property name="geometry" >
<rect>
<x>0</x>
<y>540</y>
<width>849</width>
<height>23</height>
</rect>
</property>
</widget>
<action name="actionOpen" > <action name="actionOpen" >
<property name="text" > <property name="text" >
<string>Open</string> <string>Open</string>
@ -250,7 +228,25 @@
<string>Set global upload limit</string> <string>Set global upload limit</string>
</property> </property>
</action> </action>
<action name="actionDecreasePriority" >
<property name="icon" >
<iconset resource="icons.qrc" >:/Icons/downarrow.png</iconset>
</property>
<property name="text" >
<string>Decrease priority</string>
</property>
</action>
<action name="actionIncreasePriority" >
<property name="icon" >
<iconset resource="icons.qrc" >:/Icons/uparrow.png</iconset>
</property>
<property name="text" >
<string>Increase priority</string>
</property>
</action>
</widget> </widget>
<resources/> <resources>
<include location="icons.qrc" />
</resources>
<connections/> <connections/>
</ui> </ui>

4
src/bittorrent.cpp

@ -162,7 +162,7 @@ void bittorrent::setMaxActiveDlTorrents(int val) {
maxActiveDlTorrents = val; maxActiveDlTorrents = val;
} }
void bittorrent::decreaseDlTorrentPriority(QString hash) { void bittorrent::increaseDlTorrentPriority(QString hash) {
int index = downloadQueue->indexOf(hash); int index = downloadQueue->indexOf(hash);
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index > 0) { if(index > 0) {
@ -173,7 +173,7 @@ void bittorrent::decreaseDlTorrentPriority(QString hash) {
} }
} }
void bittorrent::increaseDlTorrentPriority(QString hash) { void bittorrent::decreaseDlTorrentPriority(QString hash) {
int index = downloadQueue->indexOf(hash); int index = downloadQueue->indexOf(hash);
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index >= 0 && index < (downloadQueue->size()-1)) { if(index >= 0 && index < (downloadQueue->size()-1)) {

Loading…
Cancel
Save