예제 #1
0
void darwinDisableIconsInMenus(void)
{
    /* No icons in the menu of a mac application. */
#if QT_VERSION < 0x040400
    qt_mac_set_menubar_icons(false);
#else /* QT_VERSION < 0x040400 */
    /* Available since Qt 4.4 only */
    QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, true);
#endif /* QT_VERSION >= 0x040400 */
}
void
unicorn::Application::init()
{
#ifdef Q_OS_MAC
    addLibraryPath( applicationDirPath() + "/../plugins" );
#elif defined Q_OS_WIN
    addLibraryPath( applicationDirPath() + "/plugins" );
#endif

#ifdef Q_WS_MAC
    qt_mac_set_menubar_icons( false );
#endif

    CoreApplication::init();

    setupHotKeys();

#ifdef __APPLE__
    setGetURLEventHandler();
    AEEventHandlerUPP urlHandler = NewAEEventHandlerUPP( appleEventHandler );
    AEInstallEventHandler( kInternetEventClass, kAEGetURL, urlHandler, 0, false );

    setOpenApplicationEventHandler();
    AEEventHandlerUPP openHandler = NewAEEventHandlerUPP( appleEventHandler );
    AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, openHandler, 0, false );
#endif

#ifdef Q_WS_MAC
#define CSS_PATH "/../Resources/"
#else
#define CSS_PATH "/"
#endif

    refreshStyleSheet();

    translate();

    m_icm = new lastfm::InternetConnectionMonitor( this );

    connect( m_icm, SIGNAL( up( QString ) ), this, SIGNAL( internetConnectionUp() ) );
    connect( m_icm, SIGNAL( down( QString ) ), this, SIGNAL( internetConnectionDown() ) );

    connect( &m_bus, SIGNAL( wizardRunningQuery( QString )), SLOT( onWizardRunningQuery( QString )));
    connect( &m_bus, SIGNAL( sessionQuery( QString )), SLOT( onBusSessionQuery( QString )));
    connect( &m_bus, SIGNAL( sessionChanged( const QMap<QString, QString>& )), SLOT( onBusSessionChanged( const QMap<QString, QString>& )));
    connect( &m_bus, SIGNAL( lovedStateChanged(bool)), SIGNAL( busLovedStateChanged(bool)));

    m_bus.board();

#ifdef __APPLE__
    setQuitOnLastWindowClosed( false );
#endif
}
예제 #3
0
QLuaApplication::QLuaApplication(int &argc, char **argv, 
                                 bool guiEnabled, bool onethread)
  : QApplication(argc, argv, guiEnabled),
    d(new Private(this))
{
  // one thread only
  d->oneThread = onethread;

  // extract program name
  QString cuteName = QFileInfo(applicationFilePath()).baseName();
  d->programNameData = cuteName.toLocal8Bit();
  d->programName = d->programNameData.constData();
  QRegExp re("^(mac(?=qlua)|win(?=qlua)|)(q?)(.*)", Qt::CaseInsensitive);
  cuteName = capitalize(cuteName);
  if (re.indexIn(cuteName) >= 0 && re.numCaptures() == 3)
    cuteName = capitalize(re.cap(2)) + capitalize(re.cap(3));

  // basic setup
  setApplicationName(cuteName);
  setOrganizationName(QLUA_ORG);
  setOrganizationDomain(LUA_DOMAIN);

#ifndef Q_WS_MAC
  if (guiEnabled && windowIcon().isNull())
    setWindowIcon(QIcon(":/qlua.png"));
#else
  extern void qt_mac_set_native_menubar(bool);
  extern void qt_mac_set_menubar_icons(bool);
# ifdef QT_MAC_USE_NATIVE_MENUBAR
  qt_mac_set_native_menubar(true);
# else
  qt_mac_set_native_menubar(false);
# endif
  qt_mac_set_menubar_icons(false);
#endif
  
  // create console
  //   It is important to create this first because
  //   the console code ensures that posix signals are
  //   processed from the console thread.
  d->theConsole = new QLuaConsole(this);
  connect(d->theConsole, SIGNAL(ttyBreak()),
          d, SLOT(consoleBreak()) );
  connect(d->theConsole, SIGNAL(ttyInput(QByteArray)),
          d, SLOT(ttyInput(QByteArray)) );
  connect(d->theConsole, SIGNAL(ttyEndOfFile()),
          d, SLOT(ttyEndOfFile()) );
  connect(d->theConsole, SIGNAL(consoleOutput(QByteArray)),
          this, SIGNAL(luaConsoleOutput(QByteArray)) );
}
예제 #4
0
unicorn::Application::Application( int& argc, char** argv ) throw( StubbornUserException )
                    : QApplication( argc, argv ),
                      m_logoutAtQuit( false )
{
#ifdef Q_WS_MAC
    qt_mac_set_menubar_icons( false );
#endif    
    
    CoreApplication::init();

#ifdef __APPLE__
    AEEventHandlerUPP h = NewAEEventHandlerUPP( appleEventHandler );
    AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, h, 0, false );
#endif

    translate();

    CoreSettings s;
    if (s.value( "Username" ).toString().isEmpty() || s.value( "SessionKey" ).toString().isEmpty() || Settings().logOutOnExit())
    {
        LoginDialog d( s.value( "Username" ).toString() );
        if (d.exec() == QDialog::Accepted)
        {
            // if LogOutOnExit is enabled, really, we shouldn't store these,
            // but it means other Unicorn apps can log in while the client is 
            // loaded, and we delete the settings on exit if logOut is on
            s.setValue( "Username", d.username() );
            s.setValue( "SessionKey", d.sessionKey() );
            s.setValue( "Password", d.passwordHash() );
            
            UserSettings().setValue( UserSettings::subscriptionKey(), d.isSubscriber() );
        }
        else
        {
            throw StubbornUserException();
        }
    }

    Ws::Username = s.value( "Username" ).toString();
    Ws::SessionKey = s.value( "SessionKey" ).toString();
    
    connect( AuthenticatedUser().getInfo(), SIGNAL(finished( WsReply* )), SLOT(onUserGotInfo( WsReply* )) );

#ifdef __APPLE__
    setQuitOnLastWindowClosed( false );
#endif
}