コード例 #1
0
ファイル: option_widget.cpp プロジェクト: katja/funny-gears
OptionWidget::OptionWidget(const QString &title, QWidget *mainWidget, QWidget *parent) : QFrame(parent), mainWidget(mainWidget), isFolded(true) {

    setFrameStyle(QFrame::StyledPanel | QFrame::Raised);

    setMinimumWidth(300);

    moveButton    = new BorderlessToolButton("images/Move.png", this);
    moveButton->setDragging(true);
    connect(moveButton, SIGNAL(dragEvent(QMouseEvent*)), this, SLOT(dragEvent(QMouseEvent*)));

    foldInButton  = new BorderlessToolButton("images/ArrowUp.png", this);
    connect(foldInButton, SIGNAL(clicked()), this, SLOT(toggleFolding()));
    foldOutButton = new BorderlessToolButton("images/ArrowDown.png", this);
    connect(foldOutButton, SIGNAL(clicked()), this, SLOT(toggleFolding()));
    
    closeButton   = new BorderlessToolButton("images/Close.png", this);
    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));

    QHBoxLayout *controlsLayout = new QHBoxLayout;
    controlsLayout->setMargin(0);
    controlsLayout->setAlignment(Qt::AlignRight | Qt::AlignTop);
    controlsLayout->addWidget(moveButton);
    controlsLayout->addWidget(foldInButton);
    controlsLayout->addWidget(foldOutButton);
    controlsLayout->addWidget(closeButton);

    QWidget *controlsWidget = new QWidget;
    controlsWidget->setLayout(controlsLayout);
    controlsWidget->adjustSize();
    controlsWidget->update();

    QHBoxLayout *titleLayout = new QHBoxLayout;
    titleLayout->setMargin(0);
    titleLayout->addWidget(new QLabel(title));
    titleLayout->addWidget(controlsWidget);

    QWidget *titleWidget = new QWidget;
    titleWidget->setLayout(titleLayout);
    titleWidget->adjustSize();
    titleWidget->update();
    
    separatorLine = new QFrame;
    separatorLine->setFrameShape(QFrame::HLine);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(titleWidget);
    layout->addWidget(separatorLine);
    layout->addWidget(mainWidget);

    toggleFolding();

    layout->update();
    setLayout(layout);
};
コード例 #2
0
ファイル: tabbar.cpp プロジェクト: amosbird/CopyQ
void TabBar::setTabItemCount(const QString &tabName, const QString &itemCount)
{
    const int i = tabIndex(tabName, *this);
    if (i == -1)
        return;

    QWidget *tabCountLabel = tabButton(i, QTabBar::RightSide);

    if ( itemCount.isEmpty() ) {
        if (tabCountLabel) {
            tabCountLabel->deleteLater();
            setTabButton(i, QTabBar::RightSide, nullptr);
        }
    } else {
        if (!tabCountLabel) {
            tabCountLabel = new QLabel(this);
            tabCountLabel->setObjectName("tab_item_counter");
            setDefaultTabItemCounterStyle(tabCountLabel);
            setTabButton(i, QTabBar::RightSide, tabCountLabel);
        }

        tabCountLabel->setProperty("text", itemCount);
        tabCountLabel->adjustSize();
    }

    updateTabStyle(i);
}
コード例 #3
0
void TaskMTRTableView::fillView()
{
	TaskMTRTable *g = (TaskMTRTable *)node();
	ui->tableWidget->setColumnCount(g->columns().count());
	int rowcount = 0;
	for(int i=0; i<g->columns().count(); ++i)
		if (g->columns().at(i).count()>rowcount)
			rowcount = g->columns().at(i).count();
	ui->tableWidget->setRowCount(rowcount);
	ui->tableWidget->setHorizontalHeaderLabels(g->columnTitles());
	for(int i=0; i<g->columns().count(); ++i)
	{
		for(int j=0; j<g->columns().at(i).count(); ++j)
		{
			QWidget *widget = cell(g->columns().at(i)[j]);
			widget->adjustSize();
			if (widget->width() > ui->tableWidget->columnWidth(i))
				ui->tableWidget->setColumnWidth(i, widget->width());
			if (widget->height() > ui->tableWidget->rowHeight(j))
				ui->tableWidget->setRowHeight(j, widget->height());
			ui->tableWidget->setItem(j,i, new QTableWidgetItem());
			ui->tableWidget->setCellWidget(j, i, widget);
		}
		for(int j=g->columns().at(i).count(); j<ui->tableWidget->rowCount(); ++j)
		{
			QTableWidgetItem *item = new QTableWidgetItem();
			item->setFlags(0);
			ui->tableWidget->setItem(j, i, item);
		}
	}
}
コード例 #4
0
ファイル: reportsection.cpp プロジェクト: Wushaowei001/xtuple
void ReportSection::resizeBarDragged(int delta) {
    if(canvasview->document() && canvasview->document()->pageOptions
        && canvasview->document()->pageOptions->getPageSize() == "Labels") {
        return; // we don't want to allow this on reports that are for labels
    }

    int h = canvas->height() + delta;
    if(h < 1) h = 1;
    if(grid->isSnap()) {
        int incr = (int)(grid->yInterval() * dpiY);
        int nh = (h / incr) * incr;
        if(nh == 0) nh = incr;
        h = nh;
    }
    canvas->resize(canvas->width(), h);

    //resize(width(), h + title->height() + 5);
    if(canvasview->document()) canvasview->document()->setModified(TRUE);

    adjustSize();
    QWidget * w = parentWidget();
    if(w)
    {
      w->adjustSize();
      if(w->isA("ReportSectionDetail"))
        w->parentWidget()->adjustSize();
    }
}
コード例 #5
0
ファイル: itemwidget.cpp プロジェクト: rygwdn/CopyQ
void ItemWidget::updateSize(const QSize &maximumSize)
{
    QWidget *w = widget();
    w->setMinimumSize(0, 0);
    w->setMaximumSize(maximumSize);
    w->adjustSize();
    w->setFixedSize( w->size() );
}
コード例 #6
0
void EditableLabelWidget::onCurrentChanged(int index)
{
    QWidget* w = widget(index);
    if (w == label) {
        lineEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    } else {
        label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    }
    w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    w->adjustSize();
    adjustSize();
}
コード例 #7
0
ファイル: DNAFlexDialog.cpp プロジェクト: ugeneunipro/ugene
void DNAFlexDialog::sl_updateSizes(int index) {
    Q_UNUSED(index);

    for (int i=0; i < tabWidget->count(); i++) {
        tabWidget->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    }
    QWidget *widget = tabWidget->currentWidget();
    widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    widget->resize(widget->minimumSizeHint());
    widget->adjustSize();
    tabWidget->resize(tabWidget->minimumSizeHint());
    tabWidget->adjustSize();
}
コード例 #8
0
void MainWindow::toggleShowHide()
{
    if(ui->tab_widget_->isHidden()) {
        ui->tab_widget_->show();
        ui->show_hide_->setText("Hide");
    } else {
        ui->tab_widget_->hide();
        ui->show_hide_->setText("Show");
    }

    QWidget *parent = ui->tab_widget_->parentWidget();
    while(parent) {
        parent->adjustSize();
        parent = parent->parentWidget();
    }
}
コード例 #9
0
void QuizGroupView::fillView()
{
	QuizGroup *g = (QuizGroup *)node();
	ui->table->setColumnCount(1);
	ui->table->setRowCount(g->children().count());
	for(int i=0; i<g->children().count(); ++i)
	{
		QWidget *widget = cell(g->children()[i]);
		widget->adjustSize();
		if (widget->width()>ui->table->columnWidth(0))
			ui->table->setColumnWidth(0, widget->width());
		ui->table->setRowHeight(i, widget->height());
		ui->table->setItem(i,0, new QTableWidgetItem());
		ui->table->setCellWidget(i, 0, widget);
	}
}
コード例 #10
0
ファイル: plugincfg.cpp プロジェクト: BackupTheBerlios/sim-im
PluginCfg::PluginCfg(QWidget *parent, const QString& pluginname) : QWidget(parent)
{
	setupUi(this);
    m_pluginName = pluginname;
	if(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(m_pluginName) ||
			getPluginManager()->isPluginAlwaysEnabled(m_pluginName))
	{
		PluginPtr plugin = getPluginManager()->plugin(pluginname);
        QWidget *w = plugin->createConfigWindow(addWnd);
        if (w){
            QVBoxLayout *lay = new QVBoxLayout(addWnd);
            lay->addWidget(w);
            QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
            // adjust plugin widget
            w->setMinimumSize(w->sizeHint());
            w->adjustSize();
            // adjust addWnd widget
            addWnd->setMinimumSize(addWnd->sizeHint());
            addWnd->adjustSize();
        }
    }
    // adjust description
    if(!getPluginManager()->pluginDescription(pluginname).isNull())
	{
        lblDescription->setText(i18n(getPluginManager()->pluginDescription(pluginname)));
    }
	else
	{
        lblDescription->setText("");
    }
    // adjust tab
    tabWnd->setCurrentIndex(0);
    tabWnd->setTabText(0, i18n(getPluginManager()->pluginTitle(pluginname)));
    tabWnd->setMinimumSize(tabWnd->sizeHint());
    tabWnd->adjustSize();
    // adjust complete widget
    setMinimumSize(sizeHint());
    adjustSize();
    if (getPluginManager()->isPluginAlwaysEnabled(pluginname)) {
        chkEnable->hide();
	} else {
		chkEnable->setEnabled(true);
		chkEnable->setChecked(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(pluginname));
	}
}
コード例 #11
0
void tst_QLayout::testRetainSizeWhenHidden()
{
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
    QSKIP("Test does not work on platforms which default to showMaximized()");
#endif

    QWidget widget;
    QBoxLayout layout(QBoxLayout::TopToBottom, &widget);

    QLabel *label1 = new QLabel("label1 text", &widget);
    layout.addWidget(label1);
    QLabel *label2 = new QLabel("label2 text", &widget);
    layout.addWidget(label2);

    widget.show();
    QVERIFY(QTest::qWaitForWindowExposed(&widget));
    int normalHeight = widget.height();

    // a. Verify that a removed visible will mean lesser size after adjust
    label1->hide();
    widget.adjustSize();
    int heightWithoutLabel1 = widget.height();
    QVERIFY(heightWithoutLabel1 < normalHeight);

    // b restore with verify that the size is the same
    label1->show();
    QCOMPARE(widget.sizeHint().height(), normalHeight);

    // c verify that a policy with retainSizeWhenHidden is respected
    QSizePolicy sp_remove = label1->sizePolicy();
    QSizePolicy sp_retain = label1->sizePolicy();
    sp_retain.setRetainSizeWhenHidden(true);

    label1->setSizePolicy(sp_retain);
    label1->hide();
    QCOMPARE(widget.sizeHint().height(), normalHeight);

    // d check that changing the policy to not wanting size will result in lesser size
    label1->setSizePolicy(sp_remove);
    QCOMPARE(widget.sizeHint().height(), heightWithoutLabel1);

    // e verify that changing back the hidden widget to want the hidden size will ensure that it gets more size
    label1->setSizePolicy(sp_retain);
    QCOMPARE(widget.sizeHint().height(), normalHeight);
}
コード例 #12
0
PluginCfg::PluginCfg(QWidget *parent, pluginInfo *info)
        : PluginCfgBase(parent)
{
    m_info = info;
    if (m_info->plugin){
        QWidget *w = m_info->plugin->createConfigWindow(addWnd);
        if (w){
            QVBoxLayout *lay = new QVBoxLayout(addWnd);
            lay->addWidget(w);
            QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
            // adjust plugin widget
            w->setMinimumSize(w->sizeHint());
            w->adjustSize();
            // adjust addWnd widget
            addWnd->setMinimumSize(addWnd->sizeHint());
            addWnd->adjustSize();
        }
    }
    // adjust description
    if (m_info->info && m_info->info->description){
        lblDescription->setText(i18n(m_info->info->description));
    }else{
        lblDescription->setText("");
    }
    // adjust tab
    tabWnd->setCurrentPage(0);
    tabWnd->changeTab(tabWnd->currentPage(), i18n(m_info->info->title));
    tabWnd->setMinimumSize(tabWnd->sizeHint());
    tabWnd->adjustSize();
    // adjust complete widget
    setMinimumSize(sizeHint());
    adjustSize();
    if (m_info->info && (m_info->info->flags & PLUGIN_NODISABLE)){
        chkEnable->hide();
    }else{
        if (m_info->bNoCreate){
            chkEnable->setEnabled(false);
            chkEnable->setChecked(false);
        }else{
            chkEnable->setEnabled(true);
            chkEnable->setChecked(!m_info->bDisabled);
        }
    }
}
コード例 #13
0
ファイル: cropimgscreen.cpp プロジェクト: berezich/oneCard
CropImgScreen::CropImgScreen(QSize size, double scale, QString imgSrc, QString fileNameForSave, QWidget *parent):Overlay(parent)
{
    init();
    this->fileNameForSave = fileNameForSave;
    scaleFactor = scale;
    screenSize = size;
    setMinimumSize(size);
    setMaximumSize(size);

    sideOff = sideOff*scale;
    iconSize = iconSize*scale;
    frameWidth = frameWidth*scale;
    layout = new QVBoxLayout();
    layout->setSpacing(0);
    setLayout(layout);
    layout->setContentsMargins(0,0,0,0);

    imgIcon = new Cropper(scaleFactor,0,imgSrc,size-QSize(2*sideOff,0),false,this);

    int topOffset = (size.height()-imgIcon->height())/2;
    layout->addSpacing(topOffset);
    layout->addWidget(imgIcon);
    imgIcon->setAlignment(Qt::AlignCenter);
    layout->addStretch(1);
    QWidget *lineWidget = new QWidget(this);
    QHBoxLayout *lineLayout = new QHBoxLayout(lineWidget);
    lineWidget->setLayout(lineLayout);
    lineLayout->setContentsMargins(0,0,0,0);
    lineLayout->addStretch(1);
    iconOk = new SimpleIcon(0,":/svg/tools/OKcamera.svg","",iconSize);
    connect(iconOk,SIGNAL(click(int)),this,SLOT(onIconPressed(int)));
    iconOk->setAlignment(Qt::AlignBottom|Qt::AlignRight);
    lineLayout->addWidget(iconOk);
    iconNo = new SimpleIcon(1,":/svg/tools/NOcamera.svg","",iconSize);
    connect(iconNo,SIGNAL(click(int)),this,SLOT(onIconPressed(int)));
    iconNo->setAlignment(Qt::AlignBottom|Qt::AlignRight);
    lineLayout->addWidget(iconNo);
    lineLayout->addStretch(1);
    layout->addWidget(lineWidget);
    layout->addSpacing(10*scaleFactor);
    lineWidget->adjustSize();
}
コード例 #14
0
void JabberSearch::setSize()
{
    if (!m_bDirty || (parent() == NULL))
        return;
    m_bDirty = false;
    for (QWidget *p = this; p; p = p->parentWidget()){
        QSize s  = p->sizeHint();
        QSize s1 = QSize(p->width(), p->height());
        p->setMinimumSize(s);
        p->resize(QMAX(s.width(), s1.width()), QMAX(s.height(), s1.height()));
        if (p->layout())
            p->layout()->invalidate();
        if (p == topLevelWidget())
            break;
    }
    QWidget *t = topLevelWidget();
    QSize s = t->sizeHint();
    t->resize(QMAX(t->width(), s.width()), QMAX(t->height(), s.height()));
    t->adjustSize();
}
コード例 #15
0
void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated()
{
    QWidget main;

    QVBoxLayout *const layout = new QVBoxLayout(&main);
    layout->setMargin(0);
    SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
    frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    layout->addWidget(frame);

    SizeHinterFrame *frame2 = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
    frame2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    layout->addWidget(frame2);

    main.show();

    frame2->hide();
    main.adjustSize();
    QCOMPARE(main.size(), QSize(200, 10));
}
コード例 #16
0
ファイル: main.cpp プロジェクト: kgadek/kpfp
int main(int argc, char **argv) {
	QApplication app(argc, argv);

	QWidget *window = new QWidget;
	window->setWindowTitle("Real Life simulator: zwierzyna kontra predator");

	QHBoxLayout *layout = new QHBoxLayout;
	QVBoxLayout *settings = new QVBoxLayout();

	PlotArea *plot = new PlotArea();


	// ********************************************************************************
	QLabel *labA = new QLabel("Wsp. smierci drapieznikow z powodu braku ofiar (0,1]");
	QSlider *slA = new QSlider(Qt::Horizontal);
	slA->setMaximum((int)sliderAmax);
	slA->setMinimum(1);
	slA->setValue(0.1*sliderAmax);
	settings->addWidget(labA);
	settings->addWidget(slA);
	QObject::connect(slA,SIGNAL(valueChanged(int)),plot,SLOT(setA(int)));

	QLabel *labB = new QLabel("Wsp. narodzin ofiar, gdy nie ma drapieznikow (0,1]");
	QSlider *slB = new QSlider(Qt::Horizontal);
	slB->setMaximum((int)sliderBmax);
	slB->setMinimum(1);
	slB->setValue(0.1*sliderBmax);
	settings->addWidget(labB);
	settings->addWidget(slB);
	QObject::connect(slB,SIGNAL(valueChanged(int)),plot,SLOT(setB(int)));

	QLabel *labC = new QLabel("Efektywnosc, z jaka drapieznik wykorzystuje energie\npozyskana ze zjedzenia ofiar (0,1]");
	QSlider *slC = new QSlider(Qt::Horizontal);
	slC->setMaximum((int)sliderCmax);
	slC->setMinimum(1);
	slC->setValue(0.07*sliderCmax);
	settings->addWidget(labC);
	settings->addWidget(slC);
	QObject::connect(slC,SIGNAL(valueChanged(int)),plot,SLOT(setC(int)));

	QLabel *labD = new QLabel("Efektywnosc usmiercania ofiar przez\ndrapieznikow (0,1]");
	QSlider *slD = new QSlider(Qt::Horizontal);
	slD->setMaximum((int)sliderDmax);
	slD->setMinimum(1);
	slD->setValue(0.008*sliderDmax);
	settings->addWidget(labD);
	settings->addWidget(slD);
	QObject::connect(slD,SIGNAL(valueChanged(int)),plot,SLOT(setD(int)));

	QLabel *labH = new QLabel("Krok czasowy (0,1]");
	QSlider *slH = new QSlider(Qt::Horizontal);
	slH->setMaximum((int)sliderHmax);
	slH->setMinimum(1);
	slH->setValue(0.1*sliderHmax);
	settings->addWidget(labH);
	settings->addWidget(slH);
	QObject::connect(slH,SIGNAL(valueChanged(int)),plot,SLOT(setH(int)));

	QLabel *labN = new QLabel("Ilosc krokow (0,1000000]");
	QSlider *slN = new QSlider(Qt::Horizontal);
	slN->setMaximum(100000);
	slN->setMinimum(1);
	slN->setValue(10000);
	settings->addWidget(labN);
	settings->addWidget(slN);
	QObject::connect(slN,SIGNAL(valueChanged(int)),plot,SLOT(setN(int)));

	QLabel *labX = new QLabel("Poczatkowa ilosc drapieznikow\n(0,10000]");
	QSlider *slX = new QSlider(Qt::Horizontal);
	slX->setMaximum(1000);
	slX->setMinimum(1);
	slX->setValue(1);
	settings->addWidget(labX);
	settings->addWidget(slX);
	QObject::connect(slX,SIGNAL(valueChanged(int)),plot,SLOT(setX0(int)));

	QLabel *labY = new QLabel("Poczatkowa ilosc ofiar (0,10000]");
	QSlider *slY = new QSlider(Qt::Horizontal);
	slY->setMaximum(10000);
	slY->setMinimum(1);
	slY->setValue(1000);
	settings->addWidget(labY);
	settings->addWidget(slY);
	QObject::connect(slY,SIGNAL(valueChanged(int)),plot,SLOT(setY0(int)));


	// ********************************************************************************
	layout->addWidget(plot);
	layout->addLayout(settings);

	window->setLayout(layout);
	window->adjustSize();
	window->setFixedWidth(900);
	window->show();

	return app.exec();
}
コード例 #17
0
ファイル: qwidgetproto.cpp プロジェクト: AlFoX/qt-client
void QWidgetProto::adjustSize()
{
  QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
  if (item)
    item->adjustSize();
}
コード例 #18
0
ファイル: behaviorconfig_shorten.cpp プロジェクト: KDE/choqok
void BehaviorConfig_Shorten::slotConfigureClicked()
{
    qCDebug(CHOQOK);
    KPluginInfo pluginInfo = availablePlugins.value(shortenPlugins->itemData(shortenPlugins->currentIndex()).toString());
    qCDebug(CHOQOK) << pluginInfo.name() << pluginInfo.kcmServices().count();

    QPointer<QDialog> configDialog = new QDialog(this);
    configDialog->setWindowTitle(pluginInfo.name());
    // The number of KCModuleProxies in use determines whether to use a tabwidget
    QTabWidget *newTabWidget = 0;
    // Widget to use for the setting dialog's main widget,
    // either a QTabWidget or a KCModuleProxy
    QWidget *mainWidget = 0;
    // Widget to use as the KCModuleProxy's parent.
    // The first proxy is owned by the dialog itself
    QWidget *moduleProxyParentWidget = configDialog;

    for (const KService::Ptr &servicePtr: pluginInfo.kcmServices()) {
        if (!servicePtr->noDisplay()) {
            KCModuleInfo moduleInfo(servicePtr);
            KCModuleProxy *currentModuleProxy = new KCModuleProxy(moduleInfo, moduleProxyParentWidget);
            if (currentModuleProxy->realModule()) {
                moduleProxyList << currentModuleProxy;
                if (mainWidget && !newTabWidget) {
                    // we already created one KCModuleProxy, so we need a tab widget.
                    // Move the first proxy into the tab widget and ensure this and subsequent
                    // proxies are in the tab widget
                    newTabWidget = new QTabWidget(configDialog);
                    moduleProxyParentWidget = newTabWidget;
                    mainWidget->setParent(newTabWidget);
                    KCModuleProxy *moduleProxy = qobject_cast<KCModuleProxy *>(mainWidget);
                    if (moduleProxy) {
                        newTabWidget->addTab(mainWidget, moduleProxy->moduleInfo().moduleName());
                        mainWidget = newTabWidget;
                    } else {
                        delete newTabWidget;
                        newTabWidget = 0;
                        moduleProxyParentWidget = configDialog;
                        mainWidget->setParent(0);
                    }
                }

                if (newTabWidget) {
                    newTabWidget->addTab(currentModuleProxy, servicePtr->name());
                } else {
                    mainWidget = currentModuleProxy;
                }
            } else {
                delete currentModuleProxy;
            }
        }
    }

    // it could happen that we had services to show, but none of them were real modules.
    if (moduleProxyList.count()) {
        QWidget *showWidget = new QWidget(configDialog);
        QVBoxLayout *layout = new QVBoxLayout;
        showWidget->setLayout(layout);
        layout->addWidget(mainWidget);
        layout->insertSpacing(-1, QApplication::style()->pixelMetric(QStyle::PM_DialogButtonsSeparator));

        QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
        QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
        okButton->setDefault(true);
        okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
        connect(buttonBox, &QDialogButtonBox::accepted, configDialog.data(), &QDialog::accept);
        connect(buttonBox, &QDialogButtonBox::rejected, configDialog.data(), &QDialog::reject);
        layout->addWidget(buttonBox);
        showWidget->adjustSize();

//         connect(&configDialog, SIGNAL(defaultClicked()), this, SLOT(slotDefaultClicked()));

        if (configDialog->exec() == QDialog::Accepted) {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QLatin1String("X-KDE-ParentComponents")).toStringList();
                moduleProxy->save();
            }
        } else {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                moduleProxy->load();
            }
        }

        qDeleteAll(moduleProxyList);
        moduleProxyList.clear();
    }
}
コード例 #19
0
/******************************************************************************
* Return the minimum size for the dialog.
* If the minimum size would be too high to fit the desktop, the tab contents
* are made scrollable.
*/
QSize StackedScrollGroup::adjustSize(bool force)
{
    if (force)
        mSized = false;
    if (mSized)
        return QSize();

    // Cancel any previous minimum height and set the height of the
    // scroll widget contents widgets.
    mMinHeight = -1;
    mHeightReduction = 0;
    QSize s = maxMinimumSizeHint();
    if (s.isEmpty())
        return QSize();
    int maxTabHeight = s.height();
    for (int i = 0, count = mWidgets.count();  i < count;  ++i)
    {
        mWidgets[i]->setMinimumHeight(maxTabHeight);
        QWidget* w = static_cast<StackedScrollWidget*>(mWidgets[i])->widget();
        if (w)
            w->resize(s);
    }
    for (QWidget* w = mWidgets[0]->parentWidget();  w && w != mDialog;  w = w->parentWidget())
    {
        w->setMinimumHeight(0);
        w->adjustSize();
    }
    mDialog->setMinimumHeight(0);

    int decoration = mDialog->frameGeometry().height() - mDialog->geometry().height();
    if (!decoration)
    {
        // On X11 at least, the window decoration height may not be
        // available, so use a guess of 25 pixels.
        decoration = 25;
    }
    int desk = KAlarm::desktopWorkArea().height();
    // There is no stored size, or the deferral group is visible.
    // Allow the tab contents to be scrolled vertically if that is necessary
    // to avoid the dialog exceeding the screen height.
    QSize dlgsize = mDialog->KDialog::minimumSizeHint();
    int y = dlgsize.height() + decoration - desk;
    if (y > 0)
    {
        mHeightReduction = y;
        mMinHeight = maxTabHeight - y;
        kDebug() << "Scrolling: max tab height=" << maxTabHeight << ", reduction=" << mHeightReduction << "-> min tab height=" << mMinHeight;
        if (mMinHeight > 0)
        {
            for (int i = 0, count = mWidgets.count();  i < count;  ++i)
            {
                mWidgets[i]->setMinimumHeight(mMinHeight);
                mWidgets[i]->resize(QSize(mWidgets[i]->width(), mMinHeight));
            }
        }
        mSized = true;
        QSize s = mWidgets[0]->parentWidget()->sizeHint();
        if (s.height() < mMinHeight)
            s.setHeight(mMinHeight);
        mWidgets[0]->parentWidget()->resize(s);
        for (QWidget* w = mWidgets[0]->parentWidget();  w && w != mDialog;  w = w->parentWidget())
            w->setMinimumHeight(qMin(w->minimumSizeHint().height(), w->sizeHint().height()));
        dlgsize.setHeight(dlgsize.height() - mHeightReduction);
        s = mDialog->KDialog::minimumSizeHint();
        if (s.height() > dlgsize.height())
            dlgsize.setHeight(s.height());
        mDialog->setMinimumHeight(dlgsize.height());
    }
    mSized = true;
    mDialog->resize(dlgsize);
    return s;
}
コード例 #20
0
void ActionConfigDialog::saveCurrentAction()
{
  static_cast<TagAction *>(currentAction)->setModified(true);
  QString s;
  QDomElement el = static_cast<TagAction *>(currentAction)->data();
  s = actionIcon->icon();
  el.setAttribute("icon", s);
  currentAction->setIcon(s);
  QString oldText = el.attribute("text");
  s = lineText->text();
  s.replace('&', "&&");
  el.setAttribute("text", s);
  currentAction->setText(s);
  s = lineToolTip->text();
  el.setAttribute("tooltip", s);
  currentAction->setToolTip(s);
  s = "";
  if (customShortcut->isChecked())
  {
    s = selectedShortcut.toString();
    currentAction->setShortcut(selectedShortcut);
  } else
  {
    currentAction->setShortcut(KShortcut());
  }
  el.setAttribute("shortcut", s);


//update the tree view
  QListViewItem *listItem;
  QListViewItemIterator it(actionTreeView);
  while (it.current())
  {
    listItem = it.current();
    if (listItem->depth() > 0 && listItem->text(2) == currentAction->name())
    {
      listItem->setPixmap(0, SmallIcon(actionIcon->icon()));
      listItem->setText(0, lineText->text());
      listItem->setText(1, currentAction->shortcut().toString());
    }
    ++it;
  }

//remove all the detailed settings
  QDomElement item = el.namedItem("tag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("tag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("xtag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("script").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("text").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
//add the new detailed settings
  QDomDocument document = QDomDocument();
  int type = typeCombo->currentItem();
  switch (type)
  {
    case 1:{
        el.setAttribute("type","script");
        item = document.createElement("script");
        switch (inputBox->currentItem())
        {
          case 1:{ item.setAttribute("input", "current");
                   break;
                 }
          case 2:{ item.setAttribute("input", "selected");
                   break;
                 }
          default:{ item.setAttribute("input", "none");
                    break;
                  }
        }
        switch (outputBox->currentItem())
        {
          case 1:{ item.setAttribute("output", "cursor");
                   break;
                 }
          case 2:{ item.setAttribute("output", "selection");
                   break;
                 }
          case 3:{ item.setAttribute("output", "replace");
                   break;
                 }
          case 4:{ item.setAttribute("output", "new");
                   break;
                 }
          case 5:{ item.setAttribute("output", "message");
                   break;
                 }
          default:{ item.setAttribute("output", "none");
                    break;
                  }
        }
        switch (errorBox->currentItem())
        {
          case 1:{ item.setAttribute("error", "cursor");
                   break;
                 }
          case 2:{ item.setAttribute("error", "selection");
                   break;
                 }
          case 3:{ item.setAttribute("error", "replace");
                   break;
                 }
          case 4:{ item.setAttribute("error", "new");
                   break;
                 }
          case 5:{ item.setAttribute("error", "message");
                   break;
                 }
          default:{ item.setAttribute("error", "none");
                    break;
                  }
        }

        el.appendChild(item);
        item.appendChild(document.createTextNode(scriptPath->text()));
        break;
      }
    case 2:{
        el.setAttribute("type","text");
        item = document.createElement("text");
        el.appendChild(item);
        item.appendChild(document.createTextNode(textEdit->text()));
        break;
      }
    default:{
        el.setAttribute("type","tag");
        item = document.createElement("tag");
        item.setAttribute("useDialog", useActionDialog->isChecked() ? "true" : "false");
        el.appendChild(item);
        item.appendChild(document.createTextNode(lineTag->text()));
        item = document.createElement("xtag");
        item.setAttribute("use", useClosingTag->isChecked() ? "true" : "false");
        el.appendChild(item);
        item.appendChild(document.createTextNode(lineClosingTag->text()));
        break;
      }
  }
  ToolbarTabWidget *tb = ToolbarTabWidget::ref();
  for (int i = 0; i < tb->count(); i++)
  {
    QString toolbarName = tb->label(i);
    QString toolbarId = tb->id(i);
    ToolbarEntry *p_toolbar = m_toolbarList[toolbarId];
    bool isOnToolbar = false;
    if (p_toolbar)
    {
      QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild();
      bool placeOnToolbar = toolbarListBox->findItem(toolbarName, Qt::ExactMatch);
      while (!node.isNull())
      {
        if (node.nodeName() == "Action" &&
            node.toElement().attribute("name") == el.attribute("name"))
        {
          //if it's present in the toolbar, but not in the container list,
          //remove it also from the toolbar
          if (!placeOnToolbar)
          {
            currentAction->unplug(tb->page(i));
            currentAction->unplug(p_toolbar->menu);
            node.parentNode().removeChild(node);
            QListViewItemIterator iter(actionTreeView);
            while (iter.current())
            {
              listItem = iter.current();
              if (listItem->depth() > 0 && listItem->parent()->text(0) == toolbarName
                  && listItem->text(2) == el.attribute("name"))
              {
                delete listItem;
                break;
              }
              ++iter;
            }
          }
          isOnToolbar = true;
          break;
        }
        node = node.nextSibling();
      }
      //it's not on the toolbar, but it should be
      if (!isOnToolbar && placeOnToolbar)
      {
        currentAction->plug(tb->page(i));
        currentAction->plug(p_toolbar->menu);
        item = p_toolbar->guiClient->domDocument().createElement("Action");
        item.setAttribute("name",el.attribute("name"));
        p_toolbar->guiClient->domDocument().firstChild().firstChild().appendChild(item);
      //put it also in the treeview
        listItem = actionTreeView->findItem(toolbarName, 0);
        if (listItem)
        {
          QListViewItem *after = listItem->firstChild();
          while ( after && (!after->nextSibling() || (after->nextSibling() && after->nextSibling()->depth()!=0 ) ))
          {
            if (after->text(2) == currentAction->name())
            {
                placeOnToolbar = false;
                break;
            }
            after = after->nextSibling();
          }
          if (placeOnToolbar)
          {
              listItem = new KListViewItem(listItem, after, lineText->text(), currentAction->shortcut().toString(), currentAction->name());
              listItem->setPixmap(0, SmallIcon(actionIcon->icon()));
          }
        }
      }
      KXMLGUIFactory::saveConfigFile(p_toolbar->guiClient->domDocument(),
        p_toolbar->guiClient->xmlFile(), p_toolbar->guiClient->instance());
    }
    QWidget *toolBar = tb->page(i);
    if (toolBar->minimumSizeHint().height() > 20)
    {
      toolBar->adjustSize();
      toolBar->setGeometry(0,0, tb->width(), toolBar->height());
    } else
    {
      toolBar->setGeometry(0,0, tb->width(), tb->height() - tb->tabHeight());
    }

  }
}
コード例 #21
0
ファイル: kmixdockwidget.cpp プロジェクト: KDE/kmix
/**
 * Called whenever the icon gets "activated". Usually when its clicked.
 * @overload
 * @param pos
 */
void KMixDockWidget::activate(const QPoint &pos)
{
	QWidget* dockAreaPopup = _dockAreaPopupMenuWrapper; // TODO Refactor to use _dockAreaPopupMenuWrapper directly
	if (dockAreaPopup->isVisible())
	{
		dockAreaPopup->hide();
		return;
	}

	_dockAreaPopupMenuWrapper->removeAction(_volWA);
	delete _volWA;
	_volWA = new QWidgetAction(_dockAreaPopupMenuWrapper);
	_dockView = new ViewDockAreaPopup(_dockAreaPopupMenuWrapper, "dockArea", 0, QString("no-guiprofile-yet-in-dock"),
		_kmixMainWindow);
	_volWA->setDefaultWidget(_dockView);
	_dockAreaPopupMenuWrapper->addAction(_volWA);

	//_dockView->show(); // TODO cesken check: this should be automatic
	// Showing, to hopefully get the geometry manager started. We need width and height below. Also
	// vdesktop->availableGeometry(dockAreaPopup) needs to know on which screen the widget will be shown.
//	dockAreaPopup->show();
	_dockView->adjustSize();
	dockAreaPopup->adjustSize();

	int x = pos.x() - dockAreaPopup->width() / 2;
	if (x < 0)
		x = pos.x();
	int y = pos.y() - dockAreaPopup->height() / 2;
	if (y < 0)
		y = pos.y();

	// Now handle Multihead displays. And also make sure that the dialog is not
	// moved out-of-the screen on the right (see Bug 101742).
	const QDesktopWidget* vdesktop = QApplication::desktop();
	int screenNumber = vdesktop->screenNumber(pos);
	const QRect& vScreenSize = vdesktop->availableGeometry(screenNumber);

	if ((x + dockAreaPopup->width()) > (vScreenSize.width() + vScreenSize.x()))
	{
		// move horizontally, so that it is completely visible
		x = vScreenSize.width() + vScreenSize.x() - dockAreaPopup->width() - 1;
		kDebug() << "Multihead: (case 1) moving to" << x << "," << y;
	}
	else if (x < vScreenSize.x())
	{
		// horizontally out-of bound
		x = vScreenSize.x();
		kDebug() << "Multihead: (case 2) moving to" << x << "," << y;
	}

	if ((y + dockAreaPopup->height()) > (vScreenSize.height() + vScreenSize.y()))
	{
		// move horizontally, so that it is completely visible
		y = vScreenSize.height() + vScreenSize.y() - dockAreaPopup->height() - 1;
		kDebug() << "Multihead: (case 3) moving to" << x << "," << y;
	}
	else if (y < vScreenSize.y())
	{
		// horizontally out-of bound
		y = vScreenSize.y();
		kDebug() << "Multihead: (case 4) moving to" << x << "," << y;
	}


	KWindowSystem::setType(dockAreaPopup->winId(), NET::Dock);
	KWindowSystem::setState(dockAreaPopup->winId(), NET::StaysOnTop | NET::SkipTaskbar | NET::SkipPager);
	dockAreaPopup->show();
	dockAreaPopup->move(x, y);
}