Exemplo n.º 1
0
void DkControlWidget::showWidgetsSettings() {

	if (mViewport->getImage().isNull()) {
		showPreview(false);
		showScroller(false);
		showMetaData(false);
		showFileInfo(false);
		showPlayer(false);
		showOverview(false);
		showHistogram(false);
		showCommentWidget(false);
		return;
	}

	//qDebug() << "current app mode: " << DkSettingsManager::param().app().currentAppMode;

	showOverview(mZoomWidget->getCurrentDisplaySetting());
	showPreview(mFilePreview->getCurrentDisplaySetting());
	showMetaData(mMetaDataInfo->getCurrentDisplaySetting());
	showFileInfo(mFileInfoLabel->getCurrentDisplaySetting());
	showPlayer(mPlayer->getCurrentDisplaySetting());
	showHistogram(mHistogram->getCurrentDisplaySetting());
	showCommentWidget(mCommentWidget->getCurrentDisplaySetting());
	showScroller(mFolderScroll->getCurrentDisplaySetting());
}
Exemplo n.º 2
0
SchematicViewer::SchematicViewer(QWidget *parent)
	: QWidget(parent), m_fullSchematic(true), m_maximizedNode(false), m_sceneHandle(0)
{
	m_viewer = new SchematicSceneViewer(this);
	m_stageScene = new StageSchematicScene(this);
	m_fxScene = new FxSchematicScene(this);

	m_commonToolbar = new QToolBar(m_viewer);
	m_stageToolbar = new QToolBar(m_viewer);
	m_fxToolbar = new QToolBar(m_viewer);
	m_swapToolbar = new QToolBar(m_viewer);

	m_commonToolbar->setObjectName("ToolBarWithoutBorder");
	m_stageToolbar->setObjectName("ToolBarWithoutBorder");
	m_fxToolbar->setObjectName("ToolBarWithoutBorder");
	m_swapToolbar->setObjectName("ToolBarWithoutBorder");

	createToolbars();
	createActions();

	// layout
	QVBoxLayout *mainLayout = new QVBoxLayout();
	mainLayout->setMargin(1);
	mainLayout->setSpacing(0);
	{
		mainLayout->addWidget(m_viewer, 1);

		QFrame *bottomFrame = new QFrame(this);
		bottomFrame->setObjectName("SchematicBottomFrame");
		QHBoxLayout *horizontalLayout = new QHBoxLayout();
		horizontalLayout->setMargin(0);
		horizontalLayout->setSpacing(0);
		{
			horizontalLayout->addWidget(m_commonToolbar);
			horizontalLayout->addStretch();
			horizontalLayout->addWidget(m_fxToolbar);
			horizontalLayout->addWidget(m_stageToolbar);
			horizontalLayout->addWidget(m_swapToolbar);
		}
		bottomFrame->setLayout(horizontalLayout);

		mainLayout->addWidget(bottomFrame, 0);
	}
	setLayout(mainLayout);

	connect(m_fxScene, SIGNAL(showPreview(TFxP)), this, SIGNAL(showPreview(TFxP)));
	connect(m_fxScene, SIGNAL(doCollapse(const QList<TFxP> &)), this, SIGNAL(doCollapse(const QList<TFxP> &)));
	connect(m_stageScene, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SIGNAL(doCollapse(QList<TStageObjectId>)));
	connect(m_fxScene, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SIGNAL(doExplodeChild(const QList<TFxP> &)));
	connect(m_stageScene, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SIGNAL(doExplodeChild(QList<TStageObjectId>)));
	connect(m_stageScene, SIGNAL(editObject()), this, SIGNAL(editObject()));
	connect(m_fxScene, SIGNAL(editObject()), this, SIGNAL(editObject()));

	m_viewer->setScene(m_stageScene);
	m_fxToolbar->hide();

	setFocusProxy(m_viewer);
}
Exemplo n.º 3
0
void FilePreview::previewUrl(const QUrl &url)
{
    if (!url.isLocalFile()){
        showPreview(NULL);
        return;
    }
    QString fileName = url.toString(false, false);
    showPreview(fileName.local8Bit());
}
Exemplo n.º 4
0
void FilePreview::showPreview(const KURL &url)
{
    if (!url.isLocalFile()){
        showPreview(NULL);
        return;
    }
    QString fileName = url.directory(false, false);
    if (!fileName.isEmpty() && (fileName[fileName.length() - 1] != '/'))
        fileName += '/';
    fileName += url.fileName(false);
    showPreview((const char*)fileName.local8Bit());
}
Exemplo n.º 5
0
void SchematicScenePanel::hideEvent(QHideEvent *e) {
  TApp *app = TApp::instance();
  disconnect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this,
             SLOT(onShowPreview(TFxP)));
  disconnect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this,
             SLOT(onCollapse(const QList<TFxP> &)));
  disconnect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this,
             SLOT(onCollapse(QList<TStageObjectId>)));
  disconnect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)),
             this, SLOT(onExplodeChild(const QList<TFxP> &)));
  disconnect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)),
             this, SLOT(onExplodeChild(QList<TStageObjectId>)));
  disconnect(m_schematicViewer, SIGNAL(editObject()), this,
             SLOT(onEditObject()));
  disconnect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()),
             m_schematicViewer, SLOT(updateScenes()));
  disconnect(app->getCurrentObject(), SIGNAL(objectSwitched()),
             m_schematicViewer, SLOT(updateScenes()));
  disconnect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()),
             m_schematicViewer, SLOT(updateSchematic()));
  disconnect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()),
             m_schematicViewer, SLOT(updateSchematic()));
  disconnect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer,
             SLOT(onSceneSwitched()));
}
Exemplo n.º 6
0
void SchematicScenePanel::showEvent(QShowEvent *e) {
  if (m_schematicViewer->isStageSchematicViewed())
    setWindowTitle("Stage Schematic");
  else
    setWindowTitle("Fx Schematic");

  TApp *app = TApp::instance();
  connect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this,
          SLOT(onShowPreview(TFxP)));
  connect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this,
          SLOT(onCollapse(const QList<TFxP> &)));
  connect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this,
          SLOT(onCollapse(QList<TStageObjectId>)));
  connect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)), this,
          SLOT(onExplodeChild(const QList<TFxP> &)));
  connect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)),
          this, SLOT(onExplodeChild(QList<TStageObjectId>)));
  connect(m_schematicViewer, SIGNAL(editObject()), this, SLOT(onEditObject()));
  connect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), m_schematicViewer,
          SLOT(updateScenes()));
  connect(app->getCurrentObject(), SIGNAL(objectSwitched()), m_schematicViewer,
          SLOT(updateScenes()));
  connect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), m_schematicViewer,
          SLOT(updateSchematic()));
  connect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), m_schematicViewer,
          SLOT(updateSchematic()));
  connect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer,
          SLOT(onSceneSwitched()));
  m_schematicViewer->updateSchematic();
}
Exemplo n.º 7
0
void EntityCreatorTypeHelper::updatePreview() {
	if (mModelPreviewRenderer && mRuleTreeAdapter) {
		auto typeData = mRuleTreeAdapter->getSelectedRule();
		if (typeData.isValid()) {
			//check if the type is bound
			mCurrentType = typeData->getId();
			auto type = mConnection.getTypeService()->getTypeByName(typeData->getId());
			if (type && type->isBound()) {
				Authoring::DetachedEntity entity("0", type, mConnection.getTypeService());
				showPreview(entity);

				mCreateButton->setEnabled(true);

				auto modeElement = type->getAttribute("mode");
				if (modeElement && modeElement->isString()) {
					mDefaultModeWindow.setText("(" + modeElement->String() + ")");
				} else {
					mModeCombobox.setText("");
				}

			} else {
				mModelPreviewRenderer->showModel("");
				mCreateButton->setEnabled(false);
			}
		} else {
			mModelPreviewRenderer->showModel("");
			mCreateButton->setEnabled(false);
		}
	}
}
Exemplo n.º 8
0
void FileTransferWidget::onFileTransferFinished(ToxFile file)
{
    if (fileInfo != file)
        return;

    fileInfo = file;

    setBackgroundColor(Style::getColor(Style::Green), true);

    setupButtons();
    hideWidgets();

    ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/yes.svg"));
    ui->topButton->setObjectName("ok");
    ui->topButton->setToolTip(tr("Open file"));
    ui->topButton->show();

    ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/dir.svg"));
    ui->bottomButton->setObjectName("dir");
    ui->bottomButton->setToolTip(tr("Open file directory"));
    ui->bottomButton->show();

    // preview
    if (fileInfo.direction == ToxFile::RECEIVING)
        showPreview(fileInfo.filePath);

    disconnect(Core::getInstance(), 0, this, 0);
}
Exemplo n.º 9
0
GifsListWidget::GifsListWidget(
	QWidget *parent,
	not_null<Window::Controller*> controller)
