QTfrontend/main.cpp
branchqt5transition
changeset 13180 3961f9d0c7e4
parent 13179 ddfb4a73524b
child 13182 d2f8dafdb080
equal deleted inserted replaced
13179:ddfb4a73524b 13180:3961f9d0c7e4
   153 .arg(HWApplication::tr("Custom path to the game data folder", "command-line"))
   153 .arg(HWApplication::tr("Custom path to the game data folder", "command-line"))
   154 .arg(HWApplication::tr("Hedgewars can use a %1 (e.g. \"%2\") to connect on start.", "command-line").arg(HWApplication::tr("CONNECTSTRING", "command-line")).arg(QString("hwplay://") + NETGAME_DEFAULT_SERVER));
   154 .arg(HWApplication::tr("Hedgewars can use a %1 (e.g. \"%2\") to connect on start.", "command-line").arg(HWApplication::tr("CONNECTSTRING", "command-line")).arg(QString("hwplay://") + NETGAME_DEFAULT_SERVER));
   155 }
   155 }
   156 
   156 
   157 int main(int argc, char *argv[]) {
   157 int main(int argc, char *argv[]) {
   158 	/* Qt5 removed motif, plastique.  These are now in qt5-style-plugins which was NOT backported by debian/ubuntu to stable/LTS - windows appears to render best of the remaining options but still isn't quite right. */
   158     /* Qt5 Base removed Motif, Plastique. These are now in the Qt style plugins
   159 	// set windows initially
   159     (Ubuntu: qt5-style-plugins, which was NOT backported by Debian/Ubuntu to stable/LTS).
   160 	QApplication::setStyle(QStyleFactory::create("windows"));
   160     Windows appears to render best of the remaining options but still isn't quite right. */
   161 	// try setting plastique if available from qt5-style-plugins - in testing qt5 skips the call on fail to locate which leaves us on windows
   161 
   162 	QApplication::setStyle(QStyleFactory::create("plastique"));
   162     // Try setting Plastique if available
       
   163     QStyle* coreStyle;
       
   164     coreStyle = QStyleFactory::create("Plastique");
       
   165     if(coreStyle != 0) {
       
   166         QApplication::setStyle(coreStyle);
       
   167         qDebug("Qt style set: Plastique");
       
   168     } else {
       
   169         // Use Windows as fallback.
       
   170         // FIXME: Under Windows style, some widgets like scrollbars don't render as nicely
       
   171         coreStyle = QStyleFactory::create("Windows");
       
   172         if(coreStyle != 0) {
       
   173             QApplication::setStyle(coreStyle);
       
   174             qDebug("Qt style set: Windows");
       
   175         } else {
       
   176             // Windows style should not be missing in Qt5 Base. If it does, something went terribly wrong!
       
   177             qWarning("No Qt style could be set! Using the default one.");
       
   178         }
       
   179     }
       
   180 
   163     // Since we're calling this first, closeResources() will be the last thing called after main() returns.
   181     // Since we're calling this first, closeResources() will be the last thing called after main() returns.
   164     atexit(closeResources);
   182     atexit(closeResources);
   165 
   183 
   166 #ifdef __APPLE__
   184 #ifdef __APPLE__
   167     cocoaInit = new CocoaInitializer(); // Creates the autoreleasepool preventing cocoa object leaks on OS X.
   185     cocoaInit = new CocoaInitializer(); // Creates the autoreleasepool preventing cocoa object leaks on OS X.