Пример #1
0
void
CThirdPage::SelectMatch(Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer * manufacturer, Model * model)
{
    PopulateUI( manufacturers );

    SelectMatch( printer, service, manufacturer, model );
}
Пример #2
0
BOOL
CThirdPage::OnSetActive()
{
    CPrinterSetupWizardSheet	*	psheet;
    Printer						*	printer;
    Service						*	service;

    psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
    require_quiet( psheet, exit );

    psheet->SetWizardButtons( PSWIZB_BACK );

    printer = psheet->GetSelectedPrinter();
    require_quiet( printer, exit );

    service = printer->services.front();
    require_quiet( service, exit );

    //
    // call OnInitPage once
    //
    if (!m_initialized)
    {
        OnInitPage();
        m_initialized = true;
    }

    //
    // <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
    //
    if ( DefaultPrinterExists() )
    {
        m_defaultPrinterCtrl.SetCheck( BST_UNCHECKED );
        printer->deflt = false;
    }
    else
    {
        m_defaultPrinterCtrl.SetCheck( BST_CHECKED );
        printer->deflt = true;
    }

    //
    // update the UI with the printer name
    //
    m_printerName.SetWindowText(printer->displayName);

    //
    // populate the list controls with the manufacturers and models
    // from ntprint.inf
    //
    PopulateUI( m_manufacturers );

    //
    // and try and match the printer
    //

    if ( psheet->GetLastPage() == psheet->GetPage(0) )
    {
        MatchPrinter( m_manufacturers, printer, service, true );

        if ( ( m_manufacturerSelected != NULL ) && ( m_modelSelected != NULL  ) )
        {
            GetParent()->PostMessage(PSM_SETCURSEL, 2 );
        }
    }
    else
    {
        SelectMatch(printer, service, m_manufacturerSelected, m_modelSelected);
    }

exit:

    return CPropertyPage::OnSetActive();
}
Пример #3
0
void CThirdPage::OnBnClickedHaveDisk()
{
    CPrinterSetupWizardSheet	*	psheet;
    Printer						*	printer;
    Service						*	service;
    Manufacturers					manufacturers;

    CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, L"Setup Information (*.inf)|*.inf||", this);

    psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
    require_quiet( psheet, exit );

    printer = psheet->GetSelectedPrinter();
    require_quiet( printer, exit );

    service = printer->services.front();
    require_quiet( service, exit );

    for ( ;; )
    {
        if ( dlg.DoModal() == IDOK )
        {
            CString filename = dlg.GetPathName();

            LoadPrintDriverDefsFromFile( manufacturers, filename, true );

            // Sanity check

            if ( manufacturers.size() > 0 )
            {
                PopulateUI( manufacturers );

                if ( MatchPrinter( manufacturers, printer, service, false ) != kNoErr )
                {
                    CString errorMessage;
                    CString errorCaption;

                    errorMessage.LoadString( IDS_NO_MATCH_INF_FILE );
                    errorCaption.LoadString( IDS_NO_MATCH_INF_FILE_CAPTION );

                    MessageBox( errorMessage, errorCaption, MB_OK );
                }

                break;
            }
            else
            {
                CString errorMessage;
                CString errorCaption;

                errorMessage.LoadString( IDS_BAD_INF_FILE );
                errorCaption.LoadString( IDS_BAD_INF_FILE_CAPTION );

                MessageBox( errorMessage, errorCaption, MB_OK );
            }
        }
        else
        {
            break;
        }
    }

