Ejemplo n.º 1
0
void WicdApplet::setupActions()
{
    KAction* preferencesAction = new KAction(KIcon("preferences-system-network"), i18n("Wicd Configuration"), this);
    preferencesAction->setShortcuts(KShortcut("Ctrl+P"));
    addAction("configure_wicd", preferencesAction);
    connect(preferencesAction, SIGNAL(triggered()), this, SLOT(showPreferences()));
    
    KAction* connectInfoAction = new KAction(KIcon("help-about"), i18n("Connection information"), this);
    addAction("connection_info", connectInfoAction);
    connect(connectInfoAction, SIGNAL(triggered()), this, SLOT(connectionInfoRequested()));

    KAction* createadhocAction = new KAction(KIcon("list-add"), i18n("Create an ad-hoc network"), this);
    createadhocAction->setShortcuts(KShortcut("Ctrl+A"));
    addAction("createadhoc", createadhocAction);
    connect(createadhocAction, SIGNAL(triggered()), this, SLOT(createAdhocDialog()));
    KAction* findnetworkAction = new KAction(KIcon("edit-find"), i18n("Find a hidden network"), this);
    findnetworkAction->setShortcuts(KShortcut("Ctrl+F"));
    addAction("findnetwork", findnetworkAction);
    connect(findnetworkAction, SIGNAL(triggered()), this, SLOT(findHiddenDialog()));
    KAction* rfkillAction = new KAction(i18n("RfKill"), this);
    rfkillAction->setShortcuts(KShortcut("Ctrl+K"));
    addAction("rfkill", rfkillAction);
    connect(rfkillAction, SIGNAL(triggered()), this, SLOT(rfkill()));
    
    KAction* reloadAction = new KAction(KIcon("view-refresh"), i18n("Reload"), this);
    reloadAction->setShortcuts(KShortcut("Ctrl+R"));
    addAction("reload", reloadAction);
    connect(reloadAction, SIGNAL(triggered()), this, SLOT(scan()));

}
Ejemplo n.º 2
0
bool Controller::init()
{
    if (!m_audioControl.init()) {
        QMessageBox::warning(NULL, "Hint", QString::fromStdString(m_audioControl.errorMessage()));
        return false;
    }
    m_filterManager.init();
    m_preferencesWidget.init();

    QSettings::setDefaultFormat(QSettings::IniFormat);

    m_trayIcon.setIcon(m_icon);
    m_trayIcon.setContextMenu(&m_menu);
    m_trayIcon.show();

    m_presetAction->setDisabled(true);
    m_noPresetAction->setCheckable(false);
    m_noPresetAction->setChecked(true);

    connect(&m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(showTrayMenu()));
    connect(m_preferencesAction, SIGNAL(triggered()), this, SLOT(showPreferences()));
    connect(m_quitAction, SIGNAL(triggered()), this, SLOT(deinit()));

    // Load presets from persistence
    load();

    m_audioGraph.init(m_audioControl.loopbackInput().id, m_audioControl.defaultOutput().id);
    m_audioGraph.start();

    return true;
}
Ejemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowIcon(QIcon(":icons/icon.png"));
    setWindowTitle("quickly translate");
    QSystemTrayIcon * trayIcon = new QSystemTrayIcon(this);
    mNetManager = new QNetworkAccessManager(this);
    mLangageModel = new LanguageModel;

    trayIcon->setIcon(QIcon(":icons/icon.png"));

    trayIcon->setContextMenu(ui->menuFile);
    trayIcon->show();

    ui->dockWidget->hide();
    ui->sourceComboBox->setModel(mLangageModel);
    ui->targetComboBox->setModel(mLangageModel);

    QDesktopWidget * desktop = new QDesktopWidget;

    QPoint startPos = QPoint(desktop->geometry().bottomRight() );
    QPoint finalPos = desktop->geometry().center() - QPoint(width()/2,height()/2);

    move(finalPos);
    connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
    connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
    connect(ui->translateButton,SIGNAL(clicked()),this,SLOT(translate()));
    connect(ui->sourceTextEdit,SIGNAL(returnPressed()),this,SLOT(translate()));
    connect(ui->swapButton,SIGNAL(clicked()),this,SLOT(swapLangages()));

    connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy()));
    connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut()));
    connect(ui->actionPast,SIGNAL(triggered()),this,SLOT(past()));
    connect(ui->actionPreferences,SIGNAL(triggered()),this,SLOT(showPreferences()));
    connect(ui->actionAboutQt,SIGNAL(triggered()),this,SLOT(showAboutQt()));
    connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
    connect(ui->actionTTS,SIGNAL(triggered()),this,SLOT(showTextTTS()));


    connect(ui->sourceSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));
    connect(ui->targetSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));


    //    mPropertyAnimation  = new QPropertyAnimation(this, "pos");
    //    mPropertyAnimation->setDuration(800);
    //    mPropertyAnimation->setStartValue(startPos);
    //    mPropertyAnimation->setEndValue(finalPos);


    //load default langage

    QSettings settings;
    QString sourceId = settings.value("source").toString();
    QString targetId = settings.value("target").toString();
    ui->sourceComboBox->setCurrentIndex(mLangageModel->findLangageId(sourceId));
    ui->targetComboBox->setCurrentIndex(mLangageModel->findLangageId(targetId));

}
Ejemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    bridge(NULL),
    workerThread(NULL),
    debugListTimer(),
    debugListMessages()
{
    ui->setupUi(this);
    // Fixed width, minimum height
    this->setMinimumSize(this->size());
    this->setMaximumSize(this->size().width(), 2000);
#ifdef Q_OS_LINUX
    this->setWindowIcon(QIcon(":/images/images/icon48.png"));
#endif

    // Plumb event filter for focus events
    ui->cmbMidiIn->installEventFilter(this);
    ui->cmbMidiOut->installEventFilter(this);
    ui->cmbSerial->installEventFilter(this);

    // Load initial state
    this->workerThread = new QThread();
    this->workerThread->start(QThread::HighestPriority);
    refresh();
    scrollbackSize=Settings::getScrollbackSize();
    ui->chk_debug->setChecked( Settings::getDebug() );
    selectIfAvailable(ui->cmbMidiIn, Settings::getLastMidiIn());
    selectIfAvailable(ui->cmbMidiOut, Settings::getLastMidiOut());
    selectIfAvailable(ui->cmbSerial, Settings::getLastSerialPort());

    // Set up timer for the display list
    debugListTimer.setSingleShot(true);
    debugListTimer.setInterval(1000 / LIST_REFRESH_RATE);

    // Plumb signals & slots
    connect(ui->cmbMidiIn, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));
    connect(ui->cmbMidiOut, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));
    connect(ui->cmbSerial, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));
    connect(ui->chk_on, SIGNAL(clicked()), SLOT(onValueChanged()));
    connect(ui->chk_debug, SIGNAL(clicked(bool)), SLOT(onDebugClicked(bool)));
    connect(&debugListTimer, SIGNAL(timeout()), SLOT(refreshDebugList()));


    // Menu items
    connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutBox()));
    connect(ui->actionPreferences, SIGNAL(triggered()), SLOT(showPreferences()));

    // Get started
    onValueChanged();

#ifdef Q_OS_MAC
    // hack: avoid an empty dummy File menu on OS X
    // there might be a better way to do this, but hide() and clear() don't work.
    ui->menuFile->setTitle(""); // Doesn't do anything on OS X
#endif

}
Ejemplo n.º 5
0
CaosIsp::CaosIsp(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::CaosIsp)
{

  Settings settings(Settings::global());
  CLink * device;
  CFont::init();

  QCoreApplication::setOrganizationName("CoActionOS, Inc");
  QCoreApplication::setOrganizationDomain("coactionos.com");
  QCoreApplication::setApplicationName("CoActionOS-ISP");
  QCoreApplication::setApplicationVersion(COACTIONOS_ISP_VERSION);

  ui->setupUi(this);
  CNotify::setUpdateObjects(ui->statusBar, 0);

  link_set_debug(1);

  device = ui->connectWidget->clink();

  QFile file(":/data/CStyle.css");
  if( file.open(QFile::ReadOnly)) {
      QString StyleSheet = QLatin1String(file.readAll());
      qApp->setStyleSheet(StyleSheet);
    }

  ui->tabWidget->setTabText(TAB_INSTALLER, CFont::iconDownloadAlt());
  ui->tabWidget->setTabText(TAB_TERMINAL, CFont::iconEdit());
  ui->tabWidget->setTabText(TAB_PREFERENCES, CFont::iconCogs());
  ui->tabWidget->setTabEnabled(TAB_LABEL, false);

  ui->installTab->setLink(device);
  ui->terminalTab->setLink(device);
  ui->preferencesTab->setLink(device);

  connect(device, SIGNAL(linked(bool)), ui->installTab, SLOT(connected(bool)));
  connect(ui->installTab, SIGNAL(pauseTerminal(bool)), ui->terminalTab, SLOT(setPaused(bool)));
  connect(ui->installTab, SIGNAL(completed()), this, SLOT(installCompleted()));

  connect(ui->terminalTab, SIGNAL(resetTarget()), ui->installTab, SLOT(resetTarget()));
  connect(ui->terminalTab, SIGNAL(showPreferences()), this, SLOT(showPreferences()));

  ui->tabWidget->setCurrentIndex( settings.currentTab().toInt() );
  on_tabWidget_currentChanged(settings.currentTab().toInt());
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
	if (getuid()!=0) {
		string args;
		for (int i=0; i<argc; i++)
		{
			args+=(string) argv[i] + " ";
		}
		return system("kdesu " + args);
		
	}

	setlocale(LC_ALL, "");
	bindtextdomain( "installpkg-ng", "/usr/share/locale");
	textdomain("installpkg-ng");

	QApplication app(argc, argv);
	QTranslator translator;
	translator.load("/usr/share/mpkg/pkgmanager_ru");
	app.installTranslator(&translator);

	MainWindow mw;
	QObject::connect(mw.ui.selectAllButton, SIGNAL(clicked()), &mw, SLOT(selectAll()));
	QObject::connect(mw.ui.deselectAllButton, SIGNAL(clicked()), &mw, SLOT(deselectAll()));
	QObject::connect(mw.ui.actionQuit, SIGNAL(triggered()), &mw, SLOT(quitApp()));
	QObject::connect(mw.ui.quitButton, SIGNAL(clicked()), &mw, SLOT(quitApp()));
	QObject::connect(mw.ui.applyButton, SIGNAL(clicked()), &mw, SLOT(commitChanges()));
	QObject::connect(mw.ui.actionAbout, SIGNAL(triggered()), &mw, SLOT(showAbout()));
	QObject::connect(mw.ui.actionReset_changes, SIGNAL(triggered()), &mw, SLOT(resetChanges()));
	QObject::connect(mw.ui.actionReset_all_queue, SIGNAL(triggered()), &mw, SLOT(resetQueue()));
	QObject::connect(mw.ui.actionPreferences, SIGNAL(triggered()), &mw, SLOT(showPreferences()));
	QObject::connect(mw.ui.actionAdd_remove_repositories, SIGNAL(triggered()), &mw, SLOT(showAddRemoveRepositories()));
	QObject::connect(mw.ui.actionClean_cache, SIGNAL(triggered()), &mw, SLOT(cleanCache()));
	QObject::connect(mw.ui.actionShow_installed, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));
	QObject::connect(mw.ui.actionShow_deprecated, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));

	QObject::connect(mw.ui.actionShow_available, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));
	QObject::connect(mw.ui.actionShow_queue, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));
	QObject::connect(mw.ui.actionShow_configexist, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));
	QObject::connect(mw.ui.actionShow_unavailable, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter()));
	QObject::connect(mw.ui.actionCore_settings, SIGNAL(triggered()), &mw, SLOT(showCoreSettings()));
	QObject::connect(mw.ui.actionUpdate_data, SIGNAL(triggered()), &mw, SLOT(updateData()));
	QObject::connect(mw.ui.packageTable, SIGNAL(itemSelectionChanged()), &mw, SLOT(showPackageInfo()));
	QObject::connect(mw.ui.quickPackageSearchEdit, SIGNAL(textEdited(const QString &)), &mw, SLOT(applyPackageFilter()));



	int ret = app.exec();
	return ret;
}
Ejemplo n.º 7
0
SysTray::SysTray(Playground *playground)
    : QSystemTrayIcon(playground)
{
  this->playground = playground;
  this->prefsWindow = new PrefsWindow(playground, playground); //Why isn't QSystemTray a QWidget?
  setIcon(QIcon(":/box/box.svg"));
  
  //Quit Action
  quitAction = new QAction(tr("&Quit"), this);
  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
  
  //Clear Action
  clearAction = new QAction(tr("C&lear"), this);
  connect(clearAction, SIGNAL(triggered()), playground, SLOT(clear()));
  
  //Show Preferences Window
  prefsAction = new QAction(tr("&Preferences"), this);
  connect(prefsAction, SIGNAL(triggered()), prefsWindow, SLOT(showPreferences()));
  
  //Group of shape actions
  shapeActions = new QActionGroup(this);
     
  //Drop circle - enabled by default
  dropCircleAction = new QAction(tr("&Circles"), shapeActions);
  dropCircleAction->setCheckable(true);
  dropCircleAction->setChecked(true);
  connect(dropCircleAction, SIGNAL(triggered()), this, SLOT(setCircles()));
  setCircles();
  
  //Drop boxes
  dropSquareAction = new QAction(tr("&Squares"), shapeActions);
  dropSquareAction->setCheckable(true);
  connect(dropSquareAction, SIGNAL(triggered()), this, SLOT(setSquares()));

  //Build the menu
  trayIconMenu = new QMenu(playground);
  trayIconMenu->addAction(dropSquareAction);
  trayIconMenu->addAction(dropCircleAction);
  trayIconMenu->addSeparator();
  trayIconMenu->addAction(clearAction);
  trayIconMenu->addAction(prefsAction);
  trayIconMenu->addSeparator();
  trayIconMenu->addAction(quitAction);
  setContextMenu(trayIconMenu);
  
  //Tells us if a mouse click on the tray necessitates block creation
  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(activation(QSystemTrayIcon::ActivationReason)));
}
Ejemplo n.º 8
0
void TypingBox::keyPressEvent(QKeyEvent *event) {

    if(event->key()==Qt::Key_Return){
        emit enterPressed();
    } else if(event->key()==Qt::Key_Escape) {
        emit escapePressed();
    } else if(event->key()==Qt::Key_Tab) {
        emit switchMode();
    } else if(event->key()==Qt::Key_Period && (event->modifiers() & Qt::ControlModifier)) {
        emit showPreferences();
    } else if(event->key()==Qt::Key_Z && (event->modifiers() & Qt::ControlModifier)) {
        emit switchColoringMode();
    } else {
        QTextBrowser::keyPressEvent(event);
    }

}
Ejemplo n.º 9
0
void Window::createActions()
{
    hideAction = new QAction(tr("&Hide"), this);
    connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));

    showAction = new QAction(tr("&Show Log"), this);
    connect(showAction, SIGNAL(triggered()), this, SLOT(showNormal()));

    quitAction = new QAction(tr("&Quit"), this);
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    aboutAction = new QAction(tr("&About"), this);
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));

    prefsAction = new QAction(tr("&Preferences"), this);
    connect(prefsAction, SIGNAL(triggered()), this, SLOT(showPreferences()));
}
Ejemplo n.º 10
0
void DhcpcdQt::createActions()
{

	preferencesAction = new QAction(tr("&Preferences"), this);
	preferencesAction->setIcon(QIcon::fromTheme("preferences-system-network"));
	preferencesAction->setEnabled(false);
	connect(preferencesAction, SIGNAL(triggered()),
	    this, SLOT(showPreferences()));

	aboutAction = new QAction(tr("&About"), this);
	aboutAction->setIcon(QIcon::fromTheme("help-about"));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));

	quitAction = new QAction(tr("&Quit"), this);
	quitAction->setIcon(QIcon::fromTheme("application-exit"));
	connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

}
Ejemplo n.º 11
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags f)
   : QMainWindow(parent,f)
{
  _sessionCount = 0;
  // setup the ui
#ifdef QTOPIA_PHONE
  QMenu *m = QSoftMenuBar::menuFor(this);
#else
  resize(800,600);
  QMenu *m = menuBar()->addMenu(tr("Options"));
#endif

  acNewSession = m->addAction(tr("New Session"));
  acCloseSession = m->addAction(tr("Close Session"));
  acPreferences = m->addAction(tr("Preferences"));
#ifndef QTOPIA_PHONE
  m->addSeparator();
  QAction *m_exit = m->addAction(tr("Exit"));
  connect(m_exit, SIGNAL(triggered()), this, SLOT(closeAll()));
#endif
// FIXME: need this to close, and hide the input method
#ifdef QTOPIA_APPLICATION
  connect(QtopiaApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeAll()));
