From: Flavio Date: Tue, 11 Dec 2012 08:55:26 +0000 (+0100) Subject: Cleanup X-Git-Tag: 2.0~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=feca4be1bb26ad40dd0d3c4fd2d78c8b8ca36fea;p=minitube Cleanup --- diff --git a/src/downloadsettings.cpp b/src/downloadsettings.cpp index 80b2763..990f5c7 100644 --- a/src/downloadsettings.cpp +++ b/src/downloadsettings.cpp @@ -1,5 +1,6 @@ #include "downloadsettings.h" #include "downloadmanager.h" +#include "MainWindow.h" DownloadSettings::DownloadSettings(QWidget *parent) : QWidget(parent) { @@ -55,14 +56,10 @@ void DownloadSettings::folderChosen(const QString &dir) { QSettings settings; settings.setValue("downloadFolder", dir); updateMessage(); - QMainWindow* mainWindow = dynamic_cast(window()); - if (mainWindow) { - QString status; - status = tr("Download location changed."); - if (DownloadManager::instance()->activeItems() > 0) - status += " " + tr("Current downloads will still go in the previous location."); - mainWindow->statusBar()->showMessage(status); - } + QString status = tr("Download location changed."); + if (DownloadManager::instance()->activeItems() > 0) + status += " " + tr("Current downloads will still go in the previous location."); + MainWindow::instance()->showMessage(status); } } diff --git a/src/global.h b/src/global.h index 2285b17..a4c5ab8 100644 --- a/src/global.h +++ b/src/global.h @@ -11,17 +11,15 @@ namespace The { - static QMap *g_actions = 0; - QMap* globalActions() { + static QMap *g_actions = 0; if (!g_actions) g_actions = new QMap; return g_actions; } - static QMap *g_menus = 0; - QMap* globalMenus() { + static QMap *g_menus = 0; if (!g_menus) g_menus = new QMap; return g_menus; @@ -123,9 +121,8 @@ namespace The { } } - static QNetworkAccessManager *nam = 0; - QNetworkAccessManager* networkAccessManager() { + static QNetworkAccessManager *nam = 0; if (!nam) { networkHttpProxySetting(); maybeSetSystemProxy(); @@ -134,8 +131,8 @@ namespace The { return nam; } - static NetworkAccess *g_http = 0; NetworkAccess* http() { + static NetworkAccess *g_http = 0; if (!g_http) { // qDebug() << "Creating NetworkAccess"; g_http = new NetworkAccess(); diff --git a/src/main.cpp b/src/main.cpp index f03d0f4..fa60457 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,11 +3,13 @@ #include "constants.h" #include "MainWindow.h" #include "searchparams.h" +#include "iconloader/qticonloader.h" +#ifndef Q_WS_X11 +#include "extra.h" +#endif #ifdef Q_WS_MAC #include "mac_startup.h" -#include "macfullscreen.h" #endif -#include "iconloader/qticonloader.h" int main(int argc, char **argv) { @@ -21,7 +23,6 @@ int main(int argc, char **argv) { MainWindow::printHelp(); return 0; } - if (app.sendMessage(message)) return 0; @@ -31,18 +32,10 @@ int main(int argc, char **argv) { #ifndef APP_WIN app.setWheelScrollLines(1); #endif + app.setAttribute(Qt::AA_DontShowIconsInMenus); -#ifdef APP_MAC - app.setAttribute(Qt::AA_NativeWindows); - QFile file(":/mac.css"); - file.open(QFile::ReadOnly); - app.setStyleSheet(QLatin1String(file.readAll())); -#endif - -#ifdef APP_WIN - QFile file(":/win.css"); - file.open(QFile::ReadOnly); - app.setStyleSheet(QLatin1String(file.readAll())); +#ifndef Q_WS_X11 + Extra::appSetup(&app); #endif const QString locale = QLocale::system().name(); @@ -72,9 +65,8 @@ int main(int argc, char **argv) { MainWindow mainWin; mainWin.setWindowTitle(Constants::NAME); -#ifdef Q_WS_MAC - app.setQuitOnLastWindowClosed(false); - mac::SetupFullScreenWindow(mainWin.winId()); +#ifndef Q_WS_X11 + Extra::windowSetup(&mainWin); #endif // no window icon on Mac @@ -97,10 +89,6 @@ int main(int argc, char **argv) { mainWin.setWindowIcon(appIcon); #endif -#ifdef APP_WIN - app.setFont(QFont("Segoe UI", 9)); -#endif - mainWin.show(); mainWin.connect(&app, SIGNAL(messageReceived(const QString &)), &mainWin, SLOT(messageReceived(const QString &))); diff --git a/src/segmentedcontrol.cpp b/src/segmentedcontrol.cpp index d666e4d..d347ba0 100644 --- a/src/segmentedcontrol.cpp +++ b/src/segmentedcontrol.cpp @@ -104,8 +104,7 @@ void SegmentedControl::mouseMoveEvent (QMouseEvent *event) { update(); // status tip - QMainWindow* mainWindow = dynamic_cast(window()); - if (mainWindow) mainWindow->statusBar()->showMessage(action->statusTip()); + static_cast(window())->statusBar()->showMessage(action->statusTip()); } } @@ -129,8 +128,7 @@ void SegmentedControl::mouseReleaseEvent(QMouseEvent *event) { void SegmentedControl::leaveEvent(QEvent *event) { QWidget::leaveEvent(event); // status tip - QMainWindow* mainWindow = dynamic_cast(window()); - if (mainWindow) mainWindow->statusBar()->clearMessage(); + static_cast(window())->statusBar()->clearMessage(); d->hoveredAction = 0; d->pressedAction = 0; update();