コード例 #1
0
ファイル: module.cpp プロジェクト: Nishant23/pixelsynth
Editor::Modules::Metadata Editor::Modules::Timeline::registerModule()
{
	Metadata m;

	m.setWidget([&](QObject* app, QWidget* parent, Core::Project& project)
	{
		auto widget = new Widget(parent, project);
		app->connect(app, SIGNAL(projectMutated(std::shared_ptr<Core::MutationInfo>)), widget, SLOT(projectMutated(std::shared_ptr<Core::MutationInfo>)));
		return widget;
	});

	m.setDockWidgetArea(Qt::BottomDockWidgetArea);

	// Cut/copy/paste

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app);
		action->setSeparator(true);
		return action;
	}, "&Redo", ActionFlags::RequiresFocus);

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app->tr("&Cut"), app);
		action->setShortcuts({ QKeySequence(app->tr("Ctrl+C")) });
		return action;
	}, "&Redo", ActionFlags::RequiresFocus);

	// Debug stuff

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app);
		action->setSeparator(true);
		return action;
	}, "&Redo");

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app->tr("&Mutate"), app);
		action->setShortcuts({ QKeySequence(app->tr("Ctrl+M")) });
		action->connect(action, &QAction::triggered, widget, &Widget::mutate);
		return action;
	}, "&Redo");

	return m;
}
コード例 #2
0
ファイル: tabdlg.cpp プロジェクト: Shura0/psi
/**
 * Constructs a TabDlg
 *
 * \param tabManager The tabManager that will manage this TabDlg
 * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that
 *        will manage some aspects of the TabDlg behavior.  Ownership is not
 *        passed.
 */ 
