Esempio n. 1
0
// 
// The files addons.sqlite (stores the information that appears in the Addons tab > Extensions) and extensions.sqlite (stores data about installed extensions)
// are the places where the extensions information is stored. Instead of reading these files and entering into SqlLite dependencies, we look for the 
// extensions files on disk
bool FirefoxAddOn::IsAddOnInstalled(wstring applicationID)
{
	wstring path;
	wifstream reader;
	FirefoxPreferencesFile preferences(m_profileRootDir);
	wchar_t szPath[MAX_PATH];

	// Is extension installed in profile/extension directory? (location used when user installs the extension)
	if (preferences.GetPreferencesDirectory(path) == false)
	{
		g_log.Log(L"FirefoxAddOn::IsAddOnInstalled. No preferences directory");
		return false;
	}

	swprintf_s(szPath, L"%s\\extensions\\%s.xpi", path.c_str(), applicationID.c_str());
	if (GetFileAttributes(szPath) != INVALID_FILE_ATTRIBUTES)
	{
		return true;
	}

	// Is extension installed in m_userDataDirectory/extension directory? (location used for automated installations)
	swprintf_s(szPath, L"%sExtensions\\%s\\%s.xpi", m_userDataDirectory.c_str(), FIREFOX_EXTENSION_ID_GUID, applicationID.c_str());
	if (GetFileAttributes(szPath) != INVALID_FILE_ATTRIBUTES)
	{
		return true;
	}	
	return false;
}
TEST(WebKit2, PrivateBrowsingPushStateNoHistoryCallback)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());

    WKContextHistoryClient historyClient;
    memset(&historyClient, 0, sizeof(historyClient));

    historyClient.version = 0;
    historyClient.clientInfo = 0;
    historyClient.didNavigateWithNavigationData = didNavigateWithNavigationData;
    WKContextSetHistoryClient(context.get(), &historyClient);

    PlatformWebView webView(context.get());

    WKPageLoaderClient pageLoaderClient;
    memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));

    pageLoaderClient.version = 0;
    pageLoaderClient.clientInfo = 0;
    pageLoaderClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
    WKPageSetPageLoaderClient(webView.page(), &pageLoaderClient);

    WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate());
    WKPreferencesSetPrivateBrowsingEnabled(preferences.get(), true);

    WKPageGroupRef pageGroup = WKPageGetPageGroup(webView.page());
    WKPageGroupSetPreferences(pageGroup, preferences.get());

    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("push-state", "html"));
    WKPageLoadURL(webView.page(), url.get());

    Util::run(&testDone);
}
Esempio n. 3
0
kweather::kweather(const TQString& configFile, Type t, int actions,
        TQWidget *parent, const char *name):
        KPanelApplet(configFile, t, actions, parent, name), weatherIface(),
        mFirstRun( false ), mReport( 0 ), mClient( 0 ),
        mContextMenu( 0 ), mWeatherService( 0 ), settingsDialog( 0 ), mTextColor(TQt::black)
{
    kdDebug(12004) << "Constructor " << endl;
    setObjId("weatherIface");
    
    setBackgroundOrigin( TQWidget::AncestorOrigin );
    loadPrefs();
    initContextMenu();
    initDCOP();
    
    dockWidget = new dockwidget(reportLocation, this, "dockwidget");
    connect(dockWidget, TQT_SIGNAL(buttonClicked()), TQT_SLOT(doReport()));
    dockWidget->setViewMode(mViewMode);
    setLabelColor();
    
    timeOut = new TQTimer(this, "timeOut" );
    connect(timeOut, TQT_SIGNAL(timeout()), TQT_SLOT(timeout()));
    timeOut->start(10*60*1000);
    
    if(mFirstRun)
        preferences();
    else
        timeout();
}
Esempio n. 4
0
FreeSSM::~FreeSSM()
{
	disconnect( _dump_action, SIGNAL( triggered() ), this, SLOT( dumpCUdata() ) );
	disconnect( engine_pushButton, SIGNAL( released() ), this, SLOT( engine() ) );
	disconnect( transmission_pushButton, SIGNAL( released() ), this, SLOT( transmission() ) );
	disconnect( absvdc_pushButton, SIGNAL( released() ), this, SLOT( abs() ) );
	disconnect( cruisecontrol_pushButton, SIGNAL( released() ), this, SLOT( cruisecontrol() ) );
	disconnect( aircon_pushButton, SIGNAL( released() ), this, SLOT( aircon() ) );
	disconnect( preferences_pushButton, SIGNAL( released() ), this, SLOT( preferences() ) );
	disconnect( help_pushButton, SIGNAL( released() ), this, SLOT( help() ) );
	disconnect( about_pushButton, SIGNAL( released() ), this, SLOT( about() ) );
	disconnect( exit_pushButton, SIGNAL( released() ), this, SLOT( close() ) );
	delete _dump_action;
#ifndef SMALL_RESOLUTION
	delete _progtitle_label;
#endif
	if (_translator != NULL)
	{
		QApplication::removeTranslator(_translator);
		delete _translator;
	}
	if (_qt_translator != NULL)
	{
		QApplication::removeTranslator(_qt_translator);
		delete _qt_translator;
	}
}
// =============================================================================
void MainWindow::preferences()
{
    PreferencesDialog preferences(this);
    preferences.exec();

    // Update all time tracking timers
    updateTrackingActions();
}
Esempio n. 6
0
bool FirefoxAddOn::CanInstallAddOns()
{
	FirefoxPreferencesFile preferences(m_profileRootDir);
	bool canInstall;
	wstring path;
	
	canInstall = preferences.GetPreferencesDirectory(path);
	g_log.Log(L"FirefoxAddOn::CanInstallAddOns. Result %u", (wchar_t*) canInstall);
	return canInstall;
}
Esempio n. 7
0
QMenuBar* MainMenuHandler::newMenuBar(){
  QMenuBar* menuBar = new QMenuBar(0);
  QMenu* menuFile = menuBar->addMenu("File");
  menuFile->addAction("New Detail Window",this,SLOT(new_Detail_Window()),QKeySequence("Ctrl+N"));
  menuFile->addAction("New Batch Window",this,SLOT(new_Batch_Window()),QKeySequence("Ctrl+Shift+N"));
  menuFile->addSeparator();
  menuFile->addAction("Close Window",this,SLOT(close_Window()),QKeySequence("Ctrl+W"));
#ifdef Q_OS_MAC
  menuFile->addAction("Preferences",this,SLOT(preferences()));
  menuFile->addAction("About",this,SLOT(about()));
#endif
#ifdef Q_OS_WIN
  QMenu* menuEdit = menuBar->addMenu("Edit");
  menuEdit->addAction("Preferences",this,SLOT(preferences()));
  QMenu* menuHelp = menuBar->addMenu("Help");
  menuHelp->addAction("About",this,SLOT(about()));
#endif
  return menuBar;
}
Esempio n. 8
0
void KPanelExtension::action( Action a )
{
  if ( (a & About) )
    about();
  if ( (a & Help) )
    help();
  if ( (a & Preferences) )
    preferences();
  if ( (a & ReportBug) )
    reportBug();
}
Esempio n. 9
0
void kweather::initContextMenu()
{
    mContextMenu = new TDEPopupMenu(this);
    mContextMenu->insertTitle(i18n("KWeather - %1").arg( reportLocation ), -1, 0);
    mContextMenu->insertItem(SmallIcon("viewmag"), i18n("Show &Report"),
        this, TQT_SLOT(doReport()), 0, -1, 1);
    mContextMenu->insertItem(SmallIcon("reload"), i18n("&Update Now"),
        this, TQT_SLOT(slotUpdateNow()), 0, -1, 2);
    mContextMenu->insertSeparator();
    mContextMenu->insertItem(SmallIcon("kweather"), i18n("&About KWeather"), this, TQT_SLOT(about()));
    mContextMenu->insertItem(SmallIcon("configure"),
        i18n("&Configure KWeather..."), this, TQT_SLOT(preferences()));
    setCustomMenu(mContextMenu);
}
void SvCreator::fetchSourceList(int type, QMap<QString, SourceT>& sourceInfos)
{
  GuiPreferences preferences(Auth::OpUserRole, Preferences::NoForm);
  preferences.updateSourceStates();
  SourceT srcInfo;
  QStringList sourceList;
  for (int i = 0; i< MAX_SRCS; ++i) {
    if (preferences.loadSource(i, srcInfo)) {
      if (srcInfo.mon_type == type || type == MonitorT::Auto) {
        sourceList.push_back(srcInfo.id);
        sourceInfos.insert(srcInfo.id, srcInfo);
      }
    }
  }
}
vector<int> MapsMerge::GaleShapleyMatcherStrategy::findPreferences(const vector<int> numMatches) {
	int length = numMatches.size();
	vector<pair<int, int>> vecPairsNumMatches(length);
	for(int i = 0; i < length; i++) {
		vecPairsNumMatches[i] = pair<int,int>(i, numMatches[i]);
	}

	sort(vecPairsNumMatches.begin(), vecPairsNumMatches.end(), comparePair);	
	
	vector<int> preferences(length);
	for (int i = 0; i < length; i++) {
		preferences[i] = vecPairsNumMatches[i].first;
	}

	return preferences;
}
Esempio n. 12
0
/** Display the current weather report. */
void kweather::doReport()
{
    if ( reportLocation.isEmpty() )
    {
        // no station to display defined -> open settings dialog
        preferences();
        return;
    }

    kdDebug(12004) << "Showing out the report" << endl;
    if ( mReport == 0 )
    {
        mReport = new reportView(reportLocation);
    
        connect( mReport, TQT_SIGNAL( finished() ), TQT_SLOT( slotReportFinished() ) );
    }
    
    mReport->show();
    mReport->raise();
}
Esempio n. 13
0
// There are 3 places where extensions can be installed
//
// 1. %PROGRAMFILES%\Mozilla Firefox\browser\extensions
// 2. %appdata%\Extensions\{ec8030f7-c20a-464f-9b0e-13a3a9e97384}\[email protected]
// 3. %appdata%\Mozilla\Firefox\Profiles\PROFILE_DIR\extensions
//
//  Only option 3 allows us to update the extensions after they have been installed
//
// https://developer.mozilla.org/en-US/docs/Installing_extensions
void FirefoxAddOn::InstallAddOn(wstring applicationID, wstring file)
{
	wstring extensionsDirectory, targetfile;
	wchar_t szPath[MAX_PATH];
	wstring path;
	FirefoxPreferencesFile preferences(m_profileRootDir);

	preferences.GetPreferencesDirectory(path);
	// Create directory if it is necessary
	swprintf_s(szPath, L"%s\\extensions", path.c_str());

	if (GetFileAttributes(szPath) == INVALID_FILE_ATTRIBUTES)
	{
		CreateDirectory(szPath, NULL);
	}

	swprintf_s(szPath, L"%s\\extensions\\%s.xpi", path.c_str(), applicationID.c_str());
	if (CopyFile(file.c_str(), szPath, false) == FALSE)
	{
		g_log.Log(L"FirefoxAddOn::InstallAddOn. Unable to copy extension to '%s'", szPath);
		return;
	}
}
Esempio n. 14
0
void SimpleUI::setupActions()
{
    KStdAction::open( napp, SLOT(fileOpen()), actionCollection(), "_file_open" );
    new KAction( i18n("&Properties"), 0, propertiesDialog, SLOT(show()),
        actionCollection(), "_file_properties" );
    KStdAction::quit( napp, SLOT(quit()), actionCollection(), "_file_quit");

     NoatunStdAction::playlist( actionCollection(), "view_playlist" );
    actionCollection()->insert(video->action( "half_size" ));
    actionCollection()->insert(video->action( "normal_size" ));
    actionCollection()->insert(video->action( "double_size" ));
    actionCollection()->insert(video->action( "fullscreen_mode" ));

    actionCollection()->insert(napp->pluginActionMenu());

    menubarAction = KStdAction::showMenubar(this, SLOT(showMenubar()),
        actionCollection());
    statusbarAction = KStdAction::showStatusbar(this, SLOT(showStatusbar()),
        actionCollection());
    NoatunStdAction::effects( actionCollection(), "effects" );
    NoatunStdAction::equalizer( actionCollection(), "equalizer" );
    NoatunStdAction::loop( actionCollection(), "loop_style" );
    KStdAction::preferences( napp, SLOT(preferences()), actionCollection() );
}
Esempio n. 15
0
void YouTubeDlGui::showPreferences() {
  Preferences preferences(this);
  preferences.exec();
  populateUi();
}
		void Preferences::Save(Configuration& cfg) const
		{
			Configuration::Section preferences( cfg["preferences"] );

			{
				Configuration::Section application( preferences["application"] );

				application[ "autostart"                ].YesNo() = settings[ AUTOSTART_EMULATION      ];
				application[ "run-background"           ].YesNo() = settings[ RUN_IN_BACKGROUND        ];
				application[ "start-fullscreen"         ].YesNo() = settings[ START_IN_FULLSCREEN      ];
				application[ "suppress-warnings"        ].YesNo() = settings[ SUPPRESS_WARNINGS        ];
				application[ "exit-power-off"           ].YesNo() = settings[ FIRST_UNLOAD_ON_EXIT     ];
				application[ "confirm-exit"             ].YesNo() = settings[ CONFIRM_EXIT             ];
				application[ "confirm-reset"            ].YesNo() = settings[ CONFIRM_RESET            ];
				application[ "allow-multiple-instances" ].YesNo() = settings[ ALLOW_MULTIPLE_INSTANCES ];

				application[ "priority" ].Str() =
				(
					settings.priority == PRIORITY_HIGH         ? "high"         :
					settings.priority == PRIORITY_ABOVE_NORMAL ? "above normal" :
                                                                 "normal"
				);

				application[ "favored-system" ].Str() =
				(
					settings.favoredSystem == Nes::Machine::FAVORED_NES_PAL ? "nes-pal"    :
					settings.favoredSystem == Nes::Machine::FAVORED_FAMICOM ? "famicom"    :
					settings.favoredSystem == Nes::Machine::FAVORED_DENDY   ? "dendy"      :
                                                                              "nes-ntsc"
				);

				application[ "favored-system-always-ask" ].YesNo() = settings.alwaysAskSystem;
			}

			{
				Configuration::Section save( preferences["save"] );

				save[ "logfile"         ].YesNo() = settings[ SAVE_LOGFILE          ];
				save[ "settings"        ].YesNo() = settings[ SAVE_SETTINGS         ];
				save[ "launcher"        ].YesNo() = settings[ SAVE_LAUNCHER         ];
				save[ "cheats"          ].YesNo() = settings[ SAVE_CHEATS           ];
				save[ "netplay-list"    ].YesNo() = settings[ SAVE_NETPLAY_GAMELIST ];
				save[ "window-main"     ].YesNo() = settings[ SAVE_WINDOWPOS        ];
				save[ "window-launcher" ].YesNo() = settings[ SAVE_LAUNCHERSIZE     ];
			}

			{
				Configuration::Section appearance( preferences["appearance"] );

				appearance[ "icon-style" ].Str() =
				(
					Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? "nes" :
																									"famicom"
				);

				appearance[ "menu-desktop"    ][ "use-custom-color" ].YesNo() = settings.menuLookDesktop.enabled;
				appearance[ "menu-fullscreen" ][ "use-custom-color" ].YesNo() = settings.menuLookFullscreen.enabled;

				appearance[ "menu-desktop"    ][ "custom-color" ].Str() = HexString( 32, settings.menuLookDesktop.color );
				appearance[ "menu-fullscreen" ][ "custom-color" ].Str() = HexString( 32, settings.menuLookFullscreen.color );
			}
		}
