From 0853ae4691be8ed4b87d57a707e2011faa0a2ca0 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 4 Dec 2010 09:37:13 +0000 Subject: [PATCH] Code clean up --- src/mainwindow.cpp | 64 ++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 06cec0fd5..4407c4c88 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -436,13 +436,35 @@ void MainWindow::writeSettings() { settings.beginGroup(QString::fromUtf8("MainWindow")); settings.setValue("geometry", saveGeometry()); // Splitter size - QStringList sizes_str; - sizes_str << QString::number(vSplitter->sizes().first()); - sizes_str << QString::number(vSplitter->sizes().last()); - settings.setValue(QString::fromUtf8("vSplitterSizes"), sizes_str); + settings.setValue(QString::fromUtf8("vsplitterState"), vSplitter->saveState()); settings.endGroup(); } +void MainWindow::readSettings() { + QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.beginGroup(QString::fromUtf8("MainWindow")); + restoreGeometry(settings.value("geometry").toByteArray()); + const QByteArray splitterState = settings.value("vsplitterState").toByteArray(); + if(splitterState.isEmpty()) { + // Default sizes + vSplitter->setSizes(QList() << 120 << vSplitter->width()-120); + } else { + vSplitter->restoreState(splitterState); + } + settings.endGroup(); +} + +void MainWindow::balloonClicked() { + if(isHidden()) { + show(); + if(isMinimized()) { + showNormal(); + } + raise(); + activateWindow(); + } +} + // called when a torrent has finished void MainWindow::finishedTorrent(const QTorrentHandle& h) const { if(!TorrentPersistentData::isSeed(h.hash())) @@ -495,36 +517,6 @@ void MainWindow::displayRSSTab() const { // End of keyboard shortcuts slots -void MainWindow::readSettings() { - QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - settings.beginGroup(QString::fromUtf8("MainWindow")); - restoreGeometry(settings.value("geometry").toByteArray()); - const QStringList sizes_str = settings.value("vSplitterSizes", QStringList()).toStringList(); - // Splitter size - QList sizes; - if(sizes_str.size() == 2) { - sizes << sizes_str.first().toInt(); - sizes << sizes_str.last().toInt(); - } else { - qDebug("Default splitter size"); - sizes << 120; - sizes << vSplitter->width()-120; - } - vSplitter->setSizes(sizes); - settings.endGroup(); -} - -void MainWindow::balloonClicked() { - if(isHidden()) { - show(); - if(isMinimized()) { - showNormal(); - } - raise(); - activateWindow(); - } -} - void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h) { Preferences pref; if(pref.recursiveDownloadDisabled()) return; @@ -1042,9 +1034,9 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const { NotifyNotification* notification; notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent" -#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) + #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) , 0 -#endif + #endif ); gboolean success = notify_notification_show (notification, NULL); g_object_unref(G_OBJECT(notification));