void WPanel::setCollapsible(bool on) { if (on && !collapseIcon_) { std::string resources = WApplication::relativeResourcesUrl(); setTitleBar(true); collapseIcon_ = new WIconPair(resources + "collapse.gif", resources + "expand.gif"); collapseIcon_->setFloatSide(Left); WApplication *app = WApplication::instance(); app->theme()->apply(this, collapseIcon_, PanelCollapseButtonRole); titleBarWidget()->insertWidget(0, collapseIcon_); collapseIcon_->icon1Clicked().connect(this, &WPanel::doCollapse); collapseIcon_->icon1Clicked().connect(this, &WPanel::onCollapse); collapseIcon_->icon1Clicked().preventPropagation(); collapseIcon_->icon2Clicked().connect(this, &WPanel::doExpand); collapseIcon_->icon2Clicked().connect(this, &WPanel::onExpand); collapseIcon_->icon2Clicked().preventPropagation(); collapseIcon_->setState(isCollapsed() ? 1 : 0); titleBarWidget()->clicked().connect(this, &WPanel::toggleCollapse); } else if (!on && collapseIcon_) { delete collapseIcon_; collapseIcon_ = 0; } }
void WPanel::setTitle(const WString& title) { setTitleBar(true); if (!title_) { title_ = new WText(); WApplication *app = WApplication::instance(); app->theme()->apply(this, title_, PanelTitleRole); titleBarWidget()->insertWidget(titleBarWidget()->count(), title_); } title_->setText(title); }
TextTools::TextTools(QWidget* parent) : QDockWidget(parent) { _textElement = 0; setObjectName("text-tools"); setWindowTitle(tr("Text Tools")); setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea)); QToolBar* tb = new QToolBar(tr("Text Edit")); tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight)); showKeyboard = getAction("show-keys"); showKeyboard->setCheckable(true); tb->addAction(showKeyboard); typefaceBold = tb->addAction(*icons[int(Icons::textBold_ICON)], ""); typefaceBold->setToolTip(tr("Bold")); typefaceBold->setCheckable(true); typefaceItalic = tb->addAction(*icons[int(Icons::textItalic_ICON)], ""); typefaceItalic->setToolTip(tr("Italic")); typefaceItalic->setCheckable(true); typefaceUnderline = tb->addAction(*icons[int(Icons::textUnderline_ICON)], ""); typefaceUnderline->setToolTip(tr("Underline")); typefaceUnderline->setCheckable(true); tb->addSeparator(); typefaceSubscript = tb->addAction(*icons[int(Icons::textSub_ICON)], ""); typefaceSubscript->setToolTip(tr("Subscript")); typefaceSubscript->setCheckable(true); typefaceSuperscript = tb->addAction(*icons[int(Icons::textSuper_ICON)], ""); typefaceSuperscript->setToolTip(tr("Superscript")); typefaceSuperscript->setCheckable(true); tb->addSeparator(); typefaceFamily = new QFontComboBox(this); tb->addWidget(typefaceFamily); typefaceSize = new QDoubleSpinBox(this); typefaceSize->setFocusPolicy(Qt::ClickFocus); tb->addWidget(typefaceSize); setWidget(tb); QWidget* w = new QWidget(this); setTitleBarWidget(w); titleBarWidget()->hide(); connect(typefaceSize, SIGNAL(valueChanged(double)), SLOT(sizeChanged(double))); connect(typefaceFamily, SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&))); connect(typefaceBold, SIGNAL(triggered(bool)), SLOT(boldClicked(bool))); connect(typefaceItalic, SIGNAL(triggered(bool)), SLOT(italicClicked(bool))); connect(typefaceUnderline, SIGNAL(triggered(bool)), SLOT(underlineClicked(bool))); connect(typefaceSubscript, SIGNAL(triggered(bool)), SLOT(subscriptClicked(bool))); connect(typefaceSuperscript, SIGNAL(triggered(bool)), SLOT(superscriptClicked(bool))); connect(showKeyboard, SIGNAL(triggered(bool)), SLOT(showKeyboardClicked(bool))); }
void WPanel::setTitleBar(bool enable) { if (enable && !titleBarWidget()) { WContainerWidget *titleBar = new WContainerWidget(); impl_->bindWidget("titlebar", titleBar); WApplication *app = WApplication::instance(); app->theme()->apply(this, titleBar, PanelTitleBarRole); } else if (!enable && titleBar()) { impl_->bindWidget("titlebar", 0); title_ = 0; collapseIcon_ = 0; } }
EditTools::EditTools(QWidget* parent) : QDockWidget(parent) { setObjectName("edit-tools"); setWindowTitle(tr("Edit Mode Tools")); setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea)); QToolBar* tb = new QToolBar(tr("Edit Mode Tools")); tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight)); QToolButton* b = new QToolButton(this); QAction* a = getAction("hraster"); a->setCheckable(true); b->setDefaultAction(a); b->setContextMenuPolicy(Qt::ActionsContextMenu); b->addAction(getAction("config-raster")); tb->addWidget(b); b = new QToolButton(this); a = getAction("vraster"); a->setCheckable(true); b->setDefaultAction(a); b->setContextMenuPolicy(Qt::ActionsContextMenu); b->addAction(getAction("config-raster")); tb->addWidget(b); _editX = new QDoubleSpinBox(this); _editX->setSuffix(tr("sp")); _editX->setRange(-99999, 99999); _editX->setSingleStep(.1); _editY = new QDoubleSpinBox(this); _editY->setSuffix(tr("sp")); _editY->setRange(-99999, 99999); _editY->setSingleStep(.1); xLabel = new QLabel(tr("x:"), this); yLabel = new QLabel(tr("y:"), this); _localEdit = false; tb->addWidget(xLabel); tb->addWidget(_editX); tb->addWidget(yLabel); tb->addWidget(_editY); connect(_editX, SIGNAL(valueChanged(double)), SLOT(editXChanged(double))); connect(_editY, SIGNAL(valueChanged(double)), SLOT(editYChanged(double))); setWidget(tb); QWidget* w = new QWidget(this); setTitleBarWidget(w); titleBarWidget()->hide(); }
DrumTools::DrumTools(QWidget* parent) : QDockWidget(parent) { drumset = 0; _score = 0; setObjectName("drum-tools"); setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea)); QWidget* w = new QWidget(this); w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); w->setMaximumHeight(100); QHBoxLayout* layout = new QHBoxLayout; w->setLayout(layout); QVBoxLayout* layout1 = new QVBoxLayout; layout1->setSpacing(6); pitchName = new QLabel; pitchName->setAlignment(Qt::AlignCenter); pitchName->setWordWrap(true); pitchName->setContentsMargins(25, 0, 25, 0); layout1->addWidget(pitchName); QHBoxLayout* buttonLayout = new QHBoxLayout; buttonLayout->setContentsMargins(25, 10, 25, 10); editButton = new QToolButton; editButton->setMinimumWidth(100); editButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); buttonLayout->addWidget(editButton); layout1->addLayout(buttonLayout); layout->addLayout(layout1); drumPalette = new Palette; drumPalette->setMag(0.8); drumPalette->setSelectable(true); drumPalette->setGrid(28, 60); PaletteScrollArea* sa = new PaletteScrollArea(drumPalette); sa->setFocusPolicy(Qt::NoFocus); layout->addWidget(sa); setWidget(w); w = new QWidget(this); setTitleBarWidget(w); titleBarWidget()->hide(); connect(editButton, SIGNAL(clicked()), SLOT(editDrumset())); void boxClicked(int); connect(drumPalette, SIGNAL(boxClicked(int)), SLOT(drumNoteSelected(int))); retranslate(); drumPalette->setContextMenuPolicy(Qt::PreventContextMenu); }
/**************************************************************************** ** ** Copyright (C) 2016 - 2017 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ // Include #include "material_browser.h" #include "material_tree.h" //****************************************************************************/ MaterialTreeDockWidget::MaterialTreeDockWidget(const QString& iconDir, const QString& title, QMainWindow* parent, Qt::WindowFlags flags) : QDockWidget (title, parent, flags), mParent(parent) { mIconDir = iconDir; mEmptyString = ""; mResourceTreeWidget = new Magus::QtResourceTreeWidget(iconDir); mResourceTreeWidget->mActionDuplicateAssetText = QString("Clone material"); mResourceTreeWidget->mActionDeleteResourceText = QString("Remove from list"); mResourceTreeWidget->setAddAssetAfterDuplicateAssetSelected(false); // Do not duplicate automatically mResourceTreeWidget->setCreateTopLevelGroupContextMenuItemEnabled(false); mResourceTreeWidget->setDeleteTopLevelGroupEnabled(false); mResourceTreeWidget->setTopLevelGroupItemEditable(false); mResourceTreeWidget->setSubLevelGroupItemEditable(true); mResourceTreeWidget->setCreateAssetContextMenuItemEnabled(false); mResourceTreeWidget->setAssetItemEditable(false); mResourceTreeWidget->setDeleteResourceContextMenuItemEnabled(true); mResourceTreeWidget->setImportAssetContextMenuItemEnabled(false); mResourceTreeWidget->setDuplicateAssetContextMenuItemEnabled(true); // Miscellanious settings mResourceTreeWidget->addCustomContextMenuItem(ACTION_EDIT); // Listen to events. // Note, that although the 'create asset' context menu is disabled, the MaterialTreeDockWidget must still handle the 'resourceAdded' // signal, because it is also emitted when a subgroup is created in the mResourceTreeWidget; the subgroup must be added to // mSourceInfo after creation, to be able to recursively delete any assets resided in subgroups (these assets must also be // properly deleted from the MaterialThumbsDockWidget). connect(mResourceTreeWidget, SIGNAL(resourceSelected(int)), this, SLOT(handleResourceSelected(int))); connect(mResourceTreeWidget, SIGNAL(resourceDoubleClicked(int)), this, SLOT(handleResourceDoubleClicked(int))); connect(mResourceTreeWidget, SIGNAL(resourceAdded(int)), this, SLOT(handleResourceAdded(int))); connect(mResourceTreeWidget, SIGNAL(resourceDeleted(int)), this, SLOT(handleResourceDeleted(int))); connect(mResourceTreeWidget, SIGNAL(resourceMoved(int)), this, SLOT(handleResourceMoved(int))); connect(mResourceTreeWidget, SIGNAL(resourceSearched(QString)), this, SLOT(handleResourceSearched(QString))); connect(mResourceTreeWidget, SIGNAL(resourceSearchReset()), this, SLOT(handleResourceSearchReset())); connect(mResourceTreeWidget, SIGNAL(assetDuplicated(int)), this, SLOT(handleResourceDuplicated(int))); connect(mResourceTreeWidget, SIGNAL(customContextMenuItemSelected(QString,int)), this, SLOT(handleCustomContextMenuItemSelected(QString, int))); mInnerMain = new QMainWindow(); mInnerMain->setMinimumSize(100,100); mInnerMain->setCentralWidget(mResourceTreeWidget); setWidget(mInnerMain); QWidget* oldTitleBar = titleBarWidget(); setTitleBarWidget(new QWidget()); delete oldTitleBar; // Add toplevel groups initializeResourceTree(); }
/**************************************************************************** ** ** Copyright (C) 2014 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ // Include #include "tool_resourcewidget_collections.h" namespace Magus { //****************************************************************************/ QtCollectionsDockWidget::QtCollectionsDockWidget(const QString& iconDir, const QString& title, QMainWindow* parent, Qt::WindowFlags flags) : QDockWidget (title, parent, flags), mParent(parent) { mIconDir = iconDir; mInnerMain = new QMainWindow(); setWidget(mInnerMain); QWidget* oldTitleBar = titleBarWidget(); setTitleBarWidget(new QWidget()); delete oldTitleBar; // Perform standard functions createActions(); createMenus(); createToolBars(); }
DrumTools::DrumTools(QWidget* parent) : QDockWidget(parent) { drumset = 0; _score = 0; setObjectName("drum-tools"); setWindowTitle(tr("Drum Tools")); setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea)); QWidget* w = new QWidget(this); w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); QHBoxLayout* layout = new QHBoxLayout; w->setLayout(layout); QVBoxLayout* layout1 = new QVBoxLayout; QToolButton* tb = new QToolButton; tb->setText(tr("Edit Drumset")); layout1->addWidget(tb); layout1->addStretch(); layout->addLayout(layout1); drumPalette = new Palette; drumPalette->setName(tr("Drums")); drumPalette->setMag(0.8); drumPalette->setSelectable(true); drumPalette->setGrid(28, 60); PaletteScrollArea* sa = new PaletteScrollArea(drumPalette); sa->setFocusPolicy(Qt::NoFocus); layout->addWidget(sa); setWidget(w); // setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); w = new QWidget(this); setTitleBarWidget(w); titleBarWidget()->hide(); connect(tb, SIGNAL(clicked()), SLOT(editDrumset())); void boxClicked(int); connect(drumPalette, SIGNAL(boxClicked(int)), SLOT(drumNoteSelected(int))); }
TextTools::TextTools(QWidget* parent) : QDockWidget(parent) { _textElement = 0; setObjectName("text-tools"); setWindowTitle(tr("Text Tools")); setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea)); QToolBar* tb = new QToolBar(tr("Text Edit")); tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight)); textStyles = new QComboBox; tb->addWidget(textStyles); showKeyboard = getAction("show-keys"); showKeyboard->setCheckable(true); tb->addAction(showKeyboard); typefaceBold = tb->addAction(*icons[textBold_ICON], ""); typefaceBold->setToolTip(tr("bold")); typefaceBold->setCheckable(true); typefaceItalic = tb->addAction(*icons[textItalic_ICON], ""); typefaceItalic->setToolTip(tr("italic")); typefaceItalic->setCheckable(true); typefaceUnderline = tb->addAction(*icons[textUnderline_ICON], ""); typefaceUnderline->setToolTip(tr("underline")); typefaceUnderline->setCheckable(true); tb->addSeparator(); QActionGroup* ha = new QActionGroup(tb); leftAlign = new QAction(*icons[textLeft_ICON], "", ha); leftAlign->setToolTip(tr("align left")); leftAlign->setCheckable(true); leftAlign->setData(ALIGN_LEFT); hcenterAlign = new QAction(*icons[textCenter_ICON], "", ha); hcenterAlign->setToolTip(tr("align horizontal center")); hcenterAlign->setCheckable(true); hcenterAlign->setData(ALIGN_HCENTER); rightAlign = new QAction(*icons[textRight_ICON], "", ha); rightAlign->setToolTip(tr("align right")); rightAlign->setCheckable(true); rightAlign->setData(ALIGN_RIGHT); tb->addActions(ha->actions()); QActionGroup* va = new QActionGroup(tb); topAlign = new QAction(*icons[textTop_ICON], "", va); topAlign->setToolTip(tr("align top")); topAlign->setCheckable(true); topAlign->setData(ALIGN_TOP); bottomAlign = new QAction(*icons[textBottom_ICON], "", va); bottomAlign->setToolTip(tr("align bottom")); bottomAlign->setCheckable(true); bottomAlign->setData(ALIGN_BOTTOM); baselineAlign = new QAction(*icons[textBaseline_ICON], "", va); baselineAlign->setToolTip(tr("align vertical baseline")); baselineAlign->setCheckable(true); baselineAlign->setData(ALIGN_BASELINE); vcenterAlign = new QAction(*icons[textVCenter_ICON], "", va); vcenterAlign->setToolTip(tr("align vertical center")); vcenterAlign->setCheckable(true); vcenterAlign->setData(ALIGN_VCENTER); tb->addActions(va->actions()); typefaceSubscript = tb->addAction(*icons[textSub_ICON], ""); typefaceSubscript->setToolTip(tr("subscript")); typefaceSubscript->setCheckable(true); typefaceSuperscript = tb->addAction(*icons[textSuper_ICON], ""); typefaceSuperscript->setToolTip(tr("superscript")); typefaceSuperscript->setCheckable(true); unorderedList = tb->addAction(*icons[formatListUnordered_ICON], ""); unorderedList->setToolTip(tr("unordered list")); orderedList = tb->addAction(*icons[formatListOrdered_ICON], ""); orderedList->setToolTip(tr("ordered list")); indentMore = tb->addAction(*icons[formatIndentMore_ICON], ""); indentMore->setToolTip(tr("indent more")); indentLess = tb->addAction(*icons[formatIndentLess_ICON], ""); indentLess->setToolTip(tr("indent less")); tb->addSeparator(); typefaceFamily = new QFontComboBox(this); tb->addWidget(typefaceFamily); typefaceSize = new QDoubleSpinBox(this); tb->addWidget(typefaceSize); setWidget(tb); QWidget* w = new QWidget(this); setTitleBarWidget(w); titleBarWidget()->hide(); connect(typefaceSize, SIGNAL(valueChanged(double)), SLOT(sizeChanged(double))); connect(typefaceFamily, SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&))); connect(typefaceBold, SIGNAL(triggered(bool)), SLOT(boldClicked(bool))); connect(typefaceItalic, SIGNAL(triggered(bool)), SLOT(italicClicked(bool))); connect(typefaceUnderline, SIGNAL(triggered(bool)), SLOT(underlineClicked(bool))); connect(typefaceSubscript, SIGNAL(triggered(bool)), SLOT(subscriptClicked(bool))); connect(typefaceSuperscript, SIGNAL(triggered(bool)), SLOT(superscriptClicked(bool))); connect(typefaceFamily, SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&))); connect(ha, SIGNAL(triggered(QAction*)), SLOT(setHalign(QAction*))); connect(va, SIGNAL(triggered(QAction*)), SLOT(setValign(QAction*))); connect(showKeyboard, SIGNAL(triggered(bool)), SLOT(showKeyboardClicked(bool))); connect(textStyles, SIGNAL(currentIndexChanged(int)), SLOT(styleChanged(int))); connect(unorderedList, SIGNAL(triggered()), SLOT(unorderedListClicked())); connect(orderedList, SIGNAL(triggered()), SLOT(orderedListClicked())); connect(indentLess, SIGNAL(triggered()), SLOT(indentLessClicked())); connect(indentMore, SIGNAL(triggered()), SLOT(indentMoreClicked())); }
bool WPanel::titleBar() const { return titleBarWidget() != 0; }