PrefAssociations::PrefAssociations(QWidget * parent, Qt::WindowFlags f) : PrefWidget(parent, f ) { setupUi(this); connect(selectAll, SIGNAL(clicked(bool)), this, SLOT(selectAllClicked(bool))); connect(selectNone, SIGNAL(clicked(bool)), this, SLOT(selectNoneClicked(bool))); connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*))); connect(listWidget, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(listItemPressed(QListWidgetItem*))); if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) { //Hide Select None - One cannot restore an association in Vista. Go figure. selectNone->hide(); //QPushButton* lpbButton = new QPushButton("Launch Program Defaults", this); //hboxLayout->addWidget(lpbButton); //connect(lpbButton, SIGNAL(clicked(bool)), this, SLOT(launchAppDefaults())); } Extensions e; for (int n=0; n < e.multimedia().count(); n++) { addItem( e.multimedia()[n] ); } // Add the playlist extensions for (int n=0; n < e.playlist().count(); n++) { addItem( e.playlist()[n] ); } retranslateStrings(); something_changed = false; }
SMPlayer::ExitCode SMPlayer::processArgs(QStringList args) { qDebug("SMPlayer::processArgs: arguments: %d", args.count()); for (int n = 0; n < args.count(); n++) { qDebug("SMPlayer::processArgs: %d = %s", n, args[n].toUtf8().data()); } QString action; // Action to be passed to running instance bool show_help = false; if (!pref->gui.isEmpty()) gui_to_use = pref->gui; bool add_to_playlist = false; #ifdef Q_OS_WIN if (args.contains("-uninstall")) { #if USE_ASSOCIATIONS //Called by uninstaller. Will restore old associations. WinFileAssoc RegAssoc; Extensions exts; QStringList regExts; RegAssoc.GetRegisteredExtensions(exts.multimedia(), regExts); RegAssoc.RestoreFileAssociations(regExts); printf("Restored associations\n"); #endif return NoError; } #endif if (args.contains("-delete-config")) { CleanConfig::clean(Paths::configPath()); return NoError; } for (int n = 1; n < args.count(); n++) { QString argument = args[n]; if (argument == "-send-action") { if (n+1 < args.count()) { n++; action = args[n]; } else { printf("Error: expected parameter for -send-action\r\n"); return ErrorArgument; } } else if (argument == "-actions") { if (n+1 < args.count()) { n++; actions_list = args[n]; } else { printf("Error: expected parameter for -actions\r\n"); return ErrorArgument; } } else if (argument == "-sub") { if (n+1 < args.count()) { n++; QString file = args[n]; if (QFile::exists(file)) { subtitle_file = QFileInfo(file).absoluteFilePath(); } else { printf("Error: file '%s' doesn't exists\r\n", file.toUtf8().constData()); } } else { printf("Error: expected parameter for -sub\r\n"); return ErrorArgument; } } else if (argument == "-pos") { if (n+2 < args.count()) { bool ok_x, ok_y; n++; gui_position.setX( args[n].toInt(&ok_x) ); n++; gui_position.setY( args[n].toInt(&ok_y) ); if (ok_x && ok_y) move_gui = true; } else { printf("Error: expected parameter for -pos\r\n"); return ErrorArgument; } } else if (argument == "-size") { if (n+2 < args.count()) { bool ok_width, ok_height; n++; gui_size.setWidth( args[n].toInt(&ok_width) ); n++; gui_size.setHeight( args[n].toInt(&ok_height) ); if (ok_width && ok_height) resize_gui = true; } else { printf("Error: expected parameter for -resize\r\n"); return ErrorArgument; } } else if ((argument == "--help") || (argument == "-help") || (argument == "-h") || (argument == "-?") ) { show_help = true; } else if (argument == "-close-at-end") { close_at_end = 1; } else if (argument == "-no-close-at-end") { close_at_end = 0; } else if (argument == "-fullscreen") { start_in_fullscreen = 1; } else if (argument == "-no-fullscreen") { start_in_fullscreen = 0; } else if (argument == "-add-to-playlist") { add_to_playlist = true; } else if (argument == "-mini" || argument == "-minigui") { gui_to_use = "MiniGUI"; } else if (argument == "-mpcgui") { gui_to_use = "MpcGUI"; } else if (argument == "-defaultgui") { gui_to_use = "DefaultGUI"; } else if (argument == "-ontop") { pref->stay_on_top = Preferences::AlwaysOnTop; } else if (argument == "-no-ontop") { pref->stay_on_top = Preferences::NeverOnTop; } #ifdef SKINS else if (argument == "-skingui") { gui_to_use = "SkinGUI"; } #endif else { // File #if QT_VERSION >= 0x040600 QUrl fUrl = QUrl::fromUserInput(argument); if (fUrl.isValid() && fUrl.scheme().toLower() == "file") { argument = fUrl.toLocalFile(); } #endif if (QFile::exists( argument )) { argument = QFileInfo(argument).absoluteFilePath(); } files_to_play.append( argument ); } } if (show_help) { printf("%s\n", CLHelp::help().toLocal8Bit().data()); return NoError; } qDebug("SMPlayer::processArgs: files_to_play: count: %d", files_to_play.count() ); for (int n=0; n < files_to_play.count(); n++) { qDebug("SMPlayer::processArgs: files_to_play[%d]: '%s'", n, files_to_play[n].toUtf8().data()); } #ifdef SINGLE_INSTANCE if (pref->use_single_instance) { // Single instance MyApplication * a = MyApplication::instance(); if (a->isRunning()) { a->sendMessage("Hello"); if (!action.isEmpty()) { a->sendMessage("action " + action); } else { if (!subtitle_file.isEmpty()) { a->sendMessage("load_sub " + subtitle_file); } if (!files_to_play.isEmpty()) { /* a->sendMessage("open_file " + files_to_play[0]); */ QString command = "open_files"; if (add_to_playlist) command = "add_to_playlist"; a->sendMessage(command +" "+ files_to_play.join(" <<sep>> ")); } } return NoError; } } #endif if (!pref->default_font.isEmpty()) { QFont f; f.fromString(pref->default_font); qApp->setFont(f); } return SMPlayer::NoExit; }