Exemplo n.º 1
0
void MainForm::createProfile()
{
	CreateProfile *dlg = new CreateProfile();
	dlg->exec();
	
	if(dlg->result() == QDialog::Rejected)
	{
		setEnabledActions(0);
		statusBar()->message(tr("Cancelled"), 2000);
	}
	else
	{
		setEnabledActions(1);
		statusBar()->message(tr("Profile created"), 2000);
	}
}
Exemplo n.º 2
0
void MainForm::deleteProfile()
{
	int res = QMessageBox::warning(this, tr("Password keeper"), tr("Are you sure to delete ALL saved data?"),
				       QMessageBox::Yes,
				       QMessageBox::Cancel | QMessageBox::Escape);
	if(res == QMessageBox::Yes)
	{
		QString key;
		CheckPass *dlg = new CheckPass(key);
		dlg->exec();
		
		if(dlg->result() == QDialog::Rejected)
		{
			statusBar()->message(tr("Cancelled"), 2000);
			return;
		}
		
		listView->clear();
		QString path = QDir::homeDirPath();
		path += "/.pkeeper";
		QDir dir(path);
		if(!dir.exists())
		{
			QMessageBox::warning(this, tr("Password keeper"), tr("Probably, you profile has been deleted outside the program!") );
			return;
		}
		QString fpath = path + "/enter.dat";
		QFile file(fpath);
		if(file.exists()){
			bool ok = file.remove();
			if(!ok){
				QMessageBox::warning(this, tr("Password keeper"), tr("Can't delete file!\nProbably, you have troubles with file permissions."));
				return;
			}
		}
		fpath = path + "/data.dat";
		file.setName(fpath);
		if(file.exists()){
			bool ok = file.remove();
			if(!ok){
				QMessageBox::warning(this, tr("Password keeper"), tr("Can't delete file!\nProbably, you have troubles with file permissions."));
				return;
			}
		}
		bool ok = dir.rmdir(path);
		if(!ok){
			QMessageBox::warning(this, tr("Password keeper"), tr("Can't delete directory!\nProbably, you have troubles with file permissions."));
			return;
		}
		
		listView->clear();
		modified = false;
		Caption();
		setEnabledActions(0);
		statusBar()->message(tr("Profile has been deleted!"), 2000);
		QMessageBox::warning(this, tr("Password keeper"), tr("All your profile data have been deleted!") );
	}
}
Exemplo n.º 3
0
void MainForm::closeProfile()
{
	if(modified){
		int res = QMessageBox::warning(this, tr("Password keeper"), tr("Your data have been changed!\nDo you want to save them, before closing profile?"),
				     QMessageBox::Yes | QMessageBox::Default,
				     QMessageBox::No,
				     QMessageBox::Cancel | QMessageBox::Escape);
		if(res == QMessageBox::Yes)
		{
			save();
			clear();
		}
		else if(res == QMessageBox::No)
			clear();
		modified = false;
		Caption();
		
	}
	else
		clear();
	setEnabledActions(1);
}
Exemplo n.º 4
0
void MainForm::open()
{
	QString home = QDir::homeDirPath();
	QString path = home;
	path += "/.pkeeper";
	QString path_cph = path;
	
	QDir dir(path);
	if(!dir.exists(path))
	{
		QMessageBox::warning(this,tr("Password keeper"),tr("Error! You profile doesn't exists!") );
		return;
	}
	
	path_cph += "/data.dat";
	path += "/data2.dat";
	
	RC4 *rc4 = new RC4();
	rc4_key rc4key;
	char *key = strdup(gKey);
	char *fo = strdup(path_cph);
	char *fw = strdup(path);
	rc4->crypto_file(fo, fw, (unsigned char*)key, strlen(key), &rc4key);
	
	QFile file(path);
	if(!file.exists())
	{
		setEnabledActions(2);
		return;
	}
	
	
	if(file.open(IO_ReadOnly))
	{
		QTextStream stream(&file);
		listView->clear();
		
		
//  		rc4->prepare_key( (unsigned char*)key, strlen(key), &rc4key );
// 		rc4->prepare_key( (unsigned char*)gKey.data(), gKey.length(), &rc4key );
		
		QString str;
		str = stream.read();
		if(!str.isEmpty())
		{
			QStringList entList = QStringList::split("\t\t", str);
			for(int i = 0; i < (int)entList.count(); i++)
			{
				item = new QListViewItem(listView);
				QStringList list = QStringList::split("\t", entList[i]);
				for(int j = 0; j < (int)list.count(); j++)
					item->setText(j, list[j]);
				listView->insertItem(item);
			}
		}
		file.close();
		
		file.remove();

		if(listView->childCount() > 0)
			listView->setSelected(listView->firstChild(), true);
		
		fillListForUndo();
		fillSaveStruct(saveList);
		modified = false;
		Caption();
		setEnabledActions(2);
		statusBar()->message(tr("Opened"), 2000);
 		sortListView();
	}
	else{
		QMessageBox::warning(this, tr("Password keeper"), tr("Can't write to file.\nProbably, you have troubles with file permissions."));
	}
}
Exemplo n.º 5
0
MainForm::MainForm( QWidget* parent, const char* name, WFlags fl )
    : QMainWindow( parent, name, fl )
{
    (void)statusBar();
    if ( !name )
	setName( "MainForm" );
    setCentralWidget( new QWidget( this, "qt_central_widget" ) );
    MainFormLayout = new QVBoxLayout( centralWidget(), 11, 6, "MainFormLayout"); 

    listView = new QListView( centralWidget(), "listView" );
    listView->addColumn( tr( "Type" ) );
    listView->addColumn( tr( "Name" ) );
    listView->addColumn( tr( "Login" ) );
    listView->addColumn( tr( "Password" ) );
    listView->addColumn( tr( "Description" ) );
    listView->setResizeMode( QListView::AllColumns );
    listView->setSorting(-1);
    MainFormLayout->addWidget( listView );

    // actions
    createProfileAction = new QAction( this, "createProfileAction" );
    createProfileAction->setIconSet( QPixmap::fromMimeSource("new.png") );
    openProfileAction = new QAction(this, "openProfileAction" );
    openProfileAction->setIconSet( QPixmap::fromMimeSource("open.png") );
    tb_openProfileAction = new QAction(this, "tb_openProfileAction");
    tb_openProfileAction->setIconSet( QPixmap::fromMimeSource("tb_open.png") );
    closeProfileAction = new QAction( this, "closeProfileAction" );
    closeProfileAction->setIconSet( QPixmap::fromMimeSource("close.png") );
    tb_closeProfileAction = new QAction( this, "tb_closeProfileAction" );
    tb_closeProfileAction->setIconSet( QPixmap::fromMimeSource("tb_close.png") );
    deleteProfileAction = new QAction( this, "deleteProfileAction" );
    deleteProfileAction->setIconSet( QPixmap::fromMimeSource("delete_all.png") );
    changeProfileAction = new QAction( this, "changeProfileAction" );
    fileQuitAction = new QAction( this, "fileQuitAction" );
    fileSaveAction = new QAction( this, "fileSaveAction" );
    fileSaveAction->setIconSet( QPixmap::fromMimeSource("save.png") );
    tb_fileSaveAction = new QAction( this, "tb_fileSaveAction" );
    tb_fileSaveAction->setIconSet( QPixmap::fromMimeSource("tb_save.png") );
    editUndoAction = new QAction( this, "editUndoAction" );
    editUndoAction->setIconSet( QPixmap::fromMimeSource("undo.png") );
    tb_editUndoAction = new QAction( this, "editUndoAction" );
    tb_editUndoAction->setIconSet( QPixmap::fromMimeSource("tb_undo.png") );
    editRedoAction = new QAction( this, "editRedoAction" );
    editRedoAction->setIconSet( QPixmap::fromMimeSource("redo.png") );
    tb_editRedoAction = new QAction( this, "tb_editRedoAction" );
    tb_editRedoAction->setIconSet( QPixmap::fromMimeSource("tb_redo.png") );
    editNewField = new QAction( this, "editNewField" );
    editNewField->setIconSet( QPixmap::fromMimeSource("new.png") );
    editEditField = new QAction( this, "editEditField" );
    editEditField->setIconSet( QPixmap::fromMimeSource("edit.png") );
    tb_editEditField = new QAction( this, "tb_editEditField" );
    tb_editEditField->setIconSet( QPixmap::fromMimeSource("tb_edit.png") );
    tb_editNewField = new QAction( this, "tb_editNewField" );
    tb_editNewField->setIconSet( QPixmap::fromMimeSource("tb_new.png") );
    editDeleteField = new QAction( this, "editDeleteField" );
    editDeleteField->setIconSet( QPixmap::fromMimeSource("delete.png") );
    tb_editDeleteField = new QAction( this, "tb_editDeleteField" );
    tb_editDeleteField->setIconSet( QPixmap::fromMimeSource("tb_delete.png") );
    editDeleteAll = new QAction( this, "editDeleteAll" );
    editDeleteAll->setIconSet( QPixmap::fromMimeSource("delete_all.png") );
    helpAboutAction = new QAction( this, "helpAboutAction" );


    // toolbars
    fileToolbar = new QToolBar( tr("File"), this, DockTop );
    tb_openProfileAction->addTo( fileToolbar);
    tb_fileSaveAction->addTo( fileToolbar);
    tb_closeProfileAction->addTo( fileToolbar );
    
    editToolbar = new QToolBar( tr("Edit"), this, DockTop );
    tb_editUndoAction->addTo( editToolbar );
    tb_editRedoAction->addTo( editToolbar );
    editToolbar->addSeparator();
    tb_editNewField->addTo( editToolbar );
    tb_editEditField->addTo( editToolbar );
    tb_editDeleteField->addTo( editToolbar );

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


    File = new QPopupMenu( this );
    createProfileAction->addTo( File );
    openProfileAction->addTo( File );
    fileSaveAction->addTo( File );
    closeProfileAction->addTo( File );
    deleteProfileAction->addTo( File );
    changeProfileAction->addTo( File );
    File->insertSeparator();
    fileQuitAction->addTo( File );
    MenuBarEditor->insertItem( QString(""), File, 1 );
    
    Edit = new QPopupMenu( this );
    editUndoAction->addTo( Edit );
    editRedoAction->addTo( Edit );
    Edit->insertSeparator();
    editNewField->addTo( Edit );
    editEditField->addTo( Edit );
    editDeleteField->addTo( Edit );
    editDeleteAll->addTo(Edit);
    MenuBarEditor->insertItem( QString(""), Edit, 2 );
    
    Help = new QPopupMenu( this );
    helpAboutAction->addTo( Help );
    MenuBarEditor->insertItem( QString(""), Help, 3 );
    
    rmbMenu = new QPopupMenu( this );
    editUndoAction->addTo( rmbMenu );
    editRedoAction->addTo( rmbMenu );
    rmbMenu->insertSeparator();
    editNewField->addTo( rmbMenu );
    editEditField->addTo( rmbMenu );
    editDeleteField->addTo( rmbMenu );

    languageChange();
    resize( QSize(700, 400).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );
    
    connect(createProfileAction, SIGNAL( activated() ), this, SLOT( createProfile() )  );
    connect(openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() )  );
    connect(tb_openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) );
    connect(closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() )  );
    connect(tb_closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() )  );
    connect(deleteProfileAction, SIGNAL( activated() ), this, SLOT( deleteProfile() ) );
    connect(changeProfileAction, SIGNAL( activated() ), this, SLOT( changeProfile() ) );
    connect(fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) );
    connect(tb_fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) );
    connect(fileQuitAction, SIGNAL( activated() ), this, SLOT( close() ) );
    connect(editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) );
    connect(tb_editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) );
    connect(editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) );
    connect(tb_editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) );
    connect(editNewField, SIGNAL( activated() ), this, SLOT( newField() ) );
    connect(tb_editNewField, SIGNAL( activated() ), this, SLOT( newField() ) );
    connect(editEditField, SIGNAL(activated() ), this, SLOT( editField() ) );
    connect(tb_editEditField, SIGNAL(activated() ), this, SLOT( editField() ) );
    connect(editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) );
    connect(tb_editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) );
    connect(editDeleteAll, SIGNAL( activated() ), this, SLOT( deleteAll() ) );
    connect(helpAboutAction, SIGNAL( activated() ), this, SLOT( about() ) );
    
    connect(listView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( edit(QListViewItem *) ) );
    connect(listView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint&, int) ), this, SLOT( slotRMB( QListViewItem*, const QPoint &, int ) ) );
    
    modified = false;
    Caption();
    
    if(!ifProfileExists())
	    createProfile();
    else
	    setEnabledActions(1);
}
Exemplo n.º 6
0
void MainWindow::updateButtons()
{
    uint runstate = 0;

    if (m_interpreter && (runstate=m_interpreter->programRunning()))
    {
        m_ui->actionPlay_Pause->setIcon(QIcon(":/icons/icons/stop.png"));
        m_ui->actionPlay_Pause->setToolTip("Stop program");
    }
    else
    {
        m_ui->actionPlay_Pause->setIcon(QIcon(":/icons/icons/play.png"));
        m_ui->actionPlay_Pause->setToolTip("Run program");
    }

    if (m_pixyDFUConnected && m_pixyConnected) // we're in programming mode
    {
        m_ui->actionPlay_Pause->setEnabled(false);
        m_ui->actionDefault_program->setEnabled(false);
        m_ui->actionRaw_video->setEnabled(false);
        m_ui->actionCooked_video->setEnabled(false);
        m_ui->actionConfigure->setEnabled(false);
        setEnabledActions(false);
    }
    else if (runstate==2) // we're in forced runstate
    {
        m_ui->actionPlay_Pause->setEnabled(false);
        m_ui->actionDefault_program->setEnabled(false);
        m_ui->actionRaw_video->setEnabled(false);
        m_ui->actionCooked_video->setEnabled(false);
        m_ui->actionConfigure->setEnabled(true);
        setEnabledActions(false);
    }
    else if (runstate) // runstate==1
    {
        m_ui->actionPlay_Pause->setEnabled(true);
        m_ui->actionDefault_program->setEnabled(true);
        m_ui->actionRaw_video->setEnabled(true);
        m_ui->actionCooked_video->setEnabled(true);
        m_ui->actionConfigure->setEnabled(true);
        setEnabledActions(true);
    }
    else if (m_pixyConnected) // runstate==0
    {
        m_ui->actionPlay_Pause->setEnabled(true);
        m_ui->actionDefault_program->setEnabled(true);
        m_ui->actionRaw_video->setEnabled(true);
        m_ui->actionCooked_video->setEnabled(true);
        m_ui->actionConfigure->setEnabled(true);
        setEnabledActions(true);
    }
    else // nothing connected
    {
        m_ui->actionPlay_Pause->setEnabled(false);
        m_ui->actionDefault_program->setEnabled(false);
        m_ui->actionRaw_video->setEnabled(false);
        m_ui->actionCooked_video->setEnabled(false);
        m_ui->actionConfigure->setEnabled(false);
        setEnabledActions(false);
    }

    if (m_configDialog)
        m_ui->actionConfigure->setEnabled(false);
}