- Improved properties pannel by using a Splitter to allow the user to set the height of the pannel

This commit is contained in:
Christophe Dumez 2009-11-11 16:22:57 +00:00
parent 6199d6d543
commit 4493752d2f
5 changed files with 49 additions and 24 deletions

View file

@ -139,20 +139,17 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
qDebug("create tabWidget");
tabs = new QTabWidget();
vSplitter = new QSplitter(Qt::Horizontal);
rightPanel = new QWidget(vSplitter);
hSplitter = new QVBoxLayout(vSplitter);
rightPanel->setLayout(hSplitter);
hSplitter = new QSplitter(Qt::Vertical);
// Transfer List tab
transferList = new TransferListWidget(rightPanel, BTSession);
properties = new PropertiesWidget(rightPanel, transferList, BTSession);
transferList = new TransferListWidget(hSplitter, BTSession);
properties = new PropertiesWidget(hSplitter, transferList, BTSession);
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
hSplitter->addWidget(transferList);
hSplitter->addWidget(properties);
vSplitter->addWidget(transferListFilters);
vSplitter->addWidget(rightPanel);
vSplitter->addWidget(hSplitter);
tabs->addTab(vSplitter, QIcon(QString::fromUtf8(":/Icons/oxygen/folder-remote.png")), tr("Transfers"));
vboxLayout->addWidget(tabs);
// Transfer list slots
@ -281,10 +278,9 @@ GUI::~GUI() {
delete rssWidget;
delete searchEngine;
delete transferListFilters;
delete transferList;
delete properties;
delete transferList;
delete hSplitter;
delete rightPanel;
delete vSplitter;
delete checkConnect;
qDebug("1");

View file

@ -59,7 +59,6 @@ class TransferListWidget;
class TransferListFiltersWidget;
class QSplitter;
class PropertiesWidget;
class QVBoxLayout;
class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
@ -79,8 +78,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
PropertiesWidget *properties;
QVBoxLayout *hSplitter;
QWidget *rightPanel;
QSplitter *hSplitter;
QSplitter *vSplitter;
QLabel *connecStatusLblIcon;
bool systrayIntegration;

View file

@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>758</width>
<height>292</height>
<height>235</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -38,7 +38,7 @@
<item>
<widget class="QStackedWidget" name="stackedProperties">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View file

@ -54,13 +54,6 @@
PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) {
setupUi(this);
state = VISIBLE;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(!settings.value("TorrentProperties/Visible", false).toBool()) {
reduce();
} else {
main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS);
setEnabled(false);
}
// Set Properties list model
PropListModel = new TorrentFilesModel();
@ -122,14 +115,25 @@ PropertiesWidget::~PropertiesWidget() {
void PropertiesWidget::reduce() {
if(state == VISIBLE) {
stackedProperties->setFixedHeight(0);
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
slideSizes = hSplitter->sizes();
stackedProperties->setVisible(false);
QList<int> sizes;
sizes << hSplitter->geometry().height()-30 << 30;
hSplitter->setSizes(sizes);
hSplitter->handle(1)->setVisible(false);
hSplitter->handle(1)->setDisabled(true);
state = REDUCED;
}
}
void PropertiesWidget::slide() {
if(state == REDUCED) {
stackedProperties->setFixedHeight(260);
stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(slideSizes);
state = VISIBLE;
}
}
@ -209,6 +213,20 @@ void PropertiesWidget::readSettings() {
filesList->setColumnWidth(i, contentColsWidths.at(i).toInt());
}
}
// Restore splitter sizes
QStringList sizes_str = settings.value(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString()).toString().split(",");
if(sizes_str.size() == 2) {
slideSizes << sizes_str.first().toInt();
slideSizes << sizes_str.last().toInt();
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
hSplitter->setSizes(slideSizes);
}
if(!settings.value("TorrentProperties/Visible", false).toBool()) {
reduce();
} else {
main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS);
setEnabled(false);
}
}
void PropertiesWidget::saveSettings() {
@ -218,6 +236,18 @@ void PropertiesWidget::saveSettings() {
for(int i=0; i<PropListModel->columnCount(); ++i) {
contentColsWidths.append(filesList->columnWidth(i));
}
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
QList<int> sizes;
if(state == VISIBLE)
sizes = hSplitter->sizes();
else
sizes = slideSizes;
if(state == VISIBLE)
qDebug("Visible");
qDebug("Sizes: %d", sizes.size());
if(sizes.size() == 2) {
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString::number(sizes.first())+','+QString::number(sizes.last()));
}
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
}

View file

@ -66,6 +66,7 @@ private:
QAction *actionNormal;
QAction *actionMaximum;
QAction *actionHigh;
QList<int> slideSizes;
protected:
QPushButton* getButtonFromIndex(int index);