Example #1
0
//------------------------------------------------------------------------------
void ctkColorDialogPrivate::init()
{
  Q_Q(ctkColorDialog);
  QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout());
  QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout());
  QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout());
  
  leftLay->setParent(0);
  this->BasicTab = new QWidget(q);
  this->BasicTab->setLayout(leftLay);

  this->LeftTabWidget = new QTabWidget(q);
  topLay->insertWidget(0, this->LeftTabWidget);
  this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic"));
}
Example #2
0
//------------------------------------------------------------------------------
void ctkColorDialogPrivate::init()
{
  Q_Q(ctkColorDialog);
  QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout());
  QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout());
  QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout());
  
  leftLay->setParent(0);
  this->BasicTab = new QWidget(q);
  this->BasicTab->setLayout(leftLay);

  this->LeftTabWidget = new QTabWidget(q);
  topLay->insertWidget(0, this->LeftTabWidget);
  this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic"));
  
  // If you use a ctkColorDialog, it's probably because you have tabs to add
  // into. Which means that you are likely to want to resize the dialog as
  // well.
  q->setSizeGripEnabled(true);
  q->layout()->setSizeConstraint(QLayout::SetDefaultConstraint);

  QObject::connect(q, SIGNAL(currentColorChanged(QColor)),
                   q, SLOT(resetColorName()));
}
Example #3
0
MainWindow::MainWindow(QWidget *parent, const char *title, const QSize &size, const char *path) :
	QMainWindow(parent), _status(statusBar()), _panelManager(new PanelManager()),
	_watcher(new QFutureWatcher<void>(this)) {
	/* Window setup. */
	setWindowTitle(title);
	resize(size);

	/* Actions. */
	_actionOpenDirectory = new QAction(this);
	_actionOpenFile = new QAction(this);
	_actionClose = new QAction(this);
	_actionQuit = new QAction(this);
	_actionAbout = new QAction(this);

	_actionOpenDirectory->setText(tr("&Open directory"));
	_actionOpenDirectory->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
	_actionOpenFile->setText(tr("Open &file"));
	_actionClose->setText(tr("&Close"));
	_actionClose->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
	_actionQuit->setText(tr("&Quit"));
	_actionQuit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
	_actionAbout->setText(tr("&About"));
	_actionAbout->setShortcut(QKeySequence(Qt::Key_F1));

	/* Menu. */
	_menuBar = new QMenuBar(this);
	_menuFile = new QMenu(_menuBar);
	_menuHelp = new QMenu(_menuBar);

	_menuBar->addAction(_menuFile->menuAction());
	_menuBar->addAction(_menuHelp->menuAction());
	_menuFile->addAction(_actionOpenDirectory);
	_menuFile->addAction(_actionOpenFile);
	_menuFile->addSeparator();
	_menuFile->addAction(_actionClose);
	_menuFile->addSeparator();
	_menuFile->addAction(_actionQuit);
	_menuFile->setTitle("&File");
	_menuHelp->addAction(_actionAbout);
	_menuHelp->setTitle("&Help");

	setMenuBar(_menuBar);

	/* Slots. */
	QObject::connect(_actionOpenDirectory, &QAction::triggered, this, &MainWindow::slotOpenDirectory);
	QObject::connect(_actionOpenFile, &QAction::triggered, this, &MainWindow::slotOpenFile);
	QObject::connect(_actionClose, &QAction::triggered, this, &MainWindow::slotClose);
	QObject::connect(_actionQuit, &QAction::triggered, this, &MainWindow::slotQuit);
	QObject::connect(_actionAbout, &QAction::triggered, this, &MainWindow::slotAbout);

	/* Layout. */
	_centralWidget = new QWidget(this);
	_centralLayout = new QGridLayout(_centralWidget);
	_splitterTopBottom = new QSplitter(_centralWidget);
	_splitterLeftRight = new QSplitter(_splitterTopBottom);
	_treeView = new QTreeView(_splitterLeftRight);
	QGroupBox *logBox = new QGroupBox(_splitterTopBottom);
	QWidget *previewWrapper = new QWidget(_splitterTopBottom); // Can't add a layout directly to a splitter.
	QVBoxLayout *previewWrapperLayout = new QVBoxLayout(previewWrapper);
	QFrame *resInfoFrame = new QFrame(previewWrapper);
	_resPreviewFrame = new QFrame(previewWrapper);
	_log = new QTextEdit(logBox);
	_log->setReadOnly(true);

	// Tree
	// 1:8 ratio; tree:preview/log
	{
		QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred);
		sp.setHorizontalStretch(1);
		_treeView->setSizePolicy(sp);
	}

	// Preview wrapper
	previewWrapper->setLayout(previewWrapperLayout);
	previewWrapper->setContentsMargins(0, 0, 0, 0);
	previewWrapperLayout->setParent(previewWrapper);
	previewWrapperLayout->setMargin(0);
	previewWrapperLayout->addWidget(resInfoFrame);
	previewWrapperLayout->addWidget(_resPreviewFrame);
	{
		QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred);
		sp.setHorizontalStretch(6);
		previewWrapper->setSizePolicy(sp);
	}

	// Log
	logBox->setTitle(tr("Log"));
	{
		QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred);
		sp.setVerticalStretch(1);
		logBox->setSizePolicy(sp);

		QHBoxLayout *hl = new QHBoxLayout(logBox);
		hl->addWidget(_log);
		hl->setContentsMargins(0, 5, 0, 0);
	}

	// Left/right splitter
	// 8:1 ratio, preview:log
	_splitterLeftRight->addWidget(_treeView);
	_splitterLeftRight->addWidget(previewWrapper);
	{
		QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred);
		sp.setVerticalStretch(5);
		_splitterLeftRight->setSizePolicy(sp);
	}

	// Top/bottom splitter
	_splitterTopBottom->setOrientation(Qt::Vertical);
	_splitterTopBottom->addWidget(_splitterLeftRight);
	_splitterTopBottom->addWidget(logBox);

	// Resource info frame
	_panelManager->registerPanel(new PanelPreviewEmpty(nullptr), Aurora::kResourceNone);
	_panelManager->registerPanel(new PanelPreviewSound(nullptr), Aurora::kResourceSound);
	_panelManager->registerPanel(new PanelPreviewImage(nullptr), Aurora::kResourceImage);
	_panelManager->registerPanel(new PanelPreviewText(nullptr), Aurora::kResourceText);
	_panelManager->registerPanel(new PanelPreviewTable(nullptr), Aurora::kResourceTable);
	_panelManager->setItem(nullptr);

	PanelPreviewText *textPanel = static_cast<PanelPreviewText *>(_panelManager->getPanelByType(Aurora::kResourceText));
	PanelPreviewTable *tablePanel = static_cast<PanelPreviewTable *>(_panelManager->getPanelByType(Aurora::kResourceTable));
	QObject::connect(textPanel, &PanelPreviewText::log, this, &MainWindow::slotLog);
	QObject::connect(tablePanel, &PanelPreviewTable::log, this, &MainWindow::slotLog);

	_panelResourceInfo = new PanelResourceInfo(this);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::closeDirClicked, this, &MainWindow::slotClose);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::saveClicked, this, &MainWindow::saveItem);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::exportTGAClicked, this, &MainWindow::exportTGA);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::exportBMUMP3Clicked, this, &MainWindow::exportBMUMP3);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::exportWAVClicked, this, &MainWindow::exportWAV);
	QObject::connect(_panelResourceInfo, &PanelResourceInfo::log, this, &MainWindow::slotLog);
	resInfoFrame->setFrameShape(QFrame::StyledPanel);
	resInfoFrame->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
	resInfoFrame->setFixedHeight(140);
	{
		QHBoxLayout *hl = new QHBoxLayout(resInfoFrame);
		hl->addWidget(_panelResourceInfo);
	}

	// Resource preview frame
	_resPreviewFrame->setFrameShape(QFrame::StyledPanel);
	{
		QHBoxLayout *hl = new QHBoxLayout(_resPreviewFrame);

		hl->setMargin(0);
		_panelManager->setLayout(hl);
	}

	setCentralWidget(_centralWidget);
	_centralLayout->addWidget(_splitterTopBottom);

	/* Open path. */
	const QString qpath = QString::fromUtf8(path);

	_treeModel = std::make_unique<ResourceTree>(this, _treeView);
	_proxyModel = std::make_unique<ProxyModel>(this);

	_panelManager->setItem(nullptr);

	_status.setText("Idle...");

	if (qpath.isEmpty())
		_actionClose->setEnabled(false);
	else
		open(qpath);
}
Example #4
0
KDMDialogWidget::KDMDialogWidget(QWidget *parent)
    : QWidget(parent)
{
    QString wtstr;

    QGridLayout *grid = new QGridLayout(this);
    grid->setMargin(KDialog::marginHint());
    grid->setSpacing(KDialog::spacingHint());
    grid->setColumnStretch(1, 1);

    QHBoxLayout *hlay = new QHBoxLayout();
    hlay->setSpacing(KDialog::spacingHint());
    grid->addLayout(hlay, 0, 0, 1, 2);
    greetstr_lined = new KLineEdit(this);
    QLabel *label = new QLabel(i18n("&Greeting:"), this);
    label->setBuddy(greetstr_lined);
    hlay->addWidget(label);
    connect(greetstr_lined, SIGNAL(textChanged(QString)),
            SIGNAL(changed()));
    hlay->addWidget(greetstr_lined);
    wtstr = i18n(
        "<p>This is the \"headline\" for KDM's login window. You may want to "
        "put some nice greeting or information about the operating system here.</p>"
        "<p>KDM will substitute the following character pairs with the "
        "respective contents:</p>"
        "<ul>"
        "<li>%d -> current display</li>"
        "<li>%h -> host name, possibly with domain name</li>"
        "<li>%n -> node name, most probably the host name without domain name</li>"
        "<li>%s -> the operating system</li>"
        "<li>%r -> the operating system's version</li>"
        "<li>%m -> the machine (hardware) type</li>"
        "<li>%% -> a single %</li>"
        "</ul>");
    label->setWhatsThis(wtstr);
    greetstr_lined->setWhatsThis(wtstr);


    QGridLayout *hglay = new QGridLayout();
    hglay->setSpacing(KDialog::spacingHint());
    grid->addLayout(hglay, 1, 0);

    label = new QLabel(i18n("Logo area:"), this);
    hglay->addWidget(label, 0, 0);
    QVBoxLayout *vlay = new QVBoxLayout();
    vlay->setSpacing(KDialog::spacingHint());
    hglay->addLayout(vlay, 0, 1, 1, 2);
    noneRadio = new QRadioButton(i18nc("logo area", "&None"), this);
    clockRadio = new QRadioButton(i18n("Show cloc&k"), this);
    logoRadio = new QRadioButton(i18n("Sho&w logo"), this);
    QButtonGroup *buttonGroup = new QButtonGroup(this);
    connect(buttonGroup, SIGNAL(buttonClicked(int)),
            SLOT(slotAreaRadioClicked(int)));
    connect(buttonGroup, SIGNAL(buttonClicked(int)), SIGNAL(changed()));
    buttonGroup->addButton(noneRadio, KdmNone);
    buttonGroup->addButton(clockRadio, KdmClock);
    buttonGroup->addButton(logoRadio, KdmLogo);
    vlay->addWidget(noneRadio);
    vlay->addWidget(clockRadio);
    vlay->addWidget(logoRadio);
    wtstr = i18n("You can choose to display a custom logo (see below), a clock or no logo at all.");
    label->setWhatsThis(wtstr);
    noneRadio->setWhatsThis(wtstr);
    logoRadio->setWhatsThis(wtstr);
    clockRadio->setWhatsThis(wtstr);

    logoLabel = new QLabel(i18n("&Logo:"), this);
    logobutton = new QPushButton(this);
    logoLabel->setBuddy(logobutton);
    logobutton->setAutoDefault(false);
    logobutton->setAcceptDrops(true);
    logobutton->installEventFilter(this); // for drag and drop
    connect(logobutton, SIGNAL(clicked()), SLOT(slotLogoButtonClicked()));
    hglay->addWidget(logoLabel, 1, 0, Qt::AlignVCenter);
    hglay->addWidget(logobutton, 1, 1, Qt::AlignCenter);
    hglay->setRowMinimumHeight(1, 110);
    wtstr = i18n(
        "Click here to choose an image that KDM will display. "
        "You can also drag and drop an image onto this button "
        "(e.g. from Konqueror).");
    logoLabel->setWhatsThis(wtstr);
    logobutton->setWhatsThis(wtstr);


    vlay = new QVBoxLayout();
    grid->addLayout(vlay, 1, 1, 2, 1);
    vlay->setParent(grid);

    label = new QLabel(i18n("Dialog &position:"), this);
    vlay->addWidget(label);
    positioner = new Positioner(this);
    label->setBuddy(positioner);
    connect(positioner, SIGNAL(positionChanged()), SIGNAL(changed()));
    vlay->addWidget(positioner);

    grid->setRowStretch(3, 1);

}