Browse Source

Code clean up

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
0853ae4691
  1. 64
      src/mainwindow.cpp

64
src/mainwindow.cpp

@ -436,13 +436,35 @@ void MainWindow::writeSettings() {
settings.beginGroup(QString::fromUtf8("MainWindow")); settings.beginGroup(QString::fromUtf8("MainWindow"));
settings.setValue("geometry", saveGeometry()); settings.setValue("geometry", saveGeometry());
// Splitter size // Splitter size
QStringList sizes_str; settings.setValue(QString::fromUtf8("vsplitterState"), vSplitter->saveState());
sizes_str << QString::number(vSplitter->sizes().first());
sizes_str << QString::number(vSplitter->sizes().last());
settings.setValue(QString::fromUtf8("vSplitterSizes"), sizes_str);
settings.endGroup(); 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<int>() << 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 // called when a torrent has finished
void MainWindow::finishedTorrent(const QTorrentHandle& h) const { void MainWindow::finishedTorrent(const QTorrentHandle& h) const {
if(!TorrentPersistentData::isSeed(h.hash())) if(!TorrentPersistentData::isSeed(h.hash()))
@ -495,36 +517,6 @@ void MainWindow::displayRSSTab() const {
// End of keyboard shortcuts slots // 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<int> 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) { void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h) {
Preferences pref; Preferences pref;
if(pref.recursiveDownloadDisabled()) return; if(pref.recursiveDownloadDisabled()) return;
@ -1042,9 +1034,9 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const {
NotifyNotification* notification; NotifyNotification* notification;
notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent" 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 , 0
#endif #endif
); );
gboolean success = notify_notification_show (notification, NULL); gboolean success = notify_notification_show (notification, NULL);
g_object_unref(G_OBJECT(notification)); g_object_unref(G_OBJECT(notification));

Loading…
Cancel
Save