Пример #1
0
KStartupLogo::KStartupLogo() :
    QObject(0),
    m_splash(0)
{
  // splash screen setting
  if (!KMyMoneyGlobalSettings::showSplash())
    return;

  QString filename = KGlobal::dirs()->findResource("appdata", "pics/startlogo.png");
  QString localeFilename = KGlobal::locale()->localizedFilePath(filename);
  QPixmap logoOverlay(localeFilename);

  QPixmap logoPixmap(logoOverlay.size());
  logoPixmap.fill(KColorScheme(QPalette::Active, KColorScheme::Selection).background(KColorScheme::NormalBackground).color());
  QPainter pixmapPainter(&logoPixmap);
  pixmapPainter.drawPixmap(0, 0, logoOverlay, 0, 0, logoOverlay.width(), logoOverlay.height());

  if (!logoOverlay.isNull()) {
    const KAboutData *aboutData = KCmdLineArgs::aboutData();
    KSplashScreen* splash = new KSplashScreen(logoPixmap);
    splash->setFixedSize(logoPixmap.size());

    splash->show();
    splash->showMessage(i18n("Loading %1...", aboutData->version()),  //krazy:exclude=qmethods
                        Qt::AlignLeft | Qt::AlignBottom,
                        KColorScheme(QPalette::Active, KColorScheme::Selection)
                        .foreground(KColorScheme::NormalText).color());
    m_splash = splash;
  }
}
int main(int argc, char **argv)
{
    KAboutData about("kftpgrabber", 0, ki18n("KFTPgrabber"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2008, The KFTPgrabber developers"), KLocalizedString(), "http://www.kftp.org");
    about.addAuthor(ki18n("Jernej Kos"), ki18n("Lead developer"), "*****@*****.**");
    about.addAuthor(ki18n("Markus Brüffer"), ki18n("Developer"), "*****@*****.**");
    
    about.addCredit(ki18n("Lee Joseph"), ki18n("Fedora ambassador responsible for promotion, testing and debugging; also a package maintainer for Fedora-compatible distributions"), "*****@*****.**");
    about.addCredit(ki18n("libssh2 Developers"), ki18n("SSH library"), "*****@*****.**");
    about.addCredit(ki18n("Anthony D. Urso"), ki18n("otpCalc code"));
    about.addCredit(ki18n("Kopete Developers"), ki18n("KopeteBalloon popup code"), "*****@*****.**");
    about.addCredit(ki18n("KSysGuard Developers"), ki18n("Traffic graph widget"), "*****@*****.**");
    about.addCredit(ki18n("Bob Ziuchkovski"), ki18n("Icon design"), "*****@*****.**");
    about.addCredit(ki18n("Tobias Ussing"), ki18n("Testing and debugging"), "*****@*****.**");
    about.addCredit(ki18n("Tim Kosse"), ki18n("Directory parser code"), "*****@*****.**");
    about.addCredit(ki18n("Peter Penz"), ki18n("Listview column handling code"), "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("+[url]", ki18n("An optional URL to connect to"));
    KCmdLineArgs::addCmdLineOptions(options);
    KUniqueApplication app;
    
    if (app.isSessionRestored()) {
      RESTORE(MainWindow);
    } else {
      MainWindow *mainWindow = 0;
      KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

      KSplashScreen *splash = 0L;
      QString splashPath = KStandardDirs::locate("appdata", "kftpgrabber-logo.png");
      if (!KFTPCore::Config::startMinimized() && KFTPCore::Config::showSplash()) {
        // Show the splash screen
        if (!splashPath.isNull()) {
          QPixmap splashImage = QPixmap(splashPath);
          splash = new KSplashScreen(splashImage);
          splash->setMaximumWidth(400);
          splash->show();
        }
      }
      
      mainWindow = new MainWindow();
      if (!KFTPCore::Config::startMinimized())
        mainWindow->show();
        
      // Check if an URL was passed as a command line argument
      if (args->count() == 1) {
        KUrl remoteUrl = args->url(0);
        
        if (!remoteUrl.isLocalFile()) {
          if (!remoteUrl.port())
            remoteUrl.setPort(21);
            
          if (!remoteUrl.hasUser())
            remoteUrl.setUser("anonymous");
            
          if (!remoteUrl.hasPass()) {
            if (!KFTPCore::Config::anonMail().isEmpty())
              remoteUrl.setPass(KFTPCore::Config::anonMail());
            else
              remoteUrl.setPass("*****@*****.**");
          }

          KFTPSession::Manager::self()->spawnRemoteSession(KFTPSession::IgnoreSide, remoteUrl);
        }
      }
        
      if (splash != 0L) {
        splash->finish(mainWindow);
        delete splash;
      }
      
      args->clear();
    }
    
    return app.exec();
}