: Inner(parent, controller)
, _section(Section::Gifs)
, _updateInlineItems([=] { updateInlineItems(); })
, _previewTimer([=] { showPreview(); }) {
	setMouseTracking(true);
	setAttribute(Qt::WA_OpaquePaintEvent);

	_inlineRequestTimer.setSingleShot(true);
	connect(&_inlineRequestTimer, &QTimer::timeout, this, [this] { sendInlineRequest(); });

	Auth().data().savedGifsUpdated(
	) | rpl::start_with_next([this] {
		refreshSavedGifs();
	}, lifetime());
	subscribe(Auth().downloaderTaskFinished(), [this] {
		update();
	});
	subscribe(controller->gifPauseLevelChanged(), [this] {
		if (!this->controller()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs)) {
			update();
		}
	});
}
Exemplo n.º 10
0
void DockAppItem::onMouseEnter()
{
    if (hoverable()) {
        m_appBG->setIsHovered(true);
        showPreview();
        emit mouseEnter();
    }
}
Exemplo n.º 11
0
void DockAppItem::onMouseEnter()
{
    if (m_dockModeData->getHideState() != Dock::HideStateShown || !hoverable())
        return;

    m_appBG->setIsHovered(true);
    showPreview();
}
Exemplo n.º 12
0
void TabBarWidget::timerEvent(QTimerEvent *event)
{
	if (event->timerId() == m_previewTimer)
	{
		killTimer(m_previewTimer);

		m_previewTimer = 0;

		showPreview(tabAt(mapFromGlobal(QCursor::pos())));
	}
}
Exemplo n.º 13
0
void Grillewindow::openImage()
{
    QString title = tr("Ouvrir l'image");
    QString directory = homePath;
    QString filename = QFileDialog::getOpenFileName(
                this,
                title,
                directory,
                tr("Images (*.jpg *.jpeg *.bmp *.png)")
                );
    if(filename != "") {
        showPreview(filename);
    }
}
Exemplo n.º 14
0
void TabBarWidget::mouseMoveEvent(QMouseEvent *event)
{
	QTabBar::mouseMoveEvent(event);

	if (m_previewWidget && !m_previewWidget->isVisible() && m_previewTimer == 0)
	{
		m_previewWidget->show();
	}

	if (m_previewWidget && m_previewWidget->isVisible())
	{
		showPreview(tabAt(event->pos()));
	}
}
Exemplo n.º 15
0
void TabBarWidget::updateTabs(int index)
{
	if (index < 0 && sender() && sender()->inherits(QStringLiteral("Otter::Window").toLatin1()))
	{
		for (int i = 0; i < count(); ++i)
		{
			if (sender() == qvariant_cast<QObject*>(tabData(i)))
			{
				index = i;

				break;
			}
		}
	}

	const int limit = ((index >= 0) ? (index + 1) : count());

	for (int i = ((index >= 0) ? index : 0); i < limit; ++i)
	{
		const bool isLoading = getTabProperty(i, QLatin1String("isLoading"), false).toBool();
		QLabel *label = qobject_cast<QLabel*>(tabButton(i, QTabBar::LeftSide));

		if (label)
		{
			if (isLoading)
			{
				if (!label->movie())
				{
					QMovie *movie = new QMovie(QLatin1String(":/icons/loading.gif"), QByteArray(), label);
					movie->start();

					label->setMovie(movie);
				}
			}
			else
			{
				if (label->movie())
				{
					label->movie()->deleteLater();
					label->setMovie(NULL);
				}

				label->setPixmap(getTabProperty(i, QLatin1String("icon"), QIcon(getTabProperty(i, QLatin1String("isPrivate"), false).toBool() ? ":/icons/tab-private.png" : ":/icons/tab.png")).value<QIcon>().pixmap(16, 16));
			}
		}
	}

	showPreview(tabAt(mapFromGlobal(QCursor::pos())));
}
Exemplo n.º 16
0
void EntityCreatorTypeHelper::typeService_BoundType(Eris::TypeInfo* typeInfo) {
	//If the type that's now bound is the one that's currently handled, update the preview
	if (mModelPreviewRenderer && mRuleTreeAdapter && typeInfo->getName() == mCurrentType) {
		auto typeData = mRuleTreeAdapter->getSelectedRule();
		if (typeData.isValid()) {
			Authoring::DetachedEntity entity("0", typeInfo, mConnection.getTypeService());
			showPreview(entity);
			mCreateButton->setEnabled(true);
			auto modeElement = typeInfo->getAttribute("mode");
			if (modeElement && modeElement->isString()) {
				mDefaultModeWindow.setText("(" + modeElement->String() + ")");
			} else {
				mModeCombobox.setText("");
			}
		}
	}
}
Exemplo n.º 17
0
Trash::Trash(QHash<QString,QStringList> *backupDataHash, QWidget *parent): QDialog(parent){
     setupUi(this);

     setAttribute(Qt::WA_DeleteOnClose);

     const auto keys =  backupDataHash->keys();
     for(QString key : keys)
     {
          QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
          item->setText(0,backupDataHash->value(key).first()); //title
          item->setData(0,Qt::UserRole,backupDataHash->value(key)); //title, path and content
     }

     treeWidget->sortByColumn(0,Qt::AscendingOrder);
     // TODO flickcharm here

     connect(treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(showPreview()));
     connect(deleteButton, SIGNAL(clicked(bool)), this, SLOT(deleteBackup()));
     connect(restoreButton, SIGNAL(clicked(bool)), this, SLOT(restoreBackup()));
}
Exemplo n.º 18
0
bool HelloWorld::convert(string filePath)
{
    if (filePath =="")
        return false;
    
    size_t pos = filePath.find("file://");
    if (pos != string::npos){
        filePath = filePath.substr (pos+7);
    }
    
    Magick::Image masterImage(filePath);
    
    if (!masterImage.isValid()){
        return false;
    }
    
    showPreview(masterImage);
    
    
    string saveFolder = getFolder(filePath) + "/IconResized/" ;
    makeDirectory(saveFolder);
    
    string openDir;
    
    typedef map<string, string>::iterator it_type;
    for(it_type iterator = sizes.begin(); iterator != sizes.end(); iterator++) {
        // iterator->first = key
        // iterator->second = value
        // Repeat if you also want to iterate through the second map.
        string savePath = saveFolder + iterator->second;
        
        openDir = savePath;
        resizeAndWriteImage(masterImage, savePath, iterator->first);
    }
    
    openSavedFolder(openDir);
    
    return true;
}
Exemplo n.º 19
0
void TabBarWidget::tabHovered(int index)
{
	if (index == m_hoveredTab)
	{
		return;
	}

	m_hoveredTab = index;

	if (m_previewWidget && !m_previewWidget->isVisible() && m_previewTimer == 0)
	{
		m_previewWidget->show();
	}

	QStatusTipEvent statusTipEvent((index >= 0) ? getTabProperty(index, QLatin1String("url"), QUrl()).toString() : QString());

	QApplication::sendEvent(this, &statusTipEvent);

	if (m_previewWidget && m_previewWidget->isVisible())
	{
		showPreview(index);
	}
}
Exemplo n.º 20
0
void FormWindowManager::setupActions()
{
#ifndef QT_NO_CLIPBOARD
    m_actionCut = new QAction(createIconSet(QStringLiteral("editcut.png")), tr("Cu&t"), this);
    m_actionCut->setObjectName(QStringLiteral("__qt_cut_action"));
    m_actionCut->setShortcut(QKeySequence::Cut);
    m_actionCut->setStatusTip(tr("Cuts the selected widgets and puts them on the clipboard"));
    m_actionCut->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Cut")));
    connect(m_actionCut, SIGNAL(triggered()), this, SLOT(slotActionCutActivated()));
    m_actionCut->setEnabled(false);

    m_actionCopy = new QAction(createIconSet(QStringLiteral("editcopy.png")), tr("&Copy"), this);
    m_actionCopy->setObjectName(QStringLiteral("__qt_copy_action"));
    m_actionCopy->setShortcut(QKeySequence::Copy);
    m_actionCopy->setStatusTip(tr("Copies the selected widgets to the clipboard"));
    m_actionCopy->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Copy")));
    connect(m_actionCopy, SIGNAL(triggered()), this, SLOT(slotActionCopyActivated()));
    m_actionCopy->setEnabled(false);

    m_actionPaste = new QAction(createIconSet(QStringLiteral("editpaste.png")), tr("&Paste"), this);
    m_actionPaste->setObjectName(QStringLiteral("__qt_paste_action"));
    m_actionPaste->setShortcut(QKeySequence::Paste);
    m_actionPaste->setStatusTip(tr("Pastes the clipboard's contents"));
    m_actionPaste->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Paste")));
    connect(m_actionPaste, SIGNAL(triggered()), this, SLOT(slotActionPasteActivated()));
    m_actionPaste->setEnabled(false);
#endif

    m_actionDelete = new QAction(tr("&Delete"), this);
    m_actionDelete->setObjectName(QStringLiteral("__qt_delete_action"));
    m_actionDelete->setStatusTip(tr("Deletes the selected widgets"));
    m_actionDelete->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Delete")));
    connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(slotActionDeleteActivated()));
    m_actionDelete->setEnabled(false);

    m_actionSelectAll = new QAction(tr("Select &All"), this);
    m_actionSelectAll->setObjectName(QStringLiteral("__qt_select_all_action"));
    m_actionSelectAll->setShortcut(QKeySequence::SelectAll);
    m_actionSelectAll->setStatusTip(tr("Selects all widgets"));
    m_actionSelectAll->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Select All")));
    connect(m_actionSelectAll, SIGNAL(triggered()), this, SLOT(slotActionSelectAllActivated()));
    m_actionSelectAll->setEnabled(false);

    m_actionRaise = new QAction(createIconSet(QStringLiteral("editraise.png")), tr("Bring to &Front"), this);
    m_actionRaise->setObjectName(QStringLiteral("__qt_raise_action"));
    m_actionRaise->setShortcut(Qt::CTRL + Qt::Key_L);
    m_actionRaise->setStatusTip(tr("Raises the selected widgets"));
    m_actionRaise->setWhatsThis(tr("Raises the selected widgets"));
    connect(m_actionRaise, SIGNAL(triggered()), this, SLOT(slotActionRaiseActivated()));
    m_actionRaise->setEnabled(false);

    m_actionLower = new QAction(createIconSet(QStringLiteral("editlower.png")), tr("Send to &Back"), this);
    m_actionLower->setObjectName(QStringLiteral("__qt_lower_action"));
    m_actionLower->setShortcut(Qt::CTRL + Qt::Key_K);
    m_actionLower->setStatusTip(tr("Lowers the selected widgets"));
    m_actionLower->setWhatsThis(tr("Lowers the selected widgets"));
    connect(m_actionLower, SIGNAL(triggered()), this, SLOT(slotActionLowerActivated()));
    m_actionLower->setEnabled(false);

    m_actionAdjustSize = new QAction(createIconSet(QStringLiteral("adjustsize.png")), tr("Adjust &Size"), this);
    m_actionAdjustSize->setObjectName(QStringLiteral("__qt_adjust_size_action"));
    m_actionAdjustSize->setShortcut(Qt::CTRL + Qt::Key_J);
    m_actionAdjustSize->setStatusTip(tr("Adjusts the size of the selected widget"));
    m_actionAdjustSize->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Adjust Size")));
    connect(m_actionAdjustSize, SIGNAL(triggered()), this, SLOT(slotActionAdjustSizeActivated()));
    m_actionAdjustSize->setEnabled(false);


    m_actionHorizontalLayout = new QAction(createIconSet(QStringLiteral("edithlayout.png")), tr("Lay Out &Horizontally"), this);
    m_actionHorizontalLayout->setObjectName(QStringLiteral("__qt_horizontal_layout_action"));
    m_actionHorizontalLayout->setShortcut(Qt::CTRL + Qt::Key_1);
    m_actionHorizontalLayout->setStatusTip(tr("Lays out the selected widgets horizontally"));
    m_actionHorizontalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally")));
    m_actionHorizontalLayout->setData(LayoutInfo::HBox);
    m_actionHorizontalLayout->setEnabled(false);
    connect(m_actionHorizontalLayout, SIGNAL(triggered()), this, SLOT(createLayout()));

    m_actionVerticalLayout = new QAction(createIconSet(QStringLiteral("editvlayout.png")), tr("Lay Out &Vertically"), this);
    m_actionVerticalLayout->setObjectName(QStringLiteral("__qt_vertical_layout_action"));
    m_actionVerticalLayout->setShortcut(Qt::CTRL + Qt::Key_2);
    m_actionVerticalLayout->setStatusTip(tr("Lays out the selected widgets vertically"));
    m_actionVerticalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically")));
    m_actionVerticalLayout->setData(LayoutInfo::VBox);
    m_actionVerticalLayout->setEnabled(false);
    connect(m_actionVerticalLayout, SIGNAL(triggered()), this, SLOT(createLayout()));

    QIcon formIcon = QIcon::fromTheme(QStringLiteral("designer-form-layout"), createIconSet(QStringLiteral("editform.png")));
    m_actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this);
    m_actionFormLayout->setObjectName(QStringLiteral("__qt_form_layout_action"));
    m_actionFormLayout->setShortcut(Qt::CTRL + Qt::Key_6);
    m_actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout"));
    m_actionFormLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Form")));
    m_actionFormLayout->setData(LayoutInfo::Form);
    m_actionFormLayout->setEnabled(false);
    connect(m_actionFormLayout, SIGNAL(triggered()), this, SLOT(createLayout()));

    m_actionGridLayout = new QAction(createIconSet(QStringLiteral("editgrid.png")), tr("Lay Out in a &Grid"), this);
    m_actionGridLayout->setObjectName(QStringLiteral("__qt_grid_layout_action"));
    m_actionGridLayout->setShortcut(Qt::CTRL + Qt::Key_5);
    m_actionGridLayout->setStatusTip(tr("Lays out the selected widgets in a grid"));
    m_actionGridLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Grid")));
    m_actionGridLayout->setData(LayoutInfo::Grid);
    m_actionGridLayout->setEnabled(false);
    connect(m_actionGridLayout, SIGNAL(triggered()), this, SLOT(createLayout()));

    m_actionSplitHorizontal = new QAction(createIconSet(QStringLiteral("edithlayoutsplit.png")),
                                          tr("Lay Out Horizontally in S&plitter"), this);
    m_actionSplitHorizontal->setObjectName(QStringLiteral("__qt_split_horizontal_action"));
    m_actionSplitHorizontal->setShortcut(Qt::CTRL + Qt::Key_3);
    m_actionSplitHorizontal->setStatusTip(tr("Lays out the selected widgets horizontally in a splitter"));
    m_actionSplitHorizontal->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally in Splitter")));
    m_actionSplitHorizontal->setData(LayoutInfo::HSplitter);
    m_actionSplitHorizontal->setEnabled(false);
    connect(m_actionSplitHorizontal, SIGNAL(triggered()), this, SLOT(createLayout()));

    m_actionSplitVertical = new QAction(createIconSet(QStringLiteral("editvlayoutsplit.png")),
                                        tr("Lay Out Vertically in Sp&litter"), this);
    m_actionSplitVertical->setObjectName(QStringLiteral("__qt_split_vertical_action"));
    m_actionSplitVertical->setShortcut(Qt::CTRL + Qt::Key_4);
    m_actionSplitVertical->setStatusTip(tr("Lays out the selected widgets vertically in a splitter"));
    m_actionSplitVertical->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically in Splitter")));
    connect(m_actionSplitVertical, SIGNAL(triggered()), this, SLOT(createLayout()));
    m_actionSplitVertical->setData(LayoutInfo::VSplitter);

    m_actionSplitVertical->setEnabled(false);

    m_actionBreakLayout = new QAction(createIconSet(QStringLiteral("editbreaklayout.png")), tr("&Break Layout"), this);
    m_actionBreakLayout->setObjectName(QStringLiteral("__qt_break_layout_action"));
    m_actionBreakLayout->setShortcut(Qt::CTRL + Qt::Key_0);
    m_actionBreakLayout->setStatusTip(tr("Breaks the selected layout"));
    m_actionBreakLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Break Layout")));
    connect(m_actionBreakLayout, SIGNAL(triggered()), this, SLOT(slotActionBreakLayoutActivated()));
    m_actionBreakLayout->setEnabled(false);

    m_actionSimplifyLayout = new QAction(tr("Si&mplify Grid Layout"), this);
    m_actionSimplifyLayout->setObjectName(QStringLiteral("__qt_simplify_layout_action"));
    m_actionSimplifyLayout->setStatusTip(tr("Removes empty columns and rows"));
    m_actionSimplifyLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Simplify Layout")));
    connect(m_actionSimplifyLayout, SIGNAL(triggered()), this, SLOT(slotActionSimplifyLayoutActivated()));
    m_actionSimplifyLayout->setEnabled(false);

    m_actionDefaultPreview = new QAction(tr("&Preview..."), this);
    m_actionDefaultPreview->setObjectName(QStringLiteral("__qt_default_preview_action"));
    m_actionDefaultPreview->setStatusTip(tr("Preview current form"));
    m_actionDefaultPreview->setWhatsThis(whatsThisFrom(QStringLiteral("Form|Preview")));
    connect(m_actionDefaultPreview, SIGNAL(triggered()),
            this, SLOT(showPreview()));

    m_undoGroup = new QUndoGroup(this);

    m_actionUndo = m_undoGroup->createUndoAction(this);
    m_actionUndo->setEnabled(false);

    m_actionUndo->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"), createIconSet(QStringLiteral("undo.png"))));
    m_actionRedo = m_undoGroup->createRedoAction(this);
    m_actionRedo->setEnabled(false);
    m_actionRedo->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"), createIconSet(QStringLiteral("redo.png"))));

    m_actionShowFormWindowSettingsDialog = new QAction(tr("Form &Settings..."), this);
    m_actionShowFormWindowSettingsDialog->setObjectName(QStringLiteral("__qt_form_settings_action"));
    connect(m_actionShowFormWindowSettingsDialog, SIGNAL(triggered()), this, SLOT(slotActionShowFormWindowSettingsDialog()));
    m_actionShowFormWindowSettingsDialog->setEnabled(false);

