void SendFileTreeWidget::retranslateUi()
{
    QStringList headers;
    headers << "#" << tr("Name") << tr("Progress") << tr("Rate") <<tr("Size") << tr("Remain") << tr("Total") <<tr("Completed") << tr("State");
    this->setHeaderLabels(headers);
    QFontMetrics fm = fontMetrics();
    QHeaderView *header = this->header();
    header->resizeSection(0, qMax(fm.width(headers.at(0)+" ## "), fm.width(" ## ")));
    header->resizeSection(1, qMax(fm.width(headers.at(1)+ "####"), fm.width(" name-for-a-file.ext ")) );
    header->resizeSection(2, qMax(fm.width(headers.at(2)+"####"), fm.width("Progress")));
    header->resizeSection(3, qMax(fm.width(headers.at(3)+"####"), fm.width(" 999Kb/s ")));
    header->resizeSection(4, qMax(fm.width(headers.at(4)+"####"), fm.width(" 999Mb ")) );
    header->resizeSection(5, qMax(fm.width(headers.at(5)+"####"), fm.width(" hh:mm:ss ")) );
    header->resizeSection(6, qMax(fm.width(headers.at(6)+"####"), fm.width(" hh:mm:ss ")) );
    header->resizeSection(7, qMax(fm.width(headers.at(6)+"####"), fm.width(" 999Mb/999Mb ")) );
    header->resizeSection(8, qMax(fm.width(headers.at(7)+"####"), fm.width(" transfing... ")) );
    header->setHighlightSections(true);
}
Beispiel #2
0
pTableWidget::pTableWidget(QWidget *parent) :
    QTableWidget(parent),
    m_defaultSortedColumn(0)
{
    setSortingEnabled(true);

    QHeaderView *header;

    // Horizontal header
    header = horizontalHeader();
    header->setHighlightSections(false);
    header->setSortIndicatorShown(false);
    header->setDefaultSectionSize(50);
    header->show();

    // Vertical header
    header = verticalHeader();
    header->setDefaultSectionSize(21);
    header->hide();

    // Frame
    //setFrameStyle(QFrame::NoFrame);

    setSelectionMode(QAbstractItemView::SingleSelection);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setEditTriggers(QAbstractItemView::NoEditTriggers);

    setAlternatingRowColors(true);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));

    connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(updateToolButtonNumber()));
}
UpdateCenterImpl::UpdateCenterImpl(Updates *updates, bool autoDownloadAndInstall, QWidget * parent, Qt::WindowFlags f)
		: QDialog(parent, f)
{
	setupUi(this);
	// resize for macosx
#ifndef Q_OS_WIN32
	resize(630, 366);
#endif
	closedByButton = false;
	// version
	lblxVSTVersion->setText(QString(lblxVSTVersion->text()).arg(PROGRAM_VERSION));
	// set update class
	this->updates = updates;
	// configure updates list
	QStringList headers;
	headers << tr(" File ") << tr(" Version ") << tr(" Size ") << tr(" Progress ");
	// add the headers
	lsvUpdates->setHeaderLabels(headers);
	// change headers sizes
	QFontMetrics fm = fontMetrics();
	QHeaderView *header = lsvUpdates->header();
	// resize
	header->resizeSection(1, fm.width(headers.at(0) + "9.99.999 alpha"));
	header->resizeSection(2, fm.width(headers.at(1) + " 1024,99Mb "));
	// configure resize mode
	header->setHighlightSections(false);
	header->setStretchLastSection(false);
    header->setSectionResizeMode(0, QHeaderView::Stretch);
	// set header text aligment
	QTreeWidgetItem * headerItem = lsvUpdates->headerItem();
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(2, Qt::AlignRight   | Qt::AlignVCenter);
	headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
	// fill data
	fillUpdates();
	// signals
	connect(lsvUpdates, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*, int)));
	connect(btnCancel, SIGNAL(clicked()), this, SLOT(btnCancelClicked()));
	connect(btnUpdate, SIGNAL(clicked()), this, SLOT(btnUpdateClicked()));
	// updater
	connect(updates, SIGNAL(downloadingUpdate(int, int, int)), this, SLOT(downloadingUpdate(int, int, int)));
	connect(updates, SIGNAL(downloadUpdateFinished(int)), this, SLOT(downloadUpdateFinished(int)));
	connect(updates, SIGNAL(downloadUpdateError(int)), this, SLOT(downloadUpdateError(int)));
	connect(updates, SIGNAL(downloadsFinished()), this, SLOT(downloadsFinished()));
	connect(updates, SIGNAL(readyToInstallUpdates()), this, SLOT(readyToInstallUpdates()));
	connect(updates, SIGNAL(failedToInstallUpdates()), this, SLOT(failedToInstallUpdates()));
	// if auto download & install updates, then...
	if (autoDownloadAndInstall)
	{
		// disable update button
		lsvUpdates->setEnabled(false);
		btnUpdate->setEnabled(false);
		// start automatically to download updates (in 500ms)
		QTimer::singleShot(500, this, SLOT(btnUpdateClicked()));
	}
}
QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
    const QgsFields& fields,
    QWidget* parent ):
    QWidget( parent ), mActions( actions )
{
  setupUi( this );
  QHeaderView *header = attributeActionTable->horizontalHeader();
  header->setHighlightSections( false );
  header->setStretchLastSection( true );
  attributeActionTable->setColumnWidth( 0, 100 );
  attributeActionTable->setColumnWidth( 1, 230 );
  attributeActionTable->setCornerButtonEnabled( false );

  connect( attributeActionTable, SIGNAL( itemSelectionChanged() ),
           this, SLOT( itemSelectionChanged() ) );
  connect( actionName, SIGNAL( textChanged( QString ) ), this, SLOT( updateButtons() ) );
  connect( actionAction, SIGNAL( textChanged() ), this, SLOT( updateButtons() ) );

  connect( moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
  connect( moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
  connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
  connect( addDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) );

  connect( browseButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
  connect( insertButton, SIGNAL( clicked() ), this, SLOT( insert() ) );
  connect( updateButton, SIGNAL( clicked() ), this, SLOT( update() ) );
  connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) );
  connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) );

  connect( chooseIconButton, SIGNAL( clicked() ), this, SLOT( chooseIcon() ) );

  init();
  // Populate the combo box with the field names. Will the field names
  // change? If so, they need to be passed into the init() call, or
  // some access to them retained in this class.
  for ( int idx = 0; idx < fields.count(); ++idx )
    fieldComboBox->addItem( fields[idx].name() );
}
Beispiel #5
0
/** Default constructor */
ShareManager::ShareManager()
  : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{
    /* Invoke Qt Designer generated QObject setup routine */
    ui.setupUi(this);

    ui.headerFrame->setHeaderImage(QPixmap(":/images/fileshare64.png"));
    ui.headerFrame->setHeaderText(tr("Share Manager"));

    isLoading = false;
    load();

    Settings->loadWidgetInformation(this);

    connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( showShareDialog() ) );
    connect(ui.editButton, SIGNAL(clicked( bool ) ), this , SLOT( editShareDirectory() ) );
    connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
    connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(applyAndClose()));

    connect(ui.shareddirList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(shareddirListCostumPopupMenu(QPoint)));
    connect(ui.shareddirList, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(shareddirListCurrentCellChanged(int,int,int,int)));

    connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(updateGroups()));

    ui.editButton->setEnabled(false);
    ui.removeButton->setEnabled(false);

    QHeaderView* header = ui.shareddirList->horizontalHeader();
    QHeaderView_setSectionResizeModeColumn(header, COLUMN_PATH, QHeaderView::Stretch);

    //header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::Fixed);
    //header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::Fixed);

    header->setHighlightSections(false);

    setAcceptDrops(true);
    setAttribute(Qt::WA_DeleteOnClose, true);
}
QgsAttributeActionDialog::QgsAttributeActionDialog( const QgsActionManager& actions, QWidget* parent )
    : QWidget( parent )
    , mLayer( actions.layer() )
{
  setupUi( this );
  QHeaderView* header = mAttributeActionTable->horizontalHeader();
  header->setHighlightSections( false );
  header->setStretchLastSection( true );
  mAttributeActionTable->setColumnWidth( 0, 100 );
  mAttributeActionTable->setColumnWidth( 1, 230 );
  mAttributeActionTable->setCornerButtonEnabled( false );
  mAttributeActionTable->setEditTriggers( QAbstractItemView::AnyKeyPressed | QAbstractItemView::SelectedClicked );

  connect( mAttributeActionTable, SIGNAL( itemDoubleClicked( QTableWidgetItem* ) ), this, SLOT( itemDoubleClicked( QTableWidgetItem* ) ) );
  connect( mAttributeActionTable, SIGNAL( itemSelectionChanged() ), this, SLOT( updateButtons() ) );
  connect( mMoveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
  connect( mMoveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
  connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
  connect( mAddButton, SIGNAL( clicked( bool ) ), this, SLOT( insert() ) );
  connect( mAddDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) );

  init( actions, mLayer->attributeTableConfig() );
}
Beispiel #7
0
SalesOrderManager::SalesOrderManager(QWidget* parent)
    : QSplitter(parent)
{
    model = new SalesOrderModel(this);
    proxyModel = new SalesOrderProxyModel(this);
    proxyModel->setSourceModel(model);

    QWidget* container = new QWidget(this);
    QBoxLayout* containerLayout = new QVBoxLayout(container);
    containerLayout->setMargin(0);

    QString actionTooltip("%1<br><b>%2</b>");
    QToolBar* toolBar = new QToolBar(container);
    toolBar->setIconSize(QSize(16, 16));
    QAction* refreshAction = toolBar->addAction(QIcon(":/resources/icons/refresh.png"), "&Muat Ulang", this, SLOT(refresh()));
    refreshAction->setShortcut(QKeySequence("F5"));
    refreshAction->setToolTip(actionTooltip.arg("Muat ulang daftar pesanan").arg(refreshAction->shortcut().toString()));

    QAction* newAction = toolBar->addAction(QIcon(":/resources/icons/plus.png"), "&Baru", this, SLOT(openEditor()));
    newAction->setShortcut(QKeySequence("Ctrl+N"));
    newAction->setToolTip(actionTooltip.arg("Pesanan baru").arg(newAction->shortcut().toString()));

    QAction* closeTabAction = new QAction(this);
    closeTabAction->setShortcuts(QList<QKeySequence>({QKeySequence("Esc"), QKeySequence("Ctrl+W")}));
    addAction(closeTabAction);

    QAction* closeAllTabsAction = new QAction(this);
    closeAllTabsAction->setShortcut(QKeySequence("Ctrl+Shift+W"));
    addAction(closeAllTabsAction);

    containerLayout->addWidget(toolBar);

    QLabel* spacer = new QLabel(toolBar);
    spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    toolBar->addWidget(spacer);

    stateComboBox = new QComboBox(toolBar);
    stateComboBox->setToolTip("Saring daftar pesanan berdasarkan status");
    stateComboBox->addItem("Semua");
    stateComboBox->addItem("Aktif");
    stateComboBox->addItem("Selesai");
    stateComboBox->addItem("Dibatalkan");
    stateComboBox->setCurrentIndex(1);
    toolBar->addWidget(stateComboBox);

    searchEdit = new QLineEdit(toolBar);
    searchEdit->setToolTip("Cari di daftar pesanan");
    searchEdit->setPlaceholderText("Cari");
    searchEdit->setClearButtonEnabled(true);
    searchEdit->setMaxLength(100);
    searchEdit->setMaximumWidth(150);
    toolBar->addWidget(searchEdit);

    view = new QTableView(container);
    view->setToolTip("Klik ganda atau ketuk Enter untuk membuka pesanan");
    view->setModel(proxyModel);
    view->setAlternatingRowColors(true);
    view->setSortingEnabled(true);
    view->setSelectionMode(QAbstractItemView::SingleSelection);
    view->setSelectionBehavior(QAbstractItemView::SelectRows);
    view->setTabKeyNavigation(false);
    QHeaderView* header = view->verticalHeader();
    header->setVisible(false);
    header->setMinimumSectionSize(20);
    header->setMaximumSectionSize(20);
    header->setDefaultSectionSize(20);
    header = view->horizontalHeader();
    header->setToolTip("Klik pada header kolom untuk mengurutkan");
    header->setHighlightSections(false);

    containerLayout->addWidget(view);

    infoLabel = new QLabel(container);
    infoLabel->setStyleSheet("font-style:italic;padding-bottom:1px;");
    infoLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
    containerLayout->addWidget(infoLabel);

    tabWidget = new QTabWidget(this);
    tabWidget->setDocumentMode(true);
    tabWidget->setTabsClosable(true);
    tabWidget->setMovable(true);
    tabWidget->hide();

    setCollapsible(0, false);
    setCollapsible(1, false);

    connect(closeTabAction, SIGNAL(triggered(bool)), SLOT(closeCurrentTab()));
    connect(closeAllTabsAction, SIGNAL(triggered(bool)), SLOT(closeAllTabs()));
    connect(tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)));
    connect(stateComboBox, SIGNAL(currentIndexChanged(int)), SLOT(refresh()));
    connect(searchEdit, SIGNAL(textChanged(QString)), SLOT(applyFilter()));
    connect(view, SIGNAL(activated(QModelIndex)), SLOT(edit()));

    QTimer::singleShot(0, this, SLOT(init()));
}
Beispiel #8
0
//--------------------------------------------------------------------------------------
//! Defines the NDP2k network device page (shows the devices)
//--------------------------------------------------------------------------------------
tNDP2kDevicePage::tNDP2kDevicePage(tNDP2k& ndp2k, QWidget* pParent, bool showButtons, const QList<eColumns> customColumnList )
    : tDialog(tDialog::Full, pParent)
    , m_pNDP2k( &ndp2k )
    , m_FirstRefresh ( true )
    , m_FirstRun( true )
    , m_tableRefreshMode( false )
    , m_ShowNameColumn( false ) // For debugging purposes 
    , m_ShowButtons( showButtons )
{
    setWindowTitle( tr( "Device List", "NDP2k device list dialog title" ) );

    m_ColumnName[addressColumn] = tr("Address");
    m_ColumnName[modelIdColumn] = tr("Model ID");
    m_ColumnName[manufacturerColumn] = tr("Manufacturer");
    m_ColumnName[productCodeColumn] = tr("Product Code");
    m_ColumnName[classFunctionColumn] = tr("Class/Function");
    m_ColumnName[nameColumn] = tr("ISO Name");
    m_ColumnName[busUsageColumn] = tr("Bus %");
    m_ColumnName[deviceInstanceColumn] = tr("Instance");
    m_ColumnName[serialNumberColumn] = tr("Serial No.");

    // keep name last - it is hidden & not in sort list.
    if( false == customColumnList.isEmpty() )
    {
        m_DisplayColumns = customColumnList;
    }
    else
    {
        m_DisplayColumns = (QList<eColumns>() << modelIdColumn << serialNumberColumn);
    }

    if( tNdp2kSettings::Instance()->GetDebugEnabled() )
    {
        m_DisplayColumns << addressColumn;
        m_ShowNameColumn = true;
    }
    m_DisplayColumns << nameColumn;

    assert(m_DisplayColumns.contains(nameColumn));
    m_NameColumn = m_DisplayColumns.indexOf(nameColumn);

    m_SortOptionList = QStringList();
    m_SortOption = 0;
    for(int i = 0; i < m_DisplayColumns.count(); i++)
    {
        if( m_DisplayColumns[i] != nameColumn || m_ShowNameColumn )
        {
            m_SortOptionList << m_ColumnName[m_DisplayColumns[i]];
        }
    }

    // if we have a SKB keys don't have focus, else hide keys 
    m_NumKeys = 0;
    if ( HasSoftKeyBar() )
    {
        m_NumKeys = SoftKeyBar()->numSoftKeys(); 
        SoftKeyBar()->SetSoftKeyFocusPolicy(Qt::NoFocus);
    }
    else
    {
        SoftKeyBar()->ExplicitHide();
    }
    CreateActions();
    Connect( this, SIGNAL( CloseRequested() ), this, SLOT( accept() ) );

    m_pTableWidget = new tTableWidget(0, m_DisplayColumns.count(), this);
    m_pTableWidget->setFocusPolicy(Qt::StrongFocus);
    m_pTableWidget->setEditTriggers( QAbstractItemView::NoEditTriggers );
    m_pTableWidget->verticalHeader()->hide();
    m_pTableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    m_pTableWidget->SetSoleFocus( true );
    m_pTableWidget->SetWrapping( true );

    if( tUiSettings::Instance()->ShowTouchToolTips() == true )
    {
        m_pTableWidget->setToolTip( tr("Tap-and-hold for more options.") );
    }
    else
    {
        m_pTableWidget->setToolTip( tr("Press %1 for more options.").arg(BUTTON_HTML(tNOSStyle::FP_ButtonImageMENU, "MENU")) ); 
    }

    Connect( m_pTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( SelectionChanged() ) );
    Connect( m_pTableWidget, SIGNAL( itemClicked( QTableWidgetItem* ) ), m_pDetailsAct, SLOT( trigger() ) );

    QHeaderView* pHeaderView = m_pTableWidget->horizontalHeader();
    // Prevents header bold font
    pHeaderView->setHighlightSections(false);
    pHeaderView->setDefaultAlignment(Qt::AlignLeft);
    Connect( pHeaderView, SIGNAL( sectionClicked( int ) ), this, SLOT( SetSortOption( int ) ) );
    SetHeaderFont();

    for(int i = 0; i < m_DisplayColumns.count(); i++)
    {
        switch(m_DisplayColumns[i])
        {
        case addressColumn:
        case manufacturerColumn:
        case productCodeColumn:
        case busUsageColumn:
        case deviceInstanceColumn:
        case serialNumberColumn:
        default:
            {
                pHeaderView->setResizeMode(i, QHeaderView::ResizeToContents);
            }
            break;

        case modelIdColumn:
        case SwVersionColumn:
        case classFunctionColumn:
            {
                pHeaderView->setResizeMode(i, QHeaderView::Stretch);
            }
            break;

        case nameColumn:
            {
                if( m_ShowNameColumn )
                {
                    pHeaderView->setResizeMode(i, QHeaderView::Stretch);
                }
                else
                {
                    pHeaderView->setResizeMode(i, QHeaderView::Fixed);
                    pHeaderView->resizeSection(i, 0); // hide it this way. (actual hide breaks sorting.)
                }
            }
            break;
        }
    }

    QStringList headings;
    for(int i = 0; i < m_DisplayColumns.count(); i++)
    {
        headings << m_ColumnName[m_DisplayColumns[i]];
    }
    m_pTableWidget->setHorizontalHeaderLabels(headings);

    QVBoxLayout* pVLayout = new QVBoxLayout;
    pVLayout->addWidget(m_pTableWidget);
    setLayout(pVLayout);

    tNDP2k* pNDP2k = tGlobal<tNDP2k>::Instance();
    Connect(&pNDP2k->DeviceManager(), SIGNAL(DeviceListChanged(const tN2kName&)), this, SLOT(OnDeviceChanged(const tN2kName&)));

    /* Set the bus status on startup... */
    if(pNDP2k->IsBusOff())
    {
        m_IsBusOff = true;
    }
    else
    {
        m_IsBusOff = false;
    }

    m_SelectedName = "";
    
    //NSW-7687 (Work around LGC-4k unreliable response to global request for address claim...)
    // - No longer required - since we no longer do a global request for address claim.
    RefreshDeviceList();
    // initial row selected in UpdateDeviceList, when we have some content

    startTimer(1000);
    //TODO: tNotificationAndStatusMonitor::Instance()->SetVesselShow(false);

    if ( tProductSettings::Instance().GetProductFamily() == tProductSettings::MedusaFamily )
    {
        Connect( tApOperation::Instance(), SIGNAL( ApModeChanged(tPilotCommandInterface::tPilotMode) ), this, SLOT( OnApModeChanged(tPilotCommandInterface::tPilotMode) ) );
        OnApModeChanged( tApOperation::Instance()->GetApMode() ); // Init text
    }

    if( tProductSettings::Instance().ScreenPixelWidth() < 480 )
    {
        pVLayout->setMargin(0);
    }
}
//--------------------------------------------------------------------------------------
//! The AIS Safety and DSC distress message page
//--------------------------------------------------------------------------------------
tVesselMessagesTabPage::tVesselMessagesTabPage( int numKeys, bool soleFocus, QWidget* pParent )
: QWidget( pParent ), m_NumKeys(numKeys)
{
    m_pTableTitle = new QLabel( tr( "Messages", "[title]" ), this );
    m_pTableTitle->hide();

    CreateActions();

    m_pMessageTable = new tTableWidget( 0, columnCount, this );
    m_pMessageTable->setFrameShape( QFrame::NoFrame );
    m_pMessageTable->SetSoleFocus( soleFocus );
    m_pMessageTable->SetWrapping( soleFocus == true );
    m_pMessageTable->hideColumn( mmsiColumn );
    m_pMessageTable->hideColumn( sourceTypeColumn );
    m_pMessageTable->hideColumn( uidColumn );
    Connect( m_pMessageTable, SIGNAL( itemClicked( QTableWidgetItem* ) ), m_pDetailsAct, SLOT( trigger() ) );

    QHeaderView* pHorizontalHeaderView = m_pMessageTable->horizontalHeader();
    pHorizontalHeaderView->setClickable( false );
    pHorizontalHeaderView->setResizeMode( timeColumn, QHeaderView::Fixed );
    pHorizontalHeaderView->setResizeMode( messageColumn, QHeaderView::Stretch );

    QString timeString = QString( tr( "Time", "[title]" ) );
    QSize headerTextSize = pHorizontalHeaderView->fontMetrics().size( 0, timeString );
    m_maxTimeWidth = headerTextSize.width() + 10;
    pHorizontalHeaderView->resizeSection( timeColumn, m_maxTimeWidth );

    QStringList headings;
    headings << timeString << tr( "Message", "[title]" );
    m_pMessageTable->setHorizontalHeaderLabels( headings );
    SetHeaderFont();

    // Prevents header bold font
    pHorizontalHeaderView->setHighlightSections( false );
    pHorizontalHeaderView->setDefaultAlignment( Qt::AlignLeft );

    QHeaderView* pVerticalHeaderView = m_pMessageTable->verticalHeader();
    pVerticalHeaderView->hide();
    pVerticalHeaderView->setResizeMode( QHeaderView::Fixed );
    pVerticalHeaderView->setDefaultSectionSize( QFontMetrics( QApplication::font() ).height() * 2 + 10 );

    QVBoxLayout* pVLayout = new QVBoxLayout( this );
    pVLayout->setContentsMargins( 0, 0, 0, 0 );

    pVLayout->addWidget( m_pTableTitle );
    pVLayout->addWidget( m_pMessageTable );

    setLayout( pVLayout );

    m_pResizeTimer = new QTimer( this );
    Connect( m_pResizeTimer, SIGNAL(timeout()), this, SLOT( Resize() ) );

    RefreshTable();
    m_pMessageTable->selectRow( 0 );

    if ( tProductSettings::Instance().AISAllowed() == true )
    {
        tAisEngine* pAisEngine = tGlobal<tAisEngine>::Instance();
        Connect( pAisEngine, SIGNAL( NewSafetyMessage( tAisSafetyMessage ) ), this, SLOT( NewAisSafetyMessage( const tAisSafetyMessage& ) ) );
        Connect( pAisEngine, SIGNAL( RemoveSafetyMessage( int ) ), this, SLOT( RemoveAisSafetyMessage( int ) ) );
    }
Beispiel #10
0
DlRawfileDescTab::DlRawfileDescTab(QWidget* parent, DlProject* dlProject) :
    QWidget(parent),
    dlProject_(dlProject),
    rawSettingsDialog(nullptr),
    fieldSepTOB1Flag_(false)
{
    DEBUG_FUNC_NAME

    variableView_ = new VariableView(this);
    variableModel_ = new VariableModel(variableView_, dlProject_->variables());
    variableDelegate_ = new VariableDelegate(variableView_);

    variableView_->setModel(variableModel_);
    variableView_->setItemDelegate(variableDelegate_);
    variableView_->setSelectionMode(QAbstractItemView::SingleSelection);
    variableView_->setSelectionBehavior(QAbstractItemView::SelectColumns);
    variableView_->setCornerButtonEnabled(false);
    variableView_->setWordWrap(false);

    QHeaderView *hHeaderView = variableView_->horizontalHeader();
    hHeaderView->setDefaultSectionSize(175);
    hHeaderView->setSectionResizeMode(QHeaderView::Fixed);
    hHeaderView->setSectionsClickable(true);
    hHeaderView->setHighlightSections(true);
    hHeaderView->setSectionsMovable(false);

    variableView_->setMinimumHeight(298);
    variableView_->resizeRowsToContents();
    variableView_->resizeColumnsToContents();
    for (int i = 0; i < variableModel_->rowCount(); i++)
    {
        variableView_->verticalHeader()->resizeSection(i, 20);
    }

    auto addButton = new QToolButton;
    addButton->setObjectName(QStringLiteral("plusButton"));
    addButton->setToolTip(tr("<b>+</b> Add a variable."));

    auto removeButton = new QToolButton;
    removeButton->setObjectName(QStringLiteral("minusButton"));
    removeButton->setToolTip(tr("<b>-</b> Remove a variable."));

    auto buttonsLayout = new QVBoxLayout;
    buttonsLayout->addWidget(addButton);
    buttonsLayout->addWidget(removeButton);
    buttonsLayout->addStretch();

    rawSettingsButton = new QPushButton(tr("Raw File Settings..."));
    rawSettingsButton->setProperty("mdButton", true);
    rawSettingsButton->setStyleSheet(QStringLiteral("QPushButton {margin-top: 15px}"));

    clearCustomVarsButton = new QPushButton(tr("Clear Custom Variables"));
    clearCustomVarsButton->setProperty("mdButton", true);
    clearCustomVarsButton->setStyleSheet(QStringLiteral("QPushButton {margin-top: 15px}"));

    auto varLayout = new QGridLayout;
    varLayout->addWidget(variableView_, 0, 0, -1, 1);
    varLayout->addLayout(buttonsLayout, 0, 1, 1, 1);
    varLayout->setColumnStretch(0, 1);
    varLayout->setColumnStretch(1, 0);
    varLayout->setRowStretch(2, 0);
    varLayout->setSizeConstraint(QLayout::SetNoConstraint);

    auto varGroup = new QGroupBox(tr("Data Columns Info"));
    varGroup->setObjectName(QStringLiteral("simpleGroupBox"));
    varGroup->setFlat(true);
    varGroup->setLayout(varLayout);

    auto varScrollArea = new QScrollArea;
    varScrollArea->setWidget(varGroup);
    varScrollArea->setWidgetResizable(true);

    auto mainlayout = new QGridLayout(this);
    mainlayout->setRowMinimumHeight(0, 18);
    mainlayout->addWidget(rawSettingsButton, 1, 0, 1, 1, Qt::AlignTop);
    mainlayout->addWidget(clearCustomVarsButton, 2, 0, 1, 1, Qt::AlignTop);
    mainlayout->addWidget(varScrollArea, 0, 1, -1, -1);
    mainlayout->setRowStretch(3, 1);
    mainlayout->setColumnStretch(1, 1);
    mainlayout->setSizeConstraint(QLayout::SetNoConstraint);
    setLayout(mainlayout);

    connect(variableModel_, &VariableModel::modified, [=]()
            { dlProject_->setModified(true); });

    connect(dlProject, &DlProject::projectModified,
            this, &DlRawfileDescTab::updateModels);

    connect(dlProject, &DlProject::projectChanged,
            this, &DlRawfileDescTab::updateModels);

    connect(addButton, &QToolButton::clicked,
            variableView_, &VariableView::addVar);
    connect(removeButton, &QToolButton::clicked,
            variableView_, &VariableView::removeVar);

    connect(rawSettingsButton, &QPushButton::clicked,
            this, &DlRawfileDescTab::showRawSettingsDialog);

    connect(clearCustomVarsButton, &QPushButton::clicked,[=]()
            { variableDelegate_->clearCustomVariableBuffer(); });

    // to trigger table editing with single click without altering the
    // editTriggers property, because that way the column selection
    // clicking on the header trigger the first cell editor
    connect(variableView_, SIGNAL(clicked(const QModelIndex &)),
            variableView_, SLOT(edit(const QModelIndex &)));
}
Beispiel #11
0
Info::Info(QWidget *parent) :
QWidget(parent)
{
	setObjectName("Info");
	isStay = isPoped = updating = false;
	Utils::setGround(this, Qt::white);
	duration = -1;
	animation = new QPropertyAnimation(this, "pos", this);
	animation->setDuration(200);
	animation->setEasingCurve(QEasingCurve::OutCubic);
	timeT = new QLabel(tr("Time"), this);
	volmT = new QLabel(tr("Volume"), this);
	timeS = new QSlider(this);
	volmS = new QSlider(this);
	timeS->setOrientation(Qt::Horizontal);
	volmS->setOrientation(Qt::Horizontal);
	timeS->setRange(0, 0);
	volmS->setRange(0, 100);
	timeS->setValue(0);
	volmS->setValue(Config::getValue("/Playing/Volume", 50));
	timeS->setTracking(false);
	connect(timeS, &QSlider::valueChanged, [this](int _time){
		if (duration != -1 && !updating){
			APlayer::instance()->setTime(duration*_time / 400);
		}
	});
	connect(volmS, &QSlider::sliderMoved, [this](int _volm){
		QPoint p;
		p.setX(QCursor::pos().x());
		p.setY(volmS->mapToGlobal(volmS->rect().center()).y());
		QToolTip::showText(p, QString::number(_volm));
	});
	connect(volmS, &QSlider::valueChanged, [this](int _volm){
		if (!updating){
			APlayer::instance()->setVolume(_volm);
		}
	});
	playB = new QPushButton(this);
	stopB = new QPushButton(this);
	playI = QIcon::fromTheme("media-playback-start", QIcon(":/Picture/play.png"));
	stopI = QIcon::fromTheme("media-playback-stop", QIcon(":/Picture/stop.png"));
	pausI = QIcon::fromTheme("media-playback-pause", QIcon(":/Picture/pause.png"));
	playB->setIcon(playI);
	stopB->setIcon(stopI);
	playA = new QAction(playI, tr("Play"), this);
	stopA = new QAction(stopI, tr("Stop"), this);
	playA->setObjectName("Play");
	stopA->setObjectName("Stop");
	QList<QKeySequence> playS;
	playS << Config::getValue("/Shortcut/Play", QString("Space")) <<
		Qt::Key_MediaPlay <<
		Qt::Key_MediaPause <<
		Qt::Key_MediaTogglePlayPause;
	playA->setShortcuts(playS);
	stopA->setShortcut(Config::getValue("/Shortcut/Stop", QString()));
	addAction(playA);
	addAction(stopA);
	connect(playA, SIGNAL(triggered()), APlayer::instance(), SLOT(play()));
	connect(stopA, SIGNAL(triggered()), APlayer::instance(), SLOT(stop()));
	connect(playB, &QPushButton::clicked, playA, &QAction::trigger);
	connect(stopB, &QPushButton::clicked, stopA, &QAction::trigger);
	duraT = new QLabel(this);
	duraT->setAlignment(Qt::AlignRight | Qt::AlignBottom);
	duraT->setText("00:00/00:00");
	danmV = new MTableView(this);
	danmV->setWordWrap(false);
	danmV->setSelectionBehavior(QAbstractItemView::SelectRows);
	danmV->setSelectionMode(QAbstractItemView::ExtendedSelection);
	danmV->verticalHeader()->hide();
	danmV->setAlternatingRowColors(true);
	danmV->setContextMenuPolicy(Qt::CustomContextMenu);
	danmV->setModel(Danmaku::instance());
	QHeaderView *header;
	header = danmV->horizontalHeader();
	header->setSectionResizeMode(0, QHeaderView::Fixed);
	header->setSectionResizeMode(1, QHeaderView::Stretch);
	header->setHighlightSections(false);
	resizeHeader();
	header = danmV->verticalHeader();
	header->setDefaultSectionSize(22.5*logicalDpiY() / 72);
	connect(Danmaku::instance(), &Danmaku::layoutChanged, this, &Info::resizeHeader);
	connect(danmV, &QTableView::doubleClicked, [this](QModelIndex index){
		APlayer::instance()->setTime(((Comment *)(index.data(Qt::UserRole).value<quintptr>()))->time);
	});

	QAction *saveA = new QAction(tr("Save Danmaku to File"), this);
	saveA->setObjectName("Save");
	saveA->setShortcut(Config::getValue("/Shortcut/Save", QString()));
	saveA->setEnabled(false);
	connect(saveA, &QAction::triggered, [](){
		QFileDialog save(lApp->mainWidget(), tr("Save File"));
		save.setAcceptMode(QFileDialog::AcceptSave);
		QFileInfo info(APlayer::instance()->getMedia());
		if (info.isFile()){
			save.setDirectory(info.absolutePath());
			save.selectFile(info.completeBaseName());
		}
		else{
			save.setDirectory(List::instance()->defaultPath(Utils::Danmaku));
		}
		save.setDefaultSuffix("json");
		QStringList type;
		type << tr("Bilibili Danmaku Format (*.xml)") << tr("AcFun Danmaku Format (*.json)");
		save.setNameFilters(type);
		save.connect(&save, &QFileDialog::filterSelected, [&](QString filter){
			save.setDefaultSuffix(filter.indexOf("xml") == -1 ? "json" : "xml");
		});
		if (save.exec() == QDialog::Accepted){
			QStringList file = save.selectedFiles();
			if (file.size() == 1){
				Danmaku::instance()->saveToFile(file.first());
			}
		}
	});
	danmV->addAction(saveA);

	QAction *fullA = new QAction(tr("Full Danmaku"), this);
	fullA->setObjectName("Char");
	fullA->setShortcut(Config::getValue("/Shortcut/Char", QString()));
	fullA->setEnabled(false);
	connect(fullA, &QAction::triggered, [](){
		Load *load = Load::instance();
		for (const Record &r : Danmaku::instance()->getPool()){
			if (load->canFull(&r)){
				load->fullDanmaku(&r);
			}
		}
	});
	danmV->addAction(fullA);

	connect(Danmaku::instance(), &Danmaku::modelReset, [=](){
		const QList<Record> &pool = Danmaku::instance()->getPool();
		fullA->setEnabled(false);
		for (const Record &r : pool){
			if (Load::instance()->canFull(&r)){
				fullA->setEnabled(true);
				break;
			}
		}
		saveA->setEnabled(!pool.isEmpty());
	});

	connect(danmV, &QTableView::customContextMenuRequested, [=](QPoint p){
		QMenu menu(this);
		QList<const Comment *>selected;
		for (const QModelIndex &index : danmV->selectionModel()->selectedRows()){
			selected.append((Comment *)index.data(Qt::UserRole).value<quintptr>());
		}
		if (!selected.isEmpty()){
			connect(menu.addAction(tr("Copy Danmaku")), &QAction::triggered, [&](){
				QStringList list;
				for (const Comment *c : selected){
					list.append(c->string);
				}
				qApp->clipboard()->setText(list.join('\n'));
			});
			connect(menu.addAction(tr("Eliminate The Sender")), &QAction::triggered, [&](){
				for (const Comment *c : selected){
					if (!c->sender.isEmpty()){
						Shield::instance()->insert("u=" + c->sender);
					}
				}
				Danmaku::instance()->parse(0x2);
			});
			for (const Comment *c : selected){
				if (Shield::instance()->contains("u=" + c->sender)){
					connect(menu.addAction(tr("Recover The Sender")), &QAction::triggered, [&](){
						for (const Comment *c : selected){
							Shield::instance()->remove("u=" + c->sender);
						}
						Danmaku::instance()->parse(0x2);
					});
					break;
				}
			}
			menu.addSeparator();
		}
		menu.addAction(fullA);
		connect(menu.addAction(tr("Edit Blocking List")), &QAction::triggered, [this](){
			Prefer::exec(lApp->mainWidget(), 3);
		});
		connect(menu.addAction(tr("Edit Danmaku Pool")), &QAction::triggered, [this](){
			Editor::exec(lApp->mainWidget(), 2);
		});
		connect(menu.addAction(tr("Clear Danmaku Pool")), &QAction::triggered, Danmaku::instance(), &Danmaku::clearPool);
		menu.addAction(saveA);
		isStay = 1;
		menu.exec(danmV->viewport()->mapToGlobal(p));
		isStay = 0;
	});

	animation = new QPropertyAnimation(this, "pos", this);
	animation->setDuration(200);
	animation->setEasingCurve(QEasingCurve::OutCubic);
	connect(animation, &QPropertyAnimation::finished, [this](){
		if (!isPoped){
			hide();
			lApp->mainWidget()->setFocus();
		}
	});

	connect(APlayer::instance(), &APlayer::timeChanged, this, &Info::setTime);
	connect(APlayer::instance(), &APlayer::volumeChanged, [this](int volume){
		updating = 1;
		volmS->setValue(volume);
		updating = 0;
	});
	connect(APlayer::instance(), &APlayer::begin, [this](){
		setDuration(APlayer::instance()->getDuration());
	});
	connect(APlayer::instance(), &APlayer::reach, [this](){
		setDuration(-1);
	});
	connect(APlayer::instance(), &APlayer::stateChanged, [this](int state){
		bool playing = state == APlayer::Play;
		playB->setIcon(playing ? pausI : playI);
		playA->setIcon(playing ? pausI : playI);
		playA->setText(playing ? tr("Pause") : tr("Play"));
	});
	hide();
}