Esempio n. 1
0
void MainWindow::setupActions()
{
    actQuit         = KStandardAction::quit(this, SLOT(quit()), actionCollection());
    KAction *a = NULL;
    a = actionCollection()->addAction("minimizeRestore", this,
                                      SLOT(minimizeRestore()));
    a->setText(i18n("Minimize"));
    a->setIcon(KIcon(""));
    a->setShortcut(0);

    /** Settings : ************************************************************/
//  m_actShowToolbar   = KStandardAction::showToolbar(   this, SLOT(toggleToolBar()),   actionCollection());
    m_actShowStatusbar = KStandardAction::showStatusbar(this, SLOT(toggleStatusBar()), actionCollection());

//  m_actShowToolbar->setCheckedState( KGuiItem(i18n("Hide &Toolbar")) );

    (void) KStandardAction::keyBindings(this, SLOT(showShortcutsSettingsDialog()), actionCollection());

    (void) KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());

    //KAction *actCfgNotifs = KStandardAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection() );
    //actCfgNotifs->setEnabled(false); // Not yet implemented !

    actAppConfig = KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection());
}
Esempio n. 2
0
void MainWindow::setupActions()
{
    saveSettingsAction = new QAction(tr("&Save Settings as \"") + tr(DEFAULT_SAVE_NAME) + tr("\""), this);
    connect(saveSettingsAction, SIGNAL(triggered()), this, SLOT(saveSettings()));

    saveSettingsAsAction = new QAction(tr("&Save Settings as..."), this);
    connect(saveSettingsAsAction, SIGNAL(triggered()), this, SLOT(saveSettingsAs()));

    clearSettingsAction = new QAction(tr("&Clear Settings"), this);
    connect(clearSettingsAction, SIGNAL(triggered()), this, SLOT(clearSettings()));

    exitAction = new QAction(tr("E&xit"), this);
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    viewStatusBarAction = new QAction(tr("&Status Bar"), this);
    viewStatusBarAction->setCheckable(true);
    viewStatusBarAction->setChecked(true);
    connect(viewStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool)));

    settingsAction = new QAction(tr("&Settings"), this);
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));

    dockAllAction = new QAction(tr("&Dock All"), this);
    connect(dockAllAction, SIGNAL(triggered()), this, SLOT(dockAll()));

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

    aboutQtAction = new QAction(tr("About &Qt"), this);
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Esempio n. 3
0
/**
  * Creating needed connections
  */
void MainWindow::createConnections()
{
    connect(ui->leSearch, SIGNAL(returnPressed()), this, SLOT(searchAudio()));

    connect(playerControls, SIGNAL(play()), player, SLOT(play()));
    connect(playerControls, SIGNAL(pause()), player, SLOT(pause()));
    connect(playerControls, SIGNAL(volumeChanged(int)), player, SLOT(setVolume(int)));
    connect(playerControls, SIGNAL(playPositionChanged(qint64)), player, SLOT(setPosition(qint64)));

    connect(player, SIGNAL(positionChanged(qint64)), playerControls, SLOT(setPlayPosition(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), playerControls, SLOT(setAudioLength(qint64)));
    connect(player, SIGNAL(volumeChanged(int)), playerControls, SLOT(setVolume(int)));
    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), playerControls, SLOT(setState(QMediaPlayer::State)));
    connect(playlist, SIGNAL(titleChange(QString)), playerControls, SLOT(setTitle(QString)));

    connect(playerControls, SIGNAL(previous()), playlist, SLOT(previous()));
    connect(playerControls, SIGNAL(next()), playlist, SLOT(next()));

    connect(playerControls, SIGNAL(configure()), this, SLOT(showSettingsDialog()));

    connect(vkaudio, SIGNAL(statusChanged(QString, int)), this->statusBar(), SLOT(showMessage(QString,int)));

    connect(ui->tvSongs, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(playAudio()));
    connect(ui->tvSongs, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showSongsContextMenu(QPoint)));
    connect(ui->tvPlaylists, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPlaylistsContextMenu(QPoint)));
}
Esempio n. 4
0
void MainWindow::createFileMenu() {
  QMenu *fileMenu = this->menuBar()->addMenu(QString::fromUtf8("Файл"));
  QAction *accountsAction = fileMenu->addAction(QString::fromUtf8("Менеджер аккаунтов"));
  connect(accountsAction, SIGNAL(triggered()), this, SLOT(showAccountsDialog()));
  QAction *settingsAction = fileMenu->addAction(QString::fromUtf8("Настройки"));
  connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));
  fileMenu->addSeparator();
  QAction *quitAction = fileMenu->addAction(QString::fromUtf8("Выход"));
  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