#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
#ifndef QT_NO_CLIPBOARD
    m_actionCopy->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"), m_actionCopy->icon()));
    m_actionCut->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"), m_actionCut->icon()));
    m_actionPaste->setIcon(QIcon::fromTheme(QStringLiteral("edit-paste"), m_actionPaste->icon()));
#endif
    m_actionDelete->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"), m_actionDelete->icon()));

    // These do not currently exist, but will allow theme authors to fill in the gaps
    m_actionBreakLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-break-layout"), m_actionBreakLayout->icon()));
    m_actionGridLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-grid-layout"), m_actionGridLayout->icon()));
    m_actionHorizontalLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-horizontal-layout"), m_actionHorizontalLayout->icon()));
    m_actionVerticalLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-vertical-layout"), m_actionVerticalLayout->icon()));
    m_actionSplitHorizontal->setIcon(QIcon::fromTheme(QStringLiteral("designer-split-horizontal"), m_actionSplitHorizontal->icon()));
    m_actionSplitVertical->setIcon(QIcon::fromTheme(QStringLiteral("designer-split-vertical"), m_actionSplitVertical->icon()));
    m_actionAdjustSize->setIcon(QIcon::fromTheme(QStringLiteral("designer-adjust-size"), m_actionAdjustSize->icon()));
