예제 #1
0
파일: dirtreeview.cpp 프로젝트: komh/kfw
void DirTreeView::keyPressEvent(QKeyEvent *event)
{
    if (event->matches(QKeySequence::Copy))
    {
        copyToClipboard();

        return;
    }

    if (event->matches(QKeySequence::Cut))
    {
        copyToClipboard(false);

        return;
    }

    if (event->matches(QKeySequence::Paste))
    {
        pasteFromClipboard();

        return;
    }

    if (event->matches(QKeySequence::Delete))
    {
        deletePressed();

        return;
    }

    QTreeView::keyPressEvent(event);
}
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	_ui(new Ui::MainWindow),
	_clipboard(QApplication::clipboard()),
	_proxyModel(new QSortFilterProxyModel),
	_storageModel(),
	_objectModel(new MtpObjectsModel()),
	_uploader(new FileUploader(_objectModel, this))
{
	_ui->setupUi(this);
	setWindowIcon(QIcon(":/android-file-transfer.png"));

	_ui->listView->setModel(_proxyModel);

	_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
	_proxyModel->sort(0);
	_proxyModel->setDynamicSortFilter(true);

	_objectModel->moveToThread(QApplication::instance()->thread());

	connect(_ui->listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), SLOT(updateActionsState()));
	connect(_ui->listView, SIGNAL(doubleClicked(QModelIndex)), SLOT(onActivated(QModelIndex)));
	connect(_ui->listView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenu(QPoint)));
	connect(_ui->actionBack, SIGNAL(triggered()), SLOT(back()));
	connect(_ui->actionGo_Down, SIGNAL(triggered()), SLOT(down()));
	connect(_ui->actionCreateDirectory, SIGNAL(triggered()), SLOT(createDirectory()));
	connect(_ui->actionUploadDirectory, SIGNAL(triggered()), SLOT(uploadDirectories()));
	connect(_ui->actionUpload_Album, SIGNAL(triggered()), SLOT(uploadAlbum()));
	connect(_ui->actionUpload, SIGNAL(triggered()), SLOT(uploadFiles()));
	connect(_ui->actionRename, SIGNAL(triggered()), SLOT(renameFile()));
	connect(_ui->actionDownload, SIGNAL(triggered()), SLOT(downloadFiles()));
	connect(_ui->actionDelete, SIGNAL(triggered()), SLOT(deleteFiles()));
	connect(_ui->storageList, SIGNAL(activated(int)), SLOT(onStorageChanged(int)));
	connect(_ui->actionRefresh, SIGNAL(triggered()), SLOT(refresh()));
	connect(_ui->actionPaste, SIGNAL(triggered()), SLOT(pasteFromClipboard()));

	connect(_objectModel, SIGNAL(onFilesDropped(QStringList)), SLOT(uploadFiles(QStringList)));
	connect(_objectModel, SIGNAL(existingFileOverwrite(QString)), SLOT(confirmOverwrite(QString)), Qt::BlockingQueuedConnection);

	connect(_clipboard, SIGNAL(dataChanged()), SLOT(validateClipboard()));
	validateClipboard();

	//fixme: find out how to specify alternative in designer
	_ui->actionBack->setShortcuts(_ui->actionBack->shortcuts() << QKeySequence("Alt+Up") << QKeySequence("Esc"));
	_ui->actionGo_Down->setShortcuts(_ui->actionGo_Down->shortcuts() << QKeySequence("Alt+Down") << QKeySequence("Enter"));
	_ui->actionCreateDirectory->setShortcuts(_ui->actionCreateDirectory->shortcuts() << QKeySequence("F7"));
	_ui->actionRefresh->setShortcuts(_ui->actionRefresh->shortcuts() << QKeySequence("Ctrl+R"));
	_ui->listView->setFocus();
}
예제 #3
0
//source: http://stackoverflow.com/questions/3135737/copying-part-of-qtableview
void MyTableView::keyPressEvent(QKeyEvent* event)
{
	if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier))
	{
		this->onCopyToClipboard();
	}
	if (event->key() == Qt::Key_V && (event->modifiers() & Qt::ControlModifier))
	{
		emit pasteFromClipboard();
	}
	if (event->key() == Qt::Key_A && (event->modifiers() & Qt::ControlModifier))
	{
		this->selectAll();
	}
}
bool CodeEditorComponent::performCommand (const int commandID)
{
    switch (commandID)
    {
        case StandardApplicationCommandIDs::cut:        cutToClipboard(); break;
        case StandardApplicationCommandIDs::copy:       copyToClipboard(); break;
        case StandardApplicationCommandIDs::paste:      pasteFromClipboard(); break;
        case StandardApplicationCommandIDs::del:        cut(); break;
        case StandardApplicationCommandIDs::selectAll:  selectAll(); break;
        case StandardApplicationCommandIDs::undo:       undo(); break;
        case StandardApplicationCommandIDs::redo:       redo(); break;
        default:                                        return false;
    }

    return true;
}
FormMaterialIndicesManager::FormMaterialIndicesManager(QMainWindow *parent, QGLWidget* qlW_ptr) :
    FormImageBase(parent),
    ui(new Ui::FormMaterialIndicesManager)
{
    ui->setupUi(this);
    imageProp.glWidget_ptr = qlW_ptr;

    connect(ui->pushButtonOpenMaterialImage,SIGNAL(released()),this,SLOT(open()));
    connect(ui->pushButtonCopyToClipboard,SIGNAL(released()),this,SLOT(copyToClipboard()));
    connect(ui->pushButtonPasteFromClipboard,SIGNAL(released()),this,SLOT(pasteFromClipboard()));
    connect(ui->checkBoxDisableMaterials,SIGNAL(toggled(bool)),this,SLOT(toggleMaterials(bool)));

    connect(ui->listWidgetMaterialIndices,SIGNAL(currentRowChanged(int)),this,SLOT(changeMaterial(int)));

    ui->groupBox->setDisabled(true);
    setAcceptDrops(true);
}
예제 #6
0
int Velasquez::ToolBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: toolActivated((*reinterpret_cast< DrawingTool*(*)>(_a[1]))); break;
        case 1: copyRequest(); break;
        case 2: pasteRequest(); break;
        case 3: copyImageToClipboard(); break;
        case 4: pasteFromClipboard(); break;
        case 5: onSceneCleared(); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