#else
  connect(QApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeAll()));
#endif
  connect(acNewSession, SIGNAL(triggered()), this, SLOT(newSession()));
  connect(acCloseSession, SIGNAL(triggered()), this, SLOT(closeSession()));
  connect(acPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
  tabs = new QTabWidget();
   
  setCentralWidget(tabs);
  setWindowTitle(tr("qterminal"));
#ifdef QTOPIA_PHONE
  if (Qtopia::mousePreferred) {
    // not sure which one is preferrable
    //QtopiaApplication::setInputMethodHint(this, QtopiaApplication::AlwaysOn);
    setAttribute(Qt::WA_InputMethodEnabled, true);
    QtopiaApplication::instance()->showInputMethod();
  }
#endif
  connect(tabs,SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
  newSession();
}
Ejemplo n.º 12
0
void MainWindow::setupActions() {
  KStandardAction::preferences(this, SLOT(showPreferences()),
    actionCollection());
  KStandardAction::quit(kapp, SLOT(quit()),
    actionCollection());

  auto const show_menubar =
    KStandardAction::showMenubar(this, SLOT(toggleMenuBar()),
      actionCollection());
  show_menubar->setChecked(menuBar()->isVisibleTo(this));

  show_dicts_ = new KToggleAction(i18n("Show Dictionaries"), this);
  show_dicts_->setShortcut(Qt::CTRL + Qt::Key_D);
  connect(show_dicts_, SIGNAL(toggled(bool)),
    lookup_, SLOT(showDatabaseSelector(bool)));
  actionCollection()->addAction("show_dicts", show_dicts_);

  setupGUI();
}
Ejemplo n.º 13
0
void MainWindow::initActions()
{
    m_sessionNew = new QAction(this);
    m_sessionNew->setShortcut( tr( "Ctrl+N" ) );
    connect ( m_sessionNew , SIGNAL ( triggered() ), this , SLOT ( newSession() ) );

    m_sessionList = new QAction(this);
    m_sessionList->setShortcut( tr( "Ctrl+L" ) );
    connect ( m_sessionList , SIGNAL ( triggered() ), this , SLOT ( sessionList() ) );

    m_closeFullScreenAction = new QAction(this);
    m_closeFullScreenAction -> setIcon( QIcon( ":/shellicons/Restore") );
    connect ( m_closeFullScreenAction , SIGNAL ( triggered() ), this , SLOT ( showNormal() ) );

    //TODO: Fix fullscreen action behaviour
    m_fullScreenAction = new QAction(this);
    m_fullScreenAction -> setIcon( QIcon( ":/icons/FullScreen") );
    m_fullScreenAction->setShortcut( tr( "F11" ) );
    connect ( m_fullScreenAction, SIGNAL ( triggered() ), this , SLOT ( fullScreen() ) );
  
    m_quitAction = new QAction(this);
    m_quitAction->setShortcut(tr("Ctrl+Q"));
    m_quitAction -> setIcon( QIcon( ":/icons/Quit") );

    connect ( m_quitAction, SIGNAL ( triggered() ), this , SLOT ( close() ) );

    m_updateAllMonitorsActions = new QAction(this);
    m_updateAllMonitorsActions->setShortcut( tr("F5") );
    connect ( m_updateAllMonitorsActions, SIGNAL ( triggered() ),this, SLOT ( update() ) );

    m_selectStyleAction = new QAction(this);
    connect ( m_selectStyleAction , SIGNAL (triggered()), this , SLOT ( selectStyle() ) );

    m_preferencesAction = new QAction( this );
    connect ( m_preferencesAction, SIGNAL ( triggered() ),this, SLOT ( showPreferences() ) );

    aboutAction = new QAction(this);
    aboutQtAction = new QAction(this);
    connect ( aboutAction, SIGNAL ( triggered () ), this, SLOT ( aboutDialog() ) );
    connect ( aboutQtAction, SIGNAL ( triggered () ), qApp, SLOT ( aboutQt() ) );
}
Ejemplo n.º 14
0
YouTubeDlGui::YouTubeDlGui(QWidget * parent) : QMainWindow(parent), ui(new Ui::YouTubeDlGui) {
  ui->setupUi(this);

  connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
  connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
  connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));

  connect(ui->btnAdd, SIGNAL(clicked(bool)), this, SLOT(addDownload()));
  connect(ui->btnCollapse, SIGNAL(clicked(bool)), this, SLOT(toggleAdvancedVisiblity()));
  connect(ui->btnClearFinished, SIGNAL(clicked(bool)), ui->tblDownloadQueue, SLOT(clearFinished()));
  connect(ui->btnRemove, SIGNAL(clicked(bool)), ui->tblDownloadQueue, SLOT(remove()));
  connect(ui->btnPromote, SIGNAL(clicked(bool)), ui->tblDownloadQueue, SLOT(promote()));
  connect(ui->btnDemote, SIGNAL(clicked(bool)), ui->tblDownloadQueue, SLOT(demote()));
  connect(ui->cmbDownloadOptions, SIGNAL(currentIndexChanged(QString)), this, SLOT(enableAdvancedProperties()));

  manager = new DownloadManager(ui->tblDownloadQueue, this);
  connect(ui->btnDownload, SIGNAL(clicked(bool)), manager, SLOT(downloadAll()));

  populateUi();

  ui->frameAdvanced->setVisible(false);
  enableAdvancedProperties();
}
Ejemplo n.º 15
0
/**
 * @brief connect all buttons of the ui
 * @return
 *      void
 */
void DLDConfigureOB::connectSignals ()
{
	// connect menu actions
	connect(mainWindow.actionQuit,		SIGNAL(triggered ()), this, SLOT(close ()));
	connect(mainWindow.actionRefresh,	SIGNAL(triggered ()), this, SLOT(refreshDevices ()));
	connect(mainWindow.actionPreferences,	SIGNAL(triggered ()), this, SLOT(showPreferences ()));
	connect(mainWindow.actionOpenBeaconConfiguratorHelp, SIGNAL(triggered ()), this, SLOT(showHelp()));
	connect(mainWindow.actionAboutQt,	SIGNAL(triggered ()), qApp, SLOT(aboutQt ()));
	connect(mainWindow.actionAboutOpenBeacon,SIGNAL(triggered ()), this, SLOT(aboutOpenBeacon ()));

	// connect main Window buttons with methods
	connect(mainWindow.selectFileButton,	SIGNAL(clicked ()), this, SLOT(selectFlashImage ()));
	connect(mainWindow.flashButton,		SIGNAL(clicked ()), this, SLOT(flashDevice ()));
	connect(mainWindow.refreshButton,	SIGNAL(clicked ()), this, SLOT(refreshDevices ()));
	connect(mainWindow.executeButton,	SIGNAL(clicked ()), this, SLOT(executeCommand ()));
	connect(mainWindow.clearButton,		SIGNAL(clicked ()), this, SLOT(clearConsole ()));

	// connect box signals
	connect(mainWindow.commandCombo,	SIGNAL(highlighted (int)), this, SLOT(commandHighlighted (int)));
	connect(mainWindow.commandCombo,	SIGNAL(currentIndexChanged (int)), this, SLOT(updateCommandBoxStatusTip (int)));
	connect(mainWindow.deviceCombo,		SIGNAL(currentIndexChanged (int)), this, SLOT(updateGroupBoxVisibility (int)));
	connect(mainWindow.deviceCombo,		SIGNAL(activated (int)), this, SLOT(openNewDevice (int)));

	// connect device
	connect(device,				SIGNAL(newData (QString)), this, SLOT(receivedNewData (QString)));
	connect(device,				SIGNAL(writeFailed ()), this, SLOT(writeFailed ()));

	// connect internal signals
	connect(this,		SIGNAL(deviceSelected (bool, bool)),	this, SLOT(endisableGroupBox (bool, bool)));
	connect(this,		SIGNAL(commandListChanged ()),		this, SLOT(refillCommandList ()));
	connect(this,		SIGNAL(devicepathsChanged ()),		this, SLOT(refreshDevices ()));
	connect(refreshTimer,	SIGNAL(timeout()),			this, SLOT(refreshDevices ()));
	connect(this,		SIGNAL(logFileChanged (QString)),	this, SLOT(changeLogFile (QString)));
	connect(batchProcess,	SIGNAL(readyReadStandardOutput ()),	this, SLOT(addCharToConsole ()));
	connect(batchProcess,	SIGNAL(error (QProcess::ProcessError)),	this, SLOT(printProcessError (QProcess::ProcessError)));
	connect(batchProcess,	SIGNAL(finished (int, QProcess::ExitStatus)),this, SLOT(processFinished (int, QProcess::ExitStatus)));
}
Ejemplo n.º 16
0
KanjiBrowser::KanjiBrowser()
: KXmlGuiWindow()
, _dictFileKanjidic( 0 )
{
  // Read the configuration file.
  _config = KanjiBrowserConfigSkeleton::self();
  _config->load();

  statusBar()->show();

  // Add some actions.
  KStandardAction::quit( this, SLOT(close()), actionCollection() );
  KStandardAction::preferences( this, SLOT(showPreferences()), actionCollection() );

  _view = new KanjiBrowserView( this->parentWidget() );
  connect(_view, &KanjiBrowserView::statusBarChanged, this, &KanjiBrowser::changeStatusBar);
  // Load the necessary information and setup the view.
  loadKanji();

  setCentralWidget( _view );
  setObjectName( QLatin1String( "kanjibrowser" ) );

  setupGUI( Default, "kanjibrowserui.rc" );
}
Ejemplo n.º 17
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    //    "([^"]+)"|(\S+)

    //    ""([^""]+)""|(\\S+)


    //WavSound *w = new WavSound(":/resources/connected.wav", 0);
    //w->play();
    //return;

    //PlaySound();
    //return;
    ui->setupUi(this);

    QApplication::setWindowIcon(QIcon(":/resources/Icon/RunningIcon.png"));

    strangerPrefsWindow = new StrangerPrefsWindow(this);

    //QDockWidget *drawdock = new QDockWidget(this,Qt::Dialog);
    //this->addDockWidget(Qt::RightDockWidgetArea,drawdock);

    /*CometClient *c = new CometClient(this);

    c->get("http://gggoogle.ru", 6);
    c->get("http://gggoogle.ru", 7);
    c->get("http://google.ru", 8);
    c->get("http://googleq.ru", 9);

    c->cancelAllRequests();
    return;
*/

    /*QHBoxLayout *dockLayout = new QHBoxLayout(this);
    QComboBox *b = new QComboBox(this);
    QTextEdit *t = new QTextEdit(this);
    dockLayout->addWidget(b);
    dockLayout->addWidget(t);
    dockLayout->setSizeConstraint(QLayout::SetMinimumSize);


    ui->dockWidgetContents_2->setLayout(dockLayout);
    */

    QWidget::setTabOrder(ui->typingBox, ui->chatlogBox);

    //do not allow Qt framework to intercept Tab keypress (we use it for switching modes)
    //ui->chatlogBox->setFocusPolicy(Qt::NoFocus);


    /*QFile stylesheetFile(":/resources/stylesheet.qss");
    if(!stylesheetFile.open(QFile::ReadOnly)) {
        qDebug() << "Error opening file " << stylesheetFile.error();
    }
    QString stylesheetString = QLatin1String(stylesheetFile.readAll());
    setStyleSheet(stylesheetString);
*/

    nightColoringMode = false;
    switchColoringMode(); //switch to night coloring mode, and apply it

    QStatusBar *sb = this->statusBar();
    chatModeLabel = new QLabel(this);
    //chatModeLabel = new QPushButton(this);
    //chatModeLabel->setFlat(true);

    sb->addPermanentWidget(chatModeLabel);
    typingLabel = new QLabel(this);
    sb->addPermanentWidget(typingLabel);

    //center the window
    setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), qApp->desktop()->availableGeometry()));


    receivedMessageSound = NULL;
    sentMessageSound = NULL;
    connectedSound = NULL;
    disconnectedSound = NULL;
    receivedMessageSound = new QSound(":/resources/sounds/shuffle.wav", this);
    //sentMessageSound = new QSound(":/resources/sounds/test.wav", this);
    connectedSound = new QSound(":/resources/sounds/click1.wav", this);
    disconnectedSound = new QSound(":/resources/sounds/phone_disc.wav", this);

    //receivedMessageSound->setObjectName();