Esempio n. 17
0
void Portal::initActions()
{
  fileQuit = actionCollection()->addAction( KStandardAction::Quit, this, SLOT(slotFileQuit() ) );
  editCut = actionCollection()->addAction( KStandardAction::Cut, this, SLOT(slotEditCut() ) );
  editCopy = actionCollection()->addAction( KStandardAction::Copy, this, SLOT(slotEditCopy() ) );
  editPaste = actionCollection()->addAction( KStandardAction::Paste, this, SLOT(slotEditPaste() ) );
  viewStatusBar = KStandardAction::showStatusbar(this, SLOT(slotViewStatusBar()), actionCollection());

  actionCollection()->addAction( KStandardAction::Preferences, this, SLOT( preferences() ) );

  actNewDocument = actionCollection()->addAction( "document_new", this, SLOT( slotNewDocument()) );
  actNewDocument->setText( i18n("Create Document") );
  actNewDocument->setShortcut( KStandardShortcut::shortcut(KStandardShortcut::New) );
  actNewDocument->setIcon( KIcon("document-new"));

  actCopyDocument = actionCollection()->addAction( "document_copy", this, SLOT( slotCopyDocument()) );
  actCopyDocument->setText( i18n("Copy Document"));
  actCopyDocument->setShortcut( KStandardShortcut::shortcut(KStandardShortcut::Copy) );
  actCopyDocument->setIcon( KIcon( "document-edit"));

  actFollowDocument = actionCollection()->addAction( "document_follow", this, SLOT( slotFollowUpDocument() ) );
  actFollowDocument->setText( i18n("Follow Document" ));
  actFollowDocument->setShortcut( KShortcut( Qt::CTRL + Qt::Key_F ));
  actFollowDocument->setIcon( KIcon( "document-edit"));

  actPrintDocument = actionCollection()->addAction( "document_print", this, SLOT( slotPrintDocument()) );
  actPrintDocument->setText( i18n("Print Document"));
  actPrintDocument->setShortcut( KStandardShortcut::shortcut(KStandardShortcut::Print) );
  actPrintDocument->setIcon( KIcon("document-print"));

  actOpenArchivedDocument = actionCollection()->addAction( "archived_open", this, SLOT( slotArchivedDocExecuted()) );
  actOpenArchivedDocument->setText( i18n("Open Archived Document"));
  actOpenArchivedDocument->setShortcut( KShortcut(Qt::CTRL + Qt::Key_A) );

  actViewDocument  = actionCollection()->addAction( "document_view", this, SLOT( slotViewDocument()));
  actViewDocument->setText(i18n("Show Document"));
  actViewDocument->setShortcut( KStandardShortcut::shortcut(KStandardShortcut::Reload) );
  actViewDocument->setIcon( KIcon("document-preview" ));

  actOpenDocument = actionCollection()->addAction( "document_open", this, SLOT( slotOpenDocument()) );
  actOpenDocument->setText( i18n("Edit Document"));
  actOpenDocument->setShortcut( KStandardShortcut::shortcut(KStandardShortcut::Open) );
  actOpenDocument->setIcon( KIcon("document-open" ));

  actMailDocument = actionCollection()->addAction( "document_mail", this, SLOT( slotMailDocument()) );
  actMailDocument->setText(i18n("&Mail Document"));
  actMailDocument->setShortcut( KShortcut(Qt::CTRL + Qt::Key_M ));
  actMailDocument->setIcon( KIcon("mail-forward"));

  actEditTemplates = actionCollection()->addAction( "edit_tag_templates", this, SLOT( slotEditTagTemplates() ) );
  actEditTemplates->setText("Edit Tag Templates");
  actEditTemplates->setShortcut( KShortcut( Qt::CTRL + Qt::Key_E ));

  KAction *reconfDb = actionCollection()->addAction( "reconfigure_db", this, SLOT( slotReconfigureDatabase() ) );
  reconfDb->setText("Redo Initial Setup...");
  reconfDb->setShortcut( KShortcut( Qt::CTRL + Qt::Key_R ));

  fileQuit->setStatusTip(i18n("Quits the application"));
  editCut->setStatusTip(i18n("Cuts the selected section and puts it to the clipboard"));
  editCopy->setStatusTip(i18n("Copies the selected section to the clipboard"));
  editPaste->setStatusTip(i18n("Pastes the clipboard contents to current position"));
  viewStatusBar->setStatusTip(i18n("Enables/disables the statusbar"));

  actNewDocument->setStatusTip( i18n( "Creates a new Document" ) );
  actPrintDocument->setStatusTip( i18n( "Print and archive this Document" ) );
  actCopyDocument->setStatusTip( i18n( "Creates a new document which is a copy of the selected document" ) );
  actFollowDocument->setStatusTip( i18n( "Create a followup document for the current document" ) );
  actOpenDocument->setStatusTip( i18n( "Opens the document for editing" ) );
  actViewDocument->setStatusTip( i18n( "Opens a read only view on the document." ) );
  actMailDocument->setStatusTip( i18n( "Send document per mail" ) );
  actEditTemplates->setStatusTip( i18n("Edit the available tag templates which can be assigned to document items.") );
  reconfDb->setStatusTip( i18n( "Configure the Database Kraft is working on." ) );

  actOpenArchivedDocument->setStatusTip( i18n( "Open a viewer on an archived document" ) );
  setStandardToolBarMenuEnabled( true );
  actOpenDocument->setEnabled( false );
  actViewDocument->setEnabled( false );
  actPrintDocument->setEnabled( false );
  actCopyDocument->setEnabled( false );
  actFollowDocument->setEnabled( false );
  actMailDocument->setEnabled( false );

  actOpenArchivedDocument->setEnabled( false );
  // use the absolute path to your kraftui.rc file for testing purpose in createGUI();
  QString prjPath = QString::fromUtf8(qgetenv("KRAFT_HOME"));
  if( !prjPath.isEmpty() ) {
      createGUI(QString("%1/src/kraftui.rc").arg(prjPath));
  } else {
      createGUI( "kraftui.rc");
  }

}
DMMainWindow::DMMainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::DMMainWindow)
{
	// qt init
	Q_INIT_RESOURCE(icons);
	ui->setupUi(this);
	this->setParent(parent);

	// logger init
	log_updater = new GuiLogSink();
	connect(log_updater, SIGNAL(newLogLine(QString)), SLOT(newLogLine(QString)), Qt::QueuedConnection);
#if defined DEBUG || _DEBUG
	DM::Log::init(log_updater,DM::Debug);
#else
	DM::Log::init(log_updater,DM::Standard);
#endif
	// add log export to file
	QString logfilepath = QDir::tempPath() + "/dynamind" 
		+ QDateTime::currentDateTime().toString("_yyMMdd_hhmmss_zzz")+".log";
	if(QFile::exists(logfilepath))
		QFile::remove(logfilepath);

	outputFile = new ofstream(logfilepath.toStdString().c_str());
	DM::Log::addLogSink(new DM::OStreamLogSink(*outputFile));
	DM::Logger() << "logfile: " << logfilepath;

	// init python env
	DM::PythonEnv *env = DM::PythonEnv::getInstance();
	env->addPythonPath(QApplication::applicationDirPath().toStdString());
	env->addOverWriteStdCout();

	// init simulation, we only use one instance
	this->simulation = new GUISimulation(parent, ui->tabWidget_4);
	simulationThread = NULL;
	simulationThreadWrapper = NULL;

	this->simulation->registerModulesFromDefaultLocation();
	this->simulation->registerModulesFromSettings();
	createModuleListView();

	connect( ui->actionRun, SIGNAL( triggered() ), this, SLOT( runSimulation() ), Qt::DirectConnection );
	connect( ui->actionPreferences, SIGNAL ( triggered() ), this, SLOT(preferences() ), Qt::DirectConnection );
	connect(ui->actionSave, SIGNAL(triggered()), this , SLOT(saveSimulation()), Qt::DirectConnection);
	connect(ui->actionSaveAs, SIGNAL(triggered()), this , SLOT(saveAsSimulation()), Qt::DirectConnection);
	connect(ui->actionOpen, SIGNAL(triggered()), this , SLOT(loadSimulation()), Qt::DirectConnection);
	connect(ui->actionNew, SIGNAL(triggered()), this , SLOT(clearSimulation()), Qt::DirectConnection);
	connect(ui->actionReload_Modules, SIGNAL(triggered()), this , SLOT(ReloadModules()), Qt::DirectConnection);
	connect(ui->actionUpdate, SIGNAL(triggered()), this , SLOT(updateSimulation()), Qt::DirectConnection);
	connect(ui->actionReset, SIGNAL(triggered()), this , SLOT(resetSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionShow_Help, SIGNAL(triggered()), this, SLOT(showHelp()), Qt::DirectConnection);

	QStringList args = QCoreApplication::arguments();
	if (args.size() == 2) {
		this->clearSimulation();
		this->getSimulation()->currentDocument = args[1];
		simulation->loadSimulation(args[1].toStdString());
	}

	ui->actionCancel->setEnabled(false);

	// load from qsettings
	QSettings settings;
	DM::DBConnectorConfig cfg = DM::DBConnector::getInstance()->getConfig();
	qulonglong v = settings.value("cacheBlockwritingSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.cacheBlockwritingSize = v;

	v = settings.value("queryStackSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.queryStackSize = v;

	int i = settings.value("peterDatastream", -1).toInt();
	if (i != -1)
		cfg.peterDatastream = (bool)i;
}
Esempio n. 19
0
  void
NaughtyApplet::slotPreferences()
{
  preferences();
}
Esempio n. 20
0
void MainWindow::createActions()
{
    newAct = new QAction("&New", this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));

    openAct = new QAction("&Open...", this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open an existing file"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    saveAct = new QAction("&Save", this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tr("Save the document to disk"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

    saveAsAct = new QAction("Save &As...", this);
    saveAsAct->setShortcuts(QKeySequence::SaveAs);
    saveAsAct->setStatusTip(tr("Save the document under a new name"));
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

    exitAct = new QAction("E&xit", this);
    exitAct->setShortcuts(QKeySequence::Quit);
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    cutAct = new QAction("Cu&t", this);
    cutAct->setShortcuts(QKeySequence::Cut);
    cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));

    copyAct = new QAction("&Copy", this);
    copyAct->setShortcuts(QKeySequence::Copy);
    copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));

    pasteAct = new QAction("&Paste", this);
    pasteAct->setShortcuts(QKeySequence::Paste);
    pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));

    aboutAct = new QAction("&About", this);
    aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    preferencesAct = new QAction("&Preferences", this);
    preferencesAct->setStatusTip(tr("Application preferences"));
    preferencesAct->setMenuRole(QAction::PreferencesRole);
    connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences()));

    cutAct->setEnabled(false);
    copyAct->setEnabled(false);
    connect(textEdit, SIGNAL(copyAvailable(bool)),
            cutAct, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)),
            copyAct, SLOT(setEnabled(bool)));
}
Esempio n. 21
0
/**
 * Deal with right click's
 */