Esempio n. 5
0
QtGnuplotWindow::QtGnuplotWindow(int id, QtGnuplotEventHandler* eventHandler, QWidget* parent)
    : QMainWindow(parent)
{
    m_eventHandler = eventHandler;
    m_id = id;
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowIcon(QIcon(":/images/gnuplot"));

    // Register as the main event receiver if not already created
    if (m_eventHandler == 0)
        m_eventHandler = new QtGnuplotEventHandler(this,
                "qtgnuplot" + QString::number(QCoreApplication::applicationPid()));

    // Central widget
    m_widget = new QtGnuplotWidget(m_id, m_eventHandler, this);
    connect(m_widget, SIGNAL(statusTextChanged(const QString&)), this, SLOT(on_setStatusText(const QString&)));
    setCentralWidget(m_widget);

    // Bars
    m_toolBar = new QToolBar(this);
    addToolBar(m_toolBar);
    statusBar()->showMessage(tr("Qt frontend for gnuplot"));

    // Actions
    QAction* copyToClipboardAction = new QAction(QIcon(":/images/clipboard"   ), tr("Copy to clipboard"), this);
    QAction* printAction           = new QAction(QIcon(":/images/print"       ), tr("Print"            ), this);
    QAction* exportAction          = new QAction(QIcon(":/images/export"      ), tr("Export"           ), this);
    QAction* exportPdfAction       = new QAction(QIcon(":/images/exportPDF"   ), tr("Export to PDF"    ), this);
    QAction* exportEpsAction       = new QAction(QIcon(":/images/exportVector"), tr("Export to EPS"    ), this);
    QAction* exportSvgAction       = new QAction(QIcon(":/images/exportVector"), tr("Export to SVG"    ), this);
    QAction* exportPngAction       = new QAction(QIcon(":/images/exportRaster"), tr("Export to image"  ), this);
    QAction* settingsAction        = new QAction(QIcon(":/images/settings"    ), tr("Settings"         ), this);
    connect(copyToClipboardAction, SIGNAL(triggered()), m_widget, SLOT(copyToClipboard()));
    connect(printAction,           SIGNAL(triggered()), m_widget, SLOT(print()));
    connect(exportPdfAction,       SIGNAL(triggered()), m_widget, SLOT(exportToPdf()));
    connect(exportEpsAction,       SIGNAL(triggered()), m_widget, SLOT(exportToEps()));
    connect(exportSvgAction,       SIGNAL(triggered()), m_widget, SLOT(exportToSvg()));
    connect(exportPngAction,       SIGNAL(triggered()), m_widget, SLOT(exportToImage()));
    connect(settingsAction,        SIGNAL(triggered()), m_widget, SLOT(showSettingsDialog()));
    QMenu* exportMenu = new QMenu(this);
    exportMenu->addAction(copyToClipboardAction);
    exportMenu->addAction(printAction);
    exportMenu->addAction(exportPdfAction);
//	exportMenu->addAction(exportEpsAction);
    exportMenu->addAction(exportSvgAction);
    exportMenu->addAction(exportPngAction);
    exportAction->setMenu(exportMenu);
    m_toolBar->addAction(exportAction);
    createAction(tr("Replot")       , 'e', ":/images/replot");
    createAction(tr("Show grid")    , 'g', ":/images/grid");
    createAction(tr("Previous zoom"), 'p', ":/images/zoomPrevious");
    createAction(tr("Next zoom")    , 'n', ":/images/zoomNext");
    createAction(tr("Autoscale")    , 'a', ":/images/autoscale");
    m_toolBar->addAction(settingsAction);
}
Esempio n. 6
0
void Application::slotParseMessage(const QString &msg, QObject*)
{
    if (msg.startsWith(QLatin1String("MSG_PARSEOPTIONS:"))) {
        const int lengthOfMsgPrefix = 17;
        QStringList options = msg.mid(lengthOfMsgPrefix).split(QLatin1Char('|'));
        parseOptions(options);
        setupLogging();
    } else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) {
        showSettingsDialog();
    }
}
Esempio n. 7
0
QAction *BApplicationPrivate::createStandardAction(BGuiTools::StandardAction type, QObject *parent)
{
    if (!testInit("BApplicationPrivate"))
        return 0;
    QAction *act = 0;
    switch (type) {
    case BGuiTools::SettingsAction:
        act = new QAction(parent);
        act->setMenuRole(QAction::PreferencesRole);
        act->setObjectName("ActionSettings");
        act->setIcon(BApplication::icon("configure"));
        act->setShortcut(QKeySequence::Preferences);
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showSettingsDialog()));
        break;
    case BGuiTools::HomepageAction:
        act = new QAction(parent);
        act->setObjectName("ActionHomepage");
        act->setIcon(BApplication::icon("gohome"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(openHomepage()));
        break;
    case BGuiTools::HelpContentsAction:
        act = new QAction(parent);
        act->setObjectName("ActionHelpContents");
        act->setIcon(BApplication::beqtIcon("help_contents"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showHelpContents()));
        break;
    case BGuiTools::ContextualHelpAction:
        act = new QAction(parent);
        act->setObjectName("ActionContextualHelp");
        act->setIcon(BApplication::icon("help_contextual"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showContextualHelp()));
        break;
    case BGuiTools::WhatsThisAction:
        act = QWhatsThis::createAction(parent);
        act->setObjectName("ActionWhatsThis");
        act->setIcon(BApplication::beqtIcon("help_hint"));
        break;
    case BGuiTools::AboutAction:
        act = new QAction(parent);
        act->setMenuRole(QAction::AboutRole);
        act->setObjectName("ActionAbout");
        act->setIcon(BApplication::icon("help_about"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showAboutDialog()));
        break;
    default:
        return 0;
    }
    act->setProperty("beqt/standard_action_type", type);
    qs_func()->ds_func()->actions.insert(act, act);
    connect(act, SIGNAL(destroyed(QObject *)), qs_func()->ds_func(), SLOT(actionDestroyed(QObject *)));
    retranslateStandardAction(act);
    return act;
}
Esempio n. 8
0
MainWindow::MainWindow() :
    StackedWindow(),
    m_serviceModel(new ServiceModel(this)),
    m_serviceAction(new ValueSelectorAction(this)),
    m_nowPlayingAction(new NowPlayingAction(this)),
    m_playFolderAction(new QAction(tr("Play folder"), this)),
    m_queueFolderAction(new QAction(tr("Queue folder"), this)),
    m_playUrlAction(new QAction(tr("Play URL"), this)),
    m_queueUrlAction(new QAction(tr("Queue URL"), this)),
    m_transfersAction(new QAction(tr("Transfers"), this)),
    m_settingsAction(new QAction(tr("Settings"), this)),
    m_aboutAction(new QAction(tr("About"), this))
{
    m_serviceAction->setText(tr("Service"));
    m_serviceAction->setModel(m_serviceModel);
    m_serviceAction->setValue(Settings::currentService());
    
    menuBar()->addAction(m_serviceAction);
    menuBar()->addAction(m_playFolderAction);
    menuBar()->addAction(m_queueFolderAction);
    menuBar()->addAction(m_playUrlAction);
    menuBar()->addAction(m_queueUrlAction);
    menuBar()->addAction(m_transfersAction);
    menuBar()->addAction(m_settingsAction);
    menuBar()->addAction(m_aboutAction);
    menuBar()->addAction(m_nowPlayingAction);
    
    connect(m_serviceAction, SIGNAL(valueChanged(QVariant)), this, SLOT(setService(QVariant)));
    connect(m_playFolderAction, SIGNAL(triggered()), this, SLOT(playFolder()));
    connect(m_queueFolderAction, SIGNAL(triggered()), this, SLOT(queueFolder()));
    connect(m_playUrlAction, SIGNAL(triggered()), this, SLOT(playUrl()));
    connect(m_queueUrlAction, SIGNAL(triggered()), this, SLOT(queueUrl()));
    connect(m_transfersAction, SIGNAL(triggered()), this, SLOT(showTransfers()));
    connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));
    connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
    connect(AudioPlayer::instance(), SIGNAL(statusChanged(AudioPlayer::Status)),
            this, SLOT(onPlayerStatusChanged(AudioPlayer::Status)));
    connect(Transfers::instance(), SIGNAL(transferAdded(Transfer*)), this, SLOT(onTransferAdded(Transfer*)));
    
    setService(Settings::currentService());
}
Esempio n. 9
0
File: app.cpp Progetto: KDE/kshisen
void App::setupActions()
{
    // Game
    KStandardGameAction::gameNew(this, SIGNAL(invokeNewGame()), actionCollection());
    KStandardGameAction::restart(this, SLOT(restartGame()), actionCollection());
    KStandardGameAction::pause(this, SLOT(togglePause()), actionCollection());
    KStandardGameAction::highscores(this, SLOT(showHighscores()), actionCollection());
    KStandardGameAction::quit(this, SLOT(close()), actionCollection());

    // Move
    KStandardGameAction::undo(this, SLOT(undo()), actionCollection());
    KStandardGameAction::redo(this, SLOT(redo()), actionCollection());
    KStandardGameAction::hint(this, SLOT(hint()), actionCollection());

    auto soundAction = new KToggleAction(QIcon::fromTheme(QStringLiteral("speaker")), i18n("Play Sounds"), this);
    soundAction->setChecked(Prefs::sounds());
    actionCollection()->addAction(QStringLiteral("sounds"), soundAction);
    connect(soundAction, &KToggleAction::triggered, m_board, &Board::setSoundsEnabled);

    // Settings
    KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection());

    connect(m_board, &Board::cheatStatusChanged, this, &App::updateCheatDisplay);
    connect(m_board, &Board::changed, this, &App::updateItems);
    connect(m_board, &Board::tilesDoNotMatch, this, &App::notifyTilesDoNotMatch);
    connect(m_board, &Board::invalidMove, this, &App::notifyInvalidMove);
    connect(m_board, &Board::selectATile, this, &App::notifySelectATile);
    connect(m_board, &Board::selectAMatchingTile, this, &App::notifySelectAMatchingTile);
    connect(m_board, &Board::selectAMove, this, &App::notifySelectAMove);

    auto timer = new QTimer(this);
    connect(timer, &QTimer::timeout, this, &App::updateTimeDisplay);
    timer->start(1000);

    connect(m_board, &Board::tileCountChanged, this, &App::updateTileDisplay);
    connect(m_board, &Board::endOfGame, this, &App::slotEndOfGame);

    connect(this, &App::invokeNewGame, m_board, &Board::newGame);
    connect(m_board, &Board::newGameStarted, this, &App::newGame);
}
void MainWindow::loadConfig(){
	QDir configLocation(QDir::homePath()+"/.config/glop_conf");
	bool ok1,ok2,ok3;
	if(!configLocation.exists())
		configLocation.mkpath(QDir::homePath()+"/.config/glop_conf");
	GlopConfig::Settings s = GlopConfig::ParseFile( (QDir::homePath()+"/.config/glop_conf/simplifiedVideoLibraryRenamer.conf").toStdString() );
	importLocation = QString::fromStdString(s.values["import location"]);
	libraryLocation = QString::fromStdString(s.values["library location"]);
	ok3 = importLocation.length()>0;
	importLocation = QFileInfo(importLocation).absoluteFilePath(); // returns current dir if empty string
	libraryLocation = QFileInfo(libraryLocation).absoluteFilePath();

	QString temp = QString::fromStdString(s.values["season number length"]);
	seasonNumberLength = temp.toInt(&ok1);
	if(!ok1) seasonNumberLength = 5;

	temp = QString::fromStdString(s.values["episode number length"]);
	episodeNumberLength = temp.toInt(&ok2);
	if(!ok2) episodeNumberLength = 5;

	if(!(ok1 && ok2 && ok3)){
		showSettingsDialog();
	}
}
Esempio n. 11
0
void MainWindow::finalize()
{
	resetWindowTitle();
	setWindowIcon( embed::getIconPixmap( "icon" ) );


	// project-popup-menu
	QMenu * project_menu = new QMenu( this );
	menuBar()->addMenu( project_menu )->setText( tr( "&File" ) );
	project_menu->addAction( embed::getIconPixmap( "project_new" ),
					tr( "&New" ),
					this, SLOT( createNewProject() ),
					QKeySequence::New );

	m_templatesMenu = new QMenu( tr("New from template"), this );
	connect( m_templatesMenu, SIGNAL( aboutToShow() ), SLOT( fillTemplatesMenu() ) );
	connect( m_templatesMenu, SIGNAL( triggered( QAction * ) ),
		 SLOT( createNewProjectFromTemplate( QAction * ) ) );

	project_menu->addMenu(m_templatesMenu);

	project_menu->addAction( embed::getIconPixmap( "project_open" ),
					tr( "&Open..." ),
					this, SLOT( openProject() ),
					QKeySequence::Open );

	m_recentlyOpenedProjectsMenu = project_menu->addMenu(
				embed::getIconPixmap( "project_open_recent" ),
					tr( "&Recently Opened Projects" ) );
	connect( m_recentlyOpenedProjectsMenu, SIGNAL( aboutToShow() ),
			this, SLOT( updateRecentlyOpenedProjectsMenu() ) );
	connect( m_recentlyOpenedProjectsMenu, SIGNAL( triggered( QAction * ) ),
			this, SLOT( openRecentlyOpenedProject( QAction * ) ) );

	project_menu->addAction( embed::getIconPixmap( "project_save" ),
					tr( "&Save" ),
					this, SLOT( saveProject() ),
					QKeySequence::Save );
	project_menu->addAction( embed::getIconPixmap( "project_saveas" ),
					tr( "Save &As..." ),
					this, SLOT( saveProjectAs() ),
					Qt::CTRL + Qt::SHIFT + Qt::Key_S );
	project_menu->addAction( embed::getIconPixmap( "project_save" ),
					tr( "Save as New &Version" ),
					this, SLOT( saveProjectAsNewVersion() ),
					Qt::CTRL + Qt::ALT + Qt::Key_S );

	project_menu->addAction( tr( "Save as default template" ),
				     this, SLOT( saveProjectAsDefaultTemplate() ) );

	project_menu->addSeparator();
	project_menu->addAction( embed::getIconPixmap( "project_import" ),
					tr( "Import..." ),
					Engine::getSong(),
					SLOT( importProject() ) );
	project_menu->addAction( embed::getIconPixmap( "project_export" ),
					tr( "E&xport..." ),
					Engine::getSong(),
					SLOT( exportProject() ),
					Qt::CTRL + Qt::Key_E );
	project_menu->addAction( embed::getIconPixmap( "project_export" ),
					tr( "E&xport Tracks..." ),
					Engine::getSong(),
					SLOT( exportProjectTracks() ),
					Qt::CTRL + Qt::SHIFT + Qt::Key_E );

	// temporarily disabled broken MIDI export				
	/*project_menu->addAction( embed::getIconPixmap( "midi_file" ),
					tr( "Export &MIDI..." ),
					Engine::getSong(),
					SLOT( exportProjectMidi() ),
					Qt::CTRL + Qt::Key_M );*/

	project_menu->addSeparator();
	project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ),
					qApp, SLOT( closeAllWindows() ),
					Qt::CTRL + Qt::Key_Q );


	QMenu * edit_menu = new QMenu( this );
	menuBar()->addMenu( edit_menu )->setText( tr( "&Edit" ) );
	m_undoAction = edit_menu->addAction( embed::getIconPixmap( "edit_undo" ),
					tr( "Undo" ),
					this, SLOT( undo() ),
					QKeySequence::Undo );
	m_redoAction = edit_menu->addAction( embed::getIconPixmap( "edit_redo" ),
					tr( "Redo" ),
					this, SLOT( redo() ),
					QKeySequence::Redo );
	// Ensure that both (Ctrl+Y) and (Ctrl+Shift+Z) activate redo shortcut regardless of OS defaults
	if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::Key_Y))
	{
		new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_Y ), this, SLOT(redo()) );
	}
	if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z ))
	{
		new QShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Z ), this, SLOT(redo()) );
	}

	edit_menu->addSeparator();
	edit_menu->addAction( embed::getIconPixmap( "setup_general" ),
					tr( "Settings" ),
					this, SLOT( showSettingsDialog() ) );
	connect( edit_menu, SIGNAL(aboutToShow()), this, SLOT(updateUndoRedoButtons()) );

	m_viewMenu = new QMenu( this );
	menuBar()->addMenu( m_viewMenu )->setText( tr( "&View" ) );
	connect( m_viewMenu, SIGNAL( aboutToShow() ),
		 this, SLOT( updateViewMenu() ) );
	connect( m_viewMenu, SIGNAL(triggered(QAction*)), this,
		SLOT(updateConfig(QAction*)));


	m_toolsMenu = new QMenu( this );
	for( const Plugin::Descriptor* desc : pluginFactory->descriptors(Plugin::Tool) )
	{
		m_toolsMenu->addAction( desc->logo->pixmap(), desc->displayName );
		m_tools.push_back( ToolPlugin::instantiate( desc->name, /*this*/NULL )
						   ->createView(this) );
	}
	if( !m_toolsMenu->isEmpty() )
	{
		menuBar()->addMenu( m_toolsMenu )->setText( tr( "&Tools" ) );
		connect( m_toolsMenu, SIGNAL( triggered( QAction * ) ),
					this, SLOT( showTool( QAction * ) ) );
	}