//return;


    QObject::connect(ui->typingBox, SIGNAL(enterPressed()), this, SLOT(enterPressed()));
    QObject::connect(ui->typingBox, SIGNAL(escapePressed()), this, SLOT(escapePressed()));    
    QObject::connect(ui->typingBox, SIGNAL(switchMode()), this, SLOT(SwitchMode()));
    QObject::connect(ui->typingBox, SIGNAL(typingStarted()), this, SLOT(TypingStarted()));
    QObject::connect(ui->typingBox, SIGNAL(typingStopped()), this, SLOT(TypingStopped()));
    QObject::connect(ui->typingBox, SIGNAL(showPreferences()), this, SLOT(displayStrangerPreferencesWindow()));
    QObject::connect(ui->typingBox, SIGNAL(switchColoringMode()), this, SLOT(switchColoringMode()));



    stranger = new Stranger(this);
    spy = new Spy(this);
    rusStranger = new RusStranger(this);

    //rusStranger->requestChatKey();
    //rusStranger->requestUid();





    QObject::connect(stranger, SIGNAL(ReceivedMessage(const QString &)), this, SLOT(ReceivedMessage(const QString &)));
    QObject::connect(stranger, SIGNAL(StrangerDisconnected()), this, SLOT(StrangerDisconnected()));
    QObject::connect(stranger, SIGNAL(ConversationStarted(QStringList, bool)), this, SLOT(StrangerConnected(QStringList, bool)));
    //QObject::connect(stranger, SIGNAL(ConversationStarted()), this, SLOT(StrangerConnected()));


    QObject::connect(stranger, SIGNAL(ConversationStartedWithQuestion(QString)), this, SLOT(StrangerConnectedWithQuestion(QString)));
    QObject::connect(stranger, SIGNAL(StrangerStartsTyping()), this, SLOT(StrangerStartsTyping()));
    QObject::connect(stranger, SIGNAL(StrangerStopsTyping()), this, SLOT(StrangerStopsTyping()));
    QObject::connect(stranger, SIGNAL(SystemMessage(const QString &)), this, SLOT(SystemMessage(const QString &)));
    QObject::connect(stranger, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger()));

    QObject::connect(spy, SIGNAL(ReceivedMessage(const QString &,const QString &)), this, SLOT(SpymodeReceivedMessage(const QString &,const QString &)));
    QObject::connect(spy, SIGNAL(StrangerDisconnected(const QString &)), this, SLOT(SpymodeStrangerDisconnected(const QString &)));
    QObject::connect(spy, SIGNAL(ConversationStarted()), this, SLOT(SpymodeStrangersConnected()));
    QObject::connect(spy, SIGNAL(ConversationStartedWithQuestion(QString)), this, SLOT(StrangerConnectedWithQuestion(QString)));
    QObject::connect(spy, SIGNAL(StrangerStartsTyping(QString)), this, SLOT(SpymodeStrangerStartsTyping(const QString &)));
    QObject::connect(spy, SIGNAL(StrangerStopsTyping()), this, SLOT(SpymodeStrangerStopsTyping(const QString &)));
    QObject::connect(spy, SIGNAL(SystemMessage(const QString &)), this, SLOT(SystemMessage(const QString &)));
    QObject::connect(spy, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger()));


    QObject::connect(rusStranger, SIGNAL(ReceivedMessage(const QString &)), this, SLOT(ReceivedMessage(const QString &)));
    QObject::connect(rusStranger, SIGNAL(StrangerDisconnected()), this, SLOT(StrangerDisconnected()));
    QObject::connect(rusStranger, SIGNAL(ConversationStarted()), this, SLOT(StrangerConnected()));
    QObject::connect(rusStranger, SIGNAL(StrangerStartsTyping()), this, SLOT(StrangerStartsTyping()));
    QObject::connect(rusStranger, SIGNAL(StrangerStopsTyping()), this, SLOT(StrangerStopsTyping()));
    QObject::connect(rusStranger, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger()));




    //chatMode = Russian;
    chatMode = AnsweringQuestions;
    SwitchMode(); //switch it to regular

    this->escapePressed();

    //strangerPrefsWindow->setModal(true);
    //strangerPrefsWindow->show();

}
Ejemplo n.º 18
0
MainWindow::MainWindow(QString url, int quality, int listen_port, bool view_only):
    QMainWindow(0),
    vnc_view(0),
    scroll_area(new ScrollArea(this)),
    input_toolbuttons(new QActionGroup(this)),
    key_menu(0)
{
    setWindowTitle("Presence VNC");
#ifdef Q_WS_MAEMO_5
    setContextMenuPolicy(Qt::NoContextMenu);
    setAttribute(Qt::WA_Maemo5StackedWindow);
#endif

    migrateConfiguration();

    //set up toolbar
    toolbar = new QToolBar(0);
    key_menu_button = input_toolbuttons->addAction(toolbar->addAction(QChar(0x2026), this, SLOT(showKeyMenu()))); //"..." button
    key_menu_button->setCheckable(true); //used to indicate wether a modifier key is still pressed
    input_toolbuttons->addAction(toolbar->addAction(tr("Tab"), this, SLOT(sendTab())));
    input_toolbuttons->addAction(toolbar->addAction(tr("Esc"), this, SLOT(sendEsc())));
    input_toolbuttons->addAction(toolbar->addAction(tr("PgUp"), this, SLOT(sendPgUp())));
    input_toolbuttons->addAction(toolbar->addAction(tr("PgDn"), this, SLOT(sendPgDn())));
#ifdef Q_WS_MAEMO_5
    input_toolbuttons->addAction(toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/chat_enter.png"), "", this, SLOT(sendReturn())));
    input_toolbuttons->addAction(toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel())));
#endif

    QSettings settings;
    zoom_slider = new QSlider(Qt::Horizontal, 0);
    zoom_slider->setRange(0, 100);
    connect(zoom_slider, SIGNAL(valueChanged(int)),
            this, SLOT(setZoomLevel(int)));
    connect(zoom_slider, SIGNAL(sliderReleased()),
            this, SLOT(zoomSliderReleased()));
    zoom_slider->setValue(settings.value("zoomlevel", 95).toInt());
    toolbar->addWidget(zoom_slider);

#ifdef Q_WS_MAEMO_5
    toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen()));
#else
    toolbar->addAction(tr("Toggle Fullscreen"), this, SLOT(toggleFullscreen()));
#endif
    addToolBar(toolbar);
    toolbar->setVisible(settings.value("show_toolbar", true).toBool());
    toolbar->setEnabled(false);

    //set up menu
    QAction *connect_action = new QAction(tr("Connect"), this);
    disconnect_action = new QAction(tr("Disconnect"), this);
    show_toolbar = new QAction(tr("Show toolbar"), this);
    show_toolbar->setCheckable(true);
    show_toolbar->setChecked(settings.value("show_toolbar", true).toBool());
    QAction *pref_action = new QAction(tr("Preferences"), this);
    QAction *about_action = new QAction(tr("About"), this);

#ifdef Q_WS_MAEMO_5
    menuBar()->addAction(connect_action);
    menuBar()->addAction(disconnect_action);
    menuBar()->addAction(show_toolbar);
    menuBar()->addAction(pref_action);
    menuBar()->addAction(about_action);
#else
    QMenu* session_menu = menuBar()->addMenu(tr("&Session"));
    session_menu->addAction(connect_action);
    session_menu->addAction(disconnect_action);
    session_menu->addSeparator();
    session_menu->addAction(pref_action);
    session_menu->addSeparator();
    session_menu->addAction(tr("&Quit"), this, SLOT(close()));

    QMenu* view_menu = menuBar()->addMenu(tr("&View"));
    view_menu->addAction(show_toolbar);

    QMenu* help_menu = menuBar()->addMenu(tr("&Help"));
    help_menu->addAction(about_action);
#endif

    connect(about_action, SIGNAL(triggered()),
            this, SLOT(about()));
    connect(pref_action, SIGNAL(triggered()),
            this, SLOT(showPreferences()));
    connect(connect_action, SIGNAL(triggered()),
            this, SLOT(showConnectDialog()));
    connect(disconnect_action, SIGNAL(triggered()),
            this, SLOT(disconnectFromHost()));
    connect(show_toolbar, SIGNAL(toggled(bool)),
            toolbar, SLOT(setVisible(bool)));
    connect(show_toolbar, SIGNAL(toggled(bool)),
            this, SLOT(updateScreenSpaceDelayed()));
#ifdef Q_WS_MAEMO_5
    QDBusConnection::systemBus().connect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_DISPLAY_SIG,
                                         this, SLOT(displayStateChanged(QString)));
#endif

    setCentralWidget(scroll_area);

    connect(scroll_area, SIGNAL(fullscreenButtonClicked()),
            this, SLOT(toggleFullscreen()));

    grabZoomKeys(true);
    reloadSettings();

    if(url.isEmpty() and listen_port == 0) {
        disconnect_action->setEnabled(false);
        showConnectDialog();
    } else {
        connectToHost(url, quality, listen_port, view_only);
    }
}
Ejemplo n.º 19
0
void MainWindow::createMenus()
{
   QAction* action;
   QString  name;
   QMenu*   menu;
   QMenu*   subMenu;

   // ----- File Menu -----
   menu = menuBar()->addMenu("File");

      name = "About";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showAbout()));

      name = "New Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu()));
      action->setShortcut(QKeySequence::New);

      name = "New Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(newViewer()));

      name = "Open";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
      action->setShortcut(QKeySequence::Open);

      name = "Open Recent";
      m_recentFilesMenu = menu->addMenu(name);
      updateRecentFilesMenu();

      menu->addSeparator();

