コード例 #1
0
ファイル: fileedit.cpp プロジェクト: bjorn/tiled
FileEdit::FileEdit(QWidget *parent)
    : QWidget(parent)
    , mErrorTextColor(Qt::red)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

    mLineEdit = new QLineEdit(this);
    mLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));

    mOkTextColor = mLineEdit->palette().color(QPalette::Active, QPalette::Text);

    QToolButton *button = new QToolButton(this);
    button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
    button->setFixedWidth(20);
    button->setText(QLatin1String("..."));
    layout->addWidget(mLineEdit);
    layout->addWidget(button);

    setFocusProxy(mLineEdit);
    setFocusPolicy(Qt::StrongFocus);
    setAttribute(Qt::WA_InputMethodEnabled);

    connect(mLineEdit, &QLineEdit::textEdited,
            this, &FileEdit::textEdited);
    connect(mLineEdit, &QLineEdit::textChanged,
            this, &FileEdit::validate);
    connect(button, &QAbstractButton::clicked,
            this, &FileEdit::buttonClicked);
}
コード例 #2
0
ファイル: settingswindow.cpp プロジェクト: gustawho/dooscape
void SettingsWindow::genReset()
{
    QLabel *textView = new QLabel;
    textView->setWordWrap(true);
    textView->setText(tr("If you click \"Start Reset\", you accept close browser (loose all opened tabs) and delete :<ul><li>Account</li><li>Color background</li><li>Home Page</li><li>Elements of Interface</li><li>Account</li></ul>Do you continue ?"));
    textView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);

    QToolButton *btnReset = new QToolButton;
    btnReset->setIcon(QIcon(":/img/forward.png"));
    btnReset->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnReset->setText(tr("Start Reset"));
    btnReset->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    connect(btnReset,SIGNAL(clicked()),this,SLOT(reset()));

    // --------------------------

    QWidget *spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setSpacing(10);
    mainLayout->setContentsMargins(0,10,0,0);
    mainLayout->addWidget(textView);
    mainLayout->addWidget(btnReset);
    mainLayout->addWidget(spacer);

    tabReset = new SettingsPanel;
    tabReset->setTitle(tr("Reset"));
    tabReset->setMainLayout(mainLayout);
}
コード例 #3
0
void FilePathPropertyEditor::onInitialize()
{
   QWidget* frame = new QWidget( this );
   QHBoxLayout* layout = new QHBoxLayout( frame );
   layout->setSpacing( 0 );
   layout->setMargin( 0 );
   frame->setLayout( layout );
   addWidget( frame );

   // a field that shows the resource
   m_droppedFilePath = new DropArea( frame, new FSNodeMimeData( m_paths ) );
   connect( m_droppedFilePath, SIGNAL( changed() ), this, SLOT( valChanged() ) );
   m_droppedFilePath->setMinimumSize( 20, 20 );
   m_droppedFilePath->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
   layout->addWidget( m_droppedFilePath );

   // a button for NULLing the resource
   QToolButton* eraseButton = new QToolButton( frame );
   eraseButton->setIcon( QIcon( ":/TamyEditor/Resources/Icons/Editor/quit.png" ) );
   eraseButton->setToolTip( "Reset value" );
   connect( eraseButton, SIGNAL( clicked( bool ) ), this, SLOT( valErased( bool ) ) );
   eraseButton->setMinimumSize( 20, 20 );
   eraseButton->setMaximumSize( 20, 20 );
   eraseButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
   layout->addWidget( eraseButton );

   refreshPropertyName();
}
コード例 #4
0
ファイル: settingswindow.cpp プロジェクト: gustawho/dooscape
void SettingsWindow::genOptions()
{
    QCheckBox *checkPlugins = new QCheckBox(tr("Enable Plugins"));
    QCheckBox *checkJava = new QCheckBox(tr("Enable Java"));
    QCheckBox *checkJavaScript = new QCheckBox(tr("Enable JavaScript"));
    QCheckBox *checkJavascriptCanOpenWindows = new QCheckBox(tr("JavaScript can open windows"));
    QCheckBox *checkJavascriptCanAccessClipboard = new QCheckBox(tr("JavaScript can access clipboard"));

    QToolButton *btnCheckAll = new QToolButton;
    btnCheckAll->setIcon(QIcon(":/img/menu.png"));
    btnCheckAll->setIconSize(QSize(0,0));
    btnCheckAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnCheckAll->setText(tr("Select all"));
    btnCheckAll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);

    // --------------------------

    QWidget *spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setSpacing(10);
    mainLayout->setContentsMargins(0,10,0,0);
    mainLayout->addWidget(checkPlugins);
    mainLayout->addWidget(checkJava);
    mainLayout->addWidget(checkJavaScript);
    mainLayout->addWidget(checkJavascriptCanOpenWindows);
    mainLayout->addWidget(checkJavascriptCanAccessClipboard);
    mainLayout->addWidget(btnCheckAll);
    mainLayout->addWidget(spacer);

    tabOptions = new SettingsPanel;
    tabOptions->setTitle(tr("Options"));
    tabOptions->setMainLayout(mainLayout);
}
コード例 #5
0
ファイル: qgsguivectorlayertools.cpp プロジェクト: Ariki/QGIS
void QgsGuiVectorLayerTools::commitError( QgsVectorLayer* vlayer ) const
{
  QgsMessageViewer *mv = new QgsMessageViewer();
  mv->setWindowTitle( tr( "Commit errors" ) );
  mv->setMessageAsPlainText( tr( "Could not commit changes to layer %1" ).arg( vlayer->name() )
                             + "\n\n"
                             + tr( "Errors: %1\n" ).arg( vlayer->commitErrors().join( "\n  " ) )
                           );

  QToolButton *showMore = new QToolButton();
  // store pointer to vlayer in data of QAction
  QAction *act = new QAction( showMore );
  act->setData( QVariant( QMetaType::QObjectStar, &vlayer ) );
  act->setText( tr( "Show more" ) );
  showMore->setStyleSheet( "background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" );
  showMore->setCursor( Qt::PointingHandCursor );
  showMore->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
  showMore->addAction( act );
  showMore->setDefaultAction( act );
  connect( showMore, SIGNAL( triggered( QAction* ) ), mv, SLOT( exec() ) );
  connect( showMore, SIGNAL( triggered( QAction* ) ), showMore, SLOT( deleteLater() ) );

  // no timeout set, since notice needs attention and is only shown first time layer is labeled
  QgsMessageBarItem *errorMsg = new QgsMessageBarItem(
    tr( "Commit errors" ),
    tr( "Could not commit changes to layer %1" ).arg( vlayer->name() ),
    showMore,
    QgsMessageBar::WARNING,
    0,
    QgisApp::instance()->messageBar() );
  QgisApp::instance()->messageBar()->pushItem( errorMsg );

}
コード例 #6
0
ファイル: objectreferenceedit.cpp プロジェクト: naiello/tiled
ObjectReferenceEdit::ObjectReferenceEdit(QWidget *parent)
    : QWidget(parent),
      mErrorTextColor(Qt::red)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

    mLineEdit = new QLineEdit(this);
    mLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));

    mOkTextColor = mLineEdit->palette().color(QPalette::Active, QPalette::Text);

    QToolButton *button = new QToolButton(this);
    button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
    button->setFixedWidth(20);
    button->setText(QLatin1String("..."));
    layout->addWidget(mLineEdit);
    layout->addWidget(button);

    connect(button, SIGNAL(clicked(bool)),
            SLOT(buttonClicked()));
    connect(mLineEdit, SIGNAL(textChanged(QString)),
            SLOT(validate()));
    connect(mLineEdit, SIGNAL(textEdited(QString)),
            SLOT(setObjectId(QString)));

    setFocusProxy(mLineEdit);
    setFocusPolicy(Qt::StrongFocus);
    setAttribute(Qt::WA_InputMethodEnabled);
}
コード例 #7
0
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent)
{
	setWindowTitle(tr("Configure %1").arg(KtikzApplication::applicationName()));

	addPage(generalPage(), tr("&General"), "preferences-desktop-theme");
	addPage(editorPage(), tr("&Editor"), "accessories-text-editor");
	addPage(appearancePage(), tr("&Highlighting"), "preferences-desktop-color");

	QDialogButtonBox *buttonBox = new QDialogButtonBox;
	QAction *whatsThisAction = QWhatsThis::createAction(this);
	whatsThisAction->setIcon(Icon("help-contextual"));
	QToolButton *whatsThisButton = new QToolButton(this);
	whatsThisButton->setDefaultAction(whatsThisAction);
	whatsThisButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
	buttonBox->addButton(whatsThisButton, QDialogButtonBox::HelpRole);
	buttonBox->addButton(QDialogButtonBox::Ok);
	buttonBox->addButton(QDialogButtonBox::Cancel);
	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addWidget(centerWidget());
	mainLayout->addWidget(buttonBox);
	setLayout(mainLayout);
}
コード例 #8
0
QWidget *QgsLocatorFiltersModel::configButton( const QModelIndex &index, QWidget *parent ) const
{
  if ( !index.isValid() )
    return nullptr;

  QgsLocatorFilter *filter = filterForIndex( index );
  if ( filter && filter->hasConfigWidget() )
  {
    // use a layout to get the button center aligned
    QWidget *w = new QWidget( parent );
    QToolButton *bt = new QToolButton( );
    QHBoxLayout *layout = new QHBoxLayout();
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->addWidget( bt );
    w->setLayout( layout );

    connect( bt, &QToolButton::clicked, this, [ = ]() {filter->openConfigWidget( bt );} );
    bt->setMaximumSize( mIconSize, mIconSize );
    bt->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
    bt->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/settings.svg" ) ) );
    return w;
  }
  else
  {
    return nullptr;
  }
}
コード例 #9
0
QToolButton* 
EchonestSteerer::initButton( QWidget* parent )
{
    QToolButton* btn = new QToolButton( parent );
    btn->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
    btn->setIconSize( QSize( 14, 14 ) );
    btn->setToolButtonStyle( Qt::ToolButtonIconOnly );
    btn->setAutoRaise( true );
    btn->setContentsMargins( 0, 0, 0, 0 );
    return btn;
}
コード例 #10
0
ファイル: mainwindow.cpp プロジェクト: KDE/kaffeine
QAbstractButton *StartTab::addShortcut(const QString &name, const QIcon &icon, QWidget *parent)
{
	// QPushButton has visual problems with big icons
	QToolButton *button = new QToolButton(parent);
	button->setText(name);
	button->setIcon(icon);
	button->setFocusPolicy(Qt::NoFocus);
	button->setIconSize(QSize(48, 48));
	button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
	button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
	return button;
}
コード例 #11
0
QGraphicsProxyWidget *KGVisualItemGroup::createButton()
{
    QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
    QToolButton *bt = new QToolButton();
    bt->setText("v/h");

    bt->setAttribute(Qt::WA_TranslucentBackground, true);
    w->setWidget(bt);
    bt->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    connect(bt, SIGNAL(clicked()), this, SLOT(stickyStateChanged()));
    return w;
}
コード例 #12
0
void MainWindow::addMenu(QMenu *menu)
{
    QToolButton *toolButton = new QToolButton(_toolBar);
    toolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    toolButton->setText(menu->title());
    toolButton->setMenu(menu);
    toolButton->setPopupMode(QToolButton::InstantPopup);
    toolButton->setStyleSheet("QToolButton::menu-indicator { width: 0px; }");

    _toolBar->insertWidget(_spacerAction, toolButton);

    connect(toolButton, SIGNAL(triggered(QAction*)), this, SIGNAL(signalActionTriggered(QAction*)));
}
コード例 #13
0
QToolButton *TitleBarWidget::addButton(QBoxLayout *layout, const char *iconPath, ToolWindowSlot slot)
{
    QToolButton *button = new QToolButton();
    button->setAutoRaise(true);
    if (iconPath) button->setIcon(QIcon(iconPath));
    button->setMaximumSize(QSize(15, 15));
    button->setMinimumSize(button->maximumSize());
    button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    QObject::connect(button, &QPushButton::clicked, tool_window, slot);
    layout->addWidget(button);
    layout->setAlignment(button, Qt::AlignLeft);
    return button;
}
コード例 #14
0
QT_BEGIN_NAMESPACE

static QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) {
    QToolButton *rc =  new QToolButton();
    rc->setAttribute(Qt::WA_NoChildEventsForParent, true);
    rc->setParent(parent);
    rc->setObjectName(name);
    rc->setArrowType(at);
    rc->setAutoRaise(true);
    rc->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
    rc->setFixedSize(QSize(15, 15));
    return rc;
}
コード例 #15
0
void SideBarGroup::addAction(QAction* action)
{
    int size = KIconLoader::global()->currentSize(KIconLoader::Small);
    QToolButton* button = new SideBarButton();
    button->setFocusPolicy(Qt::NoFocus);
    button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    button->setAutoRaise(true);
    button->setDefaultAction(action);
    button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    button->setIconSize(QSize(size, size));
    if (action->menu()) {
        button->setPopupMode(QToolButton::InstantPopup);
    }
    addWidget(button);
}
コード例 #16
0
/*!
 * Constructs a numpad widget with a given \a parent.
 */
QwwNumPad::QwwNumPad(QWidget *parent) : QWidget(parent), QwwPrivatable(new QwwNumPadPrivate(this)) {
    QGridLayout *l = new QGridLayout(this);
    l->setSpacing(2);
    l->setMargin(2);
    QButtonGroup *group = new QButtonGroup(this);
    for (int i=0;i<9;i++) {
        QToolButton *b = new QToolButton;
        b->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
        b->setObjectName(QString("b%1").arg(i+1));
        b->setText(QString::number(i+1));
        l->addWidget(b, i/3, i%3);
        group->addButton(b, i+1);
    }
    QToolButton *b = new QToolButton;
    b->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    b->setObjectName("b0");
    b->setText("0");
    l->addWidget(b, 3, 1);
    group->addButton(b, 0);

    b = new QToolButton;
    b->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    b->setObjectName("bAster");
    b->setText("*");
    l->addWidget(b, 3, 0);
    group->addButton(b, 10);

    b = new QToolButton;
    b->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    b->setText("#");
    b->setObjectName("bHash");
    l->addWidget(b, 3, 2);
    group->addButton(b, 11);
    connect(group, SIGNAL(buttonClicked(int)), SLOT(_q_clicked(int)));
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
}
コード例 #17
0
ファイル: ActionListWidget.cpp プロジェクト: KDE/ktutorial
void ActionListWidget::addToolButtonForAction(QAction* action,
                                              QToolButton* before) {
    Q_ASSERT(action);

    QToolButton* button = new ForcedIconToolButton();
    button->setDefaultAction(action);
    button->setObjectName(action->objectName() + "ToolButton");
    button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    button->setAutoRaise(true);
    button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

    int index;
    if (before == 0) {
        index = layout()->count() - 1;
    } else {
        index = layout()->indexOf(before);
    }

    static_cast<QVBoxLayout*>(layout())->insertWidget(index, button);
}
コード例 #18
0
ファイル: fileedit.cpp プロジェクト: guozanhua/mapmap
FileEdit::FileEdit(QWidget *parent)
    : QWidget(parent)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);
    theLineEdit = new QLineEdit(this);
    theLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));
    QToolButton *button = new QToolButton(this);
    button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
    button->setText(QLatin1String("..."));
    layout->addWidget(theLineEdit);
    layout->addWidget(button);
    setFocusProxy(theLineEdit);
    setFocusPolicy(Qt::StrongFocus);
    setAttribute(Qt::WA_InputMethodEnabled);
    connect(theLineEdit, SIGNAL(textEdited(const QString &)),
                this, SIGNAL(filePathChanged(const QString &)));
    connect(button, SIGNAL(clicked()),
                this, SLOT(buttonClicked()));
}
コード例 #19
0
RoleEditor::RoleEditor(QWidget *parent) :
    QWidget(parent),
    m_label(new QLabel(this)),
    m_edited(false)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

    layout->addWidget(m_label);
    m_label->setAutoFillBackground(true);
    m_label->setIndent(3); // ### hardcode it should have the same value of textMargin in QItemDelegate
    setFocusProxy(m_label);

    QToolButton *button = new QToolButton(this);
    button->setToolButtonStyle(Qt::ToolButtonIconOnly);
    button->setIcon(createIconSet(QLatin1String("resetproperty.png")));
    button->setIconSize(QSize(8,8));
    button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
    layout->addWidget(button);
    connect(button, SIGNAL(clicked()), this, SLOT(emitResetProperty()));
}
コード例 #20
0
ファイル: settingswindow.cpp プロジェクト: gustawho/dooscape
void SettingsWindow::genSecurity()
{
    /*QLabel *lblPhoto = new QLabel(tr("Your photo"));
    QLineEdit *editPhoto = new QLineEdit;*/

    QLabel *lblUserName = new QLabel(tr("Pseudo"));
    editUserName = new QLineEdit;

    QLabel *lblPass1 = new QLabel(tr("Password"));
    editPass1 = new QLineEdit;
    editPass1->setEchoMode(QLineEdit::Password);

    QLabel *lblPass2 = new QLabel(tr("Retype your Password"));
    lblPass2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    editPass2 = new QLineEdit;
    editPass2->setEchoMode(QLineEdit::Password);

    QLabel *lblIndice = new QLabel(tr("Indication"));
    editIndice = new QLineEdit;

    QFormLayout *layUser = new QFormLayout;
    layUser->setContentsMargins(10,10,10,10);
    layUser->setSpacing(10);
   /* layUser->addWidget(lblPhoto,0,0);
    layUser->addWidget(editPhoto,0,1);*/

    layUser->addRow(lblUserName,editUserName);
    layUser->addRow(lblPass1,editPass1);
    layUser->addRow(lblPass2,editPass2);
    layUser->addRow(lblIndice,editIndice);

   /* for(int i(0);layUser->count();i++)
        layUser->itemAt(i)->widget()->setAlignment(Qt::AlignHCenter);*/

    /*lblPhoto->setAlignment(Qt::AlignVCenter);
    editPhoto->setAlignment(Qt::AlignVCenter);*/

    QGroupBox *boxUser = new QGroupBox(tr("Account"));
    boxUser->setLayout(layUser);

    // ----------------------------

    checkLockAtStartup = new QCheckBox(tr("At Startup"));
    checkUnlockToClose = new QCheckBox(tr("Closing"));
    checkLockConfig = new QCheckBox(tr("Open Config Window"));
    checkLockLocker = new QCheckBox(tr("To Unlock"));

    QToolButton *btnCheckAll = new QToolButton;
    btnCheckAll->setIcon(QIcon(":/img/menu.png"));
    btnCheckAll->setIconSize(QSize(0,0));
    btnCheckAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnCheckAll->setText(tr("Select all"));
    btnCheckAll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);

    QGridLayout *layAskPass = new QGridLayout;
    layAskPass->setSpacing(10);
    layAskPass->addWidget(checkLockAtStartup);
    layAskPass->addWidget(checkUnlockToClose);
    layAskPass->addWidget(checkLockConfig);
    layAskPass->addWidget(checkLockLocker);
    layAskPass->addWidget(btnCheckAll);

    HideBlock *boxAskPass = new HideBlock(tr("Ask password"));
    boxAskPass->setBlockLayout(layAskPass);

    // --------------------------

    QWidget *spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setContentsMargins(10,10,10,10);
    mainLayout->setSpacing(10);
    mainLayout->addWidget(boxUser);
    mainLayout->addWidget(boxAskPass);
    mainLayout->addWidget(spacer);

    tabSecurity = new SettingsPanel;
    tabSecurity->setTitle(tr("Security"));
    tabSecurity->setMainLayout(mainLayout);
}
コード例 #21
0
ファイル: settingswindow.cpp プロジェクト: gustawho/dooscape
void SettingsWindow::genCustomise()
{
    QLabel *lblBgColor = new QLabel(tr("Background color"));
    lblBgColor->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    editBgColor = new QLineEdit;
    editBgColor->setEnabled(false);
    editBgColor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    QToolButton *btnBgColor = new QToolButton;
    btnBgColor->setText(tr("Change color"));
    btnBgColor->setIcon(QIcon(":/img/config.png"));
    btnBgColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnBgColor->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    connect(btnBgColor,SIGNAL(clicked()),this,SLOT(chooseColor()));

    QLabel *lblBgImageMain = new QLabel(tr("Background image of the main window"));
    editBgImageMain = new QLineEdit;
    editBgImageMain->setEnabled(false);
    editBgImageMain->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    btnBgImageMain = new QToolButton;
    btnBgImageMain->setText(tr("Explore"));
    btnBgImageMain->setIcon(QIcon(":/img/config.png"));
    btnBgImageMain->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnBgImageMain->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    connect(btnBgImageMain,SIGNAL(clicked()),this,SLOT(chooseBgImage()));

    QLabel *lblBgImageLock = new QLabel(tr("Background image of the lock screen"));
    editBgImageLock = new QLineEdit;
    editBgImageLock->setEnabled(false);
    editBgImageLock->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    btnBgImageLock = new QToolButton;
    btnBgImageLock->setText(tr("Explore"));
    btnBgImageLock->setIcon(QIcon(":/img/config.png"));
    btnBgImageLock->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    btnBgImageLock->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    connect(btnBgImageLock,SIGNAL(clicked()),this,SLOT(chooseBgImage()));

    QLabel *lblAnimation = new QLabel(tr("Animations Effects / Transitions"));
    checkAnimation = new QCheckBox(tr("Enable"));
    checkAnimation->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);

    QGridLayout *layCustomise = new QGridLayout;
    layCustomise->setContentsMargins(10,10,10,10);
    layCustomise->setSpacing(10);

    layCustomise->addWidget(lblAnimation,0,0);
    layCustomise->addWidget(checkAnimation,0,1,1,2);

    layCustomise->addWidget(lblBgColor,1,0);
    layCustomise->addWidget(editBgColor,1,1);
    layCustomise->addWidget(btnBgColor,1,2);

    layCustomise->addWidget(lblBgImageMain,2,0);
    layCustomise->addWidget(editBgImageMain,2,1);
    layCustomise->addWidget(btnBgImageMain,2,2);

    layCustomise->addWidget(lblBgImageLock,3,0);
    layCustomise->addWidget(editBgImageLock,3,1);
    layCustomise->addWidget(btnBgImageLock,3,2);

    QGroupBox *boxCustomize = new QGroupBox(tr("Customize"));
    boxCustomize->setLayout(layCustomise);

    // ----------------------------

    previewBgImageMain = new QToolButton;
    previewBgImageMain->setText(tr("Background image of the main window"));
    previewBgImageMain->setIconSize(QSize(400,300));
    previewBgImageMain->setIcon(QIcon(":/img/file.png"));
    previewBgImageMain->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    previewBgImageMain->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    connect(previewBgImageMain,SIGNAL(clicked()),this,SLOT(chooseBgImage()));

    previewBgImageLock = new QToolButton;
    previewBgImageLock->setText(tr("Background image of the lock screen"));
    previewBgImageLock->setIconSize(QSize(400,300));
    previewBgImageLock->setIcon(QIcon(":/img/file.png"));
    previewBgImageLock->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    previewBgImageLock->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
    connect(previewBgImageLock,SIGNAL(clicked()),this,SLOT(chooseBgImage()));

    QGridLayout *layBgImageMain = new QGridLayout;
    layBgImageMain->setContentsMargins(10,10,10,10);
    layBgImageMain->setSpacing(10);

    layBgImageMain->addWidget(previewBgImageMain,0,0);
    layBgImageMain->addWidget(previewBgImageLock,0,1);

    HideBlock *boxBgImage = new HideBlock(tr("Background images preview"));
    boxBgImage->setBlockLayout(layBgImageMain);

    // ----------------------------

    QWidget *spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setSpacing(0);
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->addWidget(boxCustomize,0,0);
    mainLayout->addWidget(boxBgImage,1,0);
    mainLayout->addWidget(spacer,2,0);

    tabCustomise = new SettingsPanel;
    tabCustomise->setTitle(tr("Customise"));
    tabCustomise->setMainLayout(mainLayout);
}
コード例 #22
0
ファイル: window-remux.cpp プロジェクト: ZixiVideo/obs-studio
	virtual QWidget *createEditor(QWidget *parent,
			const QStyleOptionViewItem & /* option */,
			const QModelIndex &index) const override
	{
		RemuxEntryState state = index.model()
				->index(index.row(), RemuxEntryColumn::State)
				.data(RemuxEntryRole::EntryStateRole)
				.value<RemuxEntryState>();
		if (state == RemuxEntryState::Pending ||
				state == RemuxEntryState::InProgress) {
			// Never allow modification of rows that are
			// in progress.
			return Q_NULLPTR;
		} else if (isOutput && state != RemuxEntryState::Ready) {
			// Do not allow modification of output rows
			// that aren't associated with a valid input.
			return Q_NULLPTR;
		} else if (!isOutput && state == RemuxEntryState::Complete) {
			// Don't allow modification of rows that are
			// already complete.
			return Q_NULLPTR;
		} else {
			QSizePolicy buttonSizePolicy(
					QSizePolicy::Policy::Minimum,
					QSizePolicy::Policy::Expanding,
					QSizePolicy::ControlType::PushButton);

			QWidget *container = new QWidget(parent);

			auto browseCallback = [this, container]()
			{
				const_cast<RemuxEntryPathItemDelegate *>(this)
						->handleBrowse(container);
			};

			auto clearCallback = [this, container]()
			{
				const_cast<RemuxEntryPathItemDelegate *>(this)
						->handleClear(container);
			};

			QHBoxLayout *layout = new QHBoxLayout();
			layout->setMargin(0);
			layout->setSpacing(0);

			QLineEdit *text = new QLineEdit();
			text->setObjectName(QStringLiteral("text"));
			text->setSizePolicy(QSizePolicy(
					QSizePolicy::Policy::Expanding,
					QSizePolicy::Policy::Expanding,
					QSizePolicy::ControlType::LineEdit));
			layout->addWidget(text);

			QToolButton *browseButton = new QToolButton();
			browseButton->setText("...");
			browseButton->setSizePolicy(buttonSizePolicy);
			layout->addWidget(browseButton);

			container->connect(browseButton, &QToolButton::clicked,
					browseCallback);

			// The "clear" button is not shown in output cells
			// or the insertion point's input cell.
			if (!isOutput && state != RemuxEntryState::Empty) {
				QToolButton *clearButton = new QToolButton();
				clearButton->setText("X");
				clearButton->setSizePolicy(buttonSizePolicy);
				layout->addWidget(clearButton);

				container->connect(clearButton,
						&QToolButton::clicked,
						clearCallback);
			}

			container->setLayout(layout);
			container->setFocusProxy(text);

			return container;
		}
	}
