]> git.sur5r.net Git - minitube/commitdiff
Cleanup
authorFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:55:26 +0000 (09:55 +0100)
committerFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:55:26 +0000 (09:55 +0100)
src/downloadsettings.cpp
src/global.h
src/main.cpp
src/segmentedcontrol.cpp

index 80b276313b7a390286dc9f4c32c4a4e7f17811a1..990f5c7c684491af32685c165c02a31fded27c26 100644 (file)
@@ -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<QMainWindow*>(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);
     }
 }
 
index 2285b17351f491ecca9bad2d3850445ce34df5b3..a4c5ab8798bd2808ed750baca8e877fa400cae9d 100644 (file)
 
 namespace The {
 
-    static QMap<QString, QAction*> *g_actions = 0;
-
     QMap<QString, QAction*>* globalActions() {
+        static QMap<QString, QAction*> *g_actions = 0;
         if (!g_actions)
             g_actions = new QMap<QString, QAction*>;
         return g_actions;
     }
 
-    static QMap<QString, QMenu*> *g_menus = 0;
-
     QMap<QString, QMenu*>* globalMenus() {
+        static QMap<QString, QMenu*> *g_menus = 0;
         if (!g_menus)
             g_menus = new QMap<QString, QMenu*>;
         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();
index f03d0f407357892da67604c54fa746655950cae5..fa6045726f78caac54f71880e598bf1fdab6a58a 100644 (file)
@@ -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 &)));
index d666e4db057450fcd1fcb535a1eedccc2dd3f22b..d347ba0631ea7075d68a1d9be6bae51250a45c91 100644 (file)
@@ -104,8 +104,7 @@ void SegmentedControl::mouseMoveEvent (QMouseEvent *event) {
         update();
 
         // status tip
-        QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(window());
-        if (mainWindow) mainWindow->statusBar()->showMessage(action->statusTip());
+        static_cast<QMainWindow*>(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<QMainWindow*>(window());
-    if (mainWindow) mainWindow->statusBar()->clearMessage();
+    static_cast<QMainWindow*>(window())->statusBar()->clearMessage();
     d->hoveredAction = 0;
     d->pressedAction = 0;
     update();