/*
      name = "Parse Test File";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(parseFile()));

      menu->addSeparator();
*/

      name = "Close Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(close()));
      action->setShortcut(QKeySequence::Close);

      name = "Save";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll()));
      action->setShortcut(QKeySequence::Save);

      name = "Save As";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S);

      menu->addSeparator();

      name = "Save Picture";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot()));
      action->setShortcut(Qt::CTRL + Qt::Key_P);

      name = "Record Animation";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P);
      m_recordAnimationAction = action;

      name = "Show Message Log";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages()));
      action->setShortcut(Qt::CTRL + Qt::Key_L);

      name = "Quit";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(quit()));
      action->setShortcut(Qt::CTRL + Qt::Key_Q);


   // ----- Edit Menu -----
   menu = menuBar()->addMenu("Edit");
  
      name = "Undo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo()));
      action->setShortcut(QKeySequence::Undo);
      connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool)));

      name = "Redo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo()));
      action->setShortcut(QKeySequence::Redo);
      connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool)));

      menu->addSeparator();

      name = "Cut";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_X);

      name = "Copy";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_C);

      name = "Paste";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_V);

      menu->addSeparator();

      name = "Select All";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll()));
      action->setShortcut(Qt::CTRL + Qt::Key_A);

      name = "Select None";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A);

      name = "Invert Selection";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_I);

      menu->addSeparator();

      name = "Reindex Atoms";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms()));


      menu->addSeparator();

      name = "Preferences";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showPreferences()));


   // ----- Display Menu -----
   menu = menuBar()->addMenu("Display");

      name = "Full Screen";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(fullScreen()));
      action->setShortcut(Qt::CTRL + Qt::Key_0);
      m_fullScreenAction = action;

      name = "Reset View";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView()));
      action->setShortcut(Qt::CTRL + Qt::Key_R);

      name = "Show Axes";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes()));
      connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool)));
      action->setShortcut(Qt::Key_A);


      menu->addSeparator();

      name = "Atom Labels";
      subMenu = menu->addMenu(name);

         name = "Element";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Element);
         action->setShortcut(Qt::Key_E);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Index";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Index);
         action->setShortcut(Qt::Key_I);
         action->setCheckable(true);
         m_labelActions << action;
   
         name = "Mass";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Mass);
         action->setShortcut(Qt::Key_M);
         action->setCheckable(true);
         m_labelActions << action;

/*
         name = "NMR Shifts";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::NmrShifts);
         action->setShortcut(Qt::Key_N);
         action->setCheckable(true);
         m_labelActions << action;
*/

         name = "Partial Charge";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Charge);
         action->setShortcut(Qt::Key_Q);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Spin Densities";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Spin);
         action->setShortcut(Qt::Key_S);
         action->setCheckable(true);
         m_labelActions << action;

   menu->addSeparator();

   name = "Configure Appearance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance()));


      // These are not working correctly at the moment.