예제 #7
0
파일: Input.cpp 프로젝트: mpreisler/ember
void Input::keyChanged(const SDL_KeyboardEvent &keyEvent)
{
	//catch paste key presses

	//check for paste actions
	if (((keyEvent.keysym.mod & KMOD_CTRL) || (keyEvent.keysym.mod & KMOD_LCTRL) || (keyEvent.keysym.mod & KMOD_RCTRL)) && (keyEvent.keysym.sym == SDLK_v)) {
		if (keyEvent.type == SDL_KEYDOWN) {
			pasteFromClipboard();
		}
	} else if ((keyEvent.keysym.mod & KMOD_LALT) && (keyEvent.keysym.sym == SDLK_TAB)) {
		if (keyEvent.type == SDL_KEYDOWN) {
			EventAltTab.emit();
		}
	} else {
		if (keyEvent.type == SDL_KEYDOWN) {
			mKeysPressed.insert(keyEvent.keysym.sym);
			keyPressed(keyEvent);
		} else {
			mKeysPressed.erase(keyEvent.keysym.sym);
			keyReleased(keyEvent);
		}
	}

}
// Implement pasting text.
void ScintillaQt::Paste()
{
    pasteFromClipboard(QClipboard::Clipboard);
}
예제 #9
0
ListPanelActions::ListPanelActions(QObject *parent, FileManagerWindow *mainWindow) :
        ActionsBase(parent, mainWindow)
{
    // set view type
    QSignalMapper *mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), SLOT(setView(int)));
    QActionGroup *group = new QActionGroup(this);
    group->setExclusive(true);
    QList<KrViewInstance*> views = KrViewFactory::registeredViews();
    for(int i = 0; i < views.count(); i++) {
        KrViewInstance *inst = views[i];
        QAction *action = new QAction(QIcon::fromTheme(inst->icon()), inst->description(), group);
        action->setCheckable(true);
        connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
        mapper->setMapping(action, inst->id());
        _mainWindow->actions()->addAction("view" + QString::number(i), action);
        _mainWindow->actions()->setDefaultShortcut(action, inst->shortcut());
        setViewActions.insert(inst->id(), action);
    }

    // standard actions
    actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward()));
    actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward()));
    //FIXME: second shortcut for up: see actDirUp
    //   KStandardAction::up( this, SLOT( dirUp() ), actionCollection )->setShortcut(Qt::Key_Backspace);
    /* Shortcut disabled because of the Terminal Emulator bug. */
    actDirUp = stdAction(KStandardAction::Up, _func, SLOT(dirUp()));
    actHome = stdAction(KStandardAction::Home, _func, SLOT(home()));
    stdAction(KStandardAction::Cut, _func, SLOT(cut()));
    actCopy = stdAction(KStandardAction::Copy, _func, SLOT(copyToClipboard()));
    actPaste = stdAction(KStandardAction::Paste, _func, SLOT(pasteFromClipboard()));

    // Fn keys
    actF2 = action(i18n("Rename"), 0, Qt::Key_F2, _func, SLOT(rename()) , "F2_Rename");
    actF3 = action(i18n("View File"), 0, Qt::Key_F3, _func, SLOT(view()), "F3_View");
    actF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit");
    actF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy");
    actF6 = action(i18n("Move..."), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move");
    actShiftF5 = action(i18n("Copy by queue..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesByQueue()) , "F5_Copy_Queue");
    actShiftF6 = action(i18n("Move by queue..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesByQueue()) , "F6_Move_Queue");
    actF7 = action(i18n("New Directory..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir");
    actF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(deleteFiles()) , "F8_Delete");
    actF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal");
    action(i18n("&New Text File..."), "document-new", Qt::SHIFT + Qt::Key_F4, _func, SLOT(editNew()), "edit_new_file");
    action(i18n("F3 View Dialog"), 0, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg");

    // file operations
    action(i18n("Right-click Menu"), 0, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu");
    actProperties = action(i18n("&Properties..."), 0, Qt::ALT + Qt::Key_Return, _func, SLOT(properties()), "properties");
    actCompDirs = action(i18n("&Compare Directories"), "kr_comparedirs", Qt::ALT + Qt::SHIFT + Qt::Key_C, _gui, SLOT(compareDirs()), "compare dirs");
    actCalculate = action(i18n("Calculate &Occupied Space"), "accessories-calculator", 0, _func, SLOT(calcSpace()), "calculate");
    actPack = action(i18n("Pac&k..."), "archive-insert", Qt::ALT + Qt::SHIFT + Qt::Key_P, _func, SLOT(pack()), "pack");
    actUnpack = action(i18n("&Unpack..."), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_U, _func, SLOT(unpack()), "unpack");
    actCreateChecksum = action(i18n("Create Checksum..."), "document-edit-sign", 0, _func, SLOT(createChecksum()), "create checksum");
    actMatchChecksum = action(i18n("Verify Checksum..."), "document-edit-decrypt-verify", 0, _func, SLOT(matchChecksum()), "match checksum");
    action(i18n("New Symlink..."), 0, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink");
    actTest = action(i18n("T&est Archive"), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_E, _func, SLOT(testArchive()), "test archives");

    // navigation
    actRoot = action(i18n("Root"), "folder-red", Qt::CTRL + Qt::Key_Backspace, _func, SLOT(root()), "root");
    actCdToOther = action(i18n("Go to Other Panel's Directory"), 0, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel");
    action(i18n("&Reload"), "view-refresh", Qt::CTRL + Qt::Key_R, _func, SLOT(refresh()), "std_redisplay");
    actCancelRefresh = action(i18n("Cancel Refresh of View"), "dialog-cancel", 0, _gui, SLOT(inlineRefreshCancel()), "cancel refresh");
    actFTPNewConnect = action(i18n("New Net &Connection..."), "network-connect", Qt::CTRL + Qt::Key_N, _func, SLOT(newFTPconnection()), "ftp new connection");
    actFTPDisconnect = action(i18n("Disconnect &from Net"), "network-disconnect", Qt::SHIFT + Qt::CTRL + Qt::Key_F, _func, SLOT(FTPDisconnect()), "ftp disconnect");
    action(i18n("Sync Panels"), 0, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels");
    actJumpBack = action(i18n("Jump Back"), "go-jump", Qt::CTRL + Qt::Key_J, _gui, SLOT(jumpBack()), "jump_back");
    actSetJumpBack = action(i18n("Set Jump Back Point"), "go-jump-definition", Qt::CTRL + Qt::SHIFT + Qt::Key_J, _gui, SLOT(setJumpBack()), "set_jump_back");
    actSyncBrowse = action(i18n("S&ynchron Directory Changes"), "kr_syncbrowse_off", Qt::ALT + Qt::SHIFT + Qt::Key_Y, _gui, SLOT(toggleSyncBrowse()), "sync browse");
    actLocationBar = action(i18n("Go to Location Bar"), 0, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar");
    toggleAction(i18n("Toggle Popup Panel"), 0, Qt::ALT + Qt::Key_Down, _gui, SLOT(togglePanelPopup()), "toggle popup panel");
    action(i18n("Bookmarks"), 0, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks");
    action(i18n("Left Bookmarks"), 0, 0, this, SLOT(openLeftBookmarks()), "left bookmarks");
    action(i18n("Right Bookmarks"), 0, 0, this, SLOT(openRightBookmarks()), "right bookmarks");
    action(i18n("History"), 0, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history");
    action(i18n("Left History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history");
    action(i18n("Right History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history");
    action(i18n("Media"), 0, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media");
    action(i18n("Left Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media");
    action(i18n("Right Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media");

    // and at last we can set the tool-tips
    actRoot->setToolTip(i18n("ROOT (/)"));

    actF2->setToolTip(i18n("Rename file, directory, etc."));
    actF3->setToolTip(i18n("Open file in viewer."));
    actF4->setToolTip("<qt>" + i18n("<p>Edit file.</p>"
                                 "<p>The editor can be defined in Konfigurator, "
                                 "default is <b>internal editor</b>.</p>") + "</qt>");
    actF5->setToolTip(i18n("Copy file from one panel to the other."));
    actF6->setToolTip(i18n("Move file from one panel to the other."));
    actF7->setToolTip(i18n("Create directory in current panel."));
    actF8->setToolTip(i18n("Delete file, directory, etc."));
    actF9->setToolTip("<qt>" + i18n("<p>Open terminal in current directory.</p>"
                                 "<p>The terminal can be defined in Konfigurator, "
                                 "default is <b>konsole</b>.</p>") + "</qt>");
}
예제 #10
0
void PgxConsole::insertFromMimeData(const QMimeData *source)
{
    pasteFromClipboard();
}
예제 #11
0
PgxConsole::PgxConsole(Database *database)
{
    this->database = database;
    insertPlainText("");
    setViewportMargins(10, 0, 0, 0);
    setTabStopWidth(40);
    setUndoRedoEnabled(false);
    setWindowTitle(QApplication::translate("PgxConsole", "SQL console", 0, QApplication::UnicodeUTF8));
    setStyleSheet("QPlainTextEdit{background-color: white; font: bold 14px 'Courier New';}");

    createActions();
    hit = 0;

    highlighter = new Highlighter(document());
    prompt = new Prompt(this);

    toolbar = new ToolBar;
    toolbar->setIconSize(QSize(36,36));
    toolbar->setObjectName("pgxeditor");
    toolbar->setMovable(false);
    toolbar->addAction(newpgxconsole_action);
    toolbar->addAction(cut_action);
    toolbar->addAction(copy_action);
    toolbar->addAction(paste_action);
    toolbar->addSeparator();
    toolbar->addAction(clear_action);
    toolbar->addAction(find_action);

    pgxconsole_mainwin = new PgxConsoleMainWindow;
    pgxconsole_mainwin->addToolBar(toolbar);
    pgxconsole_mainwin->setCentralWidget(this);
    pgxconsole_mainwin->setAttribute(Qt::WA_DeleteOnClose);

    find_bar = new QLineEdit;
    find_bar->setPlaceholderText(tr("Find"));
    find_bar->setMaximumSize(100,find_bar->height());
    find_bar->setVisible(false);
    pgxconsole_mainwin->statusBar()->setSizeGripEnabled(false);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(casesensitivity_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(wholeword_button, 0);
    //pgxconsole_mainwin->statusBar()->addPermanentWidget(backwards_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_bar);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_previous_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_next_button, 0);

    connect(find_bar, SIGNAL(returnPressed()), SLOT(findText()));

    QShortcut *shortcut_paste = new QShortcut(QKeySequence::Paste, this);
    connect(shortcut_paste, SIGNAL(activated()), SLOT(pasteFromClipboard()));

    QShortcut *shortcut_single_paste = new QShortcut(QKeySequence("Ctrl+Shift+V"), this);
    connect(shortcut_single_paste, SIGNAL(activated()), SLOT(pasteAsSingleFromClipboard()));

    connect(this, SIGNAL(cursorPositionChanged()), SLOT(makePreviousBlocksReadonly()));

    //Tie command with QueryView creation.
    connect(this, SIGNAL(commandSignal(QString)), SLOT(showView(QString)));

    //Tie up and down keys with command history scolling.
    connect(this, SIGNAL(historyUp()), SLOT(historyUpCommand()));
    connect(this, SIGNAL(historyDown()), SLOT(historyDownCommand()));

    //Console updates.
    connect(this, SIGNAL(updateRequest(QRect,int)), SLOT(updatePrompt(QRect,int)));
    connect(pgxconsole_mainwin, SIGNAL(pgxconsoleClosing()), SLOT(pgxconsoleClosing()));
}
예제 #12
0
bool TextBox::keyboardEvent(int key, int /* scancode */, int action, int modifiers)
{
    if (mEditable && focused()) {
        if (action == SDL_KEYDOWN /*|| action == GLFW_REPEAT*/)
        {
            if (key == SDLK_LEFT )
            {
                if (modifiers == SDLK_LSHIFT)
                {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos > 0)
                    mCursorPos--;
            } else if (key == SDLK_RIGHT) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos < (int) mValueTemp.length())
                    mCursorPos++;
            } else if (key == SDLK_HOME) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = 0;
            } else if (key == SDLK_END) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = (int) mValueTemp.size();
            } else if (key == SDLK_BACKSPACE) {
                if (!deleteSelection()) {
                    if (mCursorPos > 0) {
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos - 1);
                        mCursorPos--;
                    }
                }
            } else if (key == SDLK_DELETE) {
                if (!deleteSelection()) {
                    if (mCursorPos < (int) mValueTemp.length())
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos);
                }
            }
            else if (key == SDLK_RETURN)
            {
                if (!mCommitted)
                    focusEvent(false);
            }
            else if (key == SDLK_a && modifiers == SDLK_RCTRL)
            {
                mCursorPos = (int) mValueTemp.length();
                mSelectionPos = 0;
            }
            else if (key == SDLK_x && modifiers == SDLK_RCTRL)
            {
                copySelection();
                deleteSelection();
            }
            else if (key == SDLK_c && modifiers == SDLK_RCTRL)
            {
                copySelection();
            }
            else if (key == SDLK_v && modifiers == SDLK_RCTRL)
            {
                deleteSelection();
                pasteFromClipboard();
            }

            mValidFormat =
                (mValueTemp == "") || checkFormat(mValueTemp, mFormat);
        }

        return true;
    }

    return false;
}
예제 #13
0
파일: textbox.cpp 프로젝트: eriser/vkit
bool TextBox::keyboardEvent(int key, int /* scancode */, int action, int modifiers) {
    if (mEditable && focused()) {
        if (action == GLFW_PRESS || action == GLFW_REPEAT) {
            if (key == GLFW_KEY_LEFT) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos > 0)
                    mCursorPos--;
            } else if (key == GLFW_KEY_RIGHT) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos < (int) mValueTemp.length())
                    mCursorPos++;
            } else if (key == GLFW_KEY_HOME) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = 0;
            } else if (key == GLFW_KEY_END) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = (int) mValueTemp.size();
            } else if (key == GLFW_KEY_BACKSPACE) {
                if (!deleteSelection()) {
                    if (mCursorPos > 0) {
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos - 1);
                        mCursorPos--;
                    }
                }
            } else if (key == GLFW_KEY_DELETE) {
                if (!deleteSelection()) {
                    if (mCursorPos < (int) mValueTemp.length())
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos);
                }
            } else if (key == GLFW_KEY_ENTER) {
                if (!mCommitted)
                    focusEvent(false);
            } else if (key == GLFW_KEY_A && modifiers == SYSTEM_COMMAND_MOD) {
                mCursorPos = (int) mValueTemp.length();
                mSelectionPos = 0;
            } else if (key == GLFW_KEY_X && modifiers == SYSTEM_COMMAND_MOD) {
                copySelection();
                deleteSelection();
            } else if (key == GLFW_KEY_C && modifiers == SYSTEM_COMMAND_MOD) {
                copySelection();
            } else if (key == GLFW_KEY_V && modifiers == SYSTEM_COMMAND_MOD) {
                deleteSelection();
                pasteFromClipboard();
            }

            mValidFormat =
                (mValueTemp == "") || checkFormat(mValueTemp, mFormat);
        }

        return true;
    }

    return false;
}
예제 #14
0
FormImageProp::FormImageProp(QMainWindow *parent, QGLWidget* qlW_ptr) :
    FormImageBase(parent),
    ui(new Ui::FormImageProp)
{
    ui->setupUi(this);

    bOpenNormalMapMixer   = false;

    imageProp.glWidget_ptr = qlW_ptr;
    
    connect(ui->pushButtonOpenImage,SIGNAL(released()),this,SLOT(open()));
    connect(ui->pushButtonSaveImage,SIGNAL(released()),this,SLOT(save()));
    connect(ui->pushButtonCopyToClipboard,SIGNAL(released()),this,SLOT(copyToClipboard()));
    connect(ui->pushButtonPasteFromClipboard,SIGNAL(released()),this,SLOT(pasteFromClipboard()));

    connect(ui->pushButtonRestoreSettings,SIGNAL(released()),this,SLOT(reloadImageSettings()));

    connect(ui->checkBoxRemoveShading,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->checkBoxGrayScale,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    // gray scale properties
    connect(ui->comboBoxGrayScalePresets,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->horizontalSliderGrayScaleR,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderGrayScaleG,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderGrayScaleB,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));


    connect(ui->checkBoxInvertB,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->checkBoxInvertR,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->checkBoxInvertG,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    // standard enchancement
    connect(ui->horizontalSliderRemoveShadingGaussIter,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderAOCancelation         ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRemoveShadingLFBlending,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRemoveShadingLFRadius,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));



    connect(ui->horizontalSliderBlurNoPasses          ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSmallDetails          ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderMediumDetails         ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderDetailDepth           ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderColorHue              ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    // specular manipulation tool
    connect(ui->checkBoxSpecularControl             ,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->horizontalSliderSpeculatW1          ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSpecularW2          ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSpecularRadius      ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSpecularContrast    ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSpecularAmplifier   ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSpecularBrightness  ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    connect(ui->horizontalSliderSpeculatW1           ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularW2           ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularRadius       ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularRadius       ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularContrast     ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularAmplifier    ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSpecularBrightness   ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));

    connect(ui->horizontalSliderSharpenBlur,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalsStep,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    // height conversion buttons
    connect(ui->horizontalSliderConversionHNDepth   ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->pushButtonConverToNormal            ,SIGNAL(released()),this,SLOT(applyHeightToNormalConversion()));
    connect(ui->pushButtonShowDepthCalculator       ,SIGNAL(released()),this,SLOT(showHeightCalculatorDialog()));


    // normal convertion buttons and sliders

    connect(ui->horizontalSliderNormalToHeightItersHuge     ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalToHeightItersVeryLarge,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalToHeightItersLarge    ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalToHeightItersMedium   ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalToHeightItersSmall    ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalToHeightItersVerySmall,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    connect(ui->pushButtonConvertToHeight,SIGNAL(released()),this,SLOT(applyNormalToHeightConversion()));

    // base map convertion
    connect(ui->checkBoxEnableBaseMapToOthers               ,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));


    connect(ui->pushButtonConvertToNormalAndHeight,SIGNAL(released()),this,SLOT(applyBaseConversionConversion()));

    // ssao calculation
    connect(ui->horizontalSliderSSAOBias        ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSSAODepth       ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSSAOIntensity   ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSSAONoIters     ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    connect(ui->horizontalSliderSSAOBias        ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSSAODepth       ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSSAOIntensity   ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderSSAONoIters     ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));

    connect(ui->pushButtonConvertOcclusionFromHN,SIGNAL(released()),this,SLOT(applyHeightNormalToOcclusionConversion()));



    // levels properties
    connect(ui->horizontalSliderHeightProcMinValue,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));    
    connect(ui->horizontalSliderHeightProcMaxValue,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderHeightAveRadius   ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderHeightOffsetValue ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->checkBoxHeightProcEnableNormalization ,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));

    connect(ui->horizontalSliderHeightProcMinValue,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderHeightProcMaxValue,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
    connect(ui->horizontalSliderHeightAveRadius   ,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));

    // selective blur buttons and sliders
    connect(ui->pushButtonSelectiveBlurPreviewMask,SIGNAL(released()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->pushButtonSelectiveBlurPreviewMask,SIGNAL(toggled(bool)),this,SLOT(togglePreviewSelectiveBlurMask(bool)));
    connect(ui->checkBoxSelectiveBlurInvertMask,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->checkBoxSelectiveBlurEnable,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));

    connect(ui->comboBoxSelectiveBlurTypes,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));

    connect(ui->horizontalSliderSelectiveBlurBlending,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurMaskRadius,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurDOGAmplifier,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurDOGContrast,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurDOGOffset,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurDOGRadius,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    connect(ui->horizontalSliderSelectiveBlurMinValue,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurMaxValue,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurDetails,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderSelectiveBlurOffset,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->comboBoxMaskInputImage,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->horizontalSliderSelectiveBlurNoIters,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    // roughness settings
    connect(ui->horizontalSliderRoughnessDepth,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRoughnessTreshold,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRoughnessAmplifier,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

    connect(ui->radioButtonRoughnessEnable,SIGNAL(clicked()),this,SLOT(cancelColorPicking()));
    connect(ui->radioButtonEnableColorPicking,SIGNAL(clicked()),this,SLOT(cancelColorPicking()));
    connect(ui->radioButtonRoughnessNoneEffect,SIGNAL(clicked()),this,SLOT(cancelColorPicking()));

    connect(ui->radioButtonRoughnessEnable,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->radioButtonEnableColorPicking,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
    connect(ui->radioButtonRoughnessNoneEffect,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));


    connect(ui->pushButtonRoughnessPickColor,SIGNAL(toggled(bool)),this,SLOT(toggleColorPicking(bool)));
    connect(ui->comboBoxColorPickerMethod,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->horizontalSliderRoughnessColorOffset,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRoughnessColorGlobalOffset,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderRoughnessColorAmplifier,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->checkBoxRoughnessColorInvert,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));



    // input image boxes
    connect(ui->comboBoxNormalInputImage,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->comboBoxSpecularInputImage,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->comboBoxOcclusionInputImage,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
    connect(ui->comboBoxRoughnessInputImage,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));

    // normal map mixer
    connect(ui->pushButtonNormalMixerLoadImage,SIGNAL(released())        ,this,SLOT(openNormalMixerImage()));
    connect(ui->pushButtonNormalMixerPasteFromCB,SIGNAL(released())        ,this,SLOT(pasteNormalFromClipBoard()));

    connect(ui->checkBoxNormalMixerEnable,SIGNAL(clicked())              ,this,SLOT(updateGuiCheckBoxes()));
    connect(ui->horizontalSliderNormalMixerDepth,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalMixerAngle,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalMixerScale,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalMixerScale,SIGNAL(valueChanged(int)),this,SLOT(updateSlidersNow(int)));
    connect(ui->horizontalSliderNormalMixerPosX,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
    connect(ui->horizontalSliderNormalMixerPosY,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));



    setAcceptDrops(true);
    ui->groupBoxRemoveShading->hide();
    ui->checkBoxRemoveShading->hide();
    ui->groupBoxGrayScale->hide();
    ui->groupBoxSelectiveBlurOptions->hide();
    ui->groupBoxSelectiveBlurLevels->hide();
    heightCalculator = new DialogHeightCalculator;

    ui->labelHue->hide();
    ui->labelHueValue->hide();
    ui->horizontalSliderColorHue->hide();

    ui->groupBoxRoughnessSurfaceFilter->hide();
    ui->groupBoxRoughnessColorFilter_2->hide();
    ui->groupBoxBaseToOthersProcessing->hide();
    ui->groupBoxSpecularProcessing->hide();

    // conversion levels
    for(int i = 0; i < 4 ; i++){
        baseMapConvLevels[i] = new FormBaseMapConversionLevels;
        connect(baseMapConvLevels[i],SIGNAL(slidersChanged()),this,SLOT(updateSlidersOnRelease()));
    }
    ui->verticalLayoutBaseMapConvLevel0->addWidget(baseMapConvLevels[0]);
    ui->verticalLayoutBaseMapConvLevel1->addWidget(baseMapConvLevels[1]);
    ui->verticalLayoutBaseMapConvLevel2->addWidget(baseMapConvLevels[2]);
    ui->verticalLayoutBaseMapConvLevel3->addWidget(baseMapConvLevels[3]);

    for(int i = 0; i < 4 ; i++){
        baseMapConvLevels[i]->show();
    }

    // normal mixer
    ui->groupBoxNormalMixerSettings->hide();
    ui->groupBoxNormalMixer->hide();

    setMouseTracking(true);
    setFocus();
    setFocusPolicy(Qt::ClickFocus);
}