void KBinaryClock::openContextMenu() {
		bool bImmutable = config()->isImmutable();

		KPopupMenu *menu = new KPopupMenu();
		menu->insertTitle( SmallIcon( "clock" ), i18n( "KBinaryClock" ) );

		KLocale *loc = KGlobal::locale();
		QDateTime dt = QDateTime::currentDateTime();

		KPopupMenu *copyMenu = new KPopupMenu( menu );
		copyMenu->insertItem(loc->formatDateTime(dt), 201);
		copyMenu->insertItem(loc->formatDate(dt.date()), 202);
		copyMenu->insertItem(loc->formatDate(dt.date(), true), 203);
		copyMenu->insertItem(loc->formatTime(dt.time()), 204);
		copyMenu->insertItem(loc->formatTime(dt.time(), true), 205);
		copyMenu->insertItem(dt.date().toString(), 206);
		copyMenu->insertItem(dt.time().toString(), 207);
		copyMenu->insertItem(dt.toString(), 208);
		connect( copyMenu, SIGNAL( activated(int) ), this, SLOT( slotCopyMenuActivated(int) ) );

		if (!bImmutable)
		{
				if (kapp->authorize("user/root"))
				{
						menu->insertItem(SmallIcon("date"), i18n("&Adjust Date && Time..."), 103, 4);
				}
				menu->insertItem(SmallIcon("kcontrol"), i18n("Date && Time &Format..."), 104, 5);
		}

		menu->insertItem(SmallIcon("editcopy"), i18n("C&opy to Clipboard"), copyMenu, 105, 6);
		if (!bImmutable)
		{
				menu->insertSeparator(7);
				menu->insertItem(SmallIcon("configure"), i18n("&Configure KBinaryClock..."), 102, 8);
		}
		int result = menu->exec( QCursor::pos() );

		KProcess proc;
		switch (result) {
	case 102:
		preferences();
		break;
	case 103:
		proc << locate("exe", "kdesu");
		proc << "--nonewdcop";
		proc << QString("%1 clock --lang %2")
				.arg(locate("exe", "kcmshell"))
				.arg(KGlobal::locale()->language());
		proc.start(KProcess::DontCare);
		break;
	case 104:
		proc << locate("exe", "kcmshell");
		proc << "language";
					proc.start(KProcess::DontCare);
		break;
	case 110:
		preferences();
		break;
		} /* switch() */
		delete menu;
}
		Preferences::Preferences(Managers::Emulator& e,const Configuration& cfg)
		:
		dialog   ( IDD_PREFERENCES, this, Handlers::messages, Handlers::commands ),
		emulator ( e )
		{
			NST_COMPILE_ASSERT
			(
				START_IN_FULLSCREEN      == IDC_PREFERENCES_STARTUP_FULLSCREEN    - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SUPPRESS_WARNINGS        == IDC_PREFERENCES_DISABLE_ROM_WARNINGS  - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				FIRST_UNLOAD_ON_EXIT     == IDC_PREFERENCES_CLOSE_POWER_OFF       - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				CONFIRM_EXIT             == IDC_PREFERENCES_CONFIRM_EXIT          - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				RUN_IN_BACKGROUND        == IDC_PREFERENCES_RUN_IN_BACKGROUND     - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				AUTOSTART_EMULATION      == IDC_PREFERENCES_BEGIN_EMULATION       - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_LOGFILE             == IDC_PREFERENCES_SAVE_LOGFILE          - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				ALLOW_MULTIPLE_INSTANCES == IDC_PREFERENCES_MULTIPLE_INSTANCES    - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_LAUNCHER            == IDC_PREFERENCES_SAVE_LAUNCHER         - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				CONFIRM_RESET            == IDC_PREFERENCES_CONFIRM_RESET         - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_CHEATS              == IDC_PREFERENCES_SAVE_CHEATCODES       - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_NETPLAY_GAMELIST    == IDC_PREFERENCES_SAVE_NETPLAY_GAMELIST - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_WINDOWPOS           == IDC_PREFERENCES_SAVE_WINDOWPOS        - IDC_PREFERENCES_STARTUP_FULLSCREEN &&
				SAVE_LAUNCHERSIZE        == IDC_PREFERENCES_SAVE_LAUNCHERSIZE     - IDC_PREFERENCES_STARTUP_FULLSCREEN
			);

			Configuration::ConstSection preferences( cfg["preferences"] );

			{
				Configuration::ConstSection application( preferences["application"] );

				settings[ AUTOSTART_EMULATION      ] = !application[ "autostart"                ].No();
				settings[ RUN_IN_BACKGROUND        ] =  application[ "run-background"           ].Yes();
				settings[ START_IN_FULLSCREEN      ] =  application[ "start-fullscreen"         ].Yes();
				settings[ SUPPRESS_WARNINGS        ] =  application[ "suppress-warnings"        ].Yes();
				settings[ FIRST_UNLOAD_ON_EXIT     ] =  application[ "exit-power-off"           ].Yes();
				settings[ CONFIRM_EXIT             ] = !application[ "confirm-exit"             ].No();
				settings[ CONFIRM_RESET            ] =  application[ "confirm-reset"            ].Yes();
				settings[ ALLOW_MULTIPLE_INSTANCES ] =  application[ "allow-multiple-instances" ].Yes();

				{
					const GenericString priority( application[ "priority" ].Str() );

					if (priority == L"high")
					{
						settings.priority = PRIORITY_HIGH;
					}
					else if (priority == L"above normal")
					{
						settings.priority = PRIORITY_ABOVE_NORMAL;
					}
					else
					{
						settings.priority = PRIORITY_NORMAL;
					}
				}

				{
					const GenericString favored( application[ "favored-system" ].Str() );

					if (favored == L"nes-pal")
					{
						settings.favoredSystem = Nes::Machine::FAVORED_NES_PAL;
					}
					else if (favored == L"famicom")
					{
						settings.favoredSystem = Nes::Machine::FAVORED_FAMICOM;
					}
					else if (favored == L"dendy")
					{
						settings.favoredSystem = Nes::Machine::FAVORED_DENDY;
					}
					else
					{
						settings.favoredSystem = Nes::Machine::FAVORED_NES_NTSC;
					}
				}

				settings.alwaysAskSystem = application[ "favored-system-always-ask" ].Yes();
			}

			{
				Configuration::ConstSection save( preferences["save"] );

				settings[ SAVE_LOGFILE             ] = !save[ "logfile"         ].No();
				settings[ SAVE_SETTINGS            ] = !save[ "settings"        ].No();
				settings[ SAVE_LAUNCHER            ] = !save[ "launcher"        ].No();
				settings[ SAVE_CHEATS              ] = !save[ "cheats"          ].No();
				settings[ SAVE_NETPLAY_GAMELIST    ] = !save[ "netplay-list"    ].No();
				settings[ SAVE_WINDOWPOS           ] =  save[ "window-main"     ].Yes();
				settings[ SAVE_LAUNCHERSIZE        ] =  save[ "window-launcher" ].Yes();
			}

			{
				Configuration::ConstSection appearance( preferences["appearance"] );

				settings.menuLookDesktop.enabled    = appearance[ "menu-desktop"    ][ "use-custom-color" ].Yes();
				settings.menuLookFullscreen.enabled = appearance[ "menu-fullscreen" ][ "use-custom-color" ].Yes();

				settings.menuLookDesktop.color    = appearance[ "menu-desktop"    ][ "custom-color" ].Int( DEFAULT_DESKTOP_MENU_COLOR );
				settings.menuLookFullscreen.color = appearance[ "menu-fullscreen" ][ "custom-color" ].Int( DEFAULT_FULLSCREEN_MENU_COLOR );

				Application::Instance::SetIconStyle
				(
					appearance[ "icon-style" ].Str() == L"famicom" ? Application::Instance::ICONSTYLE_FAMICOM :
                                                                     Application::Instance::ICONSTYLE_NES
				);
			}

			Association association;
			const uint iconOffset = (Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? 3 : 4);

			for (uint i=0; i < Association::NUM_EXTENSIONS; ++i)
				association.Update( i, icons[i][iconOffset] );
		}