/*
      name = "Partial Charge Type";
      QActionGroup* partialChargeGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString pc("Gasteiger");
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setChecked(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Sanderson";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Mulliken";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));
*/



   // ----- Build Menu -----
   menu = menuBar()->addMenu("Build");

      name = "Fill Valencies With Hydrogens";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens()));
      action->setShortcut(Qt::CTRL + Qt::Key_F);

      name = "Reperceive Bonds";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds()));

      menu->addSeparator();

      name = "Set Constraint";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint()));
      action->setShortcut(Qt::CTRL + Qt::Key_K);

      name = "Minimize Structure";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy()));
      action->setShortcut(Qt::CTRL + Qt::Key_M);

      name = "Select Force Field";

      QActionGroup* forceFieldGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString ff("MMFF94");
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "MMFF94s";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "UFF";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Ghemical";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Gaff";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

      menu->addSeparator();

      name = "Translate To Center";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter()));
      action->setShortcut(Qt::CTRL + Qt::Key_T );

      name = "Symmetrize Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize()));
      action->setShortcut(Qt::CTRL + Qt::Key_Y );

      name = "Set Symmetry Tolerance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance()));

      name = "Auto-detect Symmetry";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry()));



   // ----- Calculation Menu -----
   menu = menuBar()->addMenu("Calculation");

      name = "Q-Chem Setup";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI()));
      action->setShortcut(Qt::CTRL + Qt::Key_U );
      m_qchemSetupAction = action;

      name = "Job Monitor";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor()));
      action->setShortcut(Qt::CTRL + Qt::Key_J );

      menu->addSeparator();

      name = "Edit Servers";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(editServers()));

      name = "Remove All Processes";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), 
         &(ProcessMonitor::instance()), SLOT(clearProcessList()));

      name = "Reset Password Vault Key";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword()));



   // ----- Help Menu -----
   menu = menuBar()->addMenu("Help");

      name = "Show Help";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showHelp()));
}
Ejemplo n.º 20
0
void GLShaderDev::initializeActions()
{
    QSettings settings;

    QMenu* recent;
    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(QIcon(":/document-new.png"), tr("&New..."), _newFileDialog, SLOT(exec()), QKeySequence::New);
    connect(_newFileDialog, SIGNAL(accepted()), this, SLOT(newFile()));
    fileMenu->addAction(QIcon(":/document-open.png"), tr("&Open..."), this, SLOT(openFileDialog()), QKeySequence::Open);
    recent = fileMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent"));

    for (int i = 0; i < MaxRecentFiles; ++i)
        (_recentFileActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentFile())))->setVisible(true);
    (_recentFileActions[MaxRecentFiles] = recent->addSeparator())->setVisible(true);
    (_recentFileActions[MaxRecentFiles + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearFileRecent())))->setEnabled(false);
    updateRecentFiles();

    fileMenu->addSeparator();
    fileMenu->addAction(QIcon(":/document-save-all.png"), tr("Save Al&l"), _editor, SLOT(saveAll()));
    fileMenu->addAction(QIcon(":/document-save.png"), tr("&Save"), _editor, SLOT(save()), QKeySequence::Save);
    fileMenu->addAction(QIcon(":/document-save-as.png"), tr("Save &As..."), this, SLOT(saveFileAs()), QKeySequence::SaveAs);
    fileMenu->addSeparator();
    fileMenu->addAction(QIcon(":/dialog-close.png"), tr("&Close"), _editor, SLOT(closeCurrentTab()), tr("Ctrl+W"));
    fileMenu->addAction(QIcon(":/dialog-close.png"), tr("Cl&ose All"), _editor, SLOT(closeAllTabs()), tr("Ctrl+Shift+W"));
    fileMenu->addSeparator();
    fileMenu->addAction(QIcon(":/application-exit.png"), tr("&Quit"), this, SLOT(close()), QKeySequence::Quit);

    QMenu* projectMenu = menuBar()->addMenu(tr("&Project"));
    projectMenu->addAction(QIcon(":/project-development-new-template.png"), tr("&New Project"), this, SLOT(newProject()));
    projectMenu->addAction(QIcon(":/project-open.png"), tr("&Open Project..."), this, SLOT(openProjectDialog()));
    recent = projectMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent"));

    for (int i = 0; i < MaxRecentProjects; ++i)
        (_recentProjectActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentProject())))->setVisible(true);
    (_recentProjectActions[MaxRecentProjects] = recent->addSeparator())->setVisible(true);
    (_recentProjectActions[MaxRecentProjects + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearProjectRecent())))->setEnabled(false);
    updateRecentProjects();

    projectMenu->addSeparator();
    projectMenu->addAction(QIcon(":/configure.png"), tr("Open &Configuration..."), this, SLOT(openProjectConfiguration()));
    projectMenu->addAction(QIcon(":/run-build.png"), tr("&Build Current"), this, SLOT(buildCurrentProject()), tr("F8"));
    projectMenu->addSeparator();
    projectMenu->addAction(QIcon(":/project-development-close.png"), tr("&Close Project"), this, SLOT(closeProject()));

    menuBar()->addMenu("|")->setEnabled(false);

    QMenu* toolsMenu = menuBar()->addMenu(tr("&Tools"));
    toolsMenu->addAction(QIcon(":/preferences-other.png"), tr("&OpenGL Info..."), this, SLOT(showGLInfo()));

    QMenu* settingsMenu = menuBar()->addMenu(tr("&Settings"));
    settingsMenu->addAction(QIcon(":/preferences-other.png"), tr("&Preferences..."), this, SLOT(showPreferences()));

    QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(QIcon(":/glsd-icon.png"), tr("&About GLShaderDev"), this, SLOT(about()));
    helpMenu->addAction(QIcon(":/qt-icon.png"), tr("About &Qt"), qApp, SLOT(aboutQt()));
}
Ejemplo n.º 21
0
void MainWindow2::createMenus()
{
    // ---------- File Menu -------------
    connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newDocument()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openDocument()));
    connect(ui->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAsNewDocument()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveDocument()));
    connect(ui->actionPrint, SIGNAL(triggered()), editor, SLOT(print()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));

    /// --- Export Menu ---
    connect(ui->actionExport_X_sheet , SIGNAL(triggered()), editor, SLOT(exportX()));
    connect(ui->actionExport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(exportSeq()));
    connect(ui->actionExport_Image, SIGNAL(triggered()), editor, SLOT(exportImage()));
    connect(ui->actionExport_Movie, SIGNAL(triggered()), editor, SLOT(exportMov()));

    //exportFlashAct = new QAction(tr("&Flash/SWF..."), this);
    //exportFlashAct->setShortcut(tr("Ctrl+Alt+F"));
    //connect(exportFlashAct, SIGNAL(triggered()), editor, SLOT(exportFlash()));

    connect(ui->actionExport_Palette, SIGNAL(triggered()), this, SLOT(exportPalette()));

    /// --- Import Menu ---
    connect(ui->actionExport_Svg_Image, SIGNAL(triggered()), editor, SLOT(saveSvg()));
    connect(ui->actionImport_Image, SIGNAL(triggered()), editor, SLOT(importImage()));
    connect(ui->actionImport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(importImageSequence()));
    connect(ui->actionImport_Movie, SIGNAL(triggered()), editor, SLOT(importMov()));
    connect(ui->actionImport_Sound, SIGNAL(triggered()), editor, SLOT(importSound()));
    connect(ui->actionImport_Palette, SIGNAL(triggered()), this, SLOT(importPalette()));

    /// --- Edit Menu ---
    connect(ui->actionUndo, SIGNAL(triggered()), editor, SLOT(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), editor, SLOT(redo()));
    connect(ui->actionCut, SIGNAL(triggered()), editor, SLOT(cut()));
    connect(ui->actionCopy, SIGNAL(triggered()), editor, SLOT(copy()));
    connect(ui->actionPaste, SIGNAL(triggered()), editor, SLOT(paste()));
    connect(ui->actionDelete, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame()));
    connect(ui->actionCrop, SIGNAL(triggered()), editor, SLOT(crop()));
    connect(ui->actionCrop_To_Selection, SIGNAL(triggered()), editor, SLOT(croptoselect()));
    connect(ui->actionSelect_All, SIGNAL(triggered()), editor, SIGNAL(selectAll()));
    connect(ui->actionDeselect_All, SIGNAL(triggered()), editor, SLOT(deselectAll()));
    connect(ui->actionPreference, SIGNAL(triggered()), this, SLOT(showPreferences()));

    ui->actionRedo->setEnabled(false);

    /// --- Layer Menu ---
    connect(ui->actionNew_Bitmap_Layer, SIGNAL(triggered()), editor, SLOT(newBitmapLayer()));
    connect(ui->actionNew_Vector_Layer, SIGNAL(triggered()), editor, SLOT(newVectorLayer()));
    connect(ui->actionNew_Sound_Layer, SIGNAL(triggered()), editor, SLOT(newSoundLayer()));
    connect(ui->actionNew_Camera_Layer, SIGNAL(triggered()), editor, SLOT(newCameraLayer()));
    connect(ui->actionDelete_Current_Layer, SIGNAL(triggered()), editor, SLOT(deleteCurrentLayer()));

    /// --- View Menu ---
    connect(ui->actionZoom_In, SIGNAL(triggered()), editor, SLOT(setzoom()));
    connect(ui->actionZoom_Out, SIGNAL(triggered()), editor, SLOT(setzoom1()));
    connect(ui->actionRotate_Clockwise, SIGNAL(triggered()), editor, SLOT(rotatecw()));
    connect(ui->actionRotate_Anticlosewise, SIGNAL(triggered()), editor, SLOT(rotateacw()));
    connect(ui->actionReset_Windows, SIGNAL(triggered()), this, SLOT(dockAllPalettes()));
    connect(ui->actionReset_View, SIGNAL(triggered()), editor, SLOT(resetView()));
    connect(ui->actionHorizontal_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirror()));
    connect(ui->actionVertical_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirrorV()));

    ui->actionPreview->setEnabled(false);
    //#	connect(previewAct, SIGNAL(triggered()), editor, SLOT(getCameraLayer()));//TODO: Preview view

    ui->actionGrid->setEnabled(false);
    connect(ui->actionGrid, SIGNAL(triggered()), editor, SLOT(gridview())); //TODO: Grid view

    connect(ui->actionOnionPrevious, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionPrev(bool)));
    connect(editor, SIGNAL(onionPrevChanged(bool)), ui->actionOnionPrevious, SLOT(setChecked(bool)));

    connect(ui->actionOnionNext, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionNext(bool)));
    connect(editor, SIGNAL(onionNextChanged(bool)), ui->actionOnionNext, SLOT(setChecked(bool)));

    /// --- Animation Menu ---
    connect(ui->actionPlay, SIGNAL(triggered()), editor, SLOT(play()));
    connect(ui->actionLoop, SIGNAL(triggered(bool)), editor, SLOT(setLoop(bool)));
    connect(ui->actionLoop, SIGNAL(toggled(bool)), editor, SIGNAL(toggleLoop(bool))); //TODO: WTF?
    connect(editor, SIGNAL(loopToggled(bool)), ui->actionLoop, SLOT(setChecked(bool)));

    connect(ui->actionAdd_Frame, SIGNAL(triggered()), editor, SLOT(addKey()));
    connect(ui->actionRemove_Frame, SIGNAL(triggered()), editor, SLOT(removeKey()));
    connect(ui->actionNext_Frame, SIGNAL(triggered()), editor, SLOT(playNextFrame()));
    connect(ui->actionPrevious_Frame, SIGNAL(triggered()), editor, SLOT(playPrevFrame()));
    connect(ui->actionNext_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubNextKeyframe()));
    connect(ui->actionPrev_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubPreviousKeyframe()));
    connect(ui->actionDuplicate_Frame, SIGNAL(triggered()), editor, SLOT(duplicateKey()));

    /// --- Tool Menu ---
    connect(ui->actionClear, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame()));

    connect(ui->actionMove, SIGNAL(triggered()), m_toolSet, SLOT(moveOn()));
    connect(ui->actionSelect, SIGNAL(triggered()), m_toolSet, SLOT(selectOn()));
    connect(ui->actionBrush, SIGNAL(triggered()), m_toolSet, SLOT(brushOn()));
    connect(ui->actionPolyline, SIGNAL(triggered()), m_toolSet, SLOT(polylineOn()));
    connect(ui->actionSmudge, SIGNAL(triggered()), m_toolSet, SLOT(smudgeOn()));
    connect(ui->actionPen, SIGNAL(triggered()), m_toolSet, SLOT(penOn()));
    connect(ui->actionHand, SIGNAL(triggered()), m_toolSet, SLOT(handOn()));
    connect(ui->actionPencil, SIGNAL(triggered()), m_toolSet, SLOT(pencilOn()));
    connect(ui->actionBucket, SIGNAL(triggered()), m_toolSet, SLOT(bucketOn()));
    connect(ui->actionEyedropper, SIGNAL(triggered()), m_toolSet, SLOT(eyedropperOn()));
    connect(ui->actionEraser, SIGNAL(triggered()), m_toolSet, SLOT(eraserOn()));

    connect(ui->actionResetToolsDefault, SIGNAL(triggered()), this, SLOT(resetToolsSettings()));

    /// --- Help Menu ---
    connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(helpBox()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPencil()));

    // --------------- Menus ------------------
    openRecentMenu = new QMenu(tr("Open recent"), this);

    connect(ui->menuEdit, SIGNAL(aboutToShow()), this, SLOT(undoActSetText()));
    connect(ui->menuEdit, SIGNAL(aboutToHide()), this, SLOT(undoActSetEnabled()));


}
Ejemplo n.º 22
0
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
    setWindowTitle(QCoreApplication::applicationName());
    ui.setupUi(this);

    // setup preferences dialog
    connect(&preferences,   SIGNAL(accepted()),                     this,   SLOT(getApplicationSettings()));

    connect(&builder,   SIGNAL(highlightLine(const QString &,
                                             int,
                                             int,
                                             const QString &)),

            this,       SLOT(highlightFileLine(const QString &,
                                               int,
                                               int)));

    connect(&builder,   SIGNAL(finished()),     this,           SLOT(setBuildAvailable()));
    connect(&builder,   SIGNAL(buildError()),   &preferences,   SLOT(showPreferences()));

    parser = language.parser();

    connect(&preferences, SIGNAL(updateColors()),               this,   SLOT(recolorProjectView()));
    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   this,   SLOT(recolorProjectView()));

    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   this,   SLOT(recolorBuildManager()));

    connect(&preferences, SIGNAL(accepted()),                   ui.editorTabs,   SIGNAL(accepted()));
    connect(&preferences, SIGNAL(updateColors()),               ui.editorTabs,   SIGNAL(updateColors()));
    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   ui.editorTabs,   SIGNAL(updateFonts(const QFont &)));

    recolorProjectView();
    recolorBuildManager();

    // project editor tabs
    ui.finder->connectFileManager(ui.editorTabs);
    QSplitterHandle *hndl = ui.splitter->handle(1);
    hndl->setEnabled(false);

    connect(ui.editorTabs, SIGNAL(fileUpdated(int)),    this,   SLOT(setProject()));

    // File Menu
    connect(ui.action_New,              SIGNAL(triggered()),    ui.editorTabs,  SLOT(newFile()));
    connect(ui.actionNew_From_File,     SIGNAL(triggered()),    ui.editorTabs,  SLOT(newFromFile()));
    connect(ui.actionNew_From_Template, SIGNAL(triggered()),    this,           SLOT(newFromTemplate()));
    connect(ui.action_Open,             SIGNAL(triggered()),    ui.editorTabs,  SLOT(open()));

    connect(ui.action_Save,SIGNAL(triggered()),ui.editorTabs,SLOT(save()));
    connect(ui.actionSave_As,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAs()));
    connect(ui.actionSave_All,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAll()));

    ui.actionPrint->setEnabled(true);
    connect(ui.actionPrint,SIGNAL(triggered()),this,SLOT(printFile()));

    ui.action_Zip->setEnabled(true);
    connect(ui.action_Zip,SIGNAL(triggered()),this,SLOT(zipFiles()));

    recentFiles = findChildren<QAction *>(QRegExp("action_[0-9]+_File"));
    for (int i = 0; i < recentFiles.size(); i++)
        connect(recentFiles.at(i), SIGNAL(triggered()),this, SLOT(openRecentFile()));
    
    connect(ui.action_Close,       SIGNAL(triggered()),    ui.editorTabs, SLOT(closeFile()));
    connect(ui.actionClose_All,    SIGNAL(triggered()),    ui.editorTabs, SLOT(closeAll()));
    connect(ui.action_Quit,        SIGNAL(triggered()),    this,          SLOT(quitProgram()));

    connect(ui.editorTabs, SIGNAL(saveAvailable(bool)),    this,          SLOT(setSaveAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(saveAvailable(bool)),    this,          SLOT(setSaveAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setCloseAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setCloseAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setBuildAvailable(bool)));

    // Edit Menu
    connect(ui.action_Undo,        SIGNAL(triggered()), ui.editorTabs, SLOT(undo()));
    connect(ui.action_Redo,        SIGNAL(triggered()), ui.editorTabs, SLOT(redo()));

    connect(ui.action_Cut,         SIGNAL(triggered()), ui.editorTabs, SLOT(cut()));
    connect(ui.action_Copy,        SIGNAL(triggered()), ui.editorTabs, SLOT(copy()));
    connect(ui.action_Paste,       SIGNAL(triggered()), ui.editorTabs, SLOT(paste()));
    connect(ui.actionSelect_All,   SIGNAL(triggered()), ui.editorTabs, SLOT(selectAll()));

    connect(ui.action_Find,        SIGNAL(triggered()), ui.finder, SLOT(showFinder()));
    connect(ui.actionFind_Next,    SIGNAL(triggered()), ui.finder, SLOT(findNext()));
    connect(ui.actionFind_Previous,SIGNAL(triggered()), ui.finder, SLOT(findPrevious()));

    connect(ui.actionPreferences,  SIGNAL(triggered()), &preferences, SLOT(showPreferences()));

    connect(ui.editorTabs, SIGNAL(undoAvailable(bool)), ui.action_Undo,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(redoAvailable(bool)), ui.action_Redo,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Cut,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Copy,SLOT(setEnabled(bool)));

    // View Menu
    connect(ui.actionShow_Browser, SIGNAL(triggered()), this, SLOT(showBrowser()));
    connect(ui.actionBigger_Font,  SIGNAL(triggered()), this, SLOT(fontBigger()));
    connect(ui.actionSmaller_Font, SIGNAL(triggered()), this, SLOT(fontSmaller()));

    ui.actionBigger_Font->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn
                                                             << Qt::CTRL+Qt::Key_Equal);

    // Project Menu
    connect(ui.actionMemory_Map,SIGNAL(triggered()), this, SLOT(spawnMemoryMap()));
    connect(ui.actionBuild,     SIGNAL(triggered()), this, SLOT(programBuild()));
    connect(ui.actionRun,       SIGNAL(triggered()), this, SLOT(programRun()));
    connect(ui.actionWrite,     SIGNAL(triggered()), this, SLOT(programWrite()));
    connect(ui.actionTerminal,  SIGNAL(triggered()), this, SLOT(spawnTerminal()));

    // Help Menu
    connect(ui.actionPropeller_Quick_Reference, SIGNAL(triggered()), this, SLOT(propellerQuickReference()));
    connect(ui.actionPropeller_Datasheet,       SIGNAL(triggered()), this, SLOT(propellerDatasheet()));
    connect(ui.actionPropeller_Manual,          SIGNAL(triggered()), this, SLOT(propellerManual()));
    connect(ui.actionPropBASIC_Manual,          SIGNAL(triggered()), this, SLOT(propBasicManual()));
    connect(ui.action_About,                    SIGNAL(triggered()), this, SLOT(about()));

    // Toolbar Extras
    cbPort = new QComboBox(this);
    cbPort->setLayoutDirection(Qt::LeftToRight);
    cbPort->setToolTip(tr("Select Serial Port"));
    cbPort->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    ui.toolBar->addWidget(cbPort);

    connect(ui.projectview, SIGNAL(showFileLine(QString, int)),
            this,           SLOT(highlightFileLine(QString, int)));

    updateRecentFileActions();

    connect(ui.editorTabs, SIGNAL(sendMessage(const QString &)),   this,SLOT(showMessage(const QString &)));
    connect(ui.finder,     SIGNAL(sendMessage(const QString &)),   this,SLOT(showMessage(const QString &)));

    restoreGeometry(QSettings().value("windowSize").toByteArray());

    getApplicationSettings();

    connect(&manager, SIGNAL(portListChanged()), this, SLOT(updatePorts()));
    manager.enablePortMonitor(true);
    updatePorts();

    
    QSettings settings;
    QString lastport = settings.value("lastPort", QString()).toString();
    if (!lastport.isEmpty())
    {
        int index = cbPort->findText(lastport);
        if (index != -1)
            cbPort->setCurrentIndex(index);
    }

    ui.editorTabs->newFile();
    loadSession();

    installEventFilter(this);
    statusBar();
}
Ejemplo n.º 23
0
MainWindow::MainWindow(QAction* actionQuit, QAction* actionNewTab, QAction* actionFullscreen, QAction* actionLoadSession, QAction* actionSaveSession, QWidget* parent)
    : QMainWindow(parent),
    ui(new Ui::MainWindow),
    fetcher(new Fetcher),
    local(new LocalFetcher),
    source(IMAGE_SOURCE_UNKNOWN)
{
    ui->setupUi(this);

    QStringList  sources;
    sources.append("Google");
    sources.append("Local file");
//    sources.append("Picsearch");
    ui->cbSource->addItems(sources);
    ui->cbSource->setCurrentIndex(IMAGE_SOURCE_GOOGLE);

    fetcher->hide();
    local->hide();

    ui->menuFile->addAction(actionNewTab);
    ui->menuFile->addAction(actionLoadSession);
    ui->menuFile->addAction(actionSaveSession);
    ui->menuFile->addAction(actionQuit);
    ui->menuView->insertAction(ui->actionResetTransforms,actionFullscreen);

    ui->tbFullScreen->setDefaultAction(actionFullscreen);
    ui->tbNewTab->setDefaultAction(actionNewTab);
    ui->tbResetTransform->setDefaultAction(ui->actionResetTransforms);
    ui->tbSave->setDefaultAction(actionSaveSession);

    ui->glTools->addWidget(fetcher,0,6,2,1);
    ui->glTools->addWidget(local,0,6,2,1);

    updateSource();

    connect(ui->cbSource,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSource()));

    ui->actionViewOnlyMode->setShortcut(Qt::Key_Tab);
    QList<QKeySequence> keys;
    keys << Qt::Key_Delete << Qt::Key_Backspace;
    ui->actionDeleteSelected->setShortcuts(keys);
    // These are necessary if the actions are to remain accessible when the menubar is hidden:
    this->addAction(ui->actionViewOnlyMode);
    this->addAction(ui->actionResetTransforms);
    this->addAction(ui->actionZoomToFit);
    this->addAction(ui->actionIntroduction);
    this->addAction(ui->actionTips);
    this->addAction(ui->actionOpenDirectory);
    this->addAction(ui->actionOpenFile);

    this->addAction(ui->actionDeleteSelected);
    this->addAction(ui->actionUncropSelected);
    this->addAction(ui->actionCentreInView);
    this->addAction(ui->actionResetRotation);
    this->addAction(ui->actionResetScale);
    this->addAction(ui->actionScaleToFit);

    this->addAction(actionFullscreen);
    this->addAction(actionLoadSession);
    this->addAction(actionSaveSession);
    this->addAction(actionNewTab);
    this->addAction(actionQuit);

    connect(ui->actionIntroduction,SIGNAL(triggered()),this,SLOT(showHelp()));
    connect(ui->actionTips,SIGNAL(triggered()),this,SLOT(showTips()));
    connect(ui->actionViewOnlyMode,SIGNAL(triggered(bool)),this,SLOT(enterViewOnlyMode(bool)));
    connect(ui->actionPreferences,SIGNAL(triggered()),this,SLOT(showPreferences()));

    connect(fetcher,SIGNAL(queryChanged(QString)),this,SIGNAL(queryChanged(QString)));
    connect(fetcher,SIGNAL(imageResult(QUrl,QUrl,bool)),this,SLOT(processImageResult(QUrl,QUrl,bool)));
    connect(local,SIGNAL(imageResult(QUrl,QUrl,bool)),this,SLOT(processImageResult(QUrl,QUrl,bool)));
    connect(local,SIGNAL(queryChanged(QString)),this,SIGNAL(queryChanged(QString)));

    initBlacklistDocker();
    initInfoDocker();

    initView(parent);
    dlDir = QString(DEFAULT_DOWNLOAD_DIRECTORY);
    dlMgr = new QNetworkAccessManager(this);


    connect(ui->actionResetTransforms,SIGNAL(triggered()),gvMain,SLOT(resetTransforms()));
    connect(ui->actionZoomToFit,SIGNAL(triggered()),gvMain,SLOT(zoomToFit()));
    connect(ui->actionOpenDirectory,SIGNAL(triggered()),local,SLOT(selectDirectory()));
    connect(ui->actionOpenFile,SIGNAL(triggered()),local,SLOT(selectFile()));

    connect(ui->actionDeleteSelected,SIGNAL(triggered()),gsMain,SLOT(deleteSelected()));
    connect(ui->actionUncropSelected,SIGNAL(triggered()),gsMain,SLOT(uncropSelected()));
    connect(ui->actionCentreInView,SIGNAL(triggered()),gsMain,SLOT(centreSelection()));
    connect(ui->actionResetRotation,SIGNAL(triggered()),gsMain,SLOT(resetSelectionRotation()));
    connect(ui->actionResetScale,SIGNAL(triggered()),gsMain,SLOT(resetSelectionScale()));
    connect(ui->actionScaleToFit,SIGNAL(triggered()),this,SLOT(scaleSelectedToFit()));

    ui->verticalLayout->removeWidget(ui->toolWidget);
    ui->toolBar->addWidget(ui->toolWidget);
    setCentralWidget(gvMain);
    ui->thumbBar->addWidget(gvCarousel);

    ui->statusBar->addWidget(fetcher->getStatusText(),0);
    ui->statusBar->addWidget(fetcher->getProgressBar(),1);

    connect(this,SIGNAL(settingsChanged()),this,SLOT(loadSettings()));
    loadSettings();
}
Ejemplo n.º 24
0
void WMainMenuBar::initialize() {
    // FILE MENU
    QMenu* pFileMenu = new QMenu(tr("&File"));

    QString loadTrackText = tr("Load Track to Deck &%1");
    QString loadTrackStatusText = tr("Loads a track in deck %1");
    QString openText = tr("Open");
    for (unsigned int deck = 0; deck < kMaxLoadToDeckActions; ++deck) {
        QString playerLoadStatusText = loadTrackStatusText.arg(QString::number(deck + 1));
        QAction* pFileLoadSongToPlayer = new QAction(
            loadTrackText.arg(QString::number(deck + 1)), this);

        QString binding = m_pKbdConfig->getValueString(
                ConfigKey("[KeyboardShortcuts]", QString("FileMenu_LoadDeck%1").arg(deck + 1)),
                loadToDeckDefaultKeyBinding(deck));
        if (!binding.isEmpty()) {
            pFileLoadSongToPlayer->setShortcut(QKeySequence(binding));
            pFileLoadSongToPlayer->setShortcutContext(Qt::ApplicationShortcut);
        }
        pFileLoadSongToPlayer->setStatusTip(playerLoadStatusText);
        pFileLoadSongToPlayer->setWhatsThis(
            buildWhatsThis(openText, playerLoadStatusText));
        // Visibility of load to deck actions is set in
        // WMainMenuBar::onNumberOfDecksChanged.
        pFileLoadSongToPlayer->setVisible(false);
        connect(pFileLoadSongToPlayer, SIGNAL(triggered()),
                &m_loadToDeckMapper, SLOT(map()));
        m_loadToDeckMapper.setMapping(pFileLoadSongToPlayer, deck + 1);
        pFileMenu->addAction(pFileLoadSongToPlayer);
        m_loadToDeckActions.push_back(pFileLoadSongToPlayer);
    }

    pFileMenu->addSeparator();

    QString quitTitle = tr("&Exit");
    QString quitText = tr("Quits Mixxx");
    QAction* pFileQuit = new QAction(quitTitle, this);
    pFileQuit->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]", "FileMenu_Quit"),
                                                  tr("Ctrl+q"))));
    pFileQuit->setShortcutContext(Qt::ApplicationShortcut);
    pFileQuit->setStatusTip(quitText);
    pFileQuit->setWhatsThis(buildWhatsThis(quitTitle, quitText));
    pFileQuit->setMenuRole(QAction::QuitRole);
    connect(pFileQuit, SIGNAL(triggered()), this, SIGNAL(quit()));
    pFileMenu->addAction(pFileQuit);

    addMenu(pFileMenu);

    // LIBRARY MENU
    QMenu* pLibraryMenu = new QMenu(tr("&Library"));

    QString rescanTitle = tr("&Rescan Library");
    QString rescanText = tr("Rescans library folders for changes to tracks.");
    QAction* pLibraryRescan = new QAction(rescanTitle, this);
    pLibraryRescan->setStatusTip(rescanText);
    pLibraryRescan->setWhatsThis(buildWhatsThis(rescanTitle, rescanText));
    pLibraryRescan->setCheckable(false);
    connect(pLibraryRescan, SIGNAL(triggered()),
            this, SIGNAL(rescanLibrary()));
    // Disable the action when a scan is active.
    connect(this, SIGNAL(internalLibraryScanActive(bool)),
            pLibraryRescan, SLOT(setDisabled(bool)));
    pLibraryMenu->addAction(pLibraryRescan);

    pLibraryMenu->addSeparator();

    QString createPlaylistTitle = tr("Create &New Playlist");
    QString createPlaylistText = tr("Create a new playlist");
    QAction* pLibraryCreatePlaylist = new QAction(createPlaylistTitle, this);
    pLibraryCreatePlaylist->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "LibraryMenu_NewPlaylist"),
                                                  tr("Ctrl+n"))));
    pLibraryCreatePlaylist->setShortcutContext(Qt::ApplicationShortcut);
    pLibraryCreatePlaylist->setStatusTip(createPlaylistText);
    pLibraryCreatePlaylist->setWhatsThis(buildWhatsThis(createPlaylistTitle, createPlaylistText));
    connect(pLibraryCreatePlaylist, SIGNAL(triggered()),
            this, SIGNAL(createPlaylist()));
    pLibraryMenu->addAction(pLibraryCreatePlaylist);

    QString createCrateTitle = tr("Create New &Crate");
    QString createCrateText = tr("Create a new crate");
    QAction* pLibraryCreateCrate = new QAction(createCrateTitle, this);
    pLibraryCreateCrate->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "LibraryMenu_NewCrate"),
                                                  tr("Ctrl+Shift+N"))));
    pLibraryCreateCrate->setShortcutContext(Qt::ApplicationShortcut);
    pLibraryCreateCrate->setStatusTip(createCrateText);
    pLibraryCreateCrate->setWhatsThis(buildWhatsThis(createCrateTitle, createCrateText));
    connect(pLibraryCreateCrate, SIGNAL(triggered()),
            this, SIGNAL(createCrate()));
    pLibraryMenu->addAction(pLibraryCreateCrate);

    addMenu(pLibraryMenu);

    // VIEW MENU
    QMenu* pViewMenu = new QMenu(tr("&View"));

    QString mayNotBeSupported = tr("May not be supported on all skins.");
    QString showSamplersTitle = tr("Show Samplers");
    QString showSamplersText = tr("Show the sample deck section of the Mixxx interface.") +
            " " + mayNotBeSupported;
    QAction* pViewShowSamplers = new QAction(showSamplersTitle, this);
    pViewShowSamplers->setCheckable(true);
    pViewShowSamplers->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_ShowSamplers"),
                                                  tr("Ctrl+1", "Menubar|View|Show Samplers"))));
    pViewShowSamplers->setStatusTip(showSamplersText);
    pViewShowSamplers->setWhatsThis(buildWhatsThis(showSamplersTitle, showSamplersText));
    createVisibilityControl(pViewShowSamplers, ConfigKey("[Samplers]", "show_samplers"));
    pViewMenu->addAction(pViewShowSamplers);

    QString showMicrophoneTitle = tr("Show Microphone Section");
    QString showMicrophoneText = tr("Show the microphone section of the Mixxx interface.") +
            " " + mayNotBeSupported;
    QAction* pViewShowMicrophone = new QAction(showMicrophoneTitle, this);
    pViewShowMicrophone->setCheckable(true);
    pViewShowMicrophone->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(
            ConfigKey("[KeyboardShortcuts]", "ViewMenu_ShowMicrophone"),
            tr("Ctrl+2", "Menubar|View|Show Microphone Section"))));
    pViewShowMicrophone->setStatusTip(showMicrophoneText);
    pViewShowMicrophone->setWhatsThis(buildWhatsThis(showMicrophoneTitle, showMicrophoneText));
    createVisibilityControl(pViewShowMicrophone, ConfigKey("[Microphone]", "show_microphone"));
    pViewMenu->addAction(pViewShowMicrophone);

