mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 03:06:37 +03:00
- Cleaned up the way columns width are remembered
This commit is contained in:
parent
773c451050
commit
0c795cce28
1 changed files with 28 additions and 60 deletions
88
src/GUI.cpp
88
src/GUI.cpp
|
@ -809,94 +809,62 @@ void GUI::saveCheckedSearchEngines(int) const{
|
||||||
// (download list)
|
// (download list)
|
||||||
void GUI::saveColWidthDLList() const{
|
void GUI::saveColWidthDLList() const{
|
||||||
qDebug("Saving columns width in download list");
|
qDebug("Saving columns width in download list");
|
||||||
QFile lastDLListWidth(misc::qBittorrentPath()+"lastDLListWidth.txt");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
// delete old file
|
|
||||||
lastDLListWidth.remove();
|
|
||||||
QStringList width_list;
|
QStringList width_list;
|
||||||
for(int i=0; i<DLListModel->columnCount(); ++i){
|
for(int i=0; i<DLListModel->columnCount(); ++i){
|
||||||
width_list << QString(misc::toString(downloadList->columnWidth(i)).c_str());
|
width_list << QString(misc::toString(downloadList->columnWidth(i)).c_str());
|
||||||
}
|
}
|
||||||
if(lastDLListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
settings.setValue("DownloadListColsWidth", width_list.join(" "));
|
||||||
lastDLListWidth.write(width_list.join(" ").toAscii());
|
qDebug("Download list columns width saved");
|
||||||
lastDLListWidth.close();
|
|
||||||
qDebug("Columns width saved");
|
|
||||||
}else{
|
|
||||||
std::cerr << "Error: Could not save last columns width in download list\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
// Load columns width in a file that were saved previously
|
||||||
// (download list)
|
// (download list)
|
||||||
bool GUI::loadColWidthDLList(){
|
bool GUI::loadColWidthDLList(){
|
||||||
qDebug("Loading colums width in download list");
|
qDebug("Loading columns width for download list");
|
||||||
QFile lastDLListWidth(misc::qBittorrentPath()+"lastDLListWidth.txt");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
if(lastDLListWidth.exists()){
|
QString line = settings.value("DownloadListColsWidth", QString()).toString();
|
||||||
if(lastDLListWidth.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(line.isEmpty())
|
||||||
QByteArray line = lastDLListWidth.readLine();
|
return false;
|
||||||
lastDLListWidth.close();
|
QStringList width_list = line.split(' ');
|
||||||
line.chop(1);
|
if(width_list.size() != DLListModel->columnCount())
|
||||||
QStringList width_list = QString(line).split(' ');
|
return false;
|
||||||
if(width_list.size() != DLListModel-> columnCount()){
|
for(int i=0; i<width_list.size(); ++i){
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for(int i=0; i<width_list.size(); ++i){
|
|
||||||
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
|
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
}
|
|
||||||
qDebug("Loaded columns width in download list");
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
std::cerr << "Error: Could not load last columns width for download list\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
qDebug("Download list columns width loaded");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save columns width in a file to remember them
|
// Save columns width in a file to remember them
|
||||||
// (download list)
|
// (download list)
|
||||||
void GUI::saveColWidthSearchList() const{
|
void GUI::saveColWidthSearchList() const{
|
||||||
qDebug("Saving columns width in search list");
|
qDebug("Saving columns width in search list");
|
||||||
QFile lastSearchListWidth(misc::qBittorrentPath()+"lastSearchListWidth.txt");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
// delete old file
|
|
||||||
lastSearchListWidth.remove();
|
|
||||||
QStringList width_list;
|
QStringList width_list;
|
||||||
for(int i=0; i<SearchListModel->columnCount(); ++i){
|
for(int i=0; i<SearchListModel->columnCount(); ++i){
|
||||||
width_list << QString(misc::toString(resultsBrowser->columnWidth(i)).c_str());
|
width_list << QString(misc::toString(resultsBrowser->columnWidth(i)).c_str());
|
||||||
}
|
}
|
||||||
if(lastSearchListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
settings.setValue("SearchListColsWidth", width_list.join(" "));
|
||||||
lastSearchListWidth.write(width_list.join(" ").toAscii());
|
qDebug("Search list columns width saved");
|
||||||
lastSearchListWidth.close();
|
|
||||||
qDebug("Columns width saved in search list");
|
|
||||||
}else{
|
|
||||||
std::cerr << "Error: Could not save last columns width in search results list\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
// Load columns width in a file that were saved previously
|
||||||
// (search list)
|
// (search list)
|
||||||
bool GUI::loadColWidthSearchList(){
|
bool GUI::loadColWidthSearchList(){
|
||||||
qDebug("Loading column width in search list");
|
qDebug("Loading columns width for search list");
|
||||||
QFile lastSearchListWidth(misc::qBittorrentPath()+"lastSearchListWidth.txt");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
if(lastSearchListWidth.exists()){
|
QString line = settings.value("SearchListColsWidth", QString()).toString();
|
||||||
if(lastSearchListWidth.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(line.isEmpty())
|
||||||
QByteArray line = lastSearchListWidth.readLine();
|
return false;
|
||||||
lastSearchListWidth.close();
|
QStringList width_list = line.split(' ');
|
||||||
line.chop(1);
|
if(width_list.size() != SearchListModel->columnCount())
|
||||||
QStringList width_list = QString(line).split(' ');
|
return false;
|
||||||
if(width_list.size() != SearchListModel-> columnCount()){
|
for(int i=0; i<width_list.size(); ++i){
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for(int i=0; i<width_list.size(); ++i){
|
|
||||||
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
}
|
|
||||||
qDebug("Columns width loaded in search list");
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
std::cerr << "Error: Could not load last columns width for search results list\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
qDebug("Search list columns width loaded");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load last checked search engines from a file
|
// load last checked search engines from a file
|
||||||
|
|
Loading…
Reference in a new issue