TabDlg::TabDlg(TabManager* tabManager, const QString& geometryOption, TabDlgDelegate *delegate)
		: AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0)
		, delegate_(delegate)
		, tabWidget_(0)
		, detachButton_(0)
		, closeButton_(0)
		, closeCross_(0)
		, tabMenu_(new QMenu(this))
		, act_close_(0)
		, act_next_(0)
		, act_prev_(0)
		, tabManager_(tabManager)
		, userManagement_(true)
		, tabBarSingles_(true)
		, simplifiedCaption_(false)
		, activateTabMapper_(0)
{
	if (delegate_) {
		delegate_->create(this);
	}

	// FIXME
	qRegisterMetaType<TabDlg*>("TabDlg*");
	qRegisterMetaType<TabbableWidget*>("TabbableWidget*");

	tabWidget_ = new PsiTabWidget(this);
	tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon());
	connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*)));
	connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*)));
	connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*)));
	connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*)));
	connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab()));
	connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*)));

	if(delegate_)
		delegate_->tabWidgetCreated(this, tabWidget_);

	QVBoxLayout *vert1 = new QVBoxLayout(this);
	vert1->setMargin(1);
	vert1->addWidget(tabWidget_);

	setAcceptDrops(true);

	X11WM_CLASS("tabs");
	setLooks();

	act_close_ = new QAction(this);
	addAction(act_close_);
	connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab()));
	act_prev_ = new QAction(this);
	addAction(act_prev_);
	connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab()));
	act_next_ = new QAction(this);
	addAction(act_next_);
	connect(act_next_,SIGNAL(triggered()), SLOT(nextTab()));

	setShortcuts();

	setGeometryOptionPath(geometryOption);
}
コード例 #3
0
manageSystemVolumes::manageSystemVolumes( QWidget * parent ) : QDialog( parent ),m_ui( new Ui::manageSystemVolumes )
{
	m_ui->setupUi( this ) ;

	this->setFont( parent->font() ) ;
	this->setFixedSize( this->size() ) ;

	connect( m_ui->pbDone,SIGNAL( clicked() ),this,SLOT( pbDone() ) ) ;
	connect( m_ui->pbFile,SIGNAL( clicked() ),this,SLOT( pbFile() ) ) ;
	connect( m_ui->pbPartition,SIGNAL( clicked() ),this,SLOT( pbPartition() ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),this,
		SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( itemClicked( QTableWidgetItem * ) ),this,
		SLOT( itemClicked( QTableWidgetItem * ) ) ) ;

	this->addAction( [ this ](){

		auto ac = new QAction( this ) ;

		QList<QKeySequence> keys ;

		keys.append( Qt::Key_Enter ) ;
		keys.append( Qt::Key_Return ) ;
		keys.append( Qt::Key_Menu ) ;

		ac->setShortcuts( keys ) ;

		connect( ac,SIGNAL( triggered() ),this,SLOT( defaultButton() ) ) ;

		return ac ;
	}() ) ;

	this->installEventFilter( this ) ;
}
コード例 #4
0
void ShortcutsSettings::resetAllShortcuts()
{
   for(QMap<QString,QList<QKeySequence> >::const_iterator it = defaultShortCuts.begin();
                                                        it != defaultShortCuts.end(); ++it){
       setShortcuts(it.key(), it.value());
   }
   emit allShortCutsReset();
}
コード例 #5
0
void ShortcutsSettings::clearAllShortcuts()
{
    for(QMap<QString,QList<QKeySequence> >::const_iterator it = shortCuts.begin();
                                                         it != shortCuts.end(); ++it){
        setShortcuts(it.key(), "");
    }
    emit allShortCutsClear();
}
コード例 #6
0
ファイル: shortcutswidget.cpp プロジェクト: m4r71n/CopyQ
void ShortcutsWidget::saveShortcuts(QSettings *settings)
{
    auto commands = loadAllCommands();
    bool needSaveCommands = false;

    for (const auto &action : m_actions) {
        QStringList shortcutNames;
        for (const auto &shortcut : action.shortcutButton->shortcuts())
            shortcutNames.append(portableShortcutText(shortcut));

        if ( action.settingsKey.isEmpty() ) {
            auto savedCommand = findShortcutCommand(action.command.name, commands);
            const bool enable = !shortcutNames.isEmpty();
            if (savedCommand) {
                if ( savedCommand->enable != enable || (enable && shortcuts(*savedCommand) != shortcutNames) ) {
                    needSaveCommands = true;
                    savedCommand->enable = enable;
                    if (enable)
                        setShortcuts(savedCommand, shortcutNames);
                }
            } else if ( !shortcutNames.isEmpty() ) {
                needSaveCommands = true;
                auto command = action.command;
                setShortcuts(&command, shortcutNames);
                commands.append(command);
            }
        } else {
            // Workaround for QTBUG-51237 (saving empty list results in invalid value).
            if (shortcutNames.isEmpty())
                settings->setValue(action.settingsKey, QString());
            else
                settings->setValue(action.settingsKey, shortcutNames);
        }
    }

    if (needSaveCommands) {
        saveCommands(commands);
        emit commandsSaved();
    }
}
コード例 #7
0
KoUndoStackAction::KoUndoStackAction(KUndo2Stack* stack, Type type)
    : QAction(stack)
    , m_type(type)
{
    if (m_type == UNDO) {
        connect(this, SIGNAL(triggered()), stack, SLOT(undo()));
        connect(stack, SIGNAL(canUndoChanged(bool)), this, SLOT(setEnabled(bool)));
        connect(stack, SIGNAL(undoTextChanged(QString)), this, SLOT(slotUndoTextChanged(QString)));
        setIcon(koIcon("edit-undo"));
        setText(i18n("Undo"));
        setShortcuts(KStandardShortcut::undo());
        setEnabled(stack->canUndo());
    } else {
コード例 #8
0
ファイル: openvolume.cpp プロジェクト: jdoe0/zuluCrypt
openvolume::openvolume( QWidget * parent ) : QDialog( parent ),m_ui( new Ui::openvolume() )
{
	m_ui->setupUi( this ) ;

	this->setFixedSize( this->size() ) ;
	this->setFont( parent->font() ) ;

	connect( m_ui->tableWidget,SIGNAL( itemDoubleClicked( QTableWidgetItem * ) ),
		 this,SLOT( tableEntryDoubleClicked( QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),
		 this,SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->pbHelp,SIGNAL( clicked() ),this,SLOT( pbHelp() ) ) ;
	connect( m_ui->pbUUID,SIGNAL( clicked() ),this,SLOT( pbUUID() ) ) ;
	connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( pbCancel() ) ) ;
	connect( m_ui->pbOpen,SIGNAL( clicked() ),this,SLOT( pbOpen() ) ) ;

	this->addAction( [ this ](){

		auto ac = new QAction( this ) ;

		ac->setShortcuts( { Qt::Key_Enter,Qt::Key_Return } ) ;

		connect( ac,SIGNAL( triggered() ),this,SLOT( EnterKeyPressed() ) ) ;

		return ac ;
	}() ) ;

	auto tw = m_ui->tableWidget ;

	tw->setColumnWidth( 0,183 ) ;
	tw->setColumnWidth( 1,90 ) ;
	//tw->setColumnWidth( 2,110 ) ;
	tw->hideColumn( 2 ) ;
	tw->setColumnWidth( 3,90 ) ;
	tw->setColumnWidth( 4,309 ) ;

	for( int i = 0 ; i < 5 ; i++ ){

		tw->horizontalHeaderItem( i )->setFont( this->font() ) ;
	}

	tw->horizontalHeader()->setVisible( true ) ;

	m_ui->checkBoxUUID->setVisible( false ) ;

	m_ui->pbHelp->setVisible( false ) ;

	this->installEventFilter( this ) ;

	this->disableAll() ;
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: bankonme/zuluCrypt
void MainWindow::setUpShortCuts()
{
	auto ac = new QAction( this ) ;
	QList<QKeySequence> keys ;
	keys.append( Qt::Key_Enter ) ;
	keys.append( Qt::Key_Return ) ;
	ac->setShortcuts( keys ) ;
	connect( ac,SIGNAL( triggered() ),this,SLOT( defaultButton() ) ) ;
	this->addAction( ac ) ;

	auto qa = new QAction( this ) ;
	QList<QKeySequence> z ;
	z.append( Qt::Key_M ) ;
	qa->setShortcuts( z ) ;
	connect( qa,SIGNAL( triggered() ),this,SLOT( pbMount() ) ) ;
	this->addAction( qa ) ;

	qa = new QAction( this ) ;
	QList<QKeySequence> p ;
	p.append( Qt::Key_U ) ;
	qa->setShortcuts( p ) ;
	connect( qa,SIGNAL( triggered() ),this,SLOT( pbUmount() ) ) ;
	this->addAction( qa ) ;

	qa = new QAction( this ) ;
	QList<QKeySequence> q ;
	q.append( Qt::Key_R ) ;
	qa->setShortcuts( q ) ;
	connect( qa,SIGNAL( triggered() ),this,SLOT( pbUpdate() ) ) ;
	this->addAction( qa ) ;

	qa = new QAction( this ) ;
	QList<QKeySequence> e ;
	e.append( Qt::Key_C ) ;
	qa->setShortcuts( e ) ;
	connect( qa,SIGNAL( triggered() ),this,SLOT( pbClose() ) ) ;
	this->addAction( qa ) ;
}
コード例 #10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setAttribute(Qt::WA_DeleteOnClose);

    connectActions(App::instance());
    ui->menuEdit->addAction(App::instance()->undoAction());
    ui->menuEdit->addAction(App::instance()->redoAction());
    setShortcuts();

    populateMenu(ui->menuAdd);
}
コード例 #11
0
ファイル: favorites.cpp プロジェクト: ParrotSec/zulucrypt
favorites::favorites( QWidget * parent,bool e ) : QDialog( parent ),m_ui( new Ui::favorites )
{
	m_ui->setupUi( this ) ;

	this->setWindowFlags( Qt::Window | Qt::Dialog ) ;
	this->setFont( parent->font() ) ;

	this->setFixedSize( this->size() ) ;

	connect( m_ui->pbFolderAddress,SIGNAL( clicked() ),this,SLOT( folderAddress() ) ) ;
	connect( m_ui->pbDeviceAddress,SIGNAL( clicked() ),this,SLOT( deviceAddress() ) ) ;
	connect( m_ui->pbAdd,SIGNAL( clicked() ),this,SLOT( add() ) ) ;
	connect( m_ui->pbFileAddress,SIGNAL( clicked() ),this,SLOT( fileAddress() ) ) ;
	connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( cancel() ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),this,
		SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( itemClicked( QTableWidgetItem * ) ),this,
		SLOT( itemClicked( QTableWidgetItem * ) ) ) ;
	connect( m_ui->lineEditDeviceAddress,SIGNAL( textChanged( QString ) ),this,SLOT( devicePathTextChange( QString ) ) ) ;

	m_ui->pbFileAddress->setIcon( QIcon( ":/file.png" ) ) ;
	m_ui->pbDeviceAddress->setIcon( QIcon( ":/partition.png" ) ) ;
	m_ui->pbFolderAddress->setIcon( QIcon( ":/folder.png" ) ) ;

	m_ui->pbFolderAddress->setEnabled( e ) ;

	this->addAction( [ this ](){

		auto ac = new QAction( this ) ;

		QList<QKeySequence> keys ;

		keys.append( Qt::Key_Enter ) ;
		keys.append( Qt::Key_Return ) ;
		keys.append( Qt::Key_Menu ) ;

		ac->setShortcuts( keys ) ;

		connect( ac,SIGNAL( triggered() ),this,SLOT( shortcutPressed() ) ) ;

		return ac ;
	}() ) ;

	this->installEventFilter( this ) ;

	this->ShowUI() ;
}
コード例 #12
0
ファイル: chatdlg.cpp プロジェクト: hummbl/psi
void ChatDlg::init()
{
	initUi();
	initActions();
	setShortcuts();

	// TODO: this have to be moved to chatEditCreated()
	chatView()->setDialog(this);
	chatEdit()->setDialog(this);

	chatEdit()->installEventFilter(this);
	connect(chatView(), SIGNAL(selectionChanged()), SLOT(logSelectionChanged()));

	// SyntaxHighlighters modify the QTextEdit in a QTimer::singleShot(0, ...) call
	// so we need to install our hooks after it fired for the first time
	QTimer::singleShot(10, this, SLOT(initComposing()));
	connect(this, SIGNAL(composing(bool)), SLOT(updateIsComposing(bool)));

	setAcceptDrops(TRUE);
	updateContact(jid(), true);

	X11WM_CLASS("chat");
	setLooks();

	updatePGP();

	connect(account(), SIGNAL(pgpKeyChanged()), SLOT(updatePGP()));
	connect(account(), SIGNAL(encryptedMessageSent(int, bool, int, const QString &)), SLOT(encryptedMessageSent(int, bool, int, const QString &)));
	account()->dialogRegister(this, jid());

	chatView()->setFocusPolicy(Qt::NoFocus);
	chatEdit()->setFocus();

	// TODO: port to restoreSavedSize() (and adapt it from restoreSavedGeometry())
	QSize size = PsiOptions::instance()->getOption("options.ui.chat.size").toSize();
	if (!size.isEmpty()) {
		resize(size);
	} else {
		resize(defaultSize());
	}
}
コード例 #13
0
ファイル: chatdlg.cpp プロジェクト: hummbl/psi
void ChatDlg::optionsUpdate()
{
	setLooks();
	setShortcuts();

	if (isHidden()) {
		if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "instant") {
			deleteLater();
			return;
		}
		else {
			if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "hour") {
				setSelfDestruct(60);
			}
			else if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "day") {
				setSelfDestruct(60 * 24);
			}
			else {
				setSelfDestruct(0);
			}
		}
	}
}
コード例 #14
0
ファイル: qaction.cpp プロジェクト: 3163504123/phantomjs
/*!
    \since 4.2

    Sets a platform dependent list of shortcuts based on the \a key.
    The result of calling this function will depend on the currently running platform.
    Note that more than one shortcut can assigned by this action.
    If only the primary shortcut is required, use setShortcut instead.

    \sa QKeySequence::keyBindings()
*/
void QAction::setShortcuts(QKeySequence::StandardKey key)
{
    QList <QKeySequence> list = QKeySequence::keyBindings(key);
    setShortcuts(list);
}
コード例 #15
0
ファイル: tabdlg.cpp プロジェクト: AlekSi/psi
/**
 * Constructs a TabDlg
 *
 * \param tabManager The tabManager that will manage this TabDlg
 * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that
 *        will manage some aspects of the TabDlg behavior.  Ownership is not
 *        passed.
 */ 
TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate)
		: AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0)
		, delegate_(delegate)
		, tabWidget_(0)
		, detachButton_(0)
		, closeButton_(0)
		, closeCross_(0)
		, tabMenu_(new QMenu(this))
		, act_close_(0)
		, act_next_(0)
		, act_prev_(0)
		, tabManager_(tabManager)
		, userManagement_(true)
		, tabBarSingles_(true)
		, simplifiedCaption_(false) {
	if (delegate_) {
		delegate_->create(this);
	}

	// FIXME
	qRegisterMetaType<TabDlg*>("TabDlg*");
	qRegisterMetaType<TabbableWidget*>("TabbableWidget*");

	tabWidget_ = new PsiTabWidget(this);
	tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon());
	connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*)));
	connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*)));
	connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*)));
	connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*)));
	connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab()));
	connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*)));

	if(delegate_)
		delegate_->tabWidgetCreated(this, tabWidget_);

	QVBoxLayout *vert1 = new QVBoxLayout(this);
	vert1->setMargin(1);
	vert1->addWidget(tabWidget_);

	setAcceptDrops(true);

	X11WM_CLASS("tabs");
	setLooks();

	act_close_ = new QAction(this);
	addAction(act_close_);
	connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab()));
	act_prev_ = new QAction(this);
	addAction(act_prev_);
	connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab()));
	act_next_ = new QAction(this);
	addAction(act_next_);
	connect(act_next_,SIGNAL(triggered()), SLOT(nextTab()));

	setShortcuts();

	QSignalMapper* activateTabMapper_ = new QSignalMapper(this);
	connect(activateTabMapper_, SIGNAL(mapped(int)), tabWidget_, SLOT(setCurrentPage(int)));
	for (int i = 0; i < 10; ++i) {
		QAction* action = new QAction(this);
		connect(action, SIGNAL(triggered()), activateTabMapper_, SLOT(map()));
		action->setShortcuts(QList<QKeySequence>() << QKeySequence(QString("Ctrl+%1").arg(i))
		                                           << QKeySequence(QString("Alt+%1").arg(i)));
		activateTabMapper_->setMapping(action, (i > 0 ? i : 10) - 1);
		addAction(action);
	}

	if (size.isValid()) {
		resize(size);
	} else {
		resize(ChatDlg::defaultSize()); //TODO: no!
	}
}
コード例 #16
0
ファイル: app.cpp プロジェクト: hansstam/antimony
QAction* App::redoAction()
{
    auto a = stack->createRedoAction(this);
    a->setShortcuts(QKeySequence::Redo);
    return a;
}
コード例 #17
0
ファイル: tabdlg.cpp プロジェクト: Voker57/psi
/**
 * Constructs a TabDlg
 *
 * \param tabManager The tabManager that will manage this TabDlg
 * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that
 *        will manage some aspects of the TabDlg behavior.  Ownership is not
 *        passed.
 */ 
TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate)
		: AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0)
		, delegate_(delegate)
		, tabWidget_(0)
		, detachButton_(0)
		, closeButton_(0)
		, closeCross_(0)
		, tabMenu_(new QMenu(this))
		, act_close_(0)
		, act_next_(0)
		, act_prev_(0)
		, tabManager_(tabManager)
		, userManagement_(true)
		, tabBarSingles_(true)
		, simplifiedCaption_(false) {
	if (delegate_) {
		delegate_->create(this);
	}

	if (PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool()) {
		setAttribute(Qt::WA_MacMetalStyle);
	}

	// FIXME
	qRegisterMetaType<TabDlg*>("TabDlg*");
	qRegisterMetaType<TabbableWidget*>("TabbableWidget*");

	tabWidget_ = new PsiTabWidget(this);
	tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon());
	connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*)));
	connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*)));
	connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*)));
	connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab()));
	connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*)));

	if(delegate_)
		delegate_->tabWidgetCreated(this, tabWidget_);

	QVBoxLayout *vert1 = new QVBoxLayout( this, 1);
	vert1->addWidget(tabWidget_);

	setAcceptDrops(TRUE);

	X11WM_CLASS("tabs");
	setLooks();

	act_close_ = new QAction(this);
	addAction(act_close_);
	connect(act_close_,SIGNAL(activated()), SLOT(closeCurrentTab()));
	act_prev_ = new QAction(this);
	addAction(act_prev_);
	connect(act_prev_,SIGNAL(activated()), SLOT(previousTab()));
	act_next_ = new QAction(this);
	addAction(act_next_);
	connect(act_next_,SIGNAL(activated()), SLOT(nextTab()));

	setShortcuts();

	if (size.isValid()) {
		resize(size);
	} else {
		resize(ChatDlg::defaultSize()); //TODO: no!
	}
}
コード例 #18
0
void MyAction::addShortcut(QKeySequence key) {
	setShortcuts( shortcuts() << key);
}
コード例 #19
0
void ShortcutsSettings::setShortcuts(QString name, QString Sequences)
{
    setShortcuts(name,parseSequenceString(Sequences));
}
コード例 #20
0
ファイル: rootmenu.cpp プロジェクト: jsj2008/cmplayer
void RootMenu::update(const Pref &p) {
	auto &root = *this;

	auto &open = root("open", tr("Open"));
	open.a("file", tr("Open File"));
	open.a("folder", tr("Open Folder"));
	open.a("url", tr("Load URL"));
	open.a("dvd", tr("Open DVD"));
	open.a("bluray", tr("Open Blu-ray Disc"));

	auto &recent = open("recent");
	recent.setTitle(tr("Recently Opened"));
	recent.a("clear", tr("Clear"));

	auto &play = root("play", tr("Play"));
	play.a("pause", tr("Play"));
	play.a("stop", tr("Stop"));
	play.a("prev", tr("Play Previous"));
	play.a("next", tr("Play Next"));
	play.a("dvd-menu", tr("DVD Menu"));

	auto &speed = play("speed", tr("Playback Speed"));
	updateStepActions(speed, "%1%", p.speed_step);

	auto &repeat = play("repeat", tr("A-B Repeat"));
	repeat.a("range", tr("Set Range to Current Time"));
	repeat.a("subtitle", tr("Repeat Current Subtitle"));
	repeat.a("quit", tr("Quit"));

	auto &seek = play("seek", tr("Seek"));
	const auto forward = tr("Forward %1sec");
	setActionAttr(seek["forward1"], p.seek_step1, forward, p.seek_step1*0.001, false);
	setActionAttr(seek["forward2"], p.seek_step2, forward, p.seek_step2*0.001, false);
	setActionAttr(seek["forward3"], p.seek_step3, forward, p.seek_step3*0.001, false);
	const auto backward = tr("Backward %1sec");
	setActionAttr(seek["backward1"], -p.seek_step1, backward, p.seek_step1*0.001, false);
	setActionAttr(seek["backward2"], -p.seek_step2, backward, p.seek_step2*0.001, false);
	setActionAttr(seek["backward3"], -p.seek_step3, backward, p.seek_step3*0.001, false);

	seek.a("prev-subtitle", tr("To Previous Subtitle"));
	seek.a("current-subtitle", tr("To Beginning of Current Subtitle"));
	seek.a("next-subtitle", tr("To Next Subtitle"));

	play("title", tr("Title"));
	auto &chapter = play("chapter", tr("Chapter"));
	chapter.a("prev", tr("Previous Chapter"));
	chapter.a("next", tr("Next Chapter"));

	auto &sub = root("subtitle", tr("Subtitle"));

	auto &spu = sub("track", tr("Subtitle Track"));
	spu.a("open", tr("Open File(s)"));
	spu.a("clear", tr("Clear File(s)"));
	spu.a("next", tr("Select Next"));
	spu.a("all", tr("Select All"));
	spu.a("hide", tr("Hide"));

	updateEnumMenu<SubtitleDisplay>(sub);
	updateEnumActions<VerticalAlignment>(sub("align", tr("Subtitle Alignment")));
	updateStepActions(sub("position", tr("Subtitle Position")), "%1%", p.sub_pos_step);
	updateStepActions(sub("sync", tr("Subtitle Sync")), tr("%1sec"), p.sub_sync_step);

	auto &video = root("video", tr("Video"));
	video("track", tr("Video Track"));

	updateEnumActions<VideoRatio>(video("aspect", tr("Aspect Ratio")));
	updateEnumActions<VideoRatio>(video("crop", tr("Crop")));

	auto &align = video("align", tr("Screen Alignment"));
	updateEnumActions<VerticalAlignment>(align);
	updateEnumActions<HorizontalAlignment>(align);
	updateEnumActions<MoveToward>(video("move", tr("Screen Position")));

	updateEnumMenu<ColorRange>(video);
	updateEnumActions<InterpolatorType>(video("chroma-upscaler", tr("Chroma Upscaler")));
	updateEnumActions<InterpolatorType>(video("interpolator", tr("Interpolator")));
	updateEnumMenu<Dithering>(video);
	updateEnumMenu<DeintMode>(video);

	auto &effect = video("filter");
	effect.setTitle(tr("Filter"));
	effect.a("flip-v", tr("Flip Vertically"));
	effect.a("flip-h", tr("Flip Horizontally"));
	effect.a("blur", tr("Blur"));
	effect.a("sharpen", tr("Sharpen"));
	effect.a("gray", tr("Grayscale"));
	effect.a("invert", tr("Invert Color"));
	effect.a("disable", tr("Disable Filters"));

	auto updateVideoColorAdjust = [&video] (Menu &color, int step) {
		auto actions = color.g(AdjustColorInfo::typeKey())->actions();
		for (int i=0; i<actions.size(); ++i) {
			const auto action = static_cast<EnumAction<AdjustColor>*>(actions[i]);
			const auto color = action->data() * step;
			action->setText(color.getText(color & VideoColor()));
		}
	};
	updateVideoColorAdjust(video("color", tr("Adjust Color")), p.brightness_step);

	video.a("snapshot", tr("Take Snapshot"));

	auto &audio = root("audio", tr("Audio"));
	audio("track", tr("Audio Track")).a("next", tr("Select Next"));
	updateStepActions(audio("sync", tr("Audio Sync")), tr("%1sec"), p.audio_sync_step);
	audio("volume").a("mute", tr("Mute"));
	updateStepActions(audio("volume", tr("Volume")), "%1%", p.volume_step);
	updateStepActions(audio("amp", tr("Amp")), "%1%", p.amp_step);
	updateEnumMenu<ChannelLayout>(audio);
	audio.a("normalizer", tr("Volume Normalizer"));
	audio.a("tempo-scaler", tr("Tempo Scaler"));

	auto &tool = root("tool");
	tool.a("undo", tr("Undo"));
	tool.a("redo", tr("Redo"));
	tool.setTitle(tr("Tools"));
		auto &playlist = tool("playlist");
		playlist.setTitle(tr("Playlist"));
		playlist.a("toggle", tr("Show/Hide"));
		playlist.a("open", tr("Open"));
		playlist.a("save", tr("Save"));
		playlist.a("clear", tr("Clear"));
		playlist.a("append-file", tr("Append File"));
		playlist.a("append-url", tr("Append URL"));
		playlist.a("remove", tr("Remove"));
		playlist.a("move-up", tr("Move Up"));
		playlist.a("move-down", tr("Move Down"));
	tool.a("favorites", tr("Favorites"));
		auto &history = tool("history");
		history.setTitle(tr("History"));
		history.a("toggle", tr("Show/Hide"));
		history.a("clear", tr("Clear"));

	tool.a("find-subtitle", tr("Find Subtitle"));
	tool.a("subtitle", tr("Subtitle View"));
	tool.a("pref", tr("Preferences"));
	tool.a("reload-skin", tr("Reload Skin"));
	tool.a("playinfo", tr("Playback Information"));
	tool.a("auto-exit", tr("Auto-exit"));
	tool.a("auto-shutdown", tr("Auto-shutdown"));

	auto &window = root("window", tr("Window"));
	updateEnumMenu<StaysOnTop>(window);
	window.a("proper", tr("Proper Size"));
	window.a("full", tr("Fullscreen"));
	window.a("minimize", tr("Minimize"));
	window.a("maximize", tr("Maximize"));
	window.a("close", tr("Close"));

	auto &help = root("help");
	help.setTitle(tr("Help"));
	help.a("about", tr("About %1").arg("CMPlayer"));
	root.a("exit", tr("Exit"));

	setShortcuts(p.shortcuts);
}
コード例 #21
0
MainWindow::MainWindow(AudioPlayer &player, QWidget *parent)
    : QMainWindow(parent),
      statusBar_(this),
      player_(player),
      cursorFollowsPlayback_(false),
      saveTabs_(false) {
    setupUi(this);
    // Not saving a pointer to this
    QActionGroup *playbackOrderGroup = new QActionGroup(this);
    playbackOrderGroup->addAction(defaultAction);
    playbackOrderGroup->addAction(randomAction);
    playbackOrderGroup->addAction(repeatTrackAction);
    playbackOrderGroup->addAction(repeatPlaylistAction);
    installEventFilter(this);

    player.setMainWindow(this);

    QObject::connect(&player_, SIGNAL(playbackOrderChanged(PlaybackOrder)), this,
                     SLOT(playbackOrderChanged(PlaybackOrder)));
    QObject::connect(&player_, SIGNAL(audioStateChanged(AudioState)), this,
                     SLOT(slotAudioStateChanged(AudioState)));
    QObject::connect(&player_, SIGNAL(trackPlaying(PTrack)), this, SLOT(updateUI(PTrack)));
    playbackOrderChanged(player.playbackOrder());

    QObject::connect(&player_, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
    seekSlider_ = new SeekSlider(player_, this);
    volumeSlider_ = new QSlider(this);
    volumeSlider_->setOrientation(Qt::Horizontal);
    volumeSlider_->setMaximum(100);
    volumeSlider_->setMinimum(0);
    volumeSlider_->setValue(player_.volume() * 100);
    volumeSlider_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
    QObject::connect(volumeSlider_, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
    mainToolBar->addWidget(seekSlider_);
    mainToolBar->addWidget(volumeSlider_);

    trayIcon_ = new QSystemTrayIcon(this);
    setTrayIcon(false);
    connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
            SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
    trayIcon_->show();

    setStatusBar(&statusBar_);
    QObject::connect(&statusBar_, SIGNAL(statusBarDoubleClicked()), this,
                     SLOT(statusBarDoubleClicked()));

    lyricsDock_ = new QDockWidget("Lyrics", this);
    // Not setting an object name because we don't want save its state
    // since Qt doesn't restore it correctly
    //     lyricsDock_->setObjectName("LyricsDock");
    lyricsWidget_ = new QPlainTextEdit(lyricsDock_);
    //     lyricsWidget_->setObjectName("LyricsWidget");
    lyricsWidget_->setReadOnly(true);
    lyricsDock_->setWidget(lyricsWidget_);
    QObject::connect(lyricsDock_, SIGNAL(visibilityChanged(bool)), this,
                     SLOT(dockVisibilityChanged(bool)));

    //     playlistTabs->setTabsClosable(true);
    QObject::connect(playlistTabs, SIGNAL(tabCloseRequested(int)), this,
                     SLOT(removePlaylistTab(int)));
    QObject::connect(playlistTabs, SIGNAL(newTabRequested()), this, SLOT(newTabRequested()));

    QObject::connect(menu_File, SIGNAL(aboutToShow()), this, SLOT(menuFileAboutToShow()));

    setWindowIcon(QIcon(":/icon/logo22.png"));

    instance = this;

    console_ = new ConsoleWindow(this);
    QObject::connect(console_, SIGNAL(visibilityChanged(bool)), this,
                     SLOT(consoleVisibilityChanged(bool)));

    readSettings();

    config_.set("mainwindow.save_tabs", QVariant(saveTabs_));
    QObject::connect(&config_, SIGNAL(keySet(QString, QVariant)), this,
                     SLOT(configChanged(QString, QVariant)));

    setShortcuts();
}
コード例 #22
0
ファイル: chatdlg.cpp プロジェクト: hummbl/psi
void ChatDlg::ensureTabbedCorrectly() {
	TabbableWidget::ensureTabbedCorrectly();
	setShortcuts();
}
コード例 #23
0
ファイル: main_window.cpp プロジェクト: pat1005331/mapper
void MainWindow::createFileMenu()
{
	QAction* new_act = new QAction(QIcon(QString::fromLatin1(":/images/new.png")), tr("&New"), this);
	new_act->setShortcuts(QKeySequence::New);
	new_act->setStatusTip(tr("Create a new map"));
	new_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(new_act, &QAction::triggered, this, &MainWindow::showNewMapWizard);
	
	QAction* open_act = new QAction(QIcon(QString::fromLatin1(":/images/open.png")), tr("&Open..."), this);
	open_act->setShortcuts(QKeySequence::Open);
	open_act->setStatusTip(tr("Open an existing file"));
	open_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(open_act, &QAction::triggered, this, &MainWindow::showOpenDialog);
	
	open_recent_menu = new QMenu(tr("Open &recent"), this);
	open_recent_menu->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	for (int i = 0; i < max_recent_files; ++i)
	{
		recent_file_act[i] = new QAction(this);
		connect(recent_file_act[i], &QAction::triggered, this, &MainWindow::openRecentFile);
	}
	open_recent_menu_inserted = false;
	
	// NOTE: if you insert something between open_recent_menu and save_act, adjust updateRecentFileActions()!
	
	save_act = new QAction(QIcon(QString::fromLatin1(":/images/save.png")), tr("&Save"), this);
	save_act->setShortcuts(QKeySequence::Save);
	save_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(save_act, &QAction::triggered, this, &MainWindow::save);
	
	auto save_as_act = new QAction(tr("Save &as..."), this);
	if (QKeySequence::keyBindings(QKeySequence::SaveAs).empty())
		save_as_act->setShortcut(tr("Ctrl+Shift+S"));
	else
		save_as_act->setShortcuts(QKeySequence::SaveAs);
	save_as_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(save_as_act, &QAction::triggered, this, &MainWindow::showSaveAsDialog);
	
	settings_act = new QAction(tr("Settings..."), this);
	settings_act->setShortcut(QKeySequence::Preferences);
	settings_act->setMenuRole(QAction::PreferencesRole);
	connect(settings_act, &QAction::triggered, this, &MainWindow::showSettings);
	
	close_act = new QAction(QIcon(QString::fromLatin1(":/images/close.png")), tr("Close"), this);
	close_act->setShortcut(QKeySequence::Close);
	close_act->setStatusTip(tr("Close this file"));
	close_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(close_act, &QAction::triggered, this, &MainWindow::closeFile);
	
	QAction* exit_act = new QAction(tr("E&xit"), this);
	exit_act->setShortcuts(QKeySequence::Quit);
	exit_act->setStatusTip(tr("Exit the application"));
	exit_act->setMenuRole(QAction::QuitRole);
	exit_act->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	connect(exit_act, &QAction::triggered, qApp, &QApplication::closeAllWindows);
	
	if (show_menu)
	{
		file_menu = menuBar()->addMenu(tr("&File"));
	}
	else
	{
		delete file_menu;
		file_menu = new QMenu(this);
	}

	file_menu->setWhatsThis(Util::makeWhatThis("file_menu.html"));
	file_menu->addAction(new_act);
	file_menu->addAction(open_act);
	file_menu->addAction(save_act);
	file_menu->addAction(save_as_act);
	file_menu->addSeparator();
	file_menu->addAction(settings_act);
	file_menu->addSeparator();
	file_menu->addAction(close_act);
	file_menu->addAction(exit_act);
	
	general_toolbar = new QToolBar(tr("General"));
	general_toolbar->setObjectName(QString::fromLatin1("General toolbar"));
	general_toolbar->addAction(new_act);
	general_toolbar->addAction(open_act);
	general_toolbar->addAction(save_act);
	
	save_act->setEnabled(has_opened_file);
	save_as_act->setEnabled(has_opened_file);
	close_act->setEnabled(has_opened_file);
	updateRecentFileActions();
}
コード例 #24
0
ファイル: favorites2.cpp プロジェクト: mhogomchungu/SiriKali
favorites2::favorites2( QWidget * parent,favorites::type type ) :
	QDialog ( parent) ,
	m_ui( new Ui::favorites2 ),
	m_type( type ),
	m_settings( settings::instance() )
{
	m_ui->setupUi( this ) ;

	this->setFont( parent->font() ) ;

	this->setFixedSize( this->size() ) ;

	m_settings.setParent( parent,&m_parentWidget,this ) ;

	auto table = m_ui->tableWidget ;

	table->horizontalHeader()->setStretchLastSection( true ) ;

	connect( m_ui->pbConfigFilePath,&QPushButton::clicked,[ this ](){

		this->configPath() ;
	} ) ;

	connect( m_ui->pbAdd,&QPushButton::clicked,[ this ](){

		this->updateFavorite( false ) ;
	} ) ;

	connect( m_ui->pbFolderPath,&QPushButton::clicked,[ this ](){

		this->folderPath() ;
	} ) ;

	connect( m_ui->pbEdit,&QPushButton::clicked,[ this ](){

		m_editRow = m_ui->tableWidget->currentRow() ;

		this->updateFavorite( true ) ;
	} ) ;

	connect( m_ui->cbReverseMode,&QCheckBox::toggled,[ this ]( bool e ){

		m_reverseMode = e ;
	} ) ;

	connect( m_ui->cbVolumeNoPassword,&QCheckBox::toggled,[ this ]( bool e ){

		m_volumeNeedNoPassword = e ;
	} ) ;

	connect( m_ui->cbReadOnlyMode,&QCheckBox::toggled,[ this ]( bool e ){

		m_mountReadOnly = e ;
	} ) ;

	connect( m_ui->pbIdentityFile,&QPushButton::clicked,[ this ](){

		auto e = this->getExistingFile( tr( "Path To A Config File" ) ) ;

		if( !e.isEmpty() ){

			m_ui->lineEditIdleTimeOut->setText( e ) ;
		}
	} ) ;

	connect( m_ui->tabWidget,&QTabWidget::currentChanged,[ this ]( int index ){

		this->tabChanged( index ) ;
	} ) ;

	if( utility::platformIsWindows() ){

		utility::setWindowsMountPointOptions( this,m_ui->lineEditMountPath,m_ui->pbMountPointPath ) ;
		m_ui->labelDeviceAddress->setText( tr( "Mount Point Path" ) ) ;
	}else{
		m_ui->pbMountPointPath->setIcon( QIcon( ":/folder.png" ) ) ;

		m_ui->labelDeviceAddress->setText( tr( "Mount Point Prefix" ) ) ;

		connect( m_ui->pbMountPointPath,&QPushButton::clicked, [ this ](){

			this->mountPointPath() ;
		} ) ;
	}

	connect( m_ui->pbClose,&QPushButton::clicked,[ this ](){

		this->HideUI() ;
	} ) ;

	connect( table,&QTableWidget::itemClicked,[ this ]( QTableWidgetItem * item ){

		const auto volumes = m_settings.readFavorites() ;

		this->setVolumeProperties( volumes[ size_t( item->row() ) ] ) ;
	} ) ;

	connect( table,&QTableWidget::currentItemChanged,[]( QTableWidgetItem * x,QTableWidgetItem * y ){

		tablewidget::selectRow( x,y ) ;
	} ) ;

	m_ui->pbFolderPath->setIcon( QIcon( ":/sirikali.png" ) ) ;
	m_ui->pbConfigFilePath->setIcon( QIcon( ":/file.png" ) ) ;
	m_ui->pbIdentityFile->setIcon( QIcon( ":/file.png" ) ) ;

	m_ui->cbAutoMount->setChecked( false ) ;

	m_ui->cbReadOnlyMode->setEnabled( !utility::platformIsWindows() ) ;

	this->checkFavoritesConsistency() ;

	const auto volumes = m_settings.readFavorites() ;

	this->updateVolumeList( volumes,0 ) ;

	this->addAction( [ this ](){

		auto ac = new QAction( this ) ;

		ac->setShortcuts( { Qt::Key_Enter,Qt::Key_Return,Qt::Key_Menu } ) ;

		connect( ac,&QAction::triggered,[ this ](){

			this->shortcutPressed() ;
		} ) ;

		return ac ;
	}() ) ;

	this->setOptionMenu( m_optionMenu,false ) ;
	m_ui->pbOptions->setMenu( &m_optionMenu ) ;

	this->ShowUI( type ) ;
}
コード例 #25
0
void ShortcutsSettings::setShortcuts(QString name, QKeySequence Sequence)
{
    setShortcuts(name, QList<QKeySequence>() << Sequence);
}
コード例 #26
0
ファイル: mainwindow.cpp プロジェクト: EclipseSpark/zuluCrypt
MainWindow::MainWindow( MainWindow::function_t f,QWidget * parent ) :
	QWidget( parent ),m_ui( new Ui::MainWindow ),m_handle( nullptr ),m_function( std::move( f ) )
{
	m_ui->setupUi( this ) ;
	this->setFixedSize( this->size() ) ;

	m_ui->lineEditKey->setEchoMode( QLineEdit::Password ) ;

	this->setWindowIcon( QIcon( ":/default.png" ) ) ;
	m_ui->pbKeyFile->setIcon( QIcon( ":/file.png" ) ) ;

	connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( pbCancel() ) ) ;
	connect( m_ui->pbOpen,SIGNAL( clicked() ),this,SLOT( pbOpen() ) ) ;
	connect( m_ui->pbKeyFile,SIGNAL( clicked() ),this,SLOT( pbKeyFile() ) ) ;

	m_ui->lineEditKey->setFocus() ;

	m_working = false ;

	m_requireKey = false ;
	m_requireKeyFile = true ;

	auto ac = new QAction( this ) ;

	QList<QKeySequence> keys ;

	keys.append( Qt::Key_Enter ) ;
	keys.append( Qt::Key_Return ) ;

	ac->setShortcuts( keys ) ;

	connect( ac,SIGNAL( triggered() ),this,SLOT( defaultButton() ) ) ;

	this->addAction( ac ) ;

	m_findExecutable = []( QVector<QString>& updated,const QVector<QString>& original ){

		if( original.isEmpty() ){

			return QString() ;
		}

		QString e ;

		for( const auto& it : original ){

			auto _not_found = [&]( const char * path ){

				e = path + it ;

				bool r = QFile::exists( e ) ;

				if( r ){

					updated.append( e ) ;
				}else{
					updated.append( it ) ;
				}

				return r == false ;
			} ;

			if( _not_found( "/usr/local/bin/" ) ){

				if( _not_found( "/usr/bin/" ) ){

					if( _not_found( "/usr/sbin/" ) ){

						return it ;
					}
				}
			}
		}

		return QString() ;
	} ;
}
コード例 #27
0
void TkAction::setDefaultShortcuts(const QList<QKeySequence> & shortcuts) {
	_defaultShortcuts = shortcuts;
	if (this->shortcuts().isEmpty()) {
		setShortcuts(_defaultShortcuts);
	}
}
コード例 #28
0
DensityViewerWindow::DensityViewerWindow(QWidget *parent) :
    QMainWindow(parent)
{
    //ui->setupUi(this);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    densityViewer = new DensityViewer;
    mainLayout->addWidget(densityViewer);

    auto controllerBar = new QVBoxLayout;

    auto plusButton = new QPushButton("zoom in");
    connect(plusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1.2);});
    auto minusButton = new QPushButton("zoom out");
    connect(minusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1./1.2);});
    auto plusMinus = new QHBoxLayout;

    plusMinus->addWidget(minusButton);
    plusMinus->addWidget(plusButton);

    controllerBar->addLayout(plusMinus);

    colorSaturation = new QDoubleSpinBox;
    colorSaturation->setMaximum(INFINITY);
    colorSaturation->setSingleStep(1);
    colorSaturation->setValue(100);
    colorSaturation->setEnabled(false);

    controllerBar->addWidget(new QLabel("Color saturation"));
    connect(colorSaturation,
            SIGNAL(valueChanged(double)),
            densityViewer,
            SLOT(setColorSaturation(double)));
    controllerBar->addWidget(colorSaturation);

    //http://forum.qt.io/topic/17409/solved-qt-4-7-qcombobox-custom-item-delegate-doesn-t-affect-the-current-item-displayed/3

    colormapComboBox = new QComboBox;
    colormapComboBox->setEnabled(false);
    for (const auto& cmap : Colormap::AvailableColormaps )
        colormapComboBox->addItem(QString::fromStdString(cmap.first));

    connect(colormapComboBox,SIGNAL(activated(QString)),densityViewer,SLOT(setColormap(QString)));

    controllerBar->addWidget(colormapComboBox);

    controllerBar->addWidget(new QLabel("Select section:"));
    sectionComboBox = new QComboBox;

    sectionComboBox->setEnabled(false);

    connect(sectionComboBox,
            static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
            [=](QString sec){densityViewer->setSectionDirection( sec );});

    controllerBar->addWidget(sectionComboBox);

    auto xStretch = new QHBoxLayout;
    xStretch->addWidget(new QLabel("x="));
    sectionIndex = new QDoubleSpinBox;
    sectionIndex->setValue(0);
    sectionIndex->setEnabled(false);

    connect(sectionIndex, SIGNAL(valueChanged(double)),densityViewer, SLOT(setSectionIndex(double)));
    connect(densityViewer, SIGNAL(changedSectionDirection()),this,SLOT(setXLimits()));

    xStretch->addWidget(sectionIndex);
    controllerBar->addLayout(xStretch);

    auto gridOn = new QCheckBox("grid");

    gridOn->setChecked(false);
    connect(gridOn,SIGNAL(clicked(bool)),densityViewer,SLOT(setGrid(bool)));

    controllerBar->addWidget(gridOn);

    auto infoButton = new QPushButton("info");
    connect(infoButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::info);});
    controllerBar->addWidget(infoButton);

    auto panButton = new QPushButton("pan");
    connect(panButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::pan);});
    controllerBar->addWidget(panButton);

    auto zoomButton = new QPushButton("zoom");
    connect(zoomButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::zoom);});
    controllerBar->addWidget(zoomButton);

    auto homeButton = new QPushButton("home");
    connect(homeButton,
            SIGNAL(pressed()),
            densityViewer,
            SLOT(goHome()));
    controllerBar->addWidget(homeButton);

    auto updateButton = new QPushButton("update");
    connect(updateButton,
            SIGNAL(pressed()),
            this,
            SLOT(updateDataset()));
    controllerBar->addWidget(updateButton);

    controllerBar->addStretch();

    coordinateCursor = new QLabel;
    coordinateCursor->setMinimumWidth(150);
    connect(densityViewer,
            &DensityViewer::dataCursorMoved,
            [=](int, int, vector<double>,string text){coordinateCursor->setText(QString::fromStdString(text));});
    controllerBar->addWidget(coordinateCursor);

    mainLayout->addLayout(controllerBar);

    connect(densityViewer,
            SIGNAL(loadedDensityData(DensityData&)),
            this,
            SLOT(updateControls()));

    //Context menu
    auto openDataset = new QAction("&Open dataset", this);
    openDataset->setShortcuts(QKeySequence::Open);
    connect(openDataset, SIGNAL(triggered()), this, SLOT(openFile()));

    QMenu* fileMenu = menuBar()->addMenu("&File");
    fileMenu->addAction(openDataset);

    // Set layout in QWidget
    QWidget *inners = new QWidget();
    inners->setLayout(mainLayout);

    // Set QWidget as the central layout of the main window
    setCentralWidget(inners);
    //mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->setSpacing(0);

    //For debug purposes
    //densityViewer->loadDensityData("/Users/arkadiy/ag/yell/yell playground/delta-pdf.h5");

}