GalleriesDemo Example
#include <QFileDialog>
#include <QPrinter>
#include <QPrintDialog>
#include <QComboBox>
#include <QCheckBox>
#include <QProgressBar>
#include <QLineEdit>
#include <QRadioButton>
#include <QScrollBar>
#include <QFontComboBox>
#include <QAction>
#include <QMenu>
#include <QLabel>
#include <QSpinBox>
#include <QMessageBox>
#include <QButtonGroup>
#include <DevMachines/QtitanRibbon>
#include "galleryItems.h"
#include "aboutdialog.h"
#include "mainwindow.h"
static int g_margin = 2;
GalleriesDialog::GalleriesDialog(QWidget* parent)
: QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QRect geom = parent->geometry();
int width = 2 * geom.width() / 4;
m_galleryGroup = new RibbonGalleryGroup();
m_galleryGroup->setSize(QSize(72, 56));
for (int numEffect = 0; numEffect < 20; ++numEffect)
{
RibbonGalleryItem* item = m_galleryGroup->addItemFromMap(QString(), numEffect, QPixmap(QStringLiteral(":/res/galleryeffects.png")), QSize(64, 48));
QString str = QObject::tr("Effect, %1").arg(numEffect + 1);
item->setToolTip(str);
}
m_gallery = new RibbonGallery(this);
m_gallery->setMinimumColumnCount(3);
m_gallery->setBorderVisible(true);
m_gallery->setLabelsVisible(false);
m_gallery->setAutoWidth(true);
m_gallery->setGalleryGroup(m_galleryGroup);
m_gallery->move(QPoint(g_margin, g_margin));
m_gallery->resize(width, 56);
resize(width + g_margin * 2, 56 + g_margin * 2 );
}
GalleriesDialog::~GalleriesDialog()
{
delete m_galleryGroup;
}
void GalleriesDialog::resizeEvent(QResizeEvent* event)
{
QDialog::resizeEvent(event);
QSize delta = event->size() - event->oldSize();
if (delta.isNull())
return;
m_gallery->resize(width() - g_margin * 2, 56);
}
MainWindow::MainWindow(QWidget* parent)
: DemoRibbonWindow(parent)
{
setWindowTitle(tr("QtitanRibbon Galleries Sample"));
m_widgetFontTextColor = Q_NULL;
m_popupTableGallery = Q_NULL;
m_popupUndoGallery = Q_NULL;
createGalleryItems();
createRibbon();
createStatusBar();
setDefaultWidgetGeometry(this);
}
MainWindow::~MainWindow()
{
delete m_itemsFontTextColor;
delete m_itemsStyles;
delete m_itemsEffects;
delete m_itemsThemes;
delete m_itemsTable;
delete m_itemsUndo;
delete m_itemsShapes;
}
void MainWindow::createRibbon()
{
RibbonPage* pageGallery = ribbonBar()->addPage(tr("&Galleries 1"));
RibbonGroup* groupPopup = pageGallery->addGroup(tr("Popup Galleries"));
groupPopup->setOptionButtonVisible();
groupPopup->setContentAlignment(Qt::AlignVCenter);
QAction* act = groupPopup->optionButtonAction();
act->setToolTip(tr("Popup Galleries"));
connect(act, SIGNAL(triggered()), this, SLOT(dialogGallery()));
OfficePopupMenu* popup = new OfficePopupMenu(this);
RibbonGallery* popupGallery = new RibbonGallery();
popup->setMinimumSize(QSize(307, 168));
popupGallery->resize(QSize(307, 168));
popupGallery->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
popupGallery->setGalleryGroup(m_itemsStyles);
popup->addWidget(popupGallery);
popup->addSeparator();
popup->addAction(tr("Save Style"));
popup->addAction(tr("Apply Style"));
RibbonControl* control = groupPopup->controlByAction(groupPopup->addAction(QIcon(QStringLiteral(":/res/largeStyleButton.png")), tr("Styles"),
Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup));
control->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
popup = new OfficePopupMenu(this);
m_popupTableGallery = new RibbonGallery();
m_popupTableGallery->setMaximumColumnCount(10);
m_popupTableGallery->setLabelsVisible(false);
m_popupTableGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_popupTableGallery->setGalleryGroup(m_itemsTable);
popup->addWidget(m_popupTableGallery);
control = groupPopup->controlByAction(groupPopup->addAction(QIcon(QStringLiteral(":/res/largeTable.png")), tr("Table"),
Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup));
control->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
connect(m_popupTableGallery, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemTablePressed(RibbonGalleryItem*)));
popup = new OfficePopupMenu(ribbonBar());
popupGallery = new RibbonGallery();
popupGallery->setMaximumColumnCount(10);
popupGallery->setLabelsVisible(false);
popupGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff);
popupGallery->setGalleryGroup(m_itemsFontTextColor);
popup->addWidget(popupGallery);
control = groupPopup->controlByAction(groupPopup->addAction(QIcon(QStringLiteral(":/res/largeColorButton.png")), tr("Color"), Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup));
control->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
popup->addSeparator();
popup->addAction(tr("More Colors..."));
popup = new OfficePopupMenu(this);
popup->setGripVisible(false);
m_popupUndoGallery = new WidgetGalleryUndo();
m_popupUndoGallery->setGalleryGroup(m_itemsUndo);
m_popupUndoGallery->resize(QSize(120, m_itemsUndo->size().height() * m_itemsUndo->itemCount() + 2));
m_popupUndoGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff);
popup->addWidget(m_popupUndoGallery);
QLabel* label = new QLabel();
label->setAlignment(Qt::AlignCenter);
label->setMinimumWidth(118);
popup->addWidget(label);
m_popupUndoGallery->selectedItemChanged();
m_actionUndo = groupPopup->addAction(QIcon(QStringLiteral(":/res/largeUndo.png")), tr("Undo"), Qt::ToolButtonTextUnderIcon);
m_actionUndo->setMenu(popup);
control = groupPopup->controlByAction(m_actionUndo);
control->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
control->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setImageSize(RibbonControlSizeDefinition::ImageLarge);
connect(popup, SIGNAL(aboutToHide()), this, SLOT(aboutToHideUndo()));
connect(m_popupUndoGallery, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemUndoPressed(RibbonGalleryItem*)));
RibbonGroup* groupInline = pageGallery->addGroup(tr("Inline Galleries"));
groupInline->setSizeDefinition(groupInline->sizeDefinition() & ~RibbonControlSizeDefinition::GroupPopup);
groupInline->setOptionButtonVisible();
groupInline->setContentAlignment(Qt::AlignVCenter);
act = groupInline->optionButtonAction();
act->setToolTip(tr("Inline Galleries Tip"));
connect(act, SIGNAL(triggered()), this, SLOT(dialogGallery()));
RibbonGalleryControl* galleryControl = new RibbonGalleryControl();
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMaximumItemCount(8);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMinimumItemCount(8);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMaximumItemCount(7);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMinimumItemCount(4);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMaximumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMinimumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMaximumItemCount(8);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMinimumItemCount(8);
#if 0
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setVisible(false);
#endif
groupInline->addControl(galleryControl);
m_widgetStyleFont = galleryControl->widget();
m_widgetStyleFont->setLabelsVisible(false);
m_widgetStyleFont->setBorderVisible(true);
m_widgetStyleFont->setRowCount(1);
m_widgetStyleFont->setGalleryGroup(m_itemsStyles);
m_widgetStyleFont->setCheckedIndex(0);
connect(m_widgetStyleFont, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*)));
popup = new OfficePopupMenu(this);
m_widgetStyleFont->setPopupMenu(popup)->setText(tr("Styl&e"));
m_popupStyleFont = new RibbonGallery;
popup->setMinimumSize(QSize(307, 168));
m_popupStyleFont->resize(QSize(307, 168));
m_popupStyleFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_popupStyleFont->setGalleryGroup(m_itemsStyles);
m_popupStyleFont->setCheckedIndex(0);
connect(m_popupStyleFont, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*)));
popup->addWidget(m_popupStyleFont);
popup->addSeparator();
QAction* actSaveStyle = popup->addAction(tr("&Save Style"));
QObject::connect(actSaveStyle, SIGNAL(triggered()), groupInline, SIGNAL(released()));
QAction* actApplyStyle = popup->addAction(tr("&Apply Style"));
QObject::connect(actApplyStyle, SIGNAL(triggered()), groupInline, SIGNAL(released()));
pageGallery = ribbonBar()->addPage(tr("G&alleries 2"));
groupPopup = pageGallery->addGroup(tr("Shapes 1"));
galleryControl = new RibbonGalleryControl();
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMaximumItemCount(20);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMinimumItemCount(20);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMaximumItemCount(19);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMinimumItemCount(10);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMaximumItemCount(9);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMinimumItemCount(9);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMaximumItemCount(9);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMinimumItemCount(9);
groupPopup->addControl(galleryControl);
RibbonGallery* widgetGallery = galleryControl->widget();
widgetGallery->setBorderVisible(true);
widgetGallery->setLabelsVisible(false);
widgetGallery->setGalleryGroup(m_itemsShapes);
popup = new OfficePopupMenu(this);
widgetGallery->setPopupMenu(popup)->setText(tr("Shapes"));
popupGallery = new RibbonGallery;
popupGallery->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
popupGallery->setGalleryGroup(m_itemsShapes);
popup->addWidget(popupGallery);
galleryControl = new RibbonGalleryControl();
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMaximumItemCount(6);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMinimumItemCount(6);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMaximumItemCount(5);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMinimumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMaximumItemCount(2);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMinimumItemCount(2);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMaximumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMinimumItemCount(3);
groupPopup->addControl(galleryControl);
widgetGallery = galleryControl->widget();
widgetGallery->setBorderVisible(true);
widgetGallery->setLabelsVisible(false);
widgetGallery->setRowCount(1);
widgetGallery->setGalleryGroup(m_itemsEffects);
popup = new OfficePopupMenu(this);
widgetGallery->setPopupMenu(popup)->setText(tr("Arro&ws"));
m_popupEffects = new RibbonGallery;
popup->setMinimumSize(QSize(307, 168));
m_popupEffects->resize(QSize(307, 168));
m_popupEffects->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_popupEffects->setGalleryGroup(m_itemsEffects);
m_popupEffects->setCheckedIndex(0);
connect(m_popupEffects, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*)));
popup->addWidget(m_popupEffects);
groupPopup = pageGallery->addGroup(tr("Shapes 2"));
galleryControl = new RibbonGalleryControl();
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMaximumItemCount(6);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupLarge)->setMinimumItemCount(6);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMaximumItemCount(5);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupMedium)->setMinimumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMaximumItemCount(2);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupSmall)->setMinimumItemCount(2);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMaximumItemCount(3);
galleryControl->sizeDefinition(RibbonControlSizeDefinition::GroupPopup)->setMinimumItemCount(3);
groupPopup->addControl(galleryControl);
widgetGallery = galleryControl->widget();
widgetGallery->setBorderVisible(true);
widgetGallery->setLabelsVisible(false);
widgetGallery->setRowCount(1);
widgetGallery->setGalleryGroup(m_itemsThemes);
popup = new OfficePopupMenu(this);
widgetGallery->setPopupMenu(popup)->setText(tr("The&mes"));
m_popupThemes = new RibbonGallery;
popup->setMinimumSize(QSize(307, 168));
m_popupThemes->resize(QSize(307, 168));
m_popupThemes->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_popupThemes->setGalleryGroup(m_itemsThemes);
m_popupThemes->setCheckedIndex(0);
connect(m_popupThemes, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*)));
popup->addWidget(m_popupThemes);
ribbonBar()->setFrameThemeEnabled();
}
void MainWindow::createStatusBar()
{
RibbonSliderPane* sliderPane = new RibbonSliderPane();
sliderPane->setScrollButtons(true);
sliderPane->setRange(0, 100);
sliderPane->setMinimumWidth(100);
sliderPane->setSingleStep(10);
sliderPane->setMaximumWidth(130);
statusBar()->addPermanentWidget(sliderPane);
}
void MainWindow::createGalleryItems()
{
m_itemsFontTextColor = new RibbonGalleryGroup();
m_itemsFontTextColor->setSize(QSize(17, 17));
m_itemsFontTextColor->addSeparator(tr("Theme Colors"));
GalleryItemFontColor::addThemeColors(m_itemsFontTextColor, 0);
m_itemsFontTextColor->addSeparator(tr("Standard Colors"));
GalleryItemFontColor::addStandardColors(m_itemsFontTextColor);
m_itemsStyles = new RibbonGalleryGroup();
m_itemsStyles->setSize(QSize(72, 56));
for (int numStyle = 0; numStyle < 16; numStyle++)
{
RibbonGalleryItem* item = m_itemsStyles->addItemFromMap(QString(), numStyle, QPixmap(QStringLiteral(":/res/galleryStyles.png")), QSize(64, 48));
QString str = QObject::tr("Style, %1").arg(numStyle + 1);
item->setToolTip(str);
}
m_itemsTable = new RibbonGalleryGroup();
m_itemsTable->setSize(QSize(19, 19));
m_itemsTable->appendItem(new GalleryItemTableLabel());
int indexItem;
for (indexItem= 0; indexItem < 10 * 8; indexItem++)
m_itemsTable->appendItem(new GalleryItemTable());
m_itemsUndo = new RibbonGalleryGroup();
m_itemsUndo->setSize(QSize(0, 21));
for (int i = 0; i < 6; i++)
m_itemsUndo->appendItem(new GalleryItemUndo(QObject::tr("Undo Caption %1").arg(i + 1)));
m_itemsShapes = new RibbonGalleryGroup();
m_itemsShapes->setSize(QSize(24, 24));
m_itemsShapes->addSeparator(tr("Lines"));
int indexShape;
for (indexShape = 0; indexShape < 12; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsShapes->addSeparator(tr("Basic Shapes"));
for (; indexShape < 12 + 32; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsShapes->addSeparator(tr("Block Arrows"));
for (; indexShape < 12 + 32 + 27; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsShapes->addSeparator(tr("Flowchart"));
for (; indexShape < 12 + 32 + 27 + 28; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsShapes->addSeparator(tr("Callouts"));
for (; indexShape < 12 + 32 + 27 + 28 + 20; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsShapes->addSeparator(tr("Stars and Banners"));
for (; indexShape < 12 + 32 + 27 + 28 + 20 + 16; indexShape++)
m_itemsShapes->addItemFromMap(QString(), indexShape, QPixmap(QStringLiteral(":/res/galleryshapes.png")), QSize(20, 20), QColor(0xFF,0,0xFF));
m_itemsEffects = new RibbonGalleryGroup();
m_itemsEffects->setSize(QSize(72, 56));
for (int numEffect = 0; numEffect < 20; ++numEffect)
{
RibbonGalleryItem* item = m_itemsEffects->addItemFromMap(QString(), numEffect, QPixmap(QStringLiteral(":/res/galleryeffects.png")), QSize(64, 48));
QString str = QObject::tr("Effect, %1").arg(numEffect + 1);
item->setToolTip(str);
}
m_itemsThemes = new RibbonGalleryGroup();
m_itemsThemes->setSize(QSize(72, 56));
for (int numTheme = 0; numTheme < 20; ++numTheme)
{
RibbonGalleryItem* item = m_itemsThemes->addItemFromMap(QString(), numTheme, QPixmap(QStringLiteral(":/res/gallerythemes.png")), QSize(64, 48));
QString str = QObject::tr("Theme, %1").arg(numTheme + 1);
item->setToolTip(str);
}
}
void MainWindow::dialogGallery()
{
GalleriesDialog dlg(this);
dlg.exec();
}
void MainWindow::aboutToHideUndo()
{
m_itemsUndo->clear();
int count = rand() % 20 + 3;
for (int i = 0; i < count; i++)
m_itemsUndo->appendItem(new GalleryItemUndo(QObject::tr("Undo Action %1").arg(i + 1)));
m_popupUndoGallery->setBaseSize(QSize(120, m_itemsUndo->size().height() * count + 2));
}
void MainWindow::itemColorPressed(RibbonGalleryItem* item)
{
if (m_widgetFontTextColor && m_widgetFontTextColor->checkedItem() != item)
{
m_widgetFontTextColor->setCheckedItem(item);
if (GalleryItemFontColor* itemColor = dynamic_cast<GalleryItemFontColor*>(item))
{
QMessageBox messageBox(QMessageBox::Information, windowTitle(), QString(), QMessageBox::Ok, this);
QString text = tr("<p>Choose Color.</p>");
QColor color = itemColor->getColor();
text += tr("<p>R=%1 G=%2 B=%3</p>").arg(color.red()).arg(color.green()).arg(color.blue());
text += tr("<p>name=%4</p>").arg(itemColor->caption());
messageBox.setInformativeText(text);
messageBox.exec();
}
}
}
void MainWindow::itemStyleFontPressed(RibbonGalleryItem* item)
{
if (m_widgetStyleFont && m_widgetStyleFont->checkedItem() != item)
{
m_widgetStyleFont->setCheckedItem(item);
m_popupStyleFont->setCheckedItem(item);
}
}
void MainWindow::itemTablePressed(RibbonGalleryItem* item)
{
Q_UNUSED(item);
if (m_popupTableGallery)
{
int item = m_popupTableGallery->isItemSelected() ? m_popupTableGallery->selectedItem() : -1;
QRect rcItems = m_popupTableGallery->getItemsRect();
QSize szItems = m_popupTableGallery->galleryGroup()->size();
int itemsPerRow = rcItems.width() / szItems.width();
int columns = item < 1 ? 0 : (item - 1) % itemsPerRow + 1;
int rows = item < 1 ? 0 : (item- 1) / itemsPerRow + 1;
QMessageBox messageBox(QMessageBox::Information, windowTitle(), QString(), QMessageBox::Ok, this);
messageBox.setInformativeText(tr("Table size %1 x %2").arg(rows).arg(columns));
messageBox.exec();
}
}
void MainWindow::itemUndoPressed(RibbonGalleryItem* item)
{
Q_UNUSED(item);
QMessageBox messageBox(QMessageBox::Information, windowTitle(), QString(), QMessageBox::Ok, this);
messageBox.setInformativeText(tr("Undo last %1 actions").arg(m_popupUndoGallery->selectedItem() + 1));
messageBox.exec();
}
void MainWindow::updateStyleActions(const QString& styleName)
{
Q_UNUSED(styleName)
QPixmap px(QStringLiteral(":/res/galleryStyles.png"));
Office2016Style* officeStyle16 = qobject_cast<Office2016Style*>(style());
AdobePhotoshopStyle* photoshopStyle = qobject_cast<AdobePhotoshopStyle*>(style());
if ((officeStyle16 && officeStyle16->theme() == Office2016Style::Black) ||
(photoshopStyle && photoshopStyle->theme() == AdobePhotoshopStyle::Black))
px = QPixmap::fromImage(CommonStyle::invertColors(px.toImage()));
QSize sz(64, 48);
for (int i = 0, count = m_itemsStyles->itemCount(); count > i; i++)
{
RibbonGalleryItem* item = m_itemsStyles->item(i);
QRect rcImage(i * sz.width(), 0, sz.width(), sz.height());
QPixmap copyPix = px.copy(rcImage.left(), rcImage.top(), rcImage.width(), rcImage.height());
item->setIcon(copyPix);
}
px = QPixmap(QStringLiteral(":/res/galleryshapes.png"));
QColor transparentColor(0xFF,0,0xFF);
QImage copyImage = px.copy(0, 0, px.width(), px.height()).toImage();
if ((officeStyle16 && officeStyle16->theme() == Office2016Style::Black) ||
(photoshopStyle && photoshopStyle->theme() == AdobePhotoshopStyle::Black))
{
if (transparentColor.isValid())
copyImage = CommonStyle::addaptColors(copyImage, transparentColor.rgb(), QColor(255 - 48, 255 - 48, 255 - 48).rgb());
px = QPixmap::fromImage(CommonStyle::invertColors(copyImage));
}
else
{
if (transparentColor.isValid())
copyImage.setAlphaChannel(copyImage.createMaskFromColor(transparentColor.rgb(), Qt::MaskOutColor));
px = QPixmap::fromImage(copyImage);
}
sz = QSize(20, 20);
for (int i = 0, count = m_itemsShapes->itemCount(); count > i; i++)
{
RibbonGalleryItem* item = m_itemsShapes->item(i);
QRect rcImage(i * sz.width(), 0, sz.width(), sz.height());
QPixmap copyPix = px.copy(rcImage.left(), rcImage.top(), rcImage.width(), rcImage.height());
item->setIcon(copyPix);
}
}