コード例 #23
0
void QmitkToolSelectionBox::RecreateButtons()
{
  if (m_ToolManager.IsNull()) return;

  /*
  // remove all buttons that are there
  QObjectList *l = Q3ButtonGroup::queryList( "QButton" );
  QObjectListIt it( *l ); // iterate over all buttons
  QObject *obj;

  while ( (obj = it.current()) != 0 )
  {
    ++it;
    QButton* button = dynamic_cast<QButton*>(obj);
    if (button)
    {
      Q3ButtonGroup::remove(button);
      delete button;
    }
  }
  delete l; // delete the list, not the objects
  */

  // mmueller Qt impl
  QList<QAbstractButton *> l = m_ToolButtonGroup->buttons();
  // remove all buttons that are there
  QList<QAbstractButton *>::iterator it;
  QAbstractButton * btn;

  for(it=l.begin(); it!=l.end();++it)
  {
    btn = *it;
    m_ToolButtonGroup->removeButton(btn);
    //this->removeChild(btn);
    delete btn;
  }
  // end mmueller Qt impl

  mitk::ToolManager::ToolVectorTypeConst allPossibleTools = m_ToolManager->GetTools();
  mitk::ToolManager::ToolVectorTypeConst allTools;

  typedef std::pair< std::string::size_type, const mitk::Tool* > SortPairType;
  typedef std::priority_queue< SortPairType > SortedToolQueueType;
  SortedToolQueueType toolPositions;

  // clear and sort all tools
  // step one: find name/group of all tools in m_DisplayedGroups string. remember these positions for all tools.
  for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allPossibleTools.begin();
        iter != allPossibleTools.end();
        ++iter)
  {
    const mitk::Tool* tool = *iter;

    std::string::size_type namePos =  m_DisplayedGroups.find( std::string("'") + tool->GetName() + "'" );
    std::string::size_type groupPos = m_DisplayedGroups.find( std::string("'") + tool->GetGroup() + "'" );

    if ( !m_DisplayedGroups.empty() && namePos == std::string::npos && groupPos == std::string::npos ) continue; // skip

    if ( m_DisplayedGroups.empty() && std::string(tool->GetName()).length() > 0 )
    {
      namePos = static_cast<std::string::size_type> (tool->GetName()[0]);
    }

    SortPairType thisPair = std::make_pair( namePos < groupPos ? namePos : groupPos, *iter );
    toolPositions.push( thisPair );
  }

  // step two: sort tools according to previously found positions in m_DisplayedGroups
  MITK_DEBUG << "Sorting order of tools (lower number --> earlier in button group)";
  while ( !toolPositions.empty() )
  {
    SortPairType thisPair = toolPositions.top();
    MITK_DEBUG << "Position " << thisPair.first << " : " << thisPair.second->GetName();

    allTools.push_back( thisPair.second );
    toolPositions.pop();
  }
  std::reverse( allTools.begin(), allTools.end() );

  MITK_DEBUG << "Sorted tools:";
  for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin();
        iter != allTools.end();
        ++iter)
  {
    MITK_DEBUG << (*iter)->GetName();
  }

  // try to change layout... bad?
  //Q3GroupBox::setColumnLayout ( m_LayoutColumns, Qt::Horizontal );
  // mmueller using gridlayout instead of Q3GroupBox
  //this->setLayout(0);
  if(m_ButtonLayout == NULL)
    m_ButtonLayout = new QGridLayout;
  /*else
    delete m_ButtonLayout;*/

  int row(0);
  int column(-1);

  int currentButtonID(0);
  m_ButtonIDForToolID.clear();
  m_ToolIDForButtonID.clear();
  QToolButton* button = 0;

  MITK_DEBUG << "Creating buttons for tools";
  // fill group box with buttons
  for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin();
        iter != allTools.end();
        ++iter)
  {
    const mitk::Tool* tool = *iter;
    int currentToolID( m_ToolManager->GetToolID( tool ) );

    ++column;
    // new line if we are at the maximum columns
    if(column == m_LayoutColumns)
    {
      ++row;
      column = 0;
    }

    button = new QToolButton;
    button->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
    // add new button to the group
    MITK_DEBUG << "Adding button with ID " << currentToolID;
    m_ToolButtonGroup->addButton(button, currentButtonID);
    // ... and to the layout
    MITK_DEBUG << "Adding button in row/column " << row << "/" << column;
    m_ButtonLayout->addWidget(button, row, column);

    if (m_LayoutColumns == 1)
    {
      //button->setTextPosition( QToolButton::BesideIcon );
      // mmueller
      button->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
    }
    else
    {
      //button->setTextPosition( QToolButton::BelowIcon );
      // mmueller
      button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    }

    //button->setToggleButton( true );
    // mmueller
    button->setCheckable ( true );

    if(currentToolID == m_ToolManager->GetActiveToolID())
      button->setChecked(true);

    QString label;
    if (m_GenerateAccelerators)
    {
      label += "&";
    }
    label += tool->GetName();
    QString tooltip = tool->GetName();
    MITK_DEBUG << tool->GetName() << ", " << label.toLocal8Bit().constData() << ", '" << tooltip.toLocal8Bit().constData();

    if ( m_ShowNames )
    {
      /*
      button->setUsesTextLabel(true);
      button->setTextLabel( label );              // a label
      QToolTip::add( button, tooltip );
      */
      // mmueller Qt
      button->setText( label );              // a label
      button->setToolTip( tooltip );
      // mmueller

      QFont currentFont = button->font();
      currentFont.setBold(false);
      button->setFont( currentFont );
    }

    us::ModuleResource iconResource = tool->GetIconResource();

    if (!iconResource.IsValid())
    {
      button->setIcon(QIcon(QPixmap(tool->GetXPM())));
    }
    else
    {
      us::ModuleResourceStream resourceStream(iconResource, std::ios::binary);
      resourceStream.seekg(0, std::ios::end);
      std::ios::pos_type length = resourceStream.tellg();
      resourceStream.seekg(0, std::ios::beg);

      char* data = new char[length];
      resourceStream.read(data, length);
      QPixmap pixmap;
      pixmap.loadFromData(QByteArray::fromRawData(data, length));
      QIcon* icon = new QIcon(pixmap);
      delete[] data;

      button->setIcon(*icon);

      if (m_ShowNames)
      {
        if (m_LayoutColumns == 1)
          button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        else
          button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

        button->setIconSize(QSize(24, 24));
      }
      else
      {
        button->setToolButtonStyle(Qt::ToolButtonIconOnly);
        button->setIconSize(QSize(32,32));
        button->setToolTip(tooltip);
      }
    }

    if (m_GenerateAccelerators)
    {
      QString firstLetter = QString( tool->GetName() );
      firstLetter.truncate( 1 );
      button->setShortcut( firstLetter );                      // a keyboard shortcut (just the first letter of the given name w/o any CTRL or something)
    }

    mitk::DataNode* dataNode = m_ToolManager->GetReferenceData(0);

    if (dataNode != NULL && !tool->CanHandle(dataNode->GetData()))
      button->setEnabled(false);

    m_ButtonIDForToolID[currentToolID] = currentButtonID;
    m_ToolIDForButtonID[currentButtonID] = currentToolID;

    MITK_DEBUG << "m_ButtonIDForToolID[" << currentToolID << "] == " << currentButtonID;
    MITK_DEBUG << "m_ToolIDForButtonID[" << currentButtonID << "] == " << currentToolID;

    tool->GUIProcessEventsMessage += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolGUIProcessEventsMessage ); // will never add a listener twice, so we don't have to check here
    tool->ErrorMessage += mitk::MessageDelegate1<QmitkToolSelectionBox, std::string>( this, &QmitkToolSelectionBox::OnToolErrorMessage ); // will never add a listener twice, so we don't have to check here
    tool->GeneralMessage += mitk::MessageDelegate1<QmitkToolSelectionBox, std::string>( this, &QmitkToolSelectionBox::OnGeneralToolMessage );

    ++currentButtonID;
  }
  // setting grid layout for this groupbox
  this->setLayout(m_ButtonLayout);

  //this->update();
}
コード例 #24
0
WorkingSetToolTipWidget::WorkingSetToolTipWidget(QWidget* parent, WorkingSet* set, MainWindow* mainwindow) : QWidget(parent), m_set(set) {
    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->setSpacing(0);

    layout->setMargin(0);

    connect(static_cast<Sublime::MainWindow*>(mainwindow)->area(),
            SIGNAL(viewAdded(Sublime::AreaIndex*,Sublime::View*)), SLOT(updateFileButtons()),
            Qt::QueuedConnection);
    connect(static_cast<Sublime::MainWindow*>(mainwindow)->area(),
            SIGNAL(viewRemoved(Sublime::AreaIndex*,Sublime::View*)), SLOT(updateFileButtons()),
            Qt::QueuedConnection);

    connect(Core::self()->workingSetControllerInternal(), SIGNAL(workingSetSwitched()),
            SLOT(updateFileButtons()));

    // title bar
    {
        QHBoxLayout* topLayout = new QHBoxLayout;
        m_setButton = new WorkingSetToolButton(this, set, mainwindow);
        m_setButton->hide();

        topLayout->addSpacing(5);
        QLabel* icon = new QLabel;
        topLayout->addWidget(icon);
        topLayout->addSpacing(5);

        QLabel* name = new QLabel(i18n("<b>Working Set</b>"));
        name->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
        topLayout->addWidget(name);
         topLayout->addSpacing(10);

        icon->setPixmap(m_setButton->icon().pixmap(name->sizeHint().height()+8, name->sizeHint().height()+8));

        topLayout->addStretch();

        m_openButton = new QPushButton;
        m_openButton->setFlat(true);
        topLayout->addWidget(m_openButton);

        m_deleteButton = new QPushButton;
        m_deleteButton->setIcon(KIcon("edit-delete"));
        m_deleteButton->setText(i18n("Delete"));
        m_deleteButton->setToolTip(i18n("Remove this working set. The contained documents are not affected."));
        m_deleteButton->setFlat(true);
        connect(m_deleteButton, SIGNAL(clicked(bool)), m_set, SLOT(deleteSet()));
        connect(m_deleteButton, SIGNAL(clicked(bool)), this, SIGNAL(shouldClose()));
        topLayout->addWidget(m_deleteButton);
        layout->addLayout(topLayout);
        // horizontal line
        QFrame* line = new QFrame();
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Raised);
        layout->addWidget(line);
    }

    // everything else is added to the following widget which just has a different background color
    QVBoxLayout* bodyLayout = new QVBoxLayout;
    {
        QWidget* body = new QWidget();
        body->setLayout(bodyLayout);
        layout->addWidget(body);
        body->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    }

    // document list actions
    {
        QHBoxLayout* actionsLayout = new QHBoxLayout;

        QLabel* label = new QLabel(i18n("Documents:"));
        label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
        actionsLayout->addWidget(label);

        actionsLayout->addStretch();

        m_mergeButton = new QPushButton;
        m_mergeButton->setIcon(KIcon("list-add"));
        m_mergeButton->setText(i18n("Add All"));
        m_mergeButton->setToolTip(i18n("Add all documents that are part of this working set to the currently active working set."));
        m_mergeButton->setFlat(true);
        connect(m_mergeButton, SIGNAL(clicked(bool)), m_setButton, SLOT(mergeSet()));
        actionsLayout->addWidget(m_mergeButton);

        m_subtractButton = new QPushButton;
        m_subtractButton->setIcon(KIcon("list-remove"));
        m_subtractButton->setText(i18n("Subtract All"));
        m_subtractButton->setToolTip(i18n("Remove all documents that are part of this working set from the currently active working set."));
        m_subtractButton->setFlat(true);
        connect(m_subtractButton, SIGNAL(clicked(bool)), m_setButton, SLOT(subtractSet()));
        actionsLayout->addWidget(m_subtractButton);
        bodyLayout->addLayout(actionsLayout);
    }

    QSet<QString> hadFiles;

    QVBoxLayout* filesLayout = new QVBoxLayout;
    filesLayout->setMargin(0);

    foreach(const QString& file, m_set->fileList()) {

        if(hadFiles.contains(file))
            continue;

        hadFiles.insert(file);

        FileWidget* widget = new FileWidget;
        widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);

        QHBoxLayout* fileLayout = new QHBoxLayout(widget);

        QToolButton* plusButton = new QToolButton;
        plusButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);
        fileLayout->addWidget(plusButton);

        WorkingSetFileLabel* fileLabel = new WorkingSetFileLabel;
        fileLabel->setTextFormat(Qt::RichText);
        // We add spaces behind and after, to make it look nicer
        fileLabel->setText("&nbsp;" + Core::self()->projectController()->prettyFileName(KUrl(file)) + "&nbsp;");
        fileLabel->setToolTip(i18nc("@info:tooltip", "Click to open and activate this document."));
        fileLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        fileLayout->addWidget(fileLabel);
        fileLayout->setMargin(0);

        plusButton->setMaximumHeight(fileLabel->sizeHint().height() + 4);
        plusButton->setMaximumWidth(plusButton->maximumHeight());

        plusButton->setObjectName(file);
        fileLabel->setObjectName(file);
        fileLabel->setCursor(QCursor(Qt::PointingHandCursor));

        widget->m_button = plusButton;
        widget->m_label = fileLabel;

        filesLayout->addWidget(widget);
        m_fileWidgets.insert(file, widget);
        m_orderedFileWidgets.push_back(widget);

        connect(plusButton, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
        connect(fileLabel, SIGNAL(clicked()), this, SLOT(labelClicked()));
    }

    bodyLayout->addLayout(filesLayout);

    updateFileButtons();
    connect(set, SIGNAL(setChangedSignificantly()), SLOT(updateFileButtons()));
    connect(mainwindow->area(), SIGNAL(changedWorkingSet(Sublime::Area*,QString,QString)), SLOT(updateFileButtons()), Qt::QueuedConnection);

    QMetaObject::invokeMethod(this, "updateFileButtons");
}