#endif
}
Exemplo n.º 21
0
void KPImageDialogPreview::showPreview()
{
    QUrl url(d->currentUrl);
    clearPreview();
    showPreview(url);
}
Exemplo n.º 22
0
void FilePreview::clearPreview()
{
    showPreview(NULL);
}
Exemplo n.º 23
0
void StickerPreviewWidget::hidePreview() {
	showPreview(0);
}
Exemplo n.º 24
0
FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
    : QWidget(parent)
    , ui(new Ui::FileTransferWidget)
    , fileInfo(file)
    , lastTick(QTime::currentTime())
    , backgroundColor(Style::getColor(Style::LightGrey))
    , buttonColor(Style::getColor(Style::Yellow))
{
    ui->setupUi(this);

    // hide the QWidget background (background-color: transparent doesn't seem to work)
    setAttribute(Qt::WA_TranslucentBackground, true);

    ui->previewLabel->hide();
    ui->filenameLabel->setText(file.fileName);
    ui->progressBar->setValue(0);
    ui->fileSizeLabel->setText(getHumanReadableSize(file.filesize));
    ui->etaLabel->setText("");

    backgroundColorAnimation = new QVariantAnimation(this);
    backgroundColorAnimation->setDuration(500);
    backgroundColorAnimation->setEasingCurve(QEasingCurve::OutCubic);
    connect(backgroundColorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) {
        backgroundColor = val.value<QColor>();
        update();
    });

    buttonColorAnimation = new QVariantAnimation(this);
    buttonColorAnimation->setDuration(500);
    buttonColorAnimation->setEasingCurve(QEasingCurve::OutCubic);
    connect(buttonColorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) {
        buttonColor = val.value<QColor>();
        update();
    });

    setBackgroundColor(Style::getColor(Style::LightGrey), false);

    connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
    connect(Core::getInstance(), &Core::fileTransferAccepted, this, &FileTransferWidget::onFileTransferAccepted);
    connect(Core::getInstance(), &Core::fileTransferCancelled, this, &FileTransferWidget::onFileTransferCancelled);
    connect(Core::getInstance(), &Core::fileTransferPaused, this, &FileTransferWidget::onFileTransferPaused);
    connect(Core::getInstance(), &Core::fileTransferFinished, this, &FileTransferWidget::onFileTransferFinished);
    connect(Core::getInstance(), &Core::fileTransferRemotePausedUnpaused, this, &FileTransferWidget::fileTransferRemotePausedUnpaused);
    connect(Core::getInstance(), &Core::fileTransferBrokenUnbroken, this, &FileTransferWidget::fileTransferBrokenUnbroken);
    connect(ui->topButton, &QPushButton::clicked, this, &FileTransferWidget::onTopButtonClicked);
    connect(ui->bottomButton, &QPushButton::clicked, this, &FileTransferWidget::onBottomButtonClicked);

    setupButtons();

    //preview
    if (fileInfo.direction == ToxFile::SENDING)
    {
        showPreview(fileInfo.filePath);
        ui->progressLabel->setText(tr("Waiting to send...", "file transfer widget"));
    }
    else
    {
        ui->progressLabel->setText(tr("Accept to receive this file", "file transfer widget"));
    }

    setFixedHeight(78);
}
Exemplo n.º 25
0
// called via KPreviewWidgetBase interface
void KImageFilePreview::showPreview( const KUrl& url )
{
    showPreview( url, false );
}
Exemplo n.º 26
0
void KImageFilePreview::showPreview()
{
    // Pass a copy since clearPreview() will clear currentURL
    KUrl url = d->currentURL;
    showPreview( url, true );
}
Exemplo n.º 27
0
//==============================================================================
// Create MainWindow
//==============================================================================
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    bgColor (QColor(255,255,255)),
    logoPath(logoDefaultPath),
    usbPath (usbDefaultPath),
    rdPath  (rdDefaultPath)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle("BootLogo Changer for Maemo 5");

    shell = 0;

    rdShow = false;

    QMenuBar *menu = menuBar();
    enableAnySizes = new QAction("Allow any image sizes", this);
    enableAnySizes->setCheckable(true);
    connect(enableAnySizes, SIGNAL(triggered(bool)),
            this, SLOT(changeImageLimit(bool)));
    menu->addAction(enableAnySizes);
    menu->addAction("About", this, SLOT(showAbout()));
    menu->addAction("About Qt", qApp, SLOT(aboutQt()));

    ui->stack->setCurrentWidget(ui->centralPage);

    // Central/Left/Right layouts
    ui->rightTopLayout->setContentsMargins(sizeInc, 0, 0, 0);

    // Right buttons
    // Background button
    ui->bgButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->bgButton, SIGNAL(clicked()), this, SLOT(bgBtnClicked()));
    ui->bgButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->bgButton, Qt::AlignVCenter | Qt::AlignRight);
    // Logo button
    ui->logoButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->logoButton, SIGNAL(clicked()), this, SLOT(logoBtnClicked()));
    ui->logoButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->logoButton, Qt::AlignVCenter | Qt::AlignRight);
    // USB button
    ui->usbButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->usbButton, SIGNAL(clicked()), this, SLOT(usbBtnClicked()));
    ui->usbButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->usbButton, Qt::AlignVCenter | Qt::AlignRight);
    // RD button
    ui->rdButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->rdButton, SIGNAL(clicked()), this, SLOT(rdBtnClicked()));
    ui->rdButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->rdButton, Qt::AlignVCenter | Qt::AlignRight);
    // Preview button
    connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(showPreview()));
    // Apply button
    connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(applyBtnClicked()));

    // Create info widgets for buttons
    // Create Background info widget
    createBgInfo();
    // Create Logo info widget
    createLogoInfo();
    // Create USB info widget
    createUsbInfo();
    // Create RD info widget
    createRdInfo();
    // Create Preview widget
    createPreview();
    // Create Apply widget
    createApply();
}
Exemplo n.º 28
0
/**
 * Render the Preview
 * @param Cairo::Context cr
 * @return Gtk::Window::on_draw(cr)
 */
