Ejemplo n.º 1
0
AddUrlsDialog::AddUrlsDialog(QWidget *parent) :
    QDialog(parent),
    m_headerModel(new SelectionModel(this)),
    m_tabBar(new QTabBar(this)),
    m_stack(new QStackedWidget(this)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical, this)),
    m_layout(new QGridLayout(this)),
    m_urlsEdit(new QTextEdit(m_stack)),
    m_settingsTab(0),
    m_categorySelector(0),
    m_prioritySelector(0),
    m_commandEdit(0),
    m_subfolderCheckBox(0),
    m_commandCheckBox(0),
    m_pluginCheckBox(0),
    m_autoCheckBox(0),
    m_methodTab(0),
    m_methodEdit(0),
    m_postEdit(0),
    m_headersTab(0),
    m_headerView(0),
    m_headerButton(0),
    m_category(Settings::defaultCategory()),
    m_method("GET"),
    m_createSubfolder(Settings::createSubfolders()),
    m_customCommandOverrideEnabled(false),
    m_usePlugins(Settings::usePlugins()),
    m_startAutomatically(Settings::startTransfersAutomatically()),
    m_priority(TransferItem::NormalPriority)
{
    setWindowTitle(tr("Add URLs"));
    setMinimumHeight(360);
    
    m_tabBar->setExpanding(false);
    m_tabBar->setStyleSheet("QTabBar::tab { height: 40px; }");
    m_tabBar->addTab(tr("URLs"));
    m_tabBar->addTab(tr("Settings"));
    m_tabBar->addTab(tr("Method"));
    m_tabBar->addTab(tr("Headers"));
    m_tabBar->setTabEnabled(2, !Settings::usePlugins());
    m_tabBar->setTabEnabled(3, !Settings::usePlugins());

    m_urlsEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    m_urlsEdit->setFocus(Qt::OtherFocusReason);
    
    m_stack->addWidget(m_urlsEdit);

    m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    
    m_layout->addWidget(m_tabBar, 0, 0);
    m_layout->addWidget(m_stack, 1, 0);
    m_layout->addWidget(m_buttonBox, 1, 1);
    m_layout->setRowStretch(1, 1);

    connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentTab(int)));
    connect(m_urlsEdit, SIGNAL(textChanged()), this, SLOT(onUrlsChanged()));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    
    showUrlsTab();
}
Ejemplo n.º 2
0
AddUrlsDialog::AddUrlsDialog(QWidget *parent) :
    QDialog(parent),
    m_categoryModel(new CategorySelectionModel(this)),
    m_headerModel(new SelectionModel(this)),
    m_tabBar(new QTabBar(this)),
    m_stack(new QStackedWidget(this)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical, this)),
    m_layout(new QGridLayout(this)),
    m_urlsTab(new QWidget(m_stack)),
    m_urlsEdit(new QTextEdit(m_urlsTab)),
    m_categorySelector(new ValueSelector(tr("Category"), m_urlsTab)),
    m_pluginCheckBox(new QCheckBox(tr("Use plugins"), m_urlsTab)),
    m_urlsLayout(new QVBoxLayout(m_urlsTab)),
    m_methodTab(0),
    m_methodEdit(0),
    m_postEdit(0),
    m_methodLayout(0),
    m_headersTab(0),
    m_headerView(0),
    m_headerButton(0),
    m_headerLayout(0),
    m_method("GET")
{
    setWindowTitle(tr("Add URLs"));
    setMinimumHeight(360);
    
    m_tabBar->addTab(tr("URLs"));
    m_tabBar->addTab(tr("Method"));
    m_tabBar->addTab(tr("Headers"));
    m_tabBar->setTabEnabled(1, !Settings::usePlugins());
    m_tabBar->setTabEnabled(2, !Settings::usePlugins());
        
    m_urlsEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    m_urlsEdit->setFocus(Qt::OtherFocusReason);
    
    m_categorySelector->setModel(m_categoryModel);
    m_categorySelector->setValue(Settings::defaultCategory());
    
    m_pluginCheckBox->setChecked(Settings::usePlugins());
    
    m_urlsLayout->addWidget(m_urlsEdit);
    m_urlsLayout->addWidget(m_categorySelector);
    m_urlsLayout->addWidget(m_pluginCheckBox);
    
    m_urlsLayout->setContentsMargins(0, 0, 0, 0);
    
    m_stack->addWidget(m_urlsTab);

    m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    
    m_layout->addWidget(m_tabBar, 0, 0);
    m_layout->addWidget(m_stack, 1, 0);
    m_layout->addWidget(m_buttonBox, 1, 1);
    m_layout->setRowStretch(1, 1);

    connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentTab(int)));
    connect(m_urlsEdit, SIGNAL(textChanged()), this, SLOT(onUrlsChanged()));
    connect(m_pluginCheckBox, SIGNAL(toggled(bool)), this, SLOT(onUsePluginsChanged(bool)));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    
    showUrlsTab();
}