コード例 #1
0
void ProxyDlg::proxy_new()
{
	ProxyItem s;
	s.id = ""; // id of "" means 'new'
	s.name = getUniqueName();
	d->list += s;

	lbx_proxy->insertItem(s.name);
	lbx_proxy->setCurrentItem(lbx_proxy->count()-1);
	selectCurrent();
}
コード例 #2
0
void ProxyDlg::proxy_remove()
{
	int x = lbx_proxy->currentItem();
	if(x != -1) {
		ProxyItemList::Iterator it = d->list.begin();
		for(int n = 0; n < x; ++n)
			++it;
		d->list.remove(it);

		d->last = -1;
		lbx_proxy->removeItem(x);
		selectCurrent();
	}
}
コード例 #3
0
ProxyDlg::ProxyDlg(const ProxyItemList &list, const QStringList &methods, const QString &def, QWidget *parent)
	: QDialog(parent)
{
	setAttribute(Qt::WA_DeleteOnClose);
	d = new Private;
	setupUi(this);
	setWindowTitle(CAP(caption()));
	setModal(QApplication::activeModalWidget() ? true: false);

	d->list = list;
	d->last = -1;
	d->pe_settings = new ProxyEdit(gb_prop);
	replaceWidget(lb_proxyedit, d->pe_settings);
	d->pe_settings->fixTabbing(cb_type, pb_close);

	hookEdit();

	connect(pb_new, SIGNAL(clicked()), SLOT(proxy_new()));
	connect(pb_remove, SIGNAL(clicked()), SLOT(proxy_remove()));
	connect(pb_save, SIGNAL(clicked()), SLOT(doSave()));
	connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
	gb_prop->setEnabled(false);
	pb_remove->setEnabled(false);
	pb_save->setDefault(true);

	cb_type->insertStringList(methods);
	connect(cb_type, SIGNAL(activated(int)), SLOT(cb_activated(int)));

	int defIdx = -1;
	int i = 0;
	for(ProxyItemList::ConstIterator it = d->list.begin(); it != d->list.end(); ++it) {
		lbx_proxy->insertItem((*it).name);
		if ((*it).id == def) defIdx= i;
		++i;
	}
	if(!list.isEmpty()) {
		if(defIdx < 0)
			defIdx = 0;
		lbx_proxy->setCurrentItem(defIdx);
		selectCurrent();
	}

	cb_type->setWhatsThis(
		tr("If you require a proxy server to connect, select the type of proxy here.") + "  " +
		tr("Consult your network administrator if necessary."));
	// TODO: whatsthis for name
}
コード例 #4
0
//==============================================================================
// Load File
//==============================================================================
bool ViewerWindow::loadFile(const QString& aFileName, const QString& aPanelName)
{
    // Init Mime Database
    QMimeDatabase mimeDatabase;

    // Get Mime Tpye
    mime = mimeDatabase.mimeTypeForFile(aFileName).name();

    // Reset File Is New
    fileIsNew = false;

    qDebug() << "ViewerWindow::loadFile - aFileName: " << aFileName << " - mime: " << mime;

    // Set File Name
    fileName = aFileName;
    // Emit Content Source Changed
    emit contentSourceChanged(fileName);

    // Set Context Properties
    QQmlContext* ctx = ui->quickWidget->rootContext();
    // Set Context Properties - Viewer Content
    ctx->setContextProperty(DEFAULT_IMAGE_VIEWER_CONTENT, fileName);

    // Edit Mode & Check Mime Type - Load All Files As Text in Edit Mode
    if (isSupportedTextMime(editMode, mime)) {
        // Quick Widget Set Visible
        ui->quickWidget->setVisible(false);
        // Text Edit Set Visible
        ui->textEdit->setVisible(true);

        // Set Active Widget
        activeWidget = ui->textEdit;

        // Init File
        QFile file(aFileName);

        // Open File
        if (file.open(QIODevice::ReadOnly)) {
            // Init Text Stream
            QTextStream textStream(&file);

            // Check Mime Again
            if (mime.startsWith(QString(DEFAULT_MIME_PREFIX_APP) + QString(DEFAULT_MIME_XML)) ||
                mime.startsWith(QString(DEFAULT_MIME_PREFIX_APP) + QString(DEFAULT_MIME_SHELLSCRIPT))) {
                // Load From File
                ui->textEdit->setPlainText(textStream.readAll());
            } else {
                // Load From File
                ui->textEdit->setText(textStream.readAll());
            }

            // Reset Dirty Flag
            dirty = false;

            // Close File
            file.close();
            // Update Window Title
            updateWindowTitle();
        }

    } else if (!editMode && mime.startsWith(DEFAULT_MIME_PREFIX_IMAGE)) {

        // Text Edit Set Visible
        ui->textEdit->setVisible(false);
        // Quick Widget Set Visible
        ui->quickWidget->setVisible(true);

        // Set Active Widget
        activeWidget = ui->quickWidget;

        // Set Source
        ui->quickWidget->setSource(QUrl("qrc:/qml/ImageViewer.qml"));

        // Check Image Browser
        if (!imageBrowser) {
            // Create Image Browser
            imageBrowser = new ImageBrowser(fileName, aPanelName);

            // Connect Signals
            connect(imageBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(imageBrowserCurrentIndexChanged(int)));
            connect(imageBrowser, SIGNAL(currentFileChanged(QString)), this, SLOT(imageBrowserCurrentFileChanged(QString)));
            connect(imageBrowser, SIGNAL(currentFileChanged(QString)), this, SIGNAL(currentImageFileChanged(QString)));
            connect(imageBrowser, SIGNAL(selectCurrent()), this, SLOT(handleImageBrowserSelection()));

            // Set Context Properties
            QQmlContext* ctx = ui->quickWidget->rootContext();
            // Set Context Properties - Image Browser
            ctx->setContextProperty(DEFAULT_IMAGE_BROWSER, imageBrowser);
        }
コード例 #5
0
SetColorDialog::SetColorDialog(const QString & message, QColor & currentColor, QColor & standardColor, bool askPrefs, QWidget *parent) : QDialog(parent) 
{
	m_prefsCheckBox = NULL;
	m_message = message;
	m_currentColor = m_selectedColor = currentColor;
	m_standardColor = standardColor;

	this->setWindowTitle(tr("Set %1 Color...").arg(message));

	QVBoxLayout * vLayout = new QVBoxLayout(this);

	QLabel * label = new QLabel(tr("Choose a new %1 color.").arg(message.toLower()));
	vLayout->addWidget(label);

	QFrame * f1 = new QFrame();
	QHBoxLayout * hLayout1 = new QHBoxLayout(f1);
	QPushButton *button1 = new QPushButton("Choose");
	button1->setFixedWidth(BUTTON_WIDTH);
	connect(button1, SIGNAL(clicked()), this, SLOT(selectCurrent()));
	hLayout1->addWidget(button1);
	m_currentColorLabel = new ClickableLabel(tr("current %1 color (%2)").arg(message.toLower()).arg(currentColor.name()), this);
	connect(m_currentColorLabel, SIGNAL(clicked()), this, SLOT(selectCurrent()));
	m_currentColorLabel->setPalette(QPalette(currentColor));
	m_currentColorLabel->setAutoFillBackground(true);
	m_currentColorLabel->setMargin(MARGIN);
	hLayout1->addWidget(m_currentColorLabel);
	vLayout->addWidget(f1);

	QFrame * f2 = new QFrame();
	QHBoxLayout * hLayout2 = new QHBoxLayout(f2);
	QPushButton *button2 = new QPushButton("Choose");
	button2->setFixedWidth(BUTTON_WIDTH);
	connect(button2, SIGNAL(clicked()), this, SLOT(selectStandard()));
	hLayout2->addWidget(button2);
	m_standardColorLabel = new ClickableLabel(tr("standard %1 color (%2)").arg(message.toLower()).arg(standardColor.name()), this);
	connect(m_standardColorLabel, SIGNAL(clicked()), this, SLOT(selectStandard()));
	m_standardColorLabel->setPalette(QPalette(standardColor));
	m_standardColorLabel->setAutoFillBackground(true);
	m_standardColorLabel->setMargin(MARGIN);
	hLayout2->addWidget(m_standardColorLabel);
	vLayout->addWidget(f2);

	QFrame * f3 = new QFrame();
	QHBoxLayout * hLayout3 = new QHBoxLayout(f3);
	QPushButton *button3 = new QPushButton("Custom color ...");
	button3->setFixedWidth(BUTTON_WIDTH);
	connect(button3, SIGNAL(clicked()), this, SLOT(selectCustom()));
	hLayout3->addWidget(button3);
	m_customColorLabel = new ClickableLabel("", this);
	connect(m_customColorLabel, SIGNAL(clicked()), this, SLOT(selectLastCustom()));
	setCustomColor(currentColor);
	m_customColorLabel->setMargin(MARGIN);
	hLayout3->addWidget(m_customColorLabel);
	vLayout->addWidget(f3);

	QSpacerItem * spacerItem = new QSpacerItem( 0, 10 );
	vLayout->addSpacerItem(spacerItem);

	QFrame * f4 = new QFrame();
	QHBoxLayout * hLayout4 = new QHBoxLayout(f4);
	m_selectedColorLabel = new QLabel();
	setColor(currentColor);
	hLayout4->addWidget(m_selectedColorLabel);
	m_selectedColorLabel->setMargin(4);
	vLayout->addWidget(f4);

	if (askPrefs) {
		QFrame * f5 = new QFrame();
		QHBoxLayout * hLayout5 = new QHBoxLayout(f5);
		m_prefsCheckBox = new QCheckBox(tr("Make this the default %1 color").arg(message.toLower()));
		hLayout5->addWidget(m_prefsCheckBox);
		vLayout->addWidget(f5);
	}

    QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
	buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
	buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

	vLayout->addWidget(buttonBox);

	this->setLayout(vLayout);
}