#ifdef __VINYLCONTROL__
    QString showVinylControlTitle = tr("Show Vinyl Control Section");
    QString showVinylControlText = tr("Show the vinyl control section of the Mixxx interface.") +
            " " + mayNotBeSupported;
    QAction* pViewVinylControl = new QAction(showVinylControlTitle, this);
    pViewVinylControl->setCheckable(true);
    pViewVinylControl->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(
            ConfigKey("[KeyboardShortcuts]", "ViewMenu_ShowVinylControl"),
            tr("Ctrl+3", "Menubar|View|Show Vinyl Control Section"))));
    pViewVinylControl->setStatusTip(showVinylControlText);
    pViewVinylControl->setWhatsThis(buildWhatsThis(showVinylControlTitle, showVinylControlText));
    createVisibilityControl(pViewVinylControl, ConfigKey(VINYL_PREF_KEY, "show_vinylcontrol"));
    pViewMenu->addAction(pViewVinylControl);
#endif

    QString showPreviewDeckTitle = tr("Show Preview Deck");
    QString showPreviewDeckText = tr("Show the preview deck in the Mixxx interface.") +
            " " + mayNotBeSupported;
    QAction* pViewShowPreviewDeck = new QAction(showPreviewDeckTitle, this);
    pViewShowPreviewDeck->setCheckable(true);
    pViewShowPreviewDeck->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_ShowPreviewDeck"),
                                                  tr("Ctrl+4", "Menubar|View|Show Preview Deck"))));
    pViewShowPreviewDeck->setStatusTip(showPreviewDeckText);
    pViewShowPreviewDeck->setWhatsThis(buildWhatsThis(showPreviewDeckTitle, showPreviewDeckText));
    createVisibilityControl(pViewShowPreviewDeck, ConfigKey("[PreviewDeck]", "show_previewdeck"));
    pViewMenu->addAction(pViewShowPreviewDeck);

    QString showEffectsTitle = tr("Show Effect Rack");
    QString showEffectsText = tr("Show the effect rack in the Mixxx interface.") +
    " " + mayNotBeSupported;
    QAction* pViewShowEffects = new QAction(showEffectsTitle, this);
    pViewShowEffects->setCheckable(true);
    pViewShowEffects->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_ShowEffects"),
                                                  tr("Ctrl+5", "Menubar|View|Show Effect Rack"))));
    pViewShowEffects->setStatusTip(showEffectsText);
    pViewShowEffects->setWhatsThis(buildWhatsThis(showEffectsTitle, showEffectsText));
    createVisibilityControl(pViewShowEffects, ConfigKey("[EffectRack1]", "show"));
    pViewMenu->addAction(pViewShowEffects);


    QString showCoverArtTitle = tr("Show Cover Art");
    QString showCoverArtText = tr("Show cover art in the Mixxx interface.") +
            " " + mayNotBeSupported;
    QAction* pViewShowCoverArt = new QAction(showCoverArtTitle, this);
    pViewShowCoverArt->setCheckable(true);
    pViewShowCoverArt->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_ShowCoverArt"),
                                                  tr("Ctrl+6", "Menubar|View|Show Cover Art"))));
    pViewShowCoverArt->setStatusTip(showCoverArtText);
    pViewShowCoverArt->setWhatsThis(buildWhatsThis(showCoverArtTitle, showCoverArtText));
    createVisibilityControl(pViewShowCoverArt, ConfigKey("[Library]", "show_coverart"));
    pViewMenu->addAction(pViewShowCoverArt);


    QString maximizeLibraryTitle = tr("Maximize Library");
    QString maximizeLibraryText = tr("Maximize the track library to take up all the available screen space.") +
            " " + mayNotBeSupported;
    QAction* pViewMaximizeLibrary = new QAction(maximizeLibraryTitle, this);
    pViewMaximizeLibrary->setCheckable(true);
    pViewMaximizeLibrary->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_MaximizeLibrary"),
                                                  tr("Space", "Menubar|View|Maximize Library"))));
    pViewMaximizeLibrary->setStatusTip(maximizeLibraryText);
    pViewMaximizeLibrary->setWhatsThis(buildWhatsThis(maximizeLibraryTitle, maximizeLibraryText));
    createVisibilityControl(pViewMaximizeLibrary, ConfigKey("[Master]", "maximize_library"));
    pViewMenu->addAction(pViewMaximizeLibrary);


    pViewMenu->addSeparator();


    QString fullScreenTitle = tr("&Full Screen");
    QString fullScreenText = tr("Display Mixxx using the full screen");
    QAction* pViewFullScreen = new QAction(fullScreenTitle, this);
    pViewFullScreen->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "ViewMenu_Fullscreen"),
                                                  fullScreenDefaultKeyBinding())));
    pViewFullScreen->setShortcutContext(Qt::ApplicationShortcut);
    pViewFullScreen->setCheckable(true);
    pViewFullScreen->setChecked(false);
    pViewFullScreen->setStatusTip(fullScreenText);
    pViewFullScreen->setWhatsThis(buildWhatsThis(fullScreenTitle, fullScreenText));
    connect(pViewFullScreen, SIGNAL(triggered(bool)),
            this, SIGNAL(toggleFullScreen(bool)));
    connect(this, SIGNAL(internalFullScreenStateChange(bool)),
            pViewFullScreen, SLOT(setChecked(bool)));
    pViewMenu->addAction(pViewFullScreen);

    addMenu(pViewMenu);

    // OPTIONS MENU
    QMenu* pOptionsMenu = new QMenu(tr("&Options"));