Esempio n. 12
0
void KJumpingCube::initKAction() {
  QAction * action;

  QSignalMapper * gameMapper = new QSignalMapper (this);
  connect (gameMapper, SIGNAL (mapped(int)), m_game, SLOT (gameActions(int)));

  action = KStandardGameAction::gameNew (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, NEW);

  action = KStandardGameAction::load    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, LOAD);

  action = KStandardGameAction::save    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, SAVE);

  action = KStandardGameAction::saveAs  (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, SAVE_AS);

  action = KStandardGameAction::hint    (gameMapper, SLOT(map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, HINT);

  action = KStandardGameAction::undo    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, UNDO);
  action->setEnabled (false);

  action = KStandardGameAction::redo    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, REDO);
  action->setEnabled (false);

  actionButton = new QPushButton (this);
  actionButton->setObjectName ("ActionButton");
  // Action button's style sheet: parameters for red, green and clicked colors.
  buttonLook =
       "QPushButton#ActionButton { color: white; background-color: %1; "
           "border-style: outset; border-width: 2px; border-radius: 10px; "
           "border-color: beige; font: bold 14px; min-width: 10em; "
           "padding: 6px; margin: 5px; margin-left: 10px; } "
       "QPushButton#ActionButton:pressed { background-color: %2; "
           "border-style: inset; } "
       "QPushButton#ActionButton:disabled { color: white;"
            "border-color: beige; background-color: steelblue; }";
  gameMapper->setMapping (actionButton, BUTTON);
  connect (actionButton, SIGNAL(clicked()), gameMapper, SLOT(map()));

  QWidgetAction *widgetAction = new QWidgetAction(this);
  widgetAction->setDefaultWidget(actionButton);
  actionCollection()->addAction (QLatin1String ("action_button"), widgetAction);

  changeButton (true, true);		// Load the button's style sheet.
  changeButton (false);			// Set the button to be inactive.

  action = KStandardAction::preferences (m_game, SLOT(showSettingsDialog()),
                                         actionCollection());
  qDebug() << "PREFERENCES ACTION is" << action->objectName();
  action->setIconText (i18n("Settings"));

  action = KStandardGameAction::quit (this, SLOT (close()), this);
  actionCollection()->addAction (action->objectName(), action);

  setupGUI();
}
Esempio n. 13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    m_fileMenu(new QMenu(tr("&File"), this)),
    m_viewMenu(new QMenu(tr("&View"), this)),
    m_playbackMenu(new QMenu(tr("&Playback"), this)),
    m_transfersMenu(new QMenu(tr("&Downloads"), this)),
    m_editMenu(new QMenu(tr("&Edit"), this)),
    m_helpMenu(new QMenu(tr("&About"), this)),
    m_openFilesAction(new QAction(QIcon::fromTheme("document-open"), tr("&Open files"), this)),
    m_openUrlAction(new QAction(QIcon::fromTheme("folder-remote"), tr("Open &URL"), this)),
    m_addFilesAction(new QAction(QIcon::fromTheme("list-add"), tr("&Add files"), this)),
    m_addUrlAction(new QAction(QIcon::fromTheme("folder-remote"), tr("Add &URL"), this)),
    m_searchAction(new QAction(QIcon::fromTheme("edit-find"), tr("&Search"), this)),
    m_pluginsAction(new QAction(QIcon::fromTheme("view-refresh"), tr("Load &plugins"), this)),
    m_quitAction(new QAction(QIcon::fromTheme("application-exit"), tr("&Quit"), this)),
    m_showPlaybackQueueAction(new QAction(QIcon::fromTheme("music-library"), tr("Show &playback queue"), this)),
    m_showTransfersAction(new QAction(QIcon::fromTheme("folder-publicshare"), tr("Show &transfers"), this)),
    m_reloadAction(new QAction(QIcon::fromTheme("view-refresh"), tr("&Reload current tab"), this)),
    m_closeAction(new QAction(QIcon::fromTheme("list-remove"), tr("&Close current tab"), this)),
    m_playPauseAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Play"), this)),
    m_stopAction(new QAction(QIcon::fromTheme("media-playback-stop"), tr("&Stop"), this)),
    m_previousAction(new QAction(QIcon::fromTheme("media-skip-backward"), tr("&Previous"), this)),
    m_nextAction(new QAction(QIcon::fromTheme("media-skip-forward"), tr("&Next"), this)),
    m_repeatAction(new QAction(QIcon::fromTheme("media-playlist-repeat"), tr("&Repeat"), this)),
    m_shuffleAction(new QAction(QIcon::fromTheme("media-playlist-shuffle"), tr("&Shuffle"), this)),
    m_stopAfterCurrentAction(new QAction(tr("Stop &after current track"), this)),
    m_clearAction(new QAction(QIcon::fromTheme("list-remove"), tr("&Clear playback queue"), this)),
    m_startTransfersAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Start transfers"), this)),
    m_pauseTransfersAction(new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause transfers"), this)),
    m_settingsAction(new QAction(QIcon::fromTheme("preferences-desktop"), tr("&Preferences"), this)),
    m_aboutAction(new QAction(QIcon::fromTheme("help-about"), tr("&About"), this)),
    m_positionSpacer(new QWidget(this)),
    m_positionSpacerAction(0),
    m_positionSlider(new QSlider(Qt::Horizontal, this)),
    m_positionSliderAction(0),
    m_positionLabel(new QLabel(this)),
    m_positionLabelAction(0),
    m_toolBar(new QToolBar(this)),
    m_widget(new QWidget(this)),
    m_tabWidget(new QTabWidget(m_widget)),
    m_nowPlayingMetaData(new ItemMetaData(m_widget)),
    m_layout(new QVBoxLayout(m_widget))
{
    setWindowTitle("MusiKloud2");
    
    // Initialise status bar
    statusBar();
    
    // Add menus
    menuBar()->addMenu(m_fileMenu);
    menuBar()->addMenu(m_viewMenu);
    menuBar()->addMenu(m_playbackMenu);
    menuBar()->addMenu(m_transfersMenu);
    menuBar()->addMenu(m_editMenu);
    menuBar()->addMenu(m_helpMenu);
    
    // Setup file menu
    m_fileMenu->addAction(m_openFilesAction);
    m_fileMenu->addAction(m_openUrlAction);
    m_fileMenu->addAction(m_addFilesAction);
    m_fileMenu->addAction(m_addUrlAction);
    m_fileMenu->addAction(m_searchAction);
    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_pluginsAction);
    m_fileMenu->addAction(m_quitAction);
    
    // Setup file menu actions
    m_openFilesAction->setShortcut(tr("Ctrl+O"));
    m_openUrlAction->setShortcut(tr("Ctrl+U"));
    m_addFilesAction->setShortcut(tr("Ctrl+Shift+O"));
    m_addUrlAction->setShortcut(tr("Ctrl+Shift+U"));
    m_searchAction->setShortcut(tr("Ctrl+Y"));
    m_pluginsAction->setShortcut(tr("Ctrl+L"));
    m_quitAction->setShortcut(tr("Ctrl+Q"));
    
    // Setup view menu
    m_viewMenu->addAction(m_showPlaybackQueueAction);
    m_viewMenu->addAction(m_showTransfersAction);
    m_viewMenu->addSeparator();
    m_viewMenu->addAction(m_reloadAction);
    m_viewMenu->addAction(m_closeAction);
    
    // Setup view menu actions
    m_reloadAction->setEnabled(false);
    m_closeAction->setShortcut(tr("Ctrl+W"));
    m_closeAction->setEnabled(false);
    
    // Setup playback menu
    m_playbackMenu->addAction(m_playPauseAction);
    m_playbackMenu->addAction(m_stopAction);
    m_playbackMenu->addAction(m_previousAction);
    m_playbackMenu->addAction(m_nextAction);
    m_playbackMenu->addSeparator();
    m_playbackMenu->addAction(m_repeatAction);
    m_playbackMenu->addAction(m_shuffleAction);
    m_playbackMenu->addAction(m_stopAfterCurrentAction);
    m_playbackMenu->addSeparator();
    m_playbackMenu->addAction(m_clearAction);
    
    // Setup playback menu actions
    m_playPauseAction->setShortcut(tr("Ctrl+Return"));
    m_stopAction->setShortcut(tr("Ctrl+."));
    m_previousAction->setShortcut(tr("Alt+Up"));
    m_nextAction->setShortcut(tr("Alt+Down"));
    m_repeatAction->setCheckable(true);
    m_repeatAction->setShortcut(tr("Ctrl+R"));
    m_repeatAction->setToolTip(tr("Toggle repeat playback mode"));
    m_shuffleAction->setCheckable(true);
    m_shuffleAction->setShortcut(tr("Ctrl+S"));
    m_shuffleAction->setToolTip(tr("Toggle shuffle playback mode"));
    m_stopAfterCurrentAction->setCheckable(true);
    m_clearAction->setShortcut(tr("Ctrl+Shift+X"));
    
    // Setup transfers menu
    m_transfersMenu->addAction(m_startTransfersAction);
    m_transfersMenu->addAction(m_pauseTransfersAction);
    
    // Setup edit menu
    m_editMenu->addAction(m_settingsAction);
    
    // Setup edit menu actions
    m_settingsAction->setShortcut(tr("Ctrl+P"));
    
    // Setup help menu
    m_helpMenu->addAction(m_aboutAction);

    // Setup toolbar
    m_toolBar->setObjectName("mainToolBar");
    m_toolBar->setWindowTitle(tr("Main toolbar"));
    m_toolBar->setMovable(false);
    m_toolBar->setAllowedAreas(Qt::TopToolBarArea);
    m_toolBar->addAction(m_openFilesAction);
    m_toolBar->addAction(m_addFilesAction);
    m_toolBar->addAction(m_searchAction);
    m_toolBar->addAction(m_previousAction);
    m_toolBar->addAction(m_nextAction);
    m_toolBar->addAction(m_playPauseAction);
    m_toolBar->addAction(m_stopAction);
    m_positionSpacerAction = m_toolBar->addWidget(m_positionSpacer);
    m_positionSliderAction = m_toolBar->addWidget(m_positionSlider);
    m_positionLabelAction = m_toolBar->addWidget(m_positionLabel);
    m_toolBar->addAction(m_repeatAction);
    m_toolBar->addAction(m_shuffleAction);
    addToolBar(Qt::TopToolBarArea, m_toolBar);
    
    // Setup position spacer, slider and label
    m_positionSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_positionSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_positionSliderAction->setVisible(false);
    m_positionLabel->setFixedWidth(m_positionLabel->fontMetrics().width("000:00 / 000:00"));
    m_positionLabel->setAlignment(Qt::AlignCenter);
    m_positionLabelAction->setVisible(false);
    
    // Setup tab widget
    m_tabWidget->setTabsClosable(true);
    m_tabWidget->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectLeftTab);
    m_tabWidget->tabBar()->setExpanding(false);
    
    // Setup now playing metadata
    m_nowPlayingMetaData->setStyleSheet("font-weight: bold");
    m_nowPlayingMetaData->setThumbnailSize(QSize(96, 96));
    m_nowPlayingMetaData->hide();
    
    // Setup layout
    m_layout->addWidget(m_tabWidget);
    m_layout->addWidget(m_nowPlayingMetaData);
    m_layout->setContentsMargins(0, 0, 0, 0);
    setCentralWidget(m_widget);
    
    // Restore window geometry/state
    restoreGeometry(Settings::mainWindowGeometry());
    restoreState(Settings::mainWindowState());
    
    // Connect signals and slots
    connect(AudioPlayer::instance(), SIGNAL(durationChanged(qint64)), this, SLOT(onPlayerDurationChanged(qint64)));
    connect(AudioPlayer::instance(), SIGNAL(metaDataChanged()), this, SLOT(updateNowPlayingMetaData()));
    connect(AudioPlayer::instance(), SIGNAL(positionChanged(qint64)), this, SLOT(onPlayerPositionChanged(qint64)));
    connect(AudioPlayer::instance(), SIGNAL(seekableChanged(bool)), this, SLOT(onPlayerSeekableChanged(bool)));
    connect(AudioPlayer::instance(), SIGNAL(statusChanged(AudioPlayer::Status)),
            this, SLOT(onPlayerStatusChanged(AudioPlayer::Status)));
    connect(m_openFilesAction, SIGNAL(triggered()), this, SLOT(openFiles()));
    connect(m_openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(m_addFilesAction, SIGNAL(triggered()), this, SLOT(addFiles()));
    connect(m_addUrlAction, SIGNAL(triggered()), this, SLOT(addUrl()));
    connect(m_searchAction, SIGNAL(triggered()), this, SLOT(search()));
    connect(m_pluginsAction, SIGNAL(triggered()), this, SLOT(loadPlugins()));
    connect(m_quitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(m_showPlaybackQueueAction, SIGNAL(triggered()), this, SLOT(showPlaybackQueue()));
    connect(m_showTransfersAction, SIGNAL(triggered()), this, SLOT(showTransfers()));
    connect(m_reloadAction, SIGNAL(triggered()), this, SLOT(reloadCurrentTab()));
    connect(m_closeAction, SIGNAL(triggered()), this, SLOT(closeCurrentTab()));
    connect(m_playPauseAction, SIGNAL(triggered()), AudioPlayer::instance(), SLOT(togglePlaying()));
    connect(m_stopAction, SIGNAL(triggered()), AudioPlayer::instance(), SLOT(stop()));
    connect(m_previousAction, SIGNAL(triggered()), AudioPlayer::instance(), SLOT(previous()));
    connect(m_nextAction, SIGNAL(triggered()), AudioPlayer::instance(), SLOT(next()));
    connect(m_repeatAction, SIGNAL(triggered(bool)), AudioPlayer::instance(), SLOT(setRepeatEnabled(bool)));
    connect(m_shuffleAction, SIGNAL(triggered(bool)), AudioPlayer::instance(), SLOT(setShuffleEnabled(bool)));
    connect(m_stopAfterCurrentAction, SIGNAL(triggered(bool)),
            AudioPlayer::instance(), SLOT(setStopAfterCurrentTrack(bool)));
    connect(m_clearAction, SIGNAL(triggered()), AudioPlayer::instance(), SLOT(clearQueue()));
    connect(m_startTransfersAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start()));
    connect(m_pauseTransfersAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause()));
    connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));
    connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
    connect(m_positionSlider, SIGNAL(sliderReleased()), this, SLOT(updatePlayerPosition()));
    connect(m_positionSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
    connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabStatusChanged()));
    connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
}
Esempio n. 14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    m_transferMenu(new QMenu(tr("Download"), this)),
    m_packageMenu(new QMenu(tr("Package"), this)),
    m_addUrlsAction(new QAction(QIcon::fromTheme("general_add"), tr("Add URLs"), this)),
    m_importUrlsAction(new QAction(QIcon::fromTheme("general_toolbar_folder"), tr("Import URLs"), this)),
    m_retrieveUrlsAction(new QAction(QIcon::fromTheme("general_search"), tr("Retrieve URLs"), this)),
    m_clipboardUrlsAction(new QAction(QIcon::fromTheme("general_share"), tr("Clipboard URLs"), this)),
    m_queueAction(new QAction(QIcon("/etc/hildon/theme/mediaplayer/Play.png"), tr("Start all DLs"), this)),
    m_pauseAction(new QAction(QIcon("/etc/hildon/theme/mediaplayer/Pause.png"), tr("Pause all DLs"), this)),
    m_propertiesAction(new QAction(QIcon::fromTheme("general_information"), tr("Properties"), this)),
    m_transferQueueAction(new QAction(tr("Start"), this)),
    m_transferPauseAction(new QAction(tr("Pause"), this)),
    m_transferCancelAction(new QAction(tr("Remove"), this)),
    m_transferCancelDeleteAction(new QAction(tr("Remove and delete files"), this)),
    m_packageQueueAction(new QAction(tr("Start"), this)),
    m_packagePauseAction(new QAction(tr("Pause"), this)),
    m_packageCancelAction(new QAction(tr("Remove"), this)),
    m_packageCancelDeleteAction(new QAction(tr("Remove and delete files"), this)),
    m_settingsAction(new QAction(tr("Settings"), this)),
    m_pluginsAction(new QAction(tr("Load plugins"), this)),
    m_aboutAction(new QAction(tr("About"), this)),
    m_concurrentAction(new ValueSelectorAction(tr("Maximum concurrent DLs"), this)),
    m_nextAction(new ValueSelectorAction(tr("After current DLs"), this)),
    m_view(new QTreeView(this)),
    m_toolBar(new QToolBar(this)),
    m_activeLabel(new QLabel(QString("%1DLs").arg(TransferModel::instance()->activeTransfers()), this)),
    m_speedLabel(new QLabel(Utils::formatBytes(TransferModel::instance()->totalSpeed()) + "/s", this))
{
    setWindowTitle("QDL");
    setCentralWidget(m_view);
    addToolBar(Qt::BottomToolBarArea, m_toolBar);

    menuBar()->addAction(m_concurrentAction);
    menuBar()->addAction(m_nextAction);
    menuBar()->addAction(m_queueAction);
    menuBar()->addAction(m_pauseAction);
    menuBar()->addAction(m_settingsAction);
    menuBar()->addAction(m_pluginsAction);
    menuBar()->addAction(m_aboutAction);

    m_addUrlsAction->setShortcut(tr("Ctrl+N"));
    m_importUrlsAction->setShortcut(tr("Ctrl+O"));
    m_retrieveUrlsAction->setShortcut(tr("Ctrl+F"));
    m_propertiesAction->setShortcut(tr("Ctrl+I"));
    m_propertiesAction->setEnabled(false);
    m_clipboardUrlsAction->setShortcut(tr("Ctrl+U"));
    m_pluginsAction->setShortcut(tr("Ctrl+L"));

    m_transferMenu->addAction(m_transferQueueAction);
    m_transferMenu->addAction(m_transferPauseAction);
    m_transferMenu->addAction(m_transferCancelAction);
    m_transferMenu->addAction(m_transferCancelDeleteAction);

    m_packageMenu->addAction(m_packageQueueAction);
    m_packageMenu->addAction(m_packagePauseAction);
    m_packageMenu->addAction(m_packageCancelAction);
    m_packageMenu->addAction(m_packageCancelDeleteAction);

    m_concurrentAction->setModel(new ConcurrentTransfersModel(m_concurrentAction));
    m_concurrentAction->setValue(Settings::maximumConcurrentTransfers());
    m_nextAction->setModel(new ActionModel(m_nextAction));
    m_nextAction->setValue(Settings::nextAction());

    QLabel *speedIcon = new QLabel(m_toolBar);
    speedIcon->setPixmap(QIcon::fromTheme("general_received").pixmap(m_toolBar->iconSize()));

    QWidget *spacer1 = new QWidget(m_toolBar);
    spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    
    QWidget *spacer2 = new QWidget(m_toolBar);
    spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    
    m_activeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    m_speedLabel->setMinimumWidth(m_speedLabel->fontMetrics().width("9999.99MB/s"));
    m_speedLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    m_toolBar->setAllowedAreas(Qt::BottomToolBarArea);
    m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
    m_toolBar->setMovable(false);
    m_toolBar->addAction(m_addUrlsAction);
    m_toolBar->addAction(m_importUrlsAction);
    m_toolBar->addAction(m_retrieveUrlsAction);
    m_toolBar->addAction(m_clipboardUrlsAction);
    m_toolBar->addAction(m_propertiesAction);
    m_toolBar->addWidget(spacer1);
    m_toolBar->addWidget(m_activeLabel);
    m_toolBar->addWidget(spacer2);
    m_toolBar->addWidget(m_speedLabel);
    m_toolBar->addWidget(speedIcon);

    m_view->setModel(TransferModel::instance());
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setExpandsOnDoubleClick(true);
    m_view->setItemsExpandable(true);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);

    QHeaderView *header = m_view->header();
    
    if (!header->restoreState(Settings::transferViewHeaderState())) {
        const QFontMetrics fm = header->fontMetrics();
        header->resizeSection(0, 200);
        header->resizeSection(2, fm.width("999.99MB of 999.99MB (99.99%)"));
        header->resizeSection(3, fm.width("999.99KB/s"));
        header->hideSection(1); // Hide priority column
    }
    
    connect(Settings::instance(), SIGNAL(maximumConcurrentTransfersChanged(int)),
            this, SLOT(onMaximumConcurrentTransfersChanged(int)));
    connect(Settings::instance(), SIGNAL(nextActionChanged(int)), this, SLOT(onNextActionChanged(int)));
    
    connect(TransferModel::instance(), SIGNAL(captchaRequest(TransferItem*)), this, SLOT(showCaptchaDialog(TransferItem*)));
    connect(TransferModel::instance(), SIGNAL(settingsRequest(TransferItem*)), this, SLOT(showPluginSettingsDialog(TransferItem*)));
    connect(TransferModel::instance(), SIGNAL(activeTransfersChanged(int)), this, SLOT(onActiveTransfersChanged(int)));
    connect(TransferModel::instance(), SIGNAL(totalSpeedChanged(int)), this, SLOT(onTotalSpeedChanged(int)));

    connect(m_transferMenu, SIGNAL(aboutToShow()), this, SLOT(setTransferMenuActions()));
    connect(m_packageMenu, SIGNAL(aboutToShow()), this, SLOT(setPackageMenuActions()));

    connect(m_addUrlsAction, SIGNAL(triggered()), this, SLOT(showAddUrlsDialog()));
    connect(m_importUrlsAction, SIGNAL(triggered()), this, SLOT(showImportUrlsDialog()));
    connect(m_retrieveUrlsAction, SIGNAL(triggered()), this, SLOT(showRetrieveUrlsDialog()));
    connect(m_clipboardUrlsAction, SIGNAL(triggered()), this, SLOT(showClipboardUrlsDialog()));
    connect(m_queueAction, SIGNAL(triggered()), TransferModel::instance(), SLOT(queue()));
    connect(m_pauseAction, SIGNAL(triggered()), TransferModel::instance(), SLOT(pause()));
    connect(m_propertiesAction, SIGNAL(triggered()), this, SLOT(showCurrentItemProperties()));
    
    connect(m_transferQueueAction, SIGNAL(triggered()), this, SLOT(queueCurrentTransfer()));
    connect(m_transferPauseAction, SIGNAL(triggered()), this, SLOT(pauseCurrentTransfer()));
    connect(m_transferCancelAction, SIGNAL(triggered()), this, SLOT(cancelCurrentTransfer()));
    connect(m_transferCancelDeleteAction, SIGNAL(triggered()), this, SLOT(cancelAndDeleteCurrentTransfer()));

    connect(m_packageQueueAction, SIGNAL(triggered()), this, SLOT(queueCurrentPackage()));
    connect(m_packagePauseAction, SIGNAL(triggered()), this, SLOT(pauseCurrentPackage()));
    connect(m_packageCancelAction, SIGNAL(triggered()), this, SLOT(cancelCurrentPackage()));
    connect(m_packageCancelDeleteAction, SIGNAL(triggered()), this, SLOT(cancelAndDeleteCurrentPackage()));

    connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));
    connect(m_pluginsAction, SIGNAL(triggered()), this, SLOT(loadPlugins()));
    connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));

    connect(m_concurrentAction, SIGNAL(valueChanged(QVariant)), this, SLOT(setMaximumConcurrentTransfers(QVariant)));
    connect(m_nextAction, SIGNAL(valueChanged(QVariant)), this, SLOT(setNextAction(QVariant)));

    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_view->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(onCurrentRowChanged(QModelIndex)));
}
LauncherWindow::LauncherWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::LauncherWindow)
{
    // Setup form from ui-file
    ui->setupUi(this);

    // Make news menuitems like radiobuttons (it's impossible from qt-designer)
    QActionGroup *newsGroup = new QActionGroup(this);
    newsGroup->addAction(ui->ttyhNews);
    newsGroup->addAction(ui->officialNews);

    ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(ui->webView, SIGNAL(linkClicked(const QUrl&)), SLOT(linkClicked(const QUrl&)));

    // News Menu connections
    connect(ui->ttyhNews, SIGNAL(changed()), SLOT(loadTtyh()));
    connect(ui->officialNews, SIGNAL(changed()), SLOT(loadOfficial()));

    // Options Menu connections
    connect(ui->runSettings, SIGNAL(triggered()), SLOT(showSettingsDialog()));

    // Additional Menu connections
    connect(ui->changePassword, SIGNAL(triggered()), SLOT(showChangePasswordDialog()));
    connect(ui->changeSkin, SIGNAL(triggered()), SLOT(showSkinLoadDialog()));
    connect(ui->updateManager, SIGNAL(triggered()), SLOT(showUpdateManagerDialog()));

    // Help Menu connections
    connect(ui->bugReport, SIGNAL(triggered()), SLOT(showFeedBackDialog()));
    connect(ui->aboutLauncher, SIGNAL(triggered()), SLOT(showAboutDialog()));

    // Connect to settings
    Settings* settings = Settings::instance();

    // Setup login field
    ui->nickEdit->setText(settings->loadLogin());
    // Save login when changed
    connect(ui->nickEdit, SIGNAL(textChanged(QString)), settings, SLOT(saveLogin(QString)));

    // Setup password field
    ui->savePassword->setChecked(settings->loadPassStore());
    if (ui->savePassword->isChecked())
        ui->passEdit->setText(settings->loadPassword());
    // Password are saved on login or exit if savePassword is checked
    connect(ui->savePassword, SIGNAL(clicked(bool)), settings, SLOT(savePassStore(bool)));

    // Setup client combobox
    ui->clientCombo->addItems(settings->getClientsNames());
    ui->clientCombo->setCurrentIndex(settings->loadActiveClientId());
    connect(ui->clientCombo, SIGNAL(activated(int)), settings, SLOT(saveActiveClientId(int)));

    // Setup news set
    ui->ttyhNews->setChecked(true);
    emit ui->ttyhNews->changed();

    // Setup window parameters
    QRect geometry = settings->loadWindowGeometry();
    // Centering window, if loaded default values
    if (geometry.x() < 0)
        this->move(QApplication::desktop()->screen()->rect().center() - this->rect().center());
    else
        this->setGeometry(geometry);

    // Restore maximized state
    if (settings->loadMaximizedState()) this->showMaximized();

    connect(ui->playButton, SIGNAL(clicked()), this, SLOT(startGame()));

}
Esempio n. 16
0
AccountsToolButton::AccountsToolButton( QWidget* parent )
    : QToolButton( parent )
{
    m_popup = new AccountsPopupWidget( this );
    m_popup->hide();

    QToolBar* toolbar = qobject_cast< QToolBar* >( parent );
    if ( toolbar )
        setIconSize( toolbar->iconSize() );
    else
        setIconSize( QSize( 22, 22 ) );

    //Set up popup...
    QWidget *w = new QWidget( this );
    w->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
    QVBoxLayout *wMainLayout = new QVBoxLayout( w );
    w->setLayout( wMainLayout  );

    TomahawkUtils::unmarginLayout( w->layout() );

    w->setContentsMargins( 6, 6, 6, 6 );
#ifdef Q_OS_MAC
    w->setContentsMargins( 6, 6, 6, 0 );
    wMainLayout->setMargin( 12 );
#endif

    m_popup->setWidget( w );
    connect( m_popup, SIGNAL( hidden() ), SLOT( popupHidden() ) );

    m_model = new Tomahawk::Accounts::AccountModel( this );
    m_proxy = new AccountModelFactoryProxy( m_model );
    m_proxy->setSourceModel( m_model );
    m_proxy->setFilterRowType( Tomahawk::Accounts::AccountModel::TopLevelFactory );
    m_proxy->setFilterEnabled( true );

    AccountListWidget *view = new AccountListWidget( m_proxy, m_popup );
    wMainLayout->addWidget( view );
    view->setAutoFillBackground( false );
    view->setAttribute( Qt::WA_TranslucentBackground, true );

    connect( m_proxy, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
             this, SLOT( repaint() ) );

    QWidget *separatorLine = new QWidget( w );
    separatorLine->setFixedHeight( 1 );
    separatorLine->setContentsMargins( 0, 0, 0, 0 );
    separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
                                  TomahawkUtils::Colors::BORDER_LINE.name() + "; }" ); //from ProxyStyle
    wMainLayout->addWidget( separatorLine );

    wMainLayout->addSpacing( 6 );

    QPushButton *settingsButton = new QPushButton( w );
    settingsButton->setIcon( QIcon( RESPATH "images/account-settings.png" ) );
    settingsButton->setText( tr( "Configure Accounts" ) );
    connect( settingsButton, SIGNAL( clicked() ),
             window(), SLOT( showSettingsDialog() ) );

    QHBoxLayout *bottomLayout = new QHBoxLayout( w );
    TomahawkUtils::unmarginLayout( bottomLayout );
    bottomLayout->addStretch();
    bottomLayout->addWidget( settingsButton );
    wMainLayout->addLayout( bottomLayout );


    //ToolButton stuff
    m_defaultPixmap = QPixmap( RESPATH "images/account-none.png" )
                        .scaled( iconSize(),
                                 Qt::KeepAspectRatio,
                                 Qt::SmoothTransformation );

    connect( m_proxy, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
             this, SLOT( updateIcons() ) );
    connect( m_proxy, SIGNAL( rowsInserted ( QModelIndex, int, int ) ),
             this, SLOT( updateIcons() ) );
    connect( m_proxy, SIGNAL( rowsRemoved( QModelIndex, int, int ) ),
             this, SLOT( updateIcons() ) );
    connect( m_proxy, SIGNAL( modelReset() ),
             this, SLOT( updateIcons() ) );
}
Esempio n. 17
0
void MainWindow::setupActions()
{
    /*
    #StandardAction

        Offers standard actions.

        Those actions have standard names, icons and shortcuts.

        They are automatically put inside standard menus. For exampe, quit goes under "File".
    */
    {
        /* Adds "Quit" under file menu, default shortcut Ctrl + Q. */
        KStandardAction::quit(kapp, SLOT(quit()), actionCollection());

        /* Adds "Appname Preferences" under "Settings" menu. */
        KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection());
    }

    // Sample KAction action with all possible action features.
    // Activates a slot directly on textArea.
    {
        KAction* action = new KAction(this);
        action->setText(i18n("&Clear"));
        action->setIcon(KIcon("document-new"));
        action->setShortcut(Qt::CTRL + Qt::Key_W);
        // The first argument determines the action name
        actionCollection()->addAction("clear", action);
        connect(action, SIGNAL(triggered(bool)),
                textArea, SLOT(clear()));
    }

    /*
    #XMLGUI

        GUI components that can be configured via *ui.rc XML files.

        Examples:

        - KXmlGuiWindow

        XML Schema: <http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd>

    #XmlGuiWindow

        Suitable for a main window.

        Is usually used as a base class.

        Provides:

        - main menu with:

            - help
            - settings with "Configure Shortcuts" and "Configure Toolbars"

                Configure Shortcuts" automatically contains any shortcuts added to actions,
                in addition to many standard shortcuts.

                TODO where is Configure Shortcuts config stored?

            - Show statusbar

        - status bar

        As the name suggests, this class is part of the XMLGUI KDE technology.

    #MainWindow

        Good possibility for main window class.

        Inherits KXmlGuiWindow, so supports XMLGUI.
    */

    // TODO how to fix all the properties of the action via XMLGUI?
    // For example, setText().

    // This kaction activates a slot on the main window.
    {
        KAction* action = new KAction(this);
        action->setText(i18n("View Configuration"));
        actionCollection()->addAction("viewConfig", action);
        connect(action, SIGNAL(triggered(bool)),
                this, SLOT(viewConfig()));
    }

    // saveConfig action
    {
        KAction* action = new KAction(this);
        action->setText(i18n("Save Conf"));
        actionCollection()->addAction("saveConfig", action);
        connect(action, SIGNAL(triggered(bool)),
                this, SLOT(saveConfig()));
    }

    {
        KAction* action = new KAction(this);
        action->setText(i18n("Save Settings XT"));
        actionCollection()->addAction("saveSettingsXt", action);
        connect(action, SIGNAL(triggered(bool)),
                this, SLOT(saveSettingsXt()));
    }

    {
        KAction* action = new KAction(this);
        action->setText(i18n("Load Settings XT"));
        actionCollection()->addAction("loadSettingsXt", action);
        connect(action, SIGNAL(triggered(bool)),
                this, SLOT(loadSettingsXt()));
    }
}
Esempio n. 18
0
/*
 *  Constructs a MainWindow as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 */
MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
    : QMainWindow( parent, name, fl )
{
    (void)statusBar();
    if ( !name )
	setName( "MainWindow" );

    // actions
    actionFilePrint = new QAction( this, "actionFilePrint" );
    actionFilePrint->setIconSet( QIconSet( QPixmap::fromMimeSource( "print.png" ) ) );
    actionFileExit = new QAction( this, "actionFileExit" );
    actionEditCopy = new QAction( this, "actionEditCopy" );
    actionEditCopy->setIconSet( QIconSet( QPixmap::fromMimeSource( "editcopy.png" ) ) );
    actionEditFind = new QAction( this, "actionEditFind" );
    actionEditFind->setIconSet( QIconSet( QPixmap::fromMimeSource( "find.png" ) ) );
    actionEditFindAgain = new QAction( this, "actionEditFindAgain" );
    actionEditFindAgainPrev = new QAction( this, "actionEditFindAgainPrev" );
    actionGoHome = new QAction( this, "actionGoHome" );
    actionGoHome->setIconSet( QIconSet( QPixmap::fromMimeSource( "home.png" ) ) );
    actionGoPrevious = new QAction( this, "actionGoPrevious" );
    actionGoPrevious->setIconSet( QIconSet( QPixmap::fromMimeSource( "previous.png" ) ) );
    actionGoNext = new QAction( this, "actionGoNext" );
    actionGoNext->setIconSet( QIconSet( QPixmap::fromMimeSource( "next.png" ) ) );
    helpAbout_Qt_AssistantAction = new QAction( this, "helpAbout_Qt_AssistantAction" );
    actionAboutApplication = new QAction( this, "actionAboutApplication" );
    actionZoomIn = new QAction( this, "actionZoomIn" );
    actionZoomIn->setIconSet( QIconSet( QPixmap::fromMimeSource( "zoomin.png" ) ) );
    actionZoomOut = new QAction( this, "actionZoomOut" );
    actionZoomOut->setIconSet( QIconSet( QPixmap::fromMimeSource( "zoomout.png" ) ) );
    actionSettings = new QAction( this, "actionSettings" );
    actionNewWindow = new QAction( this, "actionNewWindow" );
    actionClose = new QAction( this, "actionClose" );
    actionAddBookmark = new QAction( this, "actionAddBookmark" );
    actionHelpWhatsThis = new QAction( this, "actionHelpWhatsThis" );
    actionHelpWhatsThis->setIconSet( QIconSet( QPixmap::fromMimeSource( "whatsthis.xpm" ) ) );
    actionOpenPage = new QAction( this, "actionOpenPage" );
    actionNextPage = new QAction( this, "actionNextPage" );
    actionPrevPage = new QAction( this, "actionPrevPage" );
    actionClosePage = new QAction( this, "actionClosePage" );
    actionHelpAssistant = new QAction( this, "actionHelpAssistant" );
    actionHelpAssistant->setIconSet( QIconSet( QPixmap::fromMimeSource( "assistant.png" ) ) );


    // toolbars
    Toolbar = new QToolBar( QString(""), this, DockTop ); 

    actionGoPrevious->addTo( Toolbar );
    actionGoNext->addTo( Toolbar );
    actionGoHome->addTo( Toolbar );
    Toolbar->addSeparator();
    actionEditCopy->addTo( Toolbar );
    actionEditFind->addTo( Toolbar );
    actionFilePrint->addTo( Toolbar );
    Toolbar->addSeparator();
    actionZoomIn->addTo( Toolbar );
    actionZoomOut->addTo( Toolbar );
    Toolbar->addSeparator();
    actionHelpWhatsThis->addTo( Toolbar );
    goActionToolbar = new QToolBar( QString(""), this, DockTop ); 



    // menubar
    menubar = new QMenuBar( this, "menubar" );

    menubar->setGeometry( QRect( 0, 0, 949, 29 ) );

    fileMenu = new QPopupMenu( this );
    actionNewWindow->addTo( fileMenu );
    actionOpenPage->addTo( fileMenu );
    actionClosePage->addTo( fileMenu );
    fileMenu->insertSeparator();
    actionFilePrint->addTo( fileMenu );
    fileMenu->insertSeparator();
    actionClose->addTo( fileMenu );
    actionFileExit->addTo( fileMenu );
    menubar->insertItem( QString(""), fileMenu, 2 );

    editMenu = new QPopupMenu( this );
    actionEditCopy->addTo( editMenu );
    actionEditFind->addTo( editMenu );
    actionEditFindAgain->addTo( editMenu );
    actionEditFindAgainPrev->addTo( editMenu );
    editMenu->insertSeparator();
    actionSettings->addTo( editMenu );
    menubar->insertItem( QString(""), editMenu, 3 );

    PopupMenu = new QPopupMenu( this );
    actionZoomIn->addTo( PopupMenu );
    actionZoomOut->addTo( PopupMenu );
    PopupMenu->insertSeparator();
    menubar->insertItem( QString(""), PopupMenu, 4 );

    goMenu = new QPopupMenu( this );
    actionGoPrevious->addTo( goMenu );
    actionGoNext->addTo( goMenu );
    actionGoHome->addTo( goMenu );
    goMenu->insertSeparator();
    actionNextPage->addTo( goMenu );
    actionPrevPage->addTo( goMenu );
    menubar->insertItem( QString(""), goMenu, 5 );

    bookmarkMenu = new QPopupMenu( this );
    menubar->insertItem( QString(""), bookmarkMenu, 6 );

    helpMenu = new QPopupMenu( this );
    actionHelpAssistant->addTo( helpMenu );
    helpMenu->insertSeparator();
    helpAbout_Qt_AssistantAction->addTo( helpMenu );
    actionAboutApplication->addTo( helpMenu );
    helpMenu->insertSeparator();
    actionHelpWhatsThis->addTo( helpMenu );
    menubar->insertItem( QString(""), helpMenu, 7 );

    languageChange();
    resize( QSize(949, 670).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( actionGoHome, SIGNAL( activated() ), this, SLOT( goHome() ) );
    connect( helpAbout_Qt_AssistantAction, SIGNAL( activated() ), this, SLOT( about() ) );
    connect( actionEditFind, SIGNAL( activated() ), this, SLOT( find() ) );
    connect( actionEditFindAgain, SIGNAL( activated() ), this, SLOT( findAgain() ) );
    connect( actionEditFindAgainPrev, SIGNAL( activated() ), this, SLOT( findAgainPrev() ) );
    connect( actionFilePrint, SIGNAL( activated() ), this, SLOT( print() ) );
    connect( actionSettings, SIGNAL( activated() ), this, SLOT( showSettingsDialog() ) );
    connect( actionNewWindow, SIGNAL( activated() ), this, SLOT( newWindow() ) );
    connect( actionClose, SIGNAL( activated() ), this, SLOT( close() ) );
    connect( actionHelpWhatsThis, SIGNAL( activated() ), this, SLOT( whatsThis() ) );
    connect( actionHelpAssistant, SIGNAL( activated() ), this, SLOT( showAssistantHelp() ) );
    connect( actionAboutApplication, SIGNAL( activated() ), this, SLOT( aboutApplication() ) );
    init();
}
Esempio n. 19
0
Window::Window(QWidget* parent):
    QMainWindow(parent)
{
    setObjectName("PlanetScannerWindow");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setIconSize(QSize(24, 24));
    toolbar->setFloatable(false);
    toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
    addToolBar(toolbar);

    QAction* refreshAction = toolbar->addAction(QIcon(":/icons/refresh.png"), "Refresh");
    connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshPlanets()));
    QAction* settingsAction = toolbar->addAction(QIcon(":/icons/settings.png"), "Settings");
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));

    planetTreeView = new QTreeView(this);
    planetTreeView->setMinimumHeight(10);
    planetTreeModel = new PlanetTreeModel(planetTreeView);
    planetTreeProxyModel = new PlanetTreeSortFilterProxyModel(planetTreeModel);
    planetTreeProxyModel->setSourceModel(planetTreeModel);
    planetTreeView->setModel(planetTreeProxyModel);
    planetTreeModel->setHorizontalHeaderLabels(QStringList() << "Hostname" << "Map" << "Gametype" << "Players" << "Address");
    planetTreeView->setSortingEnabled(true);
    planetTreeView->sortByColumn(0, Qt::AscendingOrder);
    planetTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
    planetTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
    connect(planetTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));

    QAction* connectAction = new QAction("Connect", planetTreeView);
    QAction* connectAsSpectatorAction = new QAction("Connect as spectator", planetTreeView);
    QAction* copyAction = new QAction("Copy", planetTreeView);
    QAction* openProfileAction = new QAction("Open profile in a browser", planetTreeView);
    connect(connectAction, SIGNAL(triggered()), this, SLOT(connectSelected()));
    connect(connectAsSpectatorAction, SIGNAL(triggered()), this, SLOT(connectAsSpectatorSelected()));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copySelected()));
    connect(openProfileAction, &QAction::triggered, this, &Window::openProfileSelected);
    gameContextMenu = new QMenu(planetTreeView);
    planetContextMenu = new QMenu(planetTreeView);
    registeredPlayerContextMenu = new QMenu(planetTreeView);
    unregisteredPlayerContextMenu = new QMenu(planetTreeView);
    gameContextMenu->addActions(QList<QAction*>() << connectAction << connectAsSpectatorAction << copyAction);
    planetContextMenu->addActions(QList<QAction*>() << copyAction);
    registeredPlayerContextMenu->addActions(QList<QAction*>() << openProfileAction << copyAction);
    unregisteredPlayerContextMenu->addActions(QList<QAction*>() << copyAction);

    setCentralWidget(planetTreeView);

    game = new QProcess(this);

    statistics = new StatisticsWebSite(this);
    connect(statistics, &StatisticsWebSite::playersInfoRecieved, this, &Window::processStatisticsPlayers);

    autoRefreshTimer = new QTimer(this);
    connect(autoRefreshTimer, SIGNAL(timeout()), this, SLOT(refreshPlanets()));

    contextMenuShown = false;

    Settings& settings = Settings::getInstance();
    connect(&settings, &Settings::dataChanged, this, &Window::applyChangedSettings);
    settings.load();
    applyChangedSettings();

    ::Settings::loadWindow(this);

    refreshPlanets();
}