|
Jeremy Bullock |
15fcba |
#include "xshtoolbar.h"
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
// Tnz6 includes
|
|
Jeremy Bullock |
15fcba |
#include "xsheetviewer.h"
|
|
Jeremy Bullock |
15fcba |
#include "tapp.h"
|
|
Jeremy Bullock |
15fcba |
#include "menubarcommandids.h"
|
|
Jeremy Bullock |
0ff1b6 |
#include "commandbarpopup.h"
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
// TnzLib includes
|
|
Jeremy Bullock |
15fcba |
#include "toonz/preferences.h"
|
|
Jeremy Bullock |
0ff1b6 |
#include "toonz/toonzscene.h"
|
|
Jeremy Bullock |
15fcba |
#include "toonz/tscenehandle.h"
|
|
Jeremy Bullock |
0ff1b6 |
#include "toonz/childstack.h"
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
// Qt includes
|
|
Jeremy Bullock |
dfde6c |
#include <qwidgetaction></qwidgetaction>
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//=============================================================================
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
namespace XsheetGUI {
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//=============================================================================
|
|
Jeremy Bullock |
15fcba |
// Toolbar
|
|
Jeremy Bullock |
15fcba |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
dfde6c |
XSheetToolbar::XSheetToolbar(XsheetViewer *parent, Qt::WindowFlags flags,
|
|
Jeremy Bullock |
dfde6c |
bool isCollapsible)
|
|
shun-iwasawa |
dfea21 |
: CommandBar(parent, flags, isCollapsible, true), m_viewer(parent) {
|
|
Jeremy Bullock |
15fcba |
setObjectName("cornerWidget");
|
|
Kite |
521c84 |
setFixedHeight(29);
|
|
Jeremy Bullock |
dfde6c |
setObjectName("XSheetToolbar");
|
|
Kite |
521c84 |
setIconSize(QSize(20, 20));
|
|
Jeremy Bullock |
15fcba |
}
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
dfde6c |
void XSheetToolbar::showToolbar(bool show) {
|
|
Jeremy Bullock |
dfde6c |
if (!m_isCollapsible) return;
|
|
Jeremy Bullock |
dfde6c |
show ? this->show() : this->hide();
|
|
Jeremy Bullock |
15fcba |
}
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
dfde6c |
void XSheetToolbar::toggleXSheetToolbar() {
|
|
Jeremy Bullock |
15fcba |
bool toolbarEnabled = Preferences::instance()->isShowXSheetToolbarEnabled();
|
|
shun-iwasawa |
8fb291 |
Preferences::instance()->setValue(showXSheetToolbar, !toolbarEnabled);
|
|
Jeremy Bullock |
15fcba |
TApp::instance()->getCurrentScene()->notifyPreferenceChanged("XSheetToolbar");
|
|
Jeremy Bullock |
15fcba |
}
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
dfde6c |
void XSheetToolbar::showEvent(QShowEvent *e) {
|
|
Jeremy Bullock |
dfde6c |
if (Preferences::instance()->isShowXSheetToolbarEnabled() || !m_isCollapsible)
|
|
Jeremy Bullock |
dfde6c |
show();
|
|
Jeremy Bullock |
dfde6c |
else
|
|
Jeremy Bullock |
dfde6c |
hide();
|
|
Jeremy Bullock |
dfde6c |
emit updateVisibility();
|
|
Jeremy Bullock |
dfde6c |
}
|
|
Jeremy Bullock |
dfde6c |
|
|
Jeremy Bullock |
0ff1b6 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
0ff1b6 |
|
|
Jeremy Bullock |
0ff1b6 |
void XSheetToolbar::contextMenuEvent(QContextMenuEvent *event) {
|
|
Jeremy Bullock |
0ff1b6 |
QMenu *menu = new QMenu(this);
|
|
Jeremy Bullock |
0ff1b6 |
QAction *customizeCommandBar =
|
|
Jeremy Bullock |
0ff1b6 |
menu->addAction(tr("Customize XSheet Toolbar"));
|
|
Jeremy Bullock |
0ff1b6 |
connect(customizeCommandBar, SIGNAL(triggered()),
|
|
Jeremy Bullock |
0ff1b6 |
SLOT(doCustomizeCommandBar()));
|
|
Jeremy Bullock |
0ff1b6 |
menu->exec(event->globalPos());
|
|
Jeremy Bullock |
0ff1b6 |
}
|
|
Jeremy Bullock |
0ff1b6 |
|
|
Jeremy Bullock |
0ff1b6 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
0ff1b6 |
|
|
Jeremy Bullock |
0ff1b6 |
void XSheetToolbar::doCustomizeCommandBar() {
|
|
Jeremy Bullock |
0ff1b6 |
CommandBarPopup *cbPopup = new CommandBarPopup(true);
|
|
Jeremy Bullock |
0ff1b6 |
|
|
Jeremy Bullock |
0ff1b6 |
if (cbPopup->exec()) {
|
|
Jeremy Bullock |
0ff1b6 |
fillToolbar(this, true);
|
|
Jeremy Bullock |
0ff1b6 |
}
|
|
Jeremy Bullock |
0ff1b6 |
delete cbPopup;
|
|
Jeremy Bullock |
0ff1b6 |
}
|
|
Jeremy Bullock |
0ff1b6 |
|
|
Jeremy Bullock |
15fcba |
//============================================================
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
class ToggleXSheetToolbarCommand final : public MenuItemHandler {
|
|
Jeremy Bullock |
15fcba |
public:
|
|
Jeremy Bullock |
15fcba |
ToggleXSheetToolbarCommand() : MenuItemHandler(MI_ToggleXSheetToolbar) {}
|
|
Jeremy Bullock |
dfde6c |
void execute() override { XSheetToolbar::toggleXSheetToolbar(); }
|
|
Jeremy Bullock |
15fcba |
} ToggleXSheetToolbarCommand;
|
|
Jeremy Bullock |
15fcba |
|
|
Jeremy Bullock |
15fcba |
//============================================================
|
|
Jeremy Bullock |
15fcba |
|
|
shun-iwasawa |
8fb291 |
} // namespace XsheetGUI
|