#ifdef __VINYLCONTROL__
    QMenu* pVinylControlMenu = new QMenu(tr("&Vinyl Control"));
    QString vinylControlText = tr(
            "Use timecoded vinyls on external turntables to control Mixxx");

    for (int i = 0; i < kMaximumVinylControlInputs; ++i) {
        QString vinylControlTitle = tr("Enable Vinyl Control &%1").arg(i + 1);
        QAction* vc_checkbox = new QAction(vinylControlTitle, this);
        m_vinylControlEnabledActions.push_back(vc_checkbox);

        QString binding = m_pKbdConfig->getValueString(
            ConfigKey("[KeyboardShortcuts]",
                      QString("OptionsMenu_EnableVinyl%1").arg(i + 1)),
            vinylControlDefaultKeyBinding(i));
        if (!binding.isEmpty()) {
            vc_checkbox->setShortcut(QKeySequence(binding));
            vc_checkbox->setShortcutContext(Qt::ApplicationShortcut);
        }

        // Either check or uncheck the vinyl control menu item depending on what
        // it was saved as.
        vc_checkbox->setCheckable(true);
        vc_checkbox->setChecked(false);
        // The visibility of these actions is set in
        // WMainMenuBar::onNumberOfDecksChanged.
        vc_checkbox->setVisible(false);
        vc_checkbox->setStatusTip(vinylControlText);
        vc_checkbox->setWhatsThis(buildWhatsThis(vinylControlTitle,
                                                 vinylControlText));

        m_vinylControlEnabledMapper.setMapping(vc_checkbox, i);
        connect(vc_checkbox, SIGNAL(triggered(bool)),
                &m_vinylControlEnabledMapper, SLOT(map()));
        pVinylControlMenu->addAction(vc_checkbox);
    }
    pOptionsMenu->addMenu(pVinylControlMenu);
    pOptionsMenu->addSeparator();
#endif

    QString recordTitle = tr("&Record Mix");
    QString recordText = tr("Record your mix to a file");
    QAction* pOptionsRecord = new QAction(recordTitle, this);
    pOptionsRecord->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "OptionsMenu_RecordMix"),
                                                  tr("Ctrl+R"))));
    pOptionsRecord->setShortcutContext(Qt::ApplicationShortcut);
    pOptionsRecord->setCheckable(true);
    pOptionsRecord->setStatusTip(recordText);
    pOptionsRecord->setWhatsThis(buildWhatsThis(recordTitle, recordText));
    connect(pOptionsRecord, SIGNAL(triggered(bool)),
            this, SIGNAL(toggleRecording(bool)));
    connect(this, SIGNAL(internalRecordingStateChange(bool)),
            pOptionsRecord, SLOT(setChecked(bool)));
    pOptionsMenu->addAction(pOptionsRecord);

#ifdef __SHOUTCAST__
    QString broadcastingTitle = tr("Enable Live &Broadcasting");
    QString broadcastingText = tr("Stream your mixes to a shoutcast or icecast server");
    QAction* pOptionsBroadcasting = new QAction(broadcastingTitle, this);
    pOptionsBroadcasting->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(
                    ConfigKey("[KeyboardShortcuts]",
                              "OptionsMenu_EnableLiveBroadcasting"),
                    tr("Ctrl+L"))));
    pOptionsBroadcasting->setShortcutContext(Qt::ApplicationShortcut);
    pOptionsBroadcasting->setCheckable(true);
    pOptionsBroadcasting->setStatusTip(broadcastingText);
    pOptionsBroadcasting->setWhatsThis(buildWhatsThis(broadcastingTitle, broadcastingText));

    connect(pOptionsBroadcasting, SIGNAL(triggered(bool)),
            this, SIGNAL(toggleBroadcasting(bool)));
    connect(this, SIGNAL(internalBroadcastingStateChange(bool)),
            pOptionsBroadcasting, SLOT(setChecked(bool)));
    pOptionsMenu->addAction(pOptionsBroadcasting);
#endif

    pOptionsMenu->addSeparator();

    QString keyboardShortcutTitle = tr("Enable &Keyboard Shortcuts");
    QString keyboardShortcutText = tr("Toggles keyboard shortcuts on or off");
    bool keyboardShortcutsEnabled = m_pConfig->getValueString(
        ConfigKey("[Keyboard]", "Enabled")) == "1";
    QAction* pOptionsKeyboard = new QAction(keyboardShortcutTitle, this);
    pOptionsKeyboard->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "OptionsMenu_EnableShortcuts"),
                                                  tr("Ctrl+`"))));
    pOptionsKeyboard->setShortcutContext(Qt::ApplicationShortcut);
    pOptionsKeyboard->setCheckable(true);
    pOptionsKeyboard->setChecked(keyboardShortcutsEnabled);
    pOptionsKeyboard->setStatusTip(keyboardShortcutText);
    pOptionsKeyboard->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
    connect(pOptionsKeyboard, SIGNAL(triggered(bool)),
            this, SIGNAL(toggleKeyboardShortcuts(bool)));

    pOptionsMenu->addAction(pOptionsKeyboard);

    pOptionsMenu->addSeparator();

    QString preferencesTitle = tr("&Preferences");
    QString preferencesText = tr("Change Mixxx settings (e.g. playback, MIDI, controls)");
    QAction* pOptionsPreferences = new QAction(preferencesTitle, this);
    pOptionsPreferences->setShortcut(
        QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                  "OptionsMenu_Preferences"),
                                                  showPreferencesKeyBinding())));
    pOptionsPreferences->setShortcutContext(Qt::ApplicationShortcut);
    pOptionsPreferences->setStatusTip(preferencesText);
    pOptionsPreferences->setWhatsThis(buildWhatsThis(preferencesTitle, preferencesText));
    pOptionsPreferences->setMenuRole(QAction::PreferencesRole);
    connect(pOptionsPreferences, SIGNAL(triggered()),
            this, SIGNAL(showPreferences()));
    pOptionsMenu->addAction(pOptionsPreferences);

    addMenu(pOptionsMenu);

    // DEVELOPER MENU
    if (CmdlineArgs::Instance().getDeveloper()) {
        QMenu* pDeveloperMenu = new QMenu(tr("&Developer"));

        QString reloadSkinTitle = tr("&Reload Skin");
        QString reloadSkinText = tr("Reload the skin");
        QAction* pDeveloperReloadSkin = new QAction(reloadSkinTitle, this);
        pDeveloperReloadSkin->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                                "OptionsMenu_ReloadSkin"),
                                                      tr("Ctrl+Shift+R"))));
        pDeveloperReloadSkin->setShortcutContext(Qt::ApplicationShortcut);
        pDeveloperReloadSkin->setStatusTip(reloadSkinText);
        pDeveloperReloadSkin->setWhatsThis(buildWhatsThis(reloadSkinTitle, reloadSkinText));
        connect(pDeveloperReloadSkin, SIGNAL(triggered()),
                this, SIGNAL(reloadSkin()));
        pDeveloperMenu->addAction(pDeveloperReloadSkin);

        QString developerToolsTitle = tr("Developer &Tools");
        QString developerToolsText = tr("Opens the developer tools dialog");
        QAction* pDeveloperTools = new QAction(developerToolsTitle, this);
        pDeveloperTools->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                                "OptionsMenu_DeveloperTools"),
                                                      tr("Ctrl+Shift+T"))));
        pDeveloperTools->setShortcutContext(Qt::ApplicationShortcut);
        pDeveloperTools->setCheckable(true);
        pDeveloperTools->setChecked(false);
        pDeveloperTools->setStatusTip(developerToolsText);
        pDeveloperTools->setWhatsThis(buildWhatsThis(developerToolsTitle, developerToolsText));
        connect(pDeveloperTools, SIGNAL(triggered(bool)),
                this, SIGNAL(toggleDeveloperTools(bool)));
        connect(this, SIGNAL(internalDeveloperToolsStateChange(bool)),
                pDeveloperTools, SLOT(setChecked(bool)));
        pDeveloperMenu->addAction(pDeveloperTools);

        QString enableExperimentTitle = tr("Stats: &Experiment Bucket");
        QString enableExperimentToolsText = tr(
            "Enables experiment mode. Collects stats in the EXPERIMENT tracking bucket.");
        QAction* pDeveloperStatsExperiment = new QAction(enableExperimentTitle, this);
        pDeveloperStatsExperiment->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                                "OptionsMenu_DeveloperStatsExperiment"),
                                                      tr("Ctrl+Shift+E"))));
        pDeveloperStatsExperiment->setShortcutContext(Qt::ApplicationShortcut);
        pDeveloperStatsExperiment->setStatusTip(enableExperimentToolsText);
        pDeveloperStatsExperiment->setWhatsThis(buildWhatsThis(
            enableExperimentTitle, enableExperimentToolsText));
        pDeveloperStatsExperiment->setCheckable(true);
        pDeveloperStatsExperiment->setChecked(Experiment::isExperiment());
        connect(pDeveloperStatsExperiment, SIGNAL(triggered(bool)),
                this, SLOT(slotDeveloperStatsExperiment(bool)));
        pDeveloperMenu->addAction(pDeveloperStatsExperiment);

        QString enableBaseTitle = tr("Stats: &Base Bucket");
        QString enableBaseToolsText = tr(
            "Enables base mode. Collects stats in the BASE tracking bucket.");
        QAction* pDeveloperStatsBase = new QAction(enableBaseTitle, this);
        pDeveloperStatsBase->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                                "OptionsMenu_DeveloperStatsBase"),
                                                      tr("Ctrl+Shift+B"))));
        pDeveloperStatsBase->setShortcutContext(Qt::ApplicationShortcut);
        pDeveloperStatsBase->setStatusTip(enableBaseToolsText);
        pDeveloperStatsBase->setWhatsThis(buildWhatsThis(
            enableBaseTitle, enableBaseToolsText));
        pDeveloperStatsBase->setCheckable(true);
        pDeveloperStatsBase->setChecked(Experiment::isBase());
        connect(pDeveloperStatsBase, SIGNAL(triggered(bool)),
                this, SLOT(slotDeveloperStatsBase(bool)));
        pDeveloperMenu->addAction(pDeveloperStatsBase);

        // "D" cannont be used with Alt here as it is already by the Developer menu
        QString scriptDebuggerTitle = tr("Deb&ugger Enabled");
        QString scriptDebuggerText = tr("Enables the debugger during skin parsing");
        bool scriptDebuggerEnabled = m_pConfig->getValueString(
            ConfigKey("[ScriptDebugger]", "Enabled")) == "1";
        QAction* pDeveloperDebugger = new QAction(scriptDebuggerTitle, this);
        pDeveloperDebugger->setShortcut(
            QKeySequence(m_pKbdConfig->getValueString(ConfigKey("[KeyboardShortcuts]",
                                                                "DeveloperMenu_EnableDebugger"),
                                                      tr("Ctrl+Shift+D"))));
        pDeveloperDebugger->setShortcutContext(Qt::ApplicationShortcut);
        pDeveloperDebugger->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
        pDeveloperDebugger->setCheckable(true);
        pDeveloperDebugger->setStatusTip(scriptDebuggerText);
        pDeveloperDebugger->setChecked(scriptDebuggerEnabled);
        connect(pDeveloperDebugger, SIGNAL(triggered(bool)),
                this, SLOT(slotDeveloperDebugger(bool)));
        pDeveloperMenu->addAction(pDeveloperDebugger);

        addMenu(pDeveloperMenu);
    }