bool Preview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
      
    Configuration::Theme theme = Configuration::getTheme();
    if (theme.forPreview().enabled()) {


        cr->set_source_rgba(
                theme.forPreview().background().red,
                theme.forPreview().background().green,
                theme.forPreview().background().blue,
                theme.forPreview().background().alpha);

        Utilities::RoundedRectangle(cr, 0, 0, this->get_width(), this->get_height(),
                theme.forPreview().roundedRatious());

        cr->fill();

    }




    if (!m_isActive) {
        return Gtk::Window::on_draw(cr);
    }


    if (m_previewtems.size() < 1) {
        this->hideMe();
        return Gtk::Window::on_draw(cr);
    }



    int idx = 0;
    for (DockItem* item : m_previewtems) {
        if (item->m_window == NULL || item->m_xid == 0 || !item->visible)
            continue;

        int pos_x = 20 + (m_previewWidth * idx);
        int pos_y = 16;
        int pos_width = m_previewWidth - DEF_PREVIEW_LEFT_MARGING;
        int pos_height = 20;


        cr->set_source_rgba(
                theme.forPreview().foreground().red,
                theme.forPreview().foreground().green,
                theme.forPreview().foreground().blue,
                theme.forPreview().foreground().alpha);

        cr->set_line_width(theme.forPreview().lineWith());

        if (item->m_imageLoadedRequired)
            cr->set_line_width(theme.forPreview().lineWith() + 0.5);

        if (theme.getPreviewBinaryValue() == 0) {
            Utilities::RoundedRectangle(cr,
                    DEF_PREVIEW_LEFT_MARGING + (m_previewWidth * idx),
                    16, m_previewWidth,
                    m_previewHeight - DEF_PREVIEW_RIGHT_MARGING,
                    theme.forPreview().roundedRatious());

            cr->stroke();
        } else {
            cr->set_line_width(theme.forPreview().lineWith());
            int pos_x = DEF_PREVIEW_LEFT_MARGING + (m_previewWidth * idx);
            int y_pos = 16;
            int width = m_previewWidth;
            int height = m_previewHeight;
            int value = theme.getPreviewBinaryValue();
            /* Vertical Left*/
            int bit = CHECK_BIT(value, 3);
            if (bit == 1) {

                cr->set_line_width(theme.forPreview().lineWith());
                cr->move_to(pos_x, y_pos);
                cr->line_to(pos_x, y_pos);
                cr->line_to(pos_x, y_pos + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                cr->stroke();

            }
            /* Top */
            bit = CHECK_BIT(value, 2);
            if (bit == 1) {
                cr->set_line_width(theme.forPreview().lineWith());
                cr->move_to(pos_x, y_pos);
                cr->line_to(pos_x, y_pos);
                cr->line_to(pos_x + (m_previewWidth), y_pos);
                cr->stroke();
            }

            /* Right vertical */
            bit = CHECK_BIT(value, 1);
            if (bit == 1) {
                cr->set_line_width(theme.forPreview().lineWith());
                cr->move_to(pos_x + m_previewWidth, y_pos);
                cr->line_to(pos_x + m_previewWidth, y_pos);
                cr->line_to(pos_x + m_previewWidth, y_pos + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                cr->stroke();
            }

            bit = CHECK_BIT(value, 0);
            if (bit == 1) {
                cr->set_line_width(theme.forPreview().lineWith());
                cr->move_to(pos_x, y_pos + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                cr->line_to(pos_x, y_pos + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                cr->line_to(pos_x + m_previewWidth, y_pos + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                cr->stroke();
            }

        }


        // TEXT 
        // draw title and create clipping rectangle
        //  JG        
        cr->set_source_rgba(
                theme.forPreviewTitle().background().red,
                theme.forPreviewTitle().background().green,
                theme.forPreviewTitle().background().blue,
                theme.forPreviewTitle().foreground().alpha);
        cr->rectangle(pos_x, pos_y + 2, pos_width + 2, pos_height);
        // cr->clip_preserve();
        cr->fill();
        //    JG
        cr->set_source_rgba(
                theme.forPreviewTitle().foreground().red,
                theme.forPreviewTitle().foreground().green,
                theme.forPreviewTitle().foreground().blue,
                theme.forPreviewTitle().foreground().alpha);
        cr->set_line_width(theme.forPreviewTitle().lineWith());
        cr->rectangle(pos_x, pos_y + 2, pos_width + 2, pos_height);
        cr->stroke();



        // draw title the clipping rectangle
        //cr->set_source_rgba(1.0, 1.0, 1.0, 0.0);

        cr->rectangle(pos_x, pos_y + 2, pos_width, pos_height);
        cr->clip_preserve();
        cr->stroke();




        cr->set_source_rgba(
                theme.forPreviewTitleText().foreground().red,
                theme.forPreviewTitleText().foreground().green,
                theme.forPreviewTitleText().foreground().blue,
                theme.forPreviewTitleText().foreground().alpha);

        auto layout = create_pango_layout(item->m_titlename);
        layout->set_font_description(font);
        //cr->set_source_rgba(1.0, 1.0, 1.0, 1.0); // white text
        cr->move_to(pos_x, pos_y + 2);
        layout->show_in_cairo_context(cr);
        cr->reset_clip(); // Reset the clipping 



        if (item->m_imageLoadedRequired) {
            GdkPixbuf *scaledpb = getScaledPixbuf(item);

            if (scaledpb == nullptr) {
                continue;
            }

            // show the loaded image. 
            showPreview(cr, scaledpb, idx);

            // Checks if the image have movement.
            if (item->isMovementDetected(scaledpb) && !item->m_isDynamic) {
                item->m_isDynamic = true;
            }

            // if no movement has been detected, means that the image 
            // is static and we don't need to reload it again 
            if (++item->m_frames > 3 && !item->m_isDynamic) {
                item->m_scaledPixbuf = scaledpb;
                item->m_frames = 0;
                item->m_imageLoadedRequired = false;
            }

            // if the image is static do not unreference the scaledpb.
            if (item->m_imageLoadedRequired)
                g_object_unref(scaledpb);

        } else {
            // show the loaded static image. 
            showPreview(cr, item->m_scaledPixbuf, idx);

        }



        // selector
        if (m_currentIndex == idx) {

            // rectangle background selector
            pos_x = DEF_PREVIEW_LEFT_MARGING + (m_previewWidth * m_currentIndex);
            pos_y = 16;
            pos_width = m_previewWidth + 1;
            pos_height = m_previewHeight - DEF_PREVIEW_RIGHT_MARGING;

            if (m_previewtems.size() > 1) {
                cr->set_source_rgba(
                        theme.forPreviewSelector().background().red,
                        theme.forPreviewSelector().background().green,
                        theme.forPreviewSelector().background().blue,
                        theme.forPreviewSelector().background().alpha);

                Utilities::RoundedRectangle(cr, pos_x, pos_y, pos_width, pos_height,
                        theme.forPreviewSelector().roundedRatious());
                cr->fill();
            }

            cr->set_source_rgba(
                    theme.forPreviewSelector().foreground().red,
                    theme.forPreviewSelector().foreground().green,
                    theme.forPreviewSelector().foreground().blue,
                    theme.forPreviewSelector().foreground().alpha);
            cr->set_line_width(theme.forPreviewSelector().lineWith());

            if (theme.getPreviewSelectorBinaryValue() == 0) {

                Utilities::RoundedRectangle(cr, pos_x, pos_y, pos_width, pos_height,
                        theme.forPreviewSelector().roundedRatious());
                cr->stroke();
            } else {


                int value = theme.getPreviewSelectorBinaryValue();
                //                /* Vertical Left*/
                int bit = CHECK_BIT(value, 3);
                if (bit == 1) {


                    cr->move_to(pos_x, pos_y);
                    cr->line_to(pos_x, pos_y);
                    cr->line_to(pos_x, pos_y + (pos_height));
                    cr->stroke();

                }
                /* Top */
                bit = CHECK_BIT(value, 2);
                if (bit == 1) {

                    cr->move_to(pos_x, pos_y);
                    cr->line_to(pos_x, pos_y);
                    cr->line_to(pos_x + (pos_width), pos_y);
                    cr->stroke();
                }

                /* Right vertical */
                bit = CHECK_BIT(value, 1);
                if (bit == 1) {

                    cr->move_to(pos_x + pos_width, pos_y);
                    cr->line_to(pos_x + pos_width, pos_y);
                    cr->line_to(pos_x + pos_width, pos_y + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                    cr->stroke();
                }

                bit = CHECK_BIT(value, 0);
                if (bit == 1) {

                    cr->move_to(pos_x, pos_y + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                    cr->line_to(pos_x, pos_y + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                    cr->line_to(pos_x + m_previewWidth, pos_y + (m_previewHeight - DEF_PREVIEW_RIGHT_MARGING));
                    cr->stroke();
                }
            }


            cr->set_source_rgba(
                    theme.forPreviewSelectorClose().background().red,
                    theme.forPreviewSelectorClose().background().green,
                    theme.forPreviewSelectorClose().background().blue,
                    theme.forPreviewSelectorClose().background().alpha);


            pos_x = (m_previewWidth - 5) + (m_previewWidth * m_currentIndex);
            cr->move_to(pos_x + 3, DEF_PREVIEW_RIGHT_MARGING);

            cr->rectangle(pos_x, 18, DEF_PREVIEW_LEFT_MARGING, DEF_PREVIEW_LEFT_MARGING + 2);
            cr->fill();

            cr->set_source_rgba(
                    theme.forPreviewSelectorClose().foreground().red,
                    theme.forPreviewSelectorClose().foreground().green,
                    theme.forPreviewSelectorClose().foreground().blue,
                    theme.forPreviewSelectorClose().foreground().alpha);
            cr->set_line_width(theme.forPreviewSelectorClose().lineWith());

            // Close X text
            cr->move_to(pos_x + 3, DEF_PREVIEW_RIGHT_MARGING - 1);
            cr->show_text("X");


        }




        idx++;
    }
    return Gtk::Window::on_draw(cr);
}
Exemplo n.º 29
0
ReportDialog::ReportDialog( SourceType source, ReportMode mode, QWidget* parent ) : CommandDialog( parent ),
    m_source( source ),
    m_mode( mode ),
    m_folderId( 0 ),
    m_typeId( 0 ),
    m_projectId( 0 ),
    m_history( IssueDetailsGenerator::NoHistory ),
    m_tableButton( NULL ),
    m_fullTableButton( NULL ),
    m_summaryButton( NULL ),
    m_fullReportButton( NULL ),
    m_page( NULL ),
    m_pdfPrinter( NULL )
{
    if ( source == FolderSource ) {
        m_tableButton = new QRadioButton( tr( "Table with visible columns only" ), this );
        m_fullTableButton = new QRadioButton( tr( "Table with all system and user columns" ), this );
    }

    if ( mode != ExportCsv ) {
        if ( source == FolderSource )
            m_summaryButton = new QRadioButton( tr( "Summary report including issue details" ), this );
        if ( source == IssueSource ) {
            m_summaryButton = new QRadioButton( tr( "Summary report without issue history" ), this );
            m_fullReportButton = new QRadioButton( tr( "Full report including issue history" ), this );
        }
    }

    QVBoxLayout* optionsLayout = NULL;

    if ( m_tableButton || m_fullTableButton || m_summaryButton || m_fullReportButton ) {
        optionsLayout = new QVBoxLayout();
        if ( m_tableButton )
            optionsLayout->addWidget( m_tableButton );
        if ( m_fullTableButton )
            optionsLayout->addWidget( m_fullTableButton );
        if ( m_summaryButton )
            optionsLayout->addWidget( m_summaryButton );
        if ( m_fullReportButton )
            optionsLayout->addWidget( m_fullReportButton );
    }

    if ( optionsLayout || mode == Print ) {
        QHBoxLayout* layout = new QHBoxLayout();

        if ( optionsLayout )
            layout->addLayout( optionsLayout );

        if ( mode == Print ) {
            QPushButton* previewButton = new QPushButton( tr( "&Print Preview..." ), this );
            previewButton->setIcon( IconLoader::icon( "print-preview" ) );
            previewButton->setIconSize( QSize( 16, 16 ) );
            layout->addWidget( previewButton, 0, Qt::AlignBottom | Qt::AlignRight );

            connect( previewButton, SIGNAL( clicked() ), this, SLOT( showPreview() ) );
        }

        setContentLayout( layout, true );
    }

    if ( m_tableButton )
        m_tableButton->setChecked( true );
    else if ( m_summaryButton )
        m_summaryButton->setChecked( true );

    QString sourceName;
    switch ( source ) {
        case FolderSource:
            sourceName = tr( "list of issues" );
            break;
        case IssueSource:
            sourceName = tr( "issue details" );
            break;
        case ProjectSource:
            sourceName = tr( "project summary" );
            break;
    }

    switch ( mode ) {
        case Print:
            setWindowTitle( tr( "Print" ) );
            setPromptPixmap( IconLoader::pixmap( "file-print", 22 ) );
            setPrompt( tr( "Print %1:" ).arg( sourceName ) );
            break;
        case ExportCsv:
            setWindowTitle( tr( "Export To CSV" ) );
            setPromptPixmap( IconLoader::pixmap( "export-csv", 22 ) );
            setPrompt( tr( "Export %1 to CSV file:" ).arg( sourceName ) );
            break;
        case ExportHtml:
            setWindowTitle( tr( "Export To HTML" ) );
            setPromptPixmap( IconLoader::pixmap( "export-html", 22 ) );
            setPrompt( tr( "Export %1 to HTML file:" ).arg( sourceName ) );
            break;
        case ExportPdf:
            setWindowTitle( tr( "Export To PDF" ) );
            setPromptPixmap( IconLoader::pixmap( "export-pdf", 22 ) );
            setPrompt( tr( "Export %1 to PDF file:" ).arg( sourceName ) );
            break;
    }

    showInfo( tr( "Create the report." ) );
}
Exemplo n.º 30
0
void TabBarWidget::updateTabs(int index)
{
	if (index < 0 && sender() && sender()->inherits(QStringLiteral("Otter::Window").toLatin1()))
	{
		for (int i = 0; i < count(); ++i)
		{
			if (sender() == qvariant_cast<QObject*>(tabData(i)))
			{
				index = i;

				break;
			}
		}
	}

	const QSize size = tabSizeHint(count() - 1);
	const int limit = ((index >= 0) ? (index + 1) : count());
	const bool canResize = (m_tabSize > 0);
	const bool isHorizontal = (shape() == QTabBar::RoundedNorth || shape() == QTabBar::RoundedSouth);
	const bool isNarrow = ((isHorizontal ? size.width() : size.height()) < 60);

	for (int i = ((index >= 0) ? index : 0); i < limit; ++i)
	{
		const bool isLoading = getTabProperty(i, QLatin1String("isLoading"), false).toBool();
		QLabel *label = qobject_cast<QLabel*>(tabButton(i, QTabBar::LeftSide));

		if (label)
		{
			if (isLoading)
			{
				if (!label->movie())
				{
					QMovie *movie = new QMovie(QLatin1String(":/icons/loading.gif"), QByteArray(), label);
					movie->start();

					label->setMovie(movie);
				}
			}
			else
			{
				if (label->movie())
				{
					label->movie()->deleteLater();
					label->setMovie(NULL);
				}

				label->setPixmap(getTabProperty(i, QLatin1String("icon"), QIcon(getTabProperty(i, QLatin1String("isPrivate"), false).toBool() ? ":/icons/tab-private.png" : ":/icons/tab.png")).value<QIcon>().pixmap(16, 16));
			}
		}

		if (canResize)
		{
			QWidget *button = tabButton(i, QTabBar::RightSide);

			if (button)
			{
				button->setVisible((!isNarrow || (i == currentIndex())) && !getTabProperty(i, QLatin1String("isPinned"), false).toBool());
			}
		}
	}

	showPreview(tabAt(mapFromGlobal(QCursor::pos())));
}