exit:

    FreeManufacturers( manufacturers );
    return;
}
trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_settings)
	: QWidget(), m_sort_column(0), m_col_sort_order(Qt::AscendingOrder), m_gui_settings(gui_settings)
{
	// Nonspecific widget settings
	setWindowTitle(tr("Trophy Manager"));
	setObjectName("trophy_manager");

	m_icon_height            = m_gui_settings->GetValue(gui::tr_icon_height).toInt();
	m_show_locked_trophies   = m_gui_settings->GetValue(gui::tr_show_locked).toBool();
	m_show_unlocked_trophies = m_gui_settings->GetValue(gui::tr_show_unlocked).toBool();
	m_show_hidden_trophies   = m_gui_settings->GetValue(gui::tr_show_hidden).toBool();
	m_show_bronze_trophies   = m_gui_settings->GetValue(gui::tr_show_bronze).toBool();
	m_show_silver_trophies   = m_gui_settings->GetValue(gui::tr_show_silver).toBool();
	m_show_gold_trophies     = m_gui_settings->GetValue(gui::tr_show_gold).toBool();
	m_show_platinum_trophies = m_gui_settings->GetValue(gui::tr_show_platinum).toBool();

	// HACK: dev_hdd0 must be mounted for vfs to work for loading trophies.
	vfs::mount("dev_hdd0", Emu.GetHddDir());

	// Trophy Tree
	m_trophy_tree = new QTreeWidget();
	m_trophy_tree->setColumnCount(6);

	QStringList column_names;
	column_names << tr("Icon") << tr("Name") << tr("Description") << tr("Type") << tr("Status") << tr("ID");
	m_trophy_tree->setHeaderLabels(column_names);
	m_trophy_tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
	m_trophy_tree->header()->setStretchLastSection(false);
	m_trophy_tree->setSortingEnabled(true);
	m_trophy_tree->setContextMenuPolicy(Qt::CustomContextMenu);

	// Populate the trophy database
	QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)));
	while (dir_iter.hasNext()) 
	{
		dir_iter.next();
		if (dir_iter.fileName() == "." || dir_iter.fileName() == ".." || dir_iter.fileName() == ".gitignore")
		{
			continue;
		}
		std::string dirName = sstr(dir_iter.fileName());
		LOG_TRACE(GENERAL, "Loading trophy dir: %s", dirName);
		LoadTrophyFolderToDB(dirName);
	}

	PopulateUI();
	ApplyFilter();

	// Checkboxes to control dialog
	QCheckBox* check_lock_trophy = new QCheckBox(tr("Show Locked Trophies"));
	check_lock_trophy->setCheckable(true);
	check_lock_trophy->setChecked(m_show_locked_trophies);

	QCheckBox* check_unlock_trophy = new QCheckBox(tr("Show Unlocked Trophies"));
	check_unlock_trophy->setCheckable(true);
	check_unlock_trophy->setChecked(m_show_unlocked_trophies);

	QCheckBox* check_hidden_trophy = new QCheckBox(tr("Show Hidden Trophies"));
	check_hidden_trophy->setCheckable(true);
	check_hidden_trophy->setChecked(m_show_hidden_trophies);

	QCheckBox* check_bronze_trophy = new QCheckBox(tr("Show Bronze Trophies"));
	check_bronze_trophy->setCheckable(true);
	check_bronze_trophy->setChecked(m_show_bronze_trophies);

	QCheckBox* check_silver_trophy = new QCheckBox(tr("Show Silver Trophies"));
	check_silver_trophy->setCheckable(true);
	check_silver_trophy->setChecked(m_show_silver_trophies);

	QCheckBox* check_gold_trophy = new QCheckBox(tr("Show Gold Trophies"));
	check_gold_trophy->setCheckable(true);
	check_gold_trophy->setChecked(m_show_gold_trophies);

	QCheckBox* check_platinum_trophy = new QCheckBox(tr("Show Platinum Trophies"));
	check_platinum_trophy->setCheckable(true);
	check_platinum_trophy->setChecked(m_show_platinum_trophies);

	QLabel* slider_label = new QLabel();
	slider_label->setText(tr("Icon Size: %0").arg(m_icon_height));

	m_icon_slider = new QSlider(Qt::Horizontal);
	m_icon_slider->setRange(25, 225);
	m_icon_slider->setValue(m_icon_height);

	// LAYOUTS
	QGroupBox* show_settings = new QGroupBox(tr("Trophy View Options"));
	show_settings->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QVBoxLayout* settings_layout = new QVBoxLayout();
	settings_layout->addWidget(check_lock_trophy);
	settings_layout->addWidget(check_unlock_trophy);
	settings_layout->addWidget(check_hidden_trophy);
	settings_layout->addWidget(check_bronze_trophy);
	settings_layout->addWidget(check_silver_trophy);
	settings_layout->addWidget(check_gold_trophy);
	settings_layout->addWidget(check_platinum_trophy);
	show_settings->setLayout(settings_layout);

	QGroupBox* icon_settings = new QGroupBox(tr("Trophy Icon Options"));
	QVBoxLayout* slider_layout = new QVBoxLayout();
	slider_layout->addWidget(slider_label);
	slider_layout->addWidget(m_icon_slider);
	icon_settings->setLayout(slider_layout);

	QVBoxLayout* options_layout = new QVBoxLayout();
	options_layout->addStretch();
	options_layout->addWidget(show_settings);
	options_layout->addWidget(icon_settings);
	options_layout->addStretch();

	QHBoxLayout* all_layout = new QHBoxLayout(this);
	all_layout->addLayout(options_layout);
	all_layout->addWidget(m_trophy_tree);
	all_layout->setStretch(1, 1);
	setLayout(all_layout);

	if (!restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray()))
		resize(QDesktopWidget().availableGeometry().size() * 0.7);

	// Make connects
	connect(m_icon_slider, &QSlider::valueChanged, this, [=](int val)
	{
		slider_label->setText(tr("Icon Size: %0").arg(val));
		ResizeTrophyIcons(val);
		if (m_save_icon_height)
		{
			m_save_icon_height = false;
			m_gui_settings->SetValue(gui::tr_icon_height, val);
		}
	});

	connect(m_icon_slider, &QSlider::sliderReleased, this, [&]()
	{
		m_gui_settings->SetValue(gui::tr_icon_height, m_icon_slider->value());
	});

	connect(m_icon_slider, &QSlider::actionTriggered, [&](int action)
	{
		if (action != QAbstractSlider::SliderNoAction && action != QAbstractSlider::SliderMove)
		{	// we only want to save on mouseclicks or slider release (the other connect handles this)
			m_save_icon_height = true; // actionTriggered happens before the value was changed
		}
	});

	connect(check_lock_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_locked_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_locked, checked);
	});

	connect(check_unlock_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_unlocked_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_unlocked, checked);
	});

	connect(check_hidden_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_hidden_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_hidden, checked);
	});

	connect(check_bronze_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_bronze_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_bronze, checked);
	});

	connect(check_silver_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_silver_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_silver, checked);
	});

	connect(check_gold_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_gold_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_gold, checked);
	});

	connect(check_platinum_trophy, &QCheckBox::clicked, [this](bool checked)
	{
		m_show_platinum_trophies = checked;
		ApplyFilter();
		m_gui_settings->SetValue(gui::tr_show_platinum, checked);
	});

	connect(m_trophy_tree->header(), &QHeaderView::sectionClicked, this, &trophy_manager_dialog::OnColClicked);

	connect(m_trophy_tree, &QTableWidget::customContextMenuRequested, this, &trophy_manager_dialog::ShowContextMenu);
}