Ejemplo n.º 25
0
void MainMenu::init()
{
#define ADD_ACTION(name, menu, icon, trName, slot, shortcut) \
    action = menu->addAction(icon, trName); \
    action->setShortcut(QKeySequence(QSL(shortcut))); \
    connect(action, SIGNAL(triggered()), this, slot); \
    m_actions[QSL(name)] = action

#define ADD_CHECKABLE_ACTION(name, menu, icon, trName, slot, shortcut) \
    action = menu->addAction(icon, trName); \
    action->setShortcut(QKeySequence(QSL(shortcut))); \
    action->setCheckable(true); \
    connect(action, SIGNAL(triggered(bool)), this, slot); \
    m_actions[QSL(name)] = action

    // Standard actions - needed on Mac to be placed correctly in "application" menu
    QAction* action = new QAction(QIcon::fromTheme(QSL("help-about")), tr("&About QupZilla"), this);
    action->setMenuRole(QAction::AboutRole);
    connect(action, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
    m_actions[QSL("Standard/About")] = action;

    action = new QAction(IconProvider::settingsIcon(), tr("Pr&eferences"), this);
    action->setMenuRole(QAction::PreferencesRole);
    action->setShortcut(QKeySequence(QKeySequence::Preferences));
    connect(action, SIGNAL(triggered()), this, SLOT(showPreferences()));
    m_actions[QSL("Standard/Preferences")] = action;

    action = new QAction(QIcon::fromTheme(QSL("application-exit")), tr("Quit"), this);
    action->setMenuRole(QAction::QuitRole);
    // shortcut set from browserwindow
    connect(action, SIGNAL(triggered()), this, SLOT(quitApplication()));
    m_actions[QSL("Standard/Quit")] = action;

    // File menu
    m_menuFile = new QMenu(tr("&File"));
    connect(m_menuFile, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFileMenu()));
    connect(m_menuFile, SIGNAL(aboutToHide()), this, SLOT(aboutToHideFileMenu()));

    ADD_ACTION("File/NewTab", m_menuFile, IconProvider::newTabIcon(), tr("New Tab"), SLOT(newTab()), "Ctrl+T");
    ADD_ACTION("File/NewWindow", m_menuFile, IconProvider::newWindowIcon(), tr("&New Window"), SLOT(newWindow()), "Ctrl+N");
    ADD_ACTION("File/NewPrivateWindow", m_menuFile, IconProvider::privateBrowsingIcon(), tr("New &Private Window"), SLOT(newPrivateWindow()), "Ctrl+Shift+P");
    ADD_ACTION("File/OpenLocation", m_menuFile, QIcon::fromTheme(QSL("document-open-remote")), tr("Open Location"), SLOT(openLocation()), "Ctrl+L");
    ADD_ACTION("File/OpenFile", m_menuFile, QIcon::fromTheme(QSL("document-open")), tr("Open &File..."), SLOT(openFile()), "Ctrl+O");
    ADD_ACTION("File/CloseWindow", m_menuFile, QIcon::fromTheme(QSL("window-close")), tr("Close Window"), SLOT(closeWindow()), "Ctrl+Shift+W");
    m_menuFile->addSeparator();
    ADD_ACTION("File/SavePageAs", m_menuFile, QIcon::fromTheme(QSL("document-save")), tr("&Save Page As..."), SLOT(savePageAs()), "Ctrl+S");
    ADD_ACTION("File/SavePageScreen", m_menuFile, QIcon::fromTheme(QSL("image-loading")), tr("Save Page Screen"), SLOT(savePageScreen()), "Ctrl+Shift+S");
    ADD_ACTION("File/SendLink", m_menuFile, QIcon::fromTheme(QSL("mail-message-new")), tr("Send Link..."), SLOT(sendLink()), "");
    ADD_ACTION("File/Print", m_menuFile, QIcon::fromTheme(QSL("document-print")), tr("&Print..."), SLOT(printPage()), "Ctrl+P");
    m_menuFile->addSeparator();
    ADD_CHECKABLE_ACTION("File/WorkOffline", m_menuFile, QIcon(), tr("Work &Offline"), SLOT(toggleOfflineMode()), "");
    m_menuFile->addSeparator();
    m_menuFile->addAction(m_actions[QSL("Standard/Quit")]);

    // Edit menu
    m_menuEdit = new QMenu(tr("&Edit"));
    connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
    connect(m_menuEdit, SIGNAL(aboutToHide()), this, SLOT(aboutToHideEditMenu()));

    ADD_ACTION("Edit/Undo", m_menuEdit, QIcon::fromTheme(QSL("edit-undo")), tr("&Undo"), SLOT(editUndo()), "Ctrl+Z");
    ADD_ACTION("Edit/Redo", m_menuEdit, QIcon::fromTheme(QSL("edit-redo")), tr("&Redo"), SLOT(editRedo()), "Ctrl+Shift+Z");
    m_menuEdit->addSeparator();
    ADD_ACTION("Edit/Cut", m_menuEdit, QIcon::fromTheme(QSL("edit-cut")), tr("&Cut"), SLOT(editCut()), "Ctrl+X");
    ADD_ACTION("Edit/Copy", m_menuEdit, QIcon::fromTheme(QSL("edit-copy")), tr("C&opy"), SLOT(editCopy()), "Ctrl+C");
    ADD_ACTION("Edit/Paste", m_menuEdit, QIcon::fromTheme(QSL("edit-paste")), tr("&Paste"), SLOT(editPaste()), "Ctrl+V");
    m_menuEdit->addSeparator();
    ADD_ACTION("Edit/SelectAll", m_menuEdit, QIcon::fromTheme(QSL("edit-select-all")), tr("Select &All"), SLOT(editSelectAll()), "Ctrl+A");
    ADD_ACTION("Edit/Find", m_menuEdit, QIcon::fromTheme(QSL("edit-find")), tr("&Find"), SLOT(editFind()), "Ctrl+F");
    m_menuEdit->addSeparator();

    // View menu
    m_menuView = new QMenu(tr("&View"));
    connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
    connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu()));

    QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
    connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu()));
    QMenu* sidebarMenu = new QMenu(tr("Sidebar"));
    connect(sidebarMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu()));
    QMenu* encodingMenu = new QMenu(tr("Character &Encoding"));
    connect(encodingMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));

    // Create menus to make shortcuts available even before first showing the menu
    m_window->createToolbarsMenu(toolbarsMenu);
    m_window->createSidebarsMenu(sidebarMenu);

    m_menuView->addMenu(toolbarsMenu);
    m_menuView->addMenu(sidebarMenu);
    ADD_CHECKABLE_ACTION("View/ShowStatusBar", m_menuView, QIcon(), tr("Sta&tus Bar"), SLOT(showStatusBar()), "");
    m_menuView->addSeparator();
    ADD_ACTION("View/Stop", m_menuView, QIcon::fromTheme(QSL("process-stop")), tr("&Stop"), SLOT(stop()), "Esc");
    ADD_ACTION("View/Reload", m_menuView, QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), SLOT(reload()), "F5");
    m_menuView->addSeparator();
    ADD_ACTION("View/ZoomIn", m_menuView, QIcon::fromTheme(QSL("zoom-in")), tr("Zoom &In"), SLOT(zoomIn()), "Ctrl++");
    ADD_ACTION("View/ZoomOut", m_menuView, QIcon::fromTheme(QSL("zoom-out")), tr("Zoom &Out"), SLOT(zoomOut()), "Ctrl+-");
    ADD_ACTION("View/ZoomReset", m_menuView, QIcon::fromTheme(QSL("zoom-original")), tr("Reset"), SLOT(zoomReset()), "Ctrl+0");
    m_menuView->addSeparator();
    ADD_CHECKABLE_ACTION("View/CaretBrowsing", m_menuView, QIcon(), tr("&Caret Browsing"), SLOT(toggleCaretBrowsing()), "F7");
    m_menuView->addMenu(encodingMenu);
    m_menuView->addSeparator();
    ADD_ACTION("View/PageSource", m_menuView, QIcon::fromTheme(QSL("text-html")), tr("&Page Source"), SLOT(showPageSource()), "Ctrl+U");
    ADD_CHECKABLE_ACTION("View/FullScreen", m_menuView, QIcon(), tr("&FullScreen"), SLOT(showFullScreen()), "F11");

    // Tools menu
    m_menuTools = new QMenu(tr("&Tools"));
    connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
    connect(m_menuTools, SIGNAL(aboutToHide()), this, SLOT(aboutToHideToolsMenu()));

    ADD_ACTION("Tools/WebSearch", m_menuTools, QIcon(), tr("&Web Search"), SLOT(webSearch()), "Ctrl+K");
    ADD_ACTION("Tools/SiteInfo", m_menuTools, QIcon::fromTheme(QSL("dialog-information")), tr("Site &Info"), SLOT(showSiteInfo()), "Ctrl+I");
    m_menuTools->addSeparator();
    ADD_ACTION("Tools/DownloadManager", m_menuTools, QIcon(), tr("&Download Manager"), SLOT(showDownloadManager()), "Ctrl+Y");
    ADD_ACTION("Tools/CookiesManager", m_menuTools, QIcon(), tr("&Cookies Manager"), SLOT(showCookieManager()), "");
    ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), "");
    ADD_ACTION("Tools/RssReader", m_menuTools, QIcon(), tr("RSS &Reader"), SLOT(showRssManager()), "");
    ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(showWebInspector()), "Ctrl+Shift+I");
    ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del");
    m_menuTools->addSeparator();

    // Help menu
    m_menuHelp = new QMenu(tr("&Help"));

#ifndef Q_OS_MAC
    ADD_ACTION("Help/AboutQt", m_menuHelp, QIcon(QSL(":/icons/menu/qt.png")), tr("About &Qt"), SLOT(aboutQt()), "");
    m_menuHelp->addAction(m_actions[QSL("Standard/About")]);
    m_menuHelp->addSeparator();
#endif

    ADD_ACTION("Help/InfoAboutApp", m_menuHelp, QIcon::fromTheme(QSL("help-contents")), tr("Information about application"), SLOT(showInfoAboutApp()), "");
    ADD_ACTION("Help/ConfigInfo", m_menuHelp, QIcon(), tr("Configuration Information"), SLOT(showConfigInfo()), "");
    ADD_ACTION("Help/ReportIssue", m_menuHelp, QIcon(), tr("Report &Issue"), SLOT(reportIssue()), "");

    m_actions[QSL("Help/InfoAboutApp")]->setShortcut(QKeySequence(QKeySequence::HelpContents));

    // History menu
    m_menuHistory = new HistoryMenu();
    m_menuHistory->setMainWindow(m_window);

    // Bookmarks menu
    m_menuBookmarks = new BookmarksMenu();
    m_menuBookmarks->setMainWindow(m_window);

    // Other actions
    action = new QAction(QIcon::fromTheme(QSL("user-trash")), tr("Restore &Closed Tab"), this);
    action->setShortcut(QKeySequence(QSL("Ctrl+Shift+T")));
    connect(action, SIGNAL(triggered()), this, SLOT(restoreClosedTab()));
    m_actions[QSL("Other/RestoreClosedTab")] = action;

#ifdef Q_OS_MAC
    m_actions[QSL("View/FullScreen")]->setShortcut(QKeySequence(QSL("F11")));

    // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "Application" menu
    m_menuFile->addAction(m_actions[QSL("Standard/About")]);
    m_menuFile->addAction(m_actions[QSL("Standard/Preferences")]);
#endif

#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
    m_menuEdit->addAction(m_actions[QSL("Standard/Preferences")]);
#elif !defined(Q_OS_MAC)
    m_menuTools->addAction(m_actions[QSL("Standard/Preferences")]);
#endif

#ifndef QTWEBKIT_FROM_2_3
    m_actions[QSL("View/CaretBrowsing")]->setVisible(false);
#endif

    // Menus are hidden by default
    aboutToHideFileMenu();
    aboutToHideViewMenu();
    aboutToHideEditMenu();
    aboutToHideToolsMenu();

    addActionsToWindow();
}