Esempio n. 23
0
// =============================================================================
void MainWindow::createActions()
{
    mCopyAction = new QAction(tr("&Copy"), this);
    mCopyAction->setIcon(QIcon(":/images/tt_copy.png"));
    mCopyAction->setShortcut(QKeySequence::Copy);
    mCopyAction->setStatusTip(tr("Copy the current selection's contents "
                                 "to the clipboard"));
    connect(mCopyAction, SIGNAL(triggered()), this, SLOT(copy()));

    mPasteAction = new QAction(tr("&Paste"), this);
    mPasteAction->setIcon(QIcon(":/images/tt_paste.png"));
    mPasteAction->setShortcut(QKeySequence::Paste);
    mPasteAction->setStatusTip(tr("Paste the clipboard's contents "
                                  "to the spread sheet"));
    connect(mPasteAction, SIGNAL(triggered()), this, SLOT(paste()));


    mStartAction = new QAction(tr("&Start"), this);
    mStartAction->setIcon(QIcon(":/images/tt_start.png"));
    mStartAction->setShortcut(QKeySequence::ZoomIn);
    mStartAction->setStatusTip(tr("Start counting"));
    connect(mStartAction, SIGNAL(triggered()), this, SLOT(startTT()));
    connect(mStartAction, SIGNAL(triggered()), this, SLOT(updateActions()));
    connect(mStartAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(startTT()));

    mStopAction = new QAction(tr("&Stop"), this);
    mStopAction->setIcon(QIcon(":/images/tt_stop.png"));
    mStopAction->setShortcut(QKeySequence::ZoomOut);
    mStopAction->setStatusTip(tr("Stop counting"));
    connect(mStopAction, SIGNAL(triggered()), this, SLOT(stopTT()));
    connect(mStopAction, SIGNAL(triggered()), this, SLOT(updateActions()));
    connect(mStopAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(stopTT()));

    mPauseAction = new QAction(tr("&Pause"), this);
    mPauseAction->setIcon(QIcon(":/images/tt_pause.png"));
    mPauseAction->setShortcut(QKeySequence::ZoomOut);
    mPauseAction->setStatusTip(tr("Set pause"));
    connect(mPauseAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(pauseTT()));
    connect(mPauseAction, SIGNAL(triggered()), this, SLOT(pauseTT()));

    mShowDialogTimeFollower = new QAction(tr("&Tracker"), this);
    mShowDialogTimeFollower->setIcon(QIcon(":/images/tt_glass.png"));
    mShowDialogTimeFollower->setShortcut(QKeySequence::ZoomIn);
    mShowDialogTimeFollower->setStatusTip(tr("Show small tracking window"));
    connect(mShowDialogTimeFollower, SIGNAL(triggered()), this, SLOT(onShowDialogTimeFollower()));

    mOpenSpreadSheet = new QAction(tr("&Open..."), this);
    mOpenSpreadSheet->setIcon(QIcon(":/images/tt_open.png"));
    mOpenSpreadSheet->setShortcut(QKeySequence::Open);
    mOpenSpreadSheet->setStatusTip(tr("Open an existing time tracking file"));
    connect(mOpenSpreadSheet, SIGNAL(triggered()), this, SLOT(openSpreadsheet()));

    mExportSpreadsheet = new QAction(tr("&Export"), this);
    mExportSpreadsheet->setIcon(QIcon(":/images/tt_export.png"));
    mExportSpreadsheet->setShortcut(QKeySequence::SelectNextWord);
    mExportSpreadsheet->setStatusTip(tr("Export current time tracking information to PDF"));
    connect(mExportSpreadsheet, SIGNAL(triggered()), this, SLOT(exportSpreadsheet()));

    mPrintPreviewSpreadsheet = new QAction(tr("P&rint preview"), this);
    mPrintPreviewSpreadsheet->setIcon(QIcon(":/images/tt_print_preview.png"));
    mPrintPreviewSpreadsheet->setStatusTip(tr("Preview current sheet"));
    connect(mPrintPreviewSpreadsheet, SIGNAL(triggered()), this, SLOT(printPreviewSpreadsheet()));

    mPrintSpreadsheet = new QAction(tr("&Print"), this);
    mPrintSpreadsheet->setIcon(QIcon(":/images/tt_print.png"));
    mPrintSpreadsheet->setStatusTip(tr("Print current sheet"));
    connect(mPrintSpreadsheet, SIGNAL(triggered()), this, SLOT(printSpreadsheet()));

    for (int i = 0; i < MaxRecentFiles; ++i) {
        QAction* tmpRecentFileActions = new QAction(this);
        tmpRecentFileActions->setVisible(false);
        connect(tmpRecentFileActions, SIGNAL(triggered()),
                this, SLOT(openRecentSpreadsheet()));
        mRecentFileActions->push_back(tmpRecentFileActions);
    }

    mExitAction = new QAction(tr("E&xit"), this);
    mExitAction->setShortcut(tr("Ctrl+Q"));
    mExitAction->setStatusTip(tr("Exit the application"));
    mExitAction->setIcon(QIcon(":/images/tt_cross.png"));
    connect(mExitAction, SIGNAL(triggered()), this, SLOT(close()));

    mAboutAction = new QAction(tr("&About"), this);
    mAboutAction->setIcon(QIcon(":/images/tt_2black_coffees_bk_gnd_30x30.png"));
    mAboutAction->setStatusTip(tr("Show the application's About box"));
    connect(mAboutAction, SIGNAL(triggered()), this, SLOT(about()));

    mModifySpreadSheet = new QAction(tr("&Lock/Unlock Sheet"), this);
    mModifySpreadSheet->setIcon(QIcon(":/images/tt_unlock.png"));
    mModifySpreadSheet->setStatusTip(tr("Allow modification on spreadsheet (Lock/Unlock)"));
    mModifySpreadSheet->setCheckable(true);
    connect(mModifySpreadSheet, SIGNAL(toggled(bool)), this, SLOT(lockUnlock(bool)));

    mPreferences = new QAction(tr("&Preferences..."), this);
    mPreferences->setStatusTip(tr("Change settings of the program"));
    mPreferences->setIcon(QIcon(":/images/tt_preferences.png"));
    connect(mPreferences, SIGNAL(triggered()), this, SLOT(preferences()));

    mAboutQtAction = new QAction(tr("About &Qt"), this);
    mAboutQtAction->setStatusTip(tr("Qt library's About box"));
    connect(mAboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Esempio n. 24
0
bool command_executor::execute_command(const hotkey_command&  cmd, int /*index*/, bool press)
{
	// hotkey release handling
	if (!press) {
		switch(cmd.id) {
			// release a scroll key, un-apply scrolling in the given direction
			case HOTKEY_SCROLL_UP:
				scroll_up(false);
				break;
			case HOTKEY_SCROLL_DOWN:
				scroll_down(false);
				break;
			case HOTKEY_SCROLL_LEFT:
				scroll_left(false);
				break;
			case HOTKEY_SCROLL_RIGHT:
				scroll_right(false);
				break;
			default:
				return false; // nothing else handles a hotkey release
		}

		return true;
	}

	// hotkey press handling
	switch(cmd.id) {
		case HOTKEY_SCROLL_UP:
			scroll_up(true);
			break;
		case HOTKEY_SCROLL_DOWN:
			scroll_down(true);
			break;
		case HOTKEY_SCROLL_LEFT:
			scroll_left(true);
			break;
		case HOTKEY_SCROLL_RIGHT:
			scroll_right(true);
			break;
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_TERRAIN_DESCRIPTION:
			terrain_description();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_LABEL_SETTINGS:
			label_settings();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_KILL_UNIT:
			kill_unit();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		case HOTKEY_LANGUAGE:
			change_language();
			break;
		case HOTKEY_REPLAY_PLAY:
			play_replay();
			break;
		case HOTKEY_REPLAY_RESET:
			reset_replay();
			break;
		case HOTKEY_REPLAY_STOP:
			stop_replay();
			break;
		case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			break;
		case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			break;
		case HOTKEY_REPLAY_NEXT_MOVE:
			replay_next_move();
			break;
		case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			break;
		case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			break;
		case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			break;
		case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			break;
		case HOTKEY_REPLAY_EXIT:
			replay_exit();
			break;
		case HOTKEY_WB_TOGGLE:
			whiteboard_toggle();
			break;
		case HOTKEY_WB_EXECUTE_ACTION:
			whiteboard_execute_action();
			break;
		case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			whiteboard_execute_all_actions();
			break;
		case HOTKEY_WB_DELETE_ACTION:
			whiteboard_delete_action();
			break;
		case HOTKEY_WB_BUMP_UP_ACTION:
			whiteboard_bump_up_action();
			break;
		case HOTKEY_WB_BUMP_DOWN_ACTION:
			whiteboard_bump_down_action();
			break;
		case HOTKEY_WB_SUPPOSE_DEAD:
			whiteboard_suppose_dead();
			break;
		case HOTKEY_SELECT_HEX:
			select_hex();
			break;
		case HOTKEY_DESELECT_HEX:
			deselect_hex();
			break;
		case HOTKEY_MOVE_ACTION:
			move_action();
			break;
		case HOTKEY_SELECT_AND_ACTION:
			select_and_action();
			break;
		case HOTKEY_ACCELERATED:
			toggle_accelerated_speed();
			break;
		case LUA_CONSOLE:
			lua_console();
			break;
		case HOTKEY_ZOOM_IN:
			zoom_in();
			break;
		case HOTKEY_ZOOM_OUT:
			zoom_out();
			break;
		case HOTKEY_ZOOM_DEFAULT:
			zoom_default();
			break;
		case HOTKEY_MAP_SCREENSHOT:
			map_screenshot();
			break;
		case HOTKEY_QUIT_TO_DESKTOP:
			quit_confirmation::quit_to_desktop();
			break;
		case HOTKEY_QUIT_GAME:
			quit_confirmation::quit_to_title();
			break;
		default:
			return false;
	}
	return true;
}
Esempio n. 25
0
void MainWindow2::createMenus()
{
    // ---------- File Menu -------------
    connect( ui->actionNew, &QAction::triggered, this, &MainWindow2::newDocument );
    connect( ui->actionOpen, &QAction::triggered, this, &MainWindow2::openDocument );
    connect( ui->actionSave_as, &QAction::triggered, this, &MainWindow2::saveAsNewDocument );
    connect( ui->actionSave, &QAction::triggered, this, &MainWindow2::saveDocument );
    connect( ui->actionExit, &QAction::triggered, this, &MainWindow2::close );

    /// --- Export Menu ---
    //connect( ui->actionExport_X_sheet, &QAction::triggered, mEditor, &Editor::exportX );
    connect( ui->actionExport_Image, &QAction::triggered, this, &MainWindow2::exportImage );
    connect( ui->actionExport_Image_Sequence, &QAction::triggered, this, &MainWindow2::exportImageSequence );
    connect( ui->actionExport_Movie, &QAction::triggered, this, &MainWindow2::exportMovie );

    connect( ui->actionExport_Palette, &QAction::triggered, this, &MainWindow2::exportPalette );

    /// --- Import Menu ---
    //connect( ui->actionExport_Svg_Image, &QAction::triggered, editor, &Editor::saveSvg );
    connect( ui->actionImport_Image, &QAction::triggered, this, &MainWindow2::importImage );
    connect( ui->actionImport_Image_Sequence, &QAction::triggered, this, &MainWindow2::importImageSequence );
    connect( ui->actionImport_Movie, &QAction::triggered, this, &MainWindow2::importMovie );

    connect( ui->actionImport_Sound, &QAction::triggered, mCommands, &CommandCenter::importSound );
    connect( ui->actionImport_Palette, &QAction::triggered, this, &MainWindow2::importPalette );

    /// --- Edit Menu ---
    ui->actionPreference->setMenuRole( QAction::PreferencesRole );

    connect( ui->actionUndo, &QAction::triggered, mEditor, &Editor::undo );
    connect( ui->actionRedo, &QAction::triggered, mEditor, &Editor::redo );
    connect( ui->actionCut, &QAction::triggered, mEditor, &Editor::cut );
    connect( ui->actionCopy, &QAction::triggered, mEditor, &Editor::copy );
    connect( ui->actionPaste, &QAction::triggered, mEditor, &Editor::paste );
    connect( ui->actionClearFrame, &QAction::triggered, mEditor, &Editor::clearCurrentFrame );
    connect( ui->actionFlip_X, &QAction::triggered, mCommands, &CommandCenter::flipX );
    connect( ui->actionFlip_Y, &QAction::triggered, mCommands, &CommandCenter::flipY );
    connect( ui->actionSelect_All, &QAction::triggered, mEditor, &Editor::selectAll );
    connect( ui->actionDeselect_All, &QAction::triggered, mEditor, &Editor::deselectAll );
    connect( ui->actionPreference, &QAction::triggered, [=] { preferences(); } );

    ui->actionRedo->setEnabled( false );

    /// --- Layer Menu ---
    connect( ui->actionNew_Bitmap_Layer, &QAction::triggered, mCommands, &CommandCenter::addNewBitmapLayer );
    connect( ui->actionNew_Vector_Layer, &QAction::triggered, mCommands, &CommandCenter::addNewVectorLayer );
    connect( ui->actionNew_Sound_Layer, &QAction::triggered, mCommands, &CommandCenter::addNewSoundLayer );
    connect( ui->actionNew_Camera_Layer, &QAction::triggered, mCommands, &CommandCenter::addNewCameraLayer );
    connect( ui->actionDelete_Current_Layer, &QAction::triggered, mEditor->layers(), &LayerManager::deleteCurrentLayer );

    /// --- View Menu ---
    connect( ui->actionZoom_In,  &QAction::triggered, mCommands, &CommandCenter::ZoomIn );
    connect( ui->actionZoom_Out, &QAction::triggered, mCommands, &CommandCenter::ZoomOut );
    connect( ui->actionRotate_Clockwise, &QAction::triggered, mCommands, &CommandCenter::rotateClockwise );
    connect( ui->actionRotate_Anticlosewise, &QAction::triggered, mCommands, &CommandCenter::rotateCounterClockwise );
    connect( ui->actionReset_Windows, &QAction::triggered, this, &MainWindow2::dockAllSubWidgets );
    connect( ui->actionReset_View, &QAction::triggered, mEditor->view(), &ViewManager::resetView );
    connect( ui->actionHorizontal_Flip, &QAction::triggered, mEditor, &Editor::toggleMirror );
    connect( ui->actionVertical_Flip, &QAction::triggered, mEditor, &Editor::toggleMirrorV );

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

    setMenuActionChecked( ui->actionGrid, mEditor->preference()->isOn( SETTING::GRID ) );
    connect( ui->actionGrid, &QAction::triggered, mCommands, &CommandCenter::showGrid );

    connect( ui->actionOnionPrevious, &QAction::triggered, mEditor, &Editor::toggleOnionPrev );
    connect( ui->actionOnionNext, &QAction::triggered, mEditor, &Editor::toggleOnionNext );
    connect( ui->actionMultiLayerOnionSkin, &QAction::triggered, mEditor, &Editor::toggleMultiLayerOnionSkin );

    //connect( mEditor, &Editor::onionPrevChanged, ui->actionOnionPrevious, &QAction::setChecked );
    //connect( mEditor, &Editor::onionNextChanged, ui->actionOnionNext, &QAction::setChecked );
    
    connect( mEditor, SIGNAL(multiLayerOnionSkinChanged(bool)), ui->actionMultiLayerOnionSkin, SLOT(setChecked(bool)));

    /// --- Animation Menu ---
    PlaybackManager* pPlaybackManager = mEditor->playback();
    connect( ui->actionPlay, &QAction::triggered, mCommands, &CommandCenter::PlayStop );

    connect( ui->actionLoop, &QAction::triggered, pPlaybackManager, &PlaybackManager::setLooping );
    connect( ui->actionLoopControl, &QAction::triggered, pPlaybackManager, &PlaybackManager::enableRangedPlayback );
    connect( pPlaybackManager, &PlaybackManager::loopStateChanged, ui->actionLoop, &QAction::setChecked );
    connect( pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, ui->actionLoopControl, &QAction::setChecked );

    connect(ui->actionAdd_Frame, &QAction::triggered, mEditor, &Editor::addNewKey );
    connect(ui->actionRemove_Frame, &QAction::triggered, mEditor, &Editor::removeKey );
    //connect(ui->actionNext_Frame, &QAction::triggered, m_pEditor, &Editor::playNextFrame );
    //connect(ui->actionPrevious_Frame, &QAction::triggered, m_pEditor, &Editor::playPrevFrame );
    connect(ui->actionNext_KeyFrame, &QAction::triggered, mEditor, &Editor::scrubNextKeyFrame );
    connect(ui->actionPrev_KeyFrame, &QAction::triggered, mEditor, &Editor::scrubPreviousKeyFrame );
    connect(ui->actionDuplicate_Frame, &QAction::triggered, mEditor, &Editor::duplicateKey );
    connect(ui->actionMove_Frame_Forward, &QAction::triggered, mEditor, &Editor::moveFrameForward ); //HERE
    connect(ui->actionMove_Frame_Backward, &QAction::triggered, mEditor, &Editor::moveFrameBackward );

    /// --- Tool Menu ---
    connect(ui->actionMove, &QAction::triggered, mToolBox, &ToolBoxWidget::moveOn );
    connect(ui->actionSelect, &QAction::triggered, mToolBox, &ToolBoxWidget::selectOn );
    connect(ui->actionBrush, &QAction::triggered, mToolBox, &ToolBoxWidget::brushOn );
    connect(ui->actionPolyline, &QAction::triggered, mToolBox, &ToolBoxWidget::polylineOn );
    connect(ui->actionSmudge, &QAction::triggered, mToolBox, &ToolBoxWidget::smudgeOn );
    connect(ui->actionPen, &QAction::triggered, mToolBox, &ToolBoxWidget::penOn );
    connect(ui->actionHand, &QAction::triggered, mToolBox, &ToolBoxWidget::handOn );
    connect(ui->actionPencil, &QAction::triggered, mToolBox, &ToolBoxWidget::pencilOn );
    connect(ui->actionBucket, &QAction::triggered, mToolBox, &ToolBoxWidget::bucketOn );
    connect(ui->actionEyedropper, &QAction::triggered, mToolBox, &ToolBoxWidget::eyedropperOn );
    connect(ui->actionEraser, &QAction::triggered, mToolBox, &ToolBoxWidget::eraserOn );
    connect(ui->actionTogglePalette, &QAction::triggered, mScribbleArea,&ScribbleArea::togglePopupPalette );
    connect(ui->actionResetToolsDefault, &QAction::triggered, mEditor->tools(), &ToolManager::resetAllTools );

    /// --- Window Menu ---
    QMenu* winMenu = ui->menuWindows;

    QAction* actions[] =
    {
        mToolBox->toggleViewAction(),
        mToolOptions->toggleViewAction(),
        mColorWheel->toggleViewAction(),
        mColorPalette->toggleViewAction(),
        mTimeLine->toggleViewAction(),
        mDisplayOptionWidget->toggleViewAction()
    };
    winMenu->clear();
    for ( QAction* action : actions )
    {
        action->setMenuRole( QAction::NoRole );
        winMenu->addAction( action );
    }

    /// --- Help Menu ---
    connect( ui->actionHelp, &QAction::triggered, this, &MainWindow2::helpBox);
    connect( ui->actionAbout, &QAction::triggered, this, &MainWindow2::aboutPencil );

    // --------------- Menus ------------------
    mRecentFileMenu = new RecentFileMenu( tr("Open Recent"), this );
    mRecentFileMenu->loadFromDisk();
    ui->menuFile->insertMenu( ui->actionSave, mRecentFileMenu );

    connect( mRecentFileMenu, &RecentFileMenu::loadRecentFile, this, &MainWindow2::openFile );

    connect( ui->menuEdit, SIGNAL( aboutToShow() ), this, SLOT( undoActSetText() ) );
    connect( ui->menuEdit, SIGNAL( aboutToHide() ), this, SLOT( undoActSetEnabled() ) );
}
Esempio n. 26
0
int main(int argc, char* argv[]) try
{
	g_thread_init(NULL);
	Gio::init();

	setlocale(LC_ALL, "");
	bindtextdomain(GETTEXT_PACKAGE, gobby_localedir().c_str());
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

	bool new_instance = false;
	bool display_version = false;
	std::vector<Glib::ustring> hostnames;

	Glib::OptionGroup opt_group_gobby("gobby",
		_("Gobby options"), _("Options related to Gobby"));
	Glib::OptionEntry opt_version;
	opt_version.set_short_name('v');
	opt_version.set_long_name("version");
	opt_version.set_description(
		_("Display version information and exit"));
	opt_group_gobby.add_entry(opt_version, display_version);

	Glib::OptionEntry opt_new_instance;
	opt_new_instance.set_short_name('n');
	opt_new_instance.set_long_name("new-instance");
	opt_new_instance.set_description(
		_("Also start a new Gobby instance when there is one "
		  "running already"));
	opt_group_gobby.add_entry(opt_new_instance, new_instance);

	Glib::OptionEntry opt_connect;
	opt_connect.set_short_name('c');
	opt_connect.set_long_name("connect");
	opt_connect.set_description(
		_("Connect to given host on startup, can be given multiple times"));
	opt_connect.set_arg_description(_("HOSTNAME"));
	opt_group_gobby.add_entry(opt_connect, hostnames);

	Glib::OptionContext opt_ctx;
	opt_ctx.set_help_enabled(true);
	opt_ctx.set_ignore_unknown_options(false);
	opt_ctx.set_main_group(opt_group_gobby);

	// I would rather like to have Gtk::Main on the stack, but I see
	// no other chance to catch exceptions from the command line option
	// parsing. armin.
	// TODO: Maybe we should parse before initializing GTK+, using
	// Gtk::Main::add_gtk_option_group() with open_default_display set
	// to false.
	std::auto_ptr<Gtk::Main> kit;

	try
	{
		kit.reset(new Gtk::Main(argc, argv, opt_ctx));
	}
	catch(Glib::Exception& e)
	{
		// Protect for non-UTF8 command lines (GTK probably already
		// converts to UTF-8 in case the system locale is not UTF-8,
		// but it can happen that input is given not in the system
		// locale, or simply invalid UTF-8. In that case, printing
		// e.what() on stdout would throw another exception, which we
		// want to avoid here, because otherwise we would want to
		// show that exception in an error dialog, but GTK+ failed
		// to initialize.
		if(e.what().validate())
			std::cerr << e.what() << std::endl;
		else
			std::cerr << "Invalid input on command line" << std::endl;

		return EXIT_FAILURE;
	}

	if(display_version)
	{
		std::cout << "Gobby " << PACKAGE_VERSION << std::endl;
		return EXIT_SUCCESS;
	}

#ifdef WITH_UNIQUE
	UniqueApp* app = unique_app_new_with_commands(
		"de._0x539.gobby", NULL,
		"UNIQUE_GOBBY_CONNECT", Gobby::UNIQUE_GOBBY_CONNECT,
		NULL);

	if(!new_instance && unique_app_is_running(app))
	{
		int exit_code = my_unique_check_other(
			app,
			argc - 1, argv + 1,
			hostnames);
		g_object_unref(app);
		return exit_code;
	}
#endif // WITH_UNIQUE

	GError* error = NULL;
	if(!inf_init(&error))
	{
		std::string message = error->message;
		g_error_free(error);
		throw std::runtime_error(message);
	}

	// Read the configuration
	Gobby::Config config(Gobby::config_filename("config.xml"));
	Gobby::Preferences preferences(config);
	Gobby::CertificateManager cert_manager(preferences);
	Gobby::IconManager icon_manager;

	// Set default icon
	Gtk::Window::set_default_icon_name("gobby-0.5");

	// Open a scope here, so that the main window is destructed
	// before we serialize the preferences, so that if the window
	// sets options at destruction time, they are stored correctly.
	{
		// Create window
		Gobby::Window wnd(
			argc-1,
			argv+1,
			config,
			preferences,
			icon_manager,
			cert_manager
#ifdef WITH_UNIQUE
			, app
#endif
			);

#ifdef WITH_UNIQUE
		g_object_unref(app);
#endif

		wnd.show();

		for(std::vector<Glib::ustring>::const_iterator i =
			hostnames.begin();
		    i != hostnames.end(); ++ i)
		{
			wnd.connect_to_host(*i);
		}

		wnd.signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit) );
		kit->run();
	}

	preferences.serialize(config);

	//inf_deinit();
	return 0;
}
catch(Glib::Exception& e)
{
	handle_exception(e.what() );
}
catch(std::exception& e)
{
	handle_exception(e.what() );
}
Esempio n. 27
0
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
{
	switch(command) {
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		 case HOTKEY_LANGUAGE:
			change_language();
			break;
		 case HOTKEY_PLAY_REPLAY:
			play_replay();
			 break;
		 case HOTKEY_RESET_REPLAY:
			reset_replay();
			 break;
		 case HOTKEY_STOP_REPLAY:
			 stop_replay();
			 break;
		 case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			 break;
		 case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			 break;
		 case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			 break;
		 case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			 break;
		 case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			 break;
		 case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			 break;
		 case HOTKEY_WB_TOGGLE:
			 whiteboard_toggle();
			 break;
		 case HOTKEY_WB_EXECUTE_ACTION:
			 whiteboard_execute_action();
			 break;
		 case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			 whiteboard_execute_all_actions();
			 break;
		 case HOTKEY_WB_DELETE_ACTION:
			 whiteboard_delete_action();
			 break;
		 case HOTKEY_WB_BUMP_UP_ACTION:
			 whiteboard_bump_up_action();
			 break;
		 case HOTKEY_WB_BUMP_DOWN_ACTION:
			 whiteboard_bump_down_action();
			 break;
		 case HOTKEY_WB_SUPPOSE_DEAD:
			 whiteboard_suppose_dead();
			 break;
		 case HOTKEY_LEFT_MOUSE_CLICK:
			 left_mouse_click();
			 break;
		 case HOTKEY_RIGHT_MOUSE_CLICK:
			 right_mouse_click();
			 break;
		 default:
			 return false;
	}
	return true;
}
Esempio n. 28
0
void MainWindow::setupActions()
{
    kDebug() << "setup actions...";

    // this let shortcuts work..
    actionCollection()->addAssociatedWidget(this);

    KAction *a;

    // new window action
    a = new KAction(KIcon("window-new"), i18n("&New Window"), this);
    a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N));
    actionCollection()->addAction(QL1S("new_window"), a);
    connect(a, SIGNAL(triggered(bool)), Application::instance(), SLOT(newWindow()));

    // Standard Actions
    KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
    KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
    KStandardAction::print(this, SLOT(printRequested()), actionCollection());
    KStandardAction::quit(this , SLOT(close()), actionCollection());

    a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
    KShortcut findShortcut = KStandardShortcut::find();
    findShortcut.setAlternate(Qt::Key_Slash);
    a->setShortcut(findShortcut);

    KStandardAction::findNext(this, SLOT(findNext()) , actionCollection());
    KStandardAction::findPrev(this, SLOT(findPrevious()) , actionCollection());

    a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection());
    KShortcut fullScreenShortcut = KStandardShortcut::fullScreen();
    fullScreenShortcut.setAlternate(Qt::Key_F11);
    a->setShortcut(fullScreenShortcut);

    a = actionCollection()->addAction(KStandardAction::Home);
    connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons, Qt::KeyboardModifiers)));
    KStandardAction::preferences(this, SLOT(preferences()), actionCollection());

    a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection());
    a->setText(i18n("Reload"));
    KShortcut reloadShortcut = KStandardShortcut::reload();
    reloadShortcut.setAlternate(Qt::CTRL + Qt::Key_R);
    a->setShortcut(reloadShortcut);

    a = new KAction(KIcon("process-stop"), i18n("&Stop"), this);
    a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Period));
    actionCollection()->addAction(QL1S("stop"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(webStop()));

    // stop reload Action
    m_stopReloadAction = new KAction(this);
    actionCollection()->addAction(QL1S("stop_reload") , m_stopReloadAction);
    m_stopReloadAction->setShortcutConfigurable(false);
    connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(browserLoading(bool)));
    browserLoading(false); //first init for blank start page

    a = new KAction(i18n("Open Location"), this);
    KShortcut openLocationShortcut(Qt::CTRL + Qt::Key_L);
    openLocationShortcut.setAlternate(Qt::Key_F6);
    a->setShortcut(openLocationShortcut);
    actionCollection()->addAction(QL1S("open_location"), a);
    connect(a, SIGNAL(triggered(bool)) , this, SLOT(openLocation()));

    // set zoom bar actions
    m_zoomBar->setupActions(this);
    
    // tab list
    m_tabListMenu = new KMenu();
    m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time
    connect(m_tabListMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabListMenu()));
    connect(m_tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionTab(QAction*)));
    KActionMenu *tabAction = new KActionMenu(i18n("Tab List"), this);
    tabAction->setMenu(m_tabListMenu);
    tabAction->setIcon(KIcon("document-multiple"));
    tabAction->setDelayed(false);
    actionCollection()->addAction(QL1S("tab_list"), tabAction);

    // =============================== Tools Actions =================================
    a = new KAction(i18n("View Page S&ource"), this);
    a->setIcon(KIcon("application-xhtml+xml"));
    a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_U));
    actionCollection()->addAction(QL1S("page_source"), a);
    connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));

    a = Application::instance()->privateBrowsingAction();
    a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P);
    actionCollection()->addAction(QL1S("private_browsing"), a);

    a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
    a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Delete);
    actionCollection()->addAction(QL1S("clear_private_data"), a);
    connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData()));

    // ========================= History related actions ==============================
    a = actionCollection()->addAction(KStandardAction::Back);
    connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers)));

    m_historyBackMenu = new KMenu(this);
    a->setMenu(m_historyBackMenu);
    connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu()));
    connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *)));

    a = actionCollection()->addAction(KStandardAction::Forward);
    connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers)));

    // ============================== General Tab Actions ====================================
    a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
    a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T));
    actionCollection()->addAction(QL1S("new_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab()));

    a = new KAction(KIcon("view-refresh"), i18n("Reload All Tabs"), this);
    actionCollection()->addAction(QL1S("reload_all_tabs"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(reloadAllTabs()));

    a = new KAction(i18n("Show Next Tab"), this);
    a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext());
    actionCollection()->addAction(QL1S("show_next_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab()));

    a = new KAction(i18n("Show Previous Tab"), this);
    a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev());
    actionCollection()->addAction(QL1S("show_prev_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab()));

    a = new KAction(KIcon("tab-new"), i18n("Open Last Closed Tab"), this);
    a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
    actionCollection()->addAction(QL1S("open_last_closed_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view, SLOT(openLastClosedTab()));

    // Closed Tabs Menu
    KActionMenu *closedTabsMenu = new KActionMenu(KIcon("tab-new"), i18n("Closed Tabs"), this);
    closedTabsMenu->setDelayed(false);
    actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu);

    // shortcuts for quickly switching to a tab
    for( int i = 1; i <= 9; i++ ) {
        a = new KAction(i18n("Switch to Tab %1", i), this);
        a->setShortcut(KShortcut( QString("Alt+%1").arg(i) ));
        a->setData( QVariant(i) );
        actionCollection()->addAction(QL1S(("switch_tab_" + QString::number(i)).toAscii()), a);
        connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab()));
    }

    // ============================== Indexed Tab Actions ====================================
    a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this);
    a->setShortcuts( KStandardShortcut::close() );
    actionCollection()->addAction(QL1S("close_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeTab()));

    a = new KAction(KIcon("tab-duplicate"), i18n("Clone Tab"), this);
    actionCollection()->addAction(QL1S("clone_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(cloneTab()));

    a = new KAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this);
    actionCollection()->addAction(QL1S("close_other_tabs"), a);
    connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeOtherTabs()));

    a = new KAction(KIcon("view-refresh"), i18n("Reload Tab"), this);
    actionCollection()->addAction(QL1S("reload_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(reloadTab()));

    a = new KAction(KIcon("tab-detach"), i18n("Detach Tab"), this);
    actionCollection()->addAction(QL1S("detach_tab"), a);
    connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab()));

    // Bookmark Menu
    KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(this);
    bmMenu->setIcon(KIcon("bookmarks"));
    bmMenu->setDelayed(false);
    bmMenu->setShortcutConfigurable(true);
    bmMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_B) );
    actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu);

    // ---------------- Encodings -----------------------------------
    a = new KAction(KIcon("character-set"), i18n("Set Encoding"), this);
    actionCollection()->addAction(QL1S("encodings"), a);
    a->setMenu(m_encodingMenu);
    connect(m_encodingMenu, SIGNAL(aboutToShow()), this, SLOT(populateEncodingMenu()));
    connect(m_encodingMenu, SIGNAL(triggered(QAction *)), this, SLOT(setEncoding(QAction *)));
}
Esempio n. 29
0
///read Preferences from file
short Preferences::getPrefs(const char* iFile, string method){
  //liest Preferences aus Datei
  ifstream preferences(iFile);
  static unsigned long fpos=0;// filePos;
  if (!preferences){
     cout<<"could not open IFile: "<<iFile<<endl;exit(3);}
  if (method=="next"){
    preferences.seekg(fpos);
  }
  //if (method=="last")
  else{
    /// \todo set filepos at beginning of last line
    int counter1=0,counter2=0,counter3=0;
    bool eofile=preferences.eof();
    while (!preferences.eof()){
          counter1=counter2;
          //counter2=counter3;
          counter2=preferences.tellg();
          preferences.ignore(10000,'\n');
    }
    preferences.seekg(counter1-1);
  }
    preferences.clear();
    char comment;
    //cout<<preferences.tellg()<<"_";
    comment=preferences.peek();
    cout<<comment<<"..\n";
    if (comment == '#')
    { // Kommentarzeile lesen und Übergehen
  	   const int maxLengthOfLine = 10000; // max length of line = 20 char * 52 params
	   char temp[maxLengthOfLine];
	   preferences.getline(temp,maxLengthOfLine);
	   fpos = (unsigned int) preferences.tellg() -2;
	   preferences.close();
  	   return 1;
    }
    else
    { // Parameter einlesen
    //---Versions-ID ausgeben---
    preferences >> ID;cout<<"ID:"<<ID<<"  ";

    if (preferences.eof()) {preferences.close();
    fpos=0; return -1; }
    //---Laufzeit und # Wiederholungen einlesen---
    preferences >> maxYears >> maxRuns;
//cout<<"MaxRuns: "<<maxRuns<<"("<<preferences.tellg();
    //---Anteile potentieller und davon initial besetzter Habitate einlesen---
    float potHab_dummi;
    preferences >> potHab_dummi>> pcInitPop;
  //pcPotHab from this source obsolete at the moment (defined in lc-grid-file)
  //---Sukzessions- und Störungsrate einlesen---
    preferences >> disturbanceRate >> patchDecreaseRate;
  //---Competetive Ability einlesen---
    preferences >> compAbil;
  //---Anteil der weiter verbreiteten Samen einlesen---
    preferences >> dispersed;cout<<"disp: "<<dispersed;
  //---Einfluss von Management einfügen    (ab V2.02)
  /// \date 14.2.08 changed from eMode
    float mode=0;preferences >> mode;manMode= mode;
  cout<<"manmode"<<manMode;
  //double mE=1; preferences >> mE;
  //manEffect=mE;
  //-neue Zeile...
    float value=0;
    for(int i=0;i<5;i++) {
      preferences >> value;cout<<value<<" \t";
      setMan((process)i,value);
    }
//cout<<"after modes: "<<preferences.tellg();
  //---Matrix der Umweltschwankungen einlesen (ab V 0.09)---
cout<<"goodJs: ";
    for(int i=0;i<5;i++) {  //gute Jahre
      preferences >> value;cout<<value<<" \t";
      setPcQuality(GOOD,(process)i,value);
    } //-neue Zeile
    cout<<"badJs: ";
    for(int i=0;i<5;i++) {   //schlechte Jahre
      preferences >> value;cout<<value<<" \t";
      setPcQuality(BAD,(process)i,value);
    }
  //-neue Zeile...
  //---Übergangsmatrix einlesen---
//cout<<"transits: "<<preferences.tellg()<<endl;
    float transit[5][5];
    for (int i=SEED; i<=GEN; i++)  for (int j=SEED; j<=GEN; j++) {
      preferences >> transit[j][i];
    }
    cout<<"last trans: "<<transit[4][4];
    setTransitions(transit);
  //---Ende des Datensatzes---
    if (preferences.good()) {
 //     comment= preferences.peek();
      fpos=(unsigned int)preferences.tellg();//fpos-=1;
    }else {fpos=0;return -1;}
  }//end ifelse '#'
  cout<<fpos<<endl;
  //preferences.close();
  return 0;
}
Esempio n. 30
0
FreeSSM::FreeSSM(QApplication *app)
{
	_qt_translator = NULL;
	_translator = NULL;
	_iface_type = AbstractDiagInterface::interface_serialPassThrough;
	_iface_filename = "";
	_language = "en";	// default language
	_dumping = false;
	QString appsPath( QCoreApplication::applicationDirPath() );
	// SETUP GUI:
	setupUi(this);
	setWindowFlags( windowFlags() & ~Qt::WindowMaximizeButtonHint );	// only necessary for MS Windows
#ifndef SMALL_RESOLUTION
	// LOAD BACKGROUND PICTURE:
	background_label->setPixmap(appsPath + "/background.png");
	// SHOW PROGRAM TITEL + VERSION:
	QFont titlefont = this->font();
	titlefont.setPointSize(20);
	titlefont.setBold(true);
	_progtitle_label = new QLabel(this);
	_progtitle_label->setGeometry(20, 17, 315, 34);
	_progtitle_label->setFont( titlefont );
	_progtitle_label->setText("FreeSSM " + QApplication::applicationVersion());
	this->setWindowTitle("FreeSSM " + QApplication::applicationVersion());
	// PLACE WINDOW IN THE CENTER OF THE SCREEN:
	QDesktopWidget desktop;
	int x = (desktop.width() - size().width()) / 2;
	int y = (desktop.height() - size().height()) / 2 - 50;
	this->move ( x, y );
#endif
	// LOAD PREFERENCES FROM FILE:
	QString savedinterfacefilename = "";
	QString savedlanguage = "";
	QString savedGUIstyle = "";
	QString savedinterfacetype = "";
	QFile prefsfile(QDir::homePath() + "/FreeSSM.prefs");
	if (prefsfile.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QByteArray line;
		if (!prefsfile.atEnd())
		{
			// Load interface type settings:
			line = prefsfile.readLine();
			line.truncate(line.length()-1);	// truncate newline-character
			savedinterfacefilename = static_cast<QString>(line);
		}
		if (!prefsfile.atEnd())
		{
			// Load language settings:
			line = prefsfile.readLine();
			line.truncate(line.length()-1);
			savedlanguage = static_cast<QString>(line);
		}
		if (!prefsfile.atEnd())
		{
			// Load GUI-style settings:
			line = prefsfile.readLine();
			line.truncate(line.length()-1);
			savedGUIstyle = static_cast<QString>(line);
		}
		if (!prefsfile.atEnd())
		{
			// Load interface file name settings:
			line = prefsfile.readLine();
			line.truncate(line.length()-1);
			savedinterfacetype = static_cast<QString>(line);
		}
		prefsfile.close();
	}
	// SET PREFERRED GUI-Style:
	if (savedGUIstyle.size())
	{
		QStyle *qstyle = QStyleFactory::create( savedGUIstyle );
		if (qstyle)
			QApplication::setStyle( qstyle );
	}
	// CHECK SAVED LANGUAGE:
	bool sl_valid = false;
	QLocale loc = QLocale(savedlanguage);
	if ((loc != QLocale::C) && (__supportedLocales.indexOf( loc ) > -1))
	{
		_language = savedlanguage;
		sl_valid = true;
	}
	// TRY TO SELECT SYSTEM LANGUAGE, IF SAVED LANGUAGE IS INVALID:
	if (!sl_valid)
	{
		if (__supportedLocales.indexOf( QLocale::system() ) > -1)
			_language = QLocale::system().name().section('_', 0, 0);
	}
	// SET TRANSLATOR AND RETRANSLATE:
	_translator = new QTranslator;
	bool langfileerror = false;
	langfileerror = !_translator->load("FreeSSM_" + _language + ".qm", appsPath);
	if (langfileerror && (_language != "en"))
	{
		// Fallback to English
		_language = "en";
		langfileerror = !_translator->load("FreeSSM_en.qm", appsPath);
		// Display error message about missing language file:
		QMessageBox msg( QMessageBox::Critical, tr("Error"), tr("Error:\n- Language file missing or damaged -"), QMessageBox::Ok, this);
		QFont msgfont = msg.font();
		msgfont.setPointSize(9);
		msg.setFont( msgfont );
		msg.show();
		msg.exec();
		msg.close();
	}
	if (!langfileerror)
	{
		app->installTranslator(_translator);
		retranslateUi(this);
	}
	else
	{
		delete _translator;
		_translator = NULL;
	}
	// SET Qt-TRANSLATOR (if necessary and available):
	if (_language != "en")
	{
		QString qt_ts_path = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
		if (qt_ts_path.isEmpty())
			qt_ts_path = QCoreApplication::applicationDirPath();
		_qt_translator = new QTranslator;
		if (_qt_translator->load("qt_" + _language, qt_ts_path))
			app->installTranslator(_qt_translator);
		else
		{
			delete _qt_translator;
			_qt_translator = NULL;
		}
	}
	// CHECK THE SAVED INTERFACE SETTINGS AND CORRECT IF NECESSARY:
	if (savedinterfacetype == QString::number(AbstractDiagInterface::interface_J2534))	// J2534-Pass-Through
	{
		_iface_type = AbstractDiagInterface::interface_J2534;
		const std::vector<J2534Library> J2534libs = J2534_API::getAvailableJ2534Libs();
		if (J2534libs.size())
		{
			if (!savedinterfacefilename.isEmpty())
			{
				for (const J2534Library& lib : J2534libs)
				{
					if (savedinterfacefilename == QString::fromStdString(lib.path))
					{
						_iface_filename = savedinterfacefilename;
						break;
					}
				}
			}
			if (_iface_filename.isEmpty())
				_iface_filename = QString::fromStdString(J2534libs.at(0).path);
		}
		// NOTE: otherwise _iface_filename remains empty
	}
	else	// Serial Pass-Through, AT-comand controlled (e.g. ELM, AGV, Diamex) or invalid
	{
		if (savedinterfacetype == QString::number(AbstractDiagInterface::interface_ATcommandControlled))
			_iface_type = AbstractDiagInterface::interface_ATcommandControlled;
		else
			_iface_type = AbstractDiagInterface::interface_serialPassThrough;
		std::vector<std::string> portlist;
		portlist = serialCOM::GetAvailablePorts();
		if (portlist.size())
		{
			if (!savedinterfacetype.isEmpty() && !savedinterfacefilename.isEmpty())
			{
				for (unsigned int k=0; k<portlist.size(); k++)
				{
					if (savedinterfacefilename == QString::fromStdString(portlist.at(k)))
					{
						_iface_filename = savedinterfacefilename;
						break;
					}
				}
			}
			if (_iface_filename.isEmpty())
				_iface_filename = QString::fromStdString(portlist.at(0));
		}
		// NOTE: otherwise _iface_filename remains empty
	}
	// CREATE ACTION FOR DUMPING CONTROL UNIT ID-DATA TO FILE:
	_dump_action = new QAction(this);
	_dump_action->setShortcut( QKeySequence("Ctrl+Alt+Return") );
	this->addAction(_dump_action);
	// CONNECT SIGNALS/SLOTS:
	connect( engine_pushButton, SIGNAL( released() ), this, SLOT( engine() ) );
	connect( transmission_pushButton, SIGNAL( released() ), this, SLOT( transmission() ) );
	connect( absvdc_pushButton, SIGNAL( released() ), this, SLOT( abs() ) );
	connect( cruisecontrol_pushButton, SIGNAL( released() ), this, SLOT( cruisecontrol() ) );
	connect( aircon_pushButton, SIGNAL( released() ), this, SLOT( aircon() ) );
	connect( preferences_pushButton, SIGNAL( released() ), this, SLOT( preferences() ) );
	connect( help_pushButton, SIGNAL( released() ), this, SLOT( help() ) );
	connect( about_pushButton, SIGNAL( released() ), this, SLOT( about() ) );
	connect( exit_pushButton, SIGNAL( released() ), this, SLOT( close() ) );
	// NOTE: using released() instead of pressed() as workaround for a Qt-Bug occuring under MS Windows
	connect( _dump_action, SIGNAL(triggered()), this, SLOT(dumpCUdata()) );
}