X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=mainwindow.cpp;h=b7160cc463a25138fb95f175f1b67dac32dc2433;hb=b977b76e836699dde4e00c54b9e6fe9cde7cb1a0;hp=2f05cc5894c554f249d6d0b37a0863a0311196b1;hpb=36939412a9beff7e2eac9f679577a181654b007c;p=gefu%2FGefu.git diff --git a/mainwindow.cpp b/mainwindow.cpp index 2f05cc5..b7160cc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -88,8 +88,8 @@ MainWindow::MainWindow(QWidget *parent) : // メニュー項目の状態を初期化する ui->view_Hidden->setChecked(settings.value(IniKey_ShowHidden).toBool()); ui->view_System->setChecked(settings.value(IniKey_ShowSystem).toBool()); - ui->action_OpenEditor->setEnabled(!settings.value(IniKey_EditorPath).toString().isEmpty()); - ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_TerminalPath).toString().isEmpty()); +// ui->action_OpenEditor->setEnabled(!settings.value(IniKey_PathEditor).toString().isEmpty()); +// ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_PathTerminal).toString().isEmpty()); // 追加のショートカットキーを設定する QList shortcuts; @@ -252,6 +252,34 @@ void MainWindow::executeCommand() } } +void MainWindow::expandLeft() +{ + qDebug() << "MainWindow::expandLeft();"; + + QList sizes = ui->splitter->sizes(); + QList newSizes; + + newSizes << sizes[0] + 30; + newSizes << sizes[1] - 30; + + ui->splitter->setSizes(newSizes); + +} + +void MainWindow::expandRight() +{ + qDebug() << "MainWindow::expandLeft();"; + + QList sizes = ui->splitter->sizes(); + QList newSizes; + + newSizes << sizes[0] - 30; + newSizes << sizes[1] + 30; + + ui->splitter->setSizes(newSizes); + +} + void MainWindow::historyBack() { qDebug() << "MainWindow::historyBack();"; @@ -724,7 +752,7 @@ void MainWindow::openEditor(const QString &path) Q_CHECK_PTR(view); QSettings settings; - QString exe = settings.value(IniKey_EditorPath).toString(); + QString exe = settings.value(IniKey_PathEditor).toString(); if (exe.isEmpty()) { QMessageBox::critical( this, tr("エラー"), @@ -740,18 +768,17 @@ void MainWindow::openEditor(const QString &path) list << path; } + QString files; foreach (const QFileInfo &info, list) { - QString opt = settings.value(IniKey_EditorOption).toString(); - replaceVars(opt, info); - + files += " " + QQ(info.absoluteFilePath()); + } #ifdef Q_OS_MAC - QString command = "open -a " + exe + " " + opt; + QString command = "open -a " + exe + files; #else - QString command = QQ(exe) + " " + opt; + QString command = exe + files; #endif - if (!startProcess(command, info.absolutePath(), tr("外部エディタの起動に失敗しました。"))) { - break; - } + if (!startProcess(command, view->dir(), tr("外部エディタの起動に失敗しました。"))) { + qDebug() << command; } } @@ -763,7 +790,7 @@ void MainWindow::openTerminal() Q_CHECK_PTR(view); QSettings settings; - QString exe = settings.value(IniKey_TerminalPath).toString(); + QString exe = settings.value(IniKey_PathTerminal).toString(); if (exe.isEmpty()) { QMessageBox::critical( this, tr("エラー"), @@ -771,19 +798,56 @@ void MainWindow::openTerminal() return; } + QSet dirs; foreach (const QFileInfo &info, view->selectedItems()) { - QString opt = settings.value(IniKey_TerminalOption).toString(); - replaceVars(opt, info); + if (info.isDir()) { + dirs.insert(info.absoluteFilePath()); + } + else { + dirs.insert(info.absolutePath()); + } + } + foreach (const QString &dir, dirs) { #ifdef Q_OS_MAC - QString command = "open -a " + QQ(exe) + " --args " + opt; + QString command = "open -n -a " + exe + " " + QQ(dir); #else - QString command = QQ(exe) + " " + opt; + QString command = exe + " " + QQ(dir); #endif - if (!startProcess(command, info.absolutePath(), tr("ターミナルの起動に失敗しました。"))) { + if (!startProcess(command, view->dir(), tr("ターミナルの起動に失敗しました。"))) { + qDebug() << command; break; } - Sleep(1000); + } +} + +void MainWindow::openArchiver() +{ + qDebug() << "MainWindow::openArchiver"; + + FolderView *view = static_cast(qApp->focusWidget()); + Q_CHECK_PTR(view); + + QSettings settings; + QString exe = settings.value(IniKey_PathArchiver).toString(); + if (exe.isEmpty()) { + QMessageBox::critical( + this, tr("エラー"), + tr("アーカイバのパスが未定義です。")); + return; + } + + QString files; + foreach (const QFileInfo &info, view->selectedItems()) { + files += " " + QQ(info.absoluteFilePath()); + } +#ifdef Q_OS_MAC + QString command = "open -a " + exe + files; +#else + QString command = exe + files; +#endif + if (!startProcess(command, view->dir(), tr("アーカイバの起動に失敗しました。"))) { + qDebug() << command; } } @@ -980,6 +1044,17 @@ void MainWindow::showSortDialog() } } +void MainWindow::splitCenter() +{ + qDebug() << "MainWindow::splitCenter();"; + + QList sizes = ui->splitter->sizes(); + int sizeTotal = sizes[0] + sizes[1]; + sizes[0] = sizeTotal / 2; + sizes[1] = sizeTotal - sizes[0]; + ui->splitter->setSizes(sizes); +} + void MainWindow::swapView() { qDebug() << "MainWindow::swapView();"; @@ -1408,6 +1483,7 @@ void MainWindow::showContextMenu(QContextMenuEvent *event) menu.addAction(ui->action_Exec); menu.addAction(ui->action_OpenEditor); menu.addAction(ui->action_OpenTerminal); + menu.addAction(ui->action_OpenArchiver); menu.addSeparator(); menu.addAction(ui->cmd_Copy); menu.addAction(ui->cmd_Move); @@ -1513,6 +1589,7 @@ void MainWindow::initActionConnections() connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(open())); connect(ui->action_OpenEditor, SIGNAL(triggered()), this, SLOT(openEditor())); connect(ui->action_OpenTerminal, SIGNAL(triggered()), this, SLOT(openTerminal())); + connect(ui->action_OpenArchiver, SIGNAL(triggered()), this, SLOT(openArchiver())); connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->action_Search, SIGNAL(toggled(bool)), this, SLOT(toggleSearchBox(bool))); connect(ui->action_SearchNext, SIGNAL(triggered()), this, SLOT(searchNext())); @@ -1561,6 +1638,9 @@ void MainWindow::initActionConnections() connect(ui->view_ToOther, SIGNAL(triggered()), this, SLOT(setPathToOther())); connect(ui->bookmark_Edit, SIGNAL(triggered()), this, SLOT(editBookmark())); connect(ui->bookmark_Show, SIGNAL(triggered()), this, SLOT(showBookmarkDialog())); + connect(ui->split_Center, SIGNAL(triggered()), this, SLOT(splitCenter())); + connect(ui->expand_Left, SIGNAL(triggered()), this, SLOT(expandLeft())); + connect(ui->expand_Right, SIGNAL(triggered()), this, SLOT(expandRight())); } void MainWindow::replaceVars(QString &str, const QFileInfo info) @@ -1664,8 +1744,8 @@ void MainWindow::updateActions() ui->move_Forward->setEnabled(!view->history()->isEnd()); QSettings settings; - ui->action_OpenEditor->setEnabled(!settings.value(IniKey_EditorPath).toString().isEmpty()); - ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_TerminalPath).toString().isEmpty()); + ui->action_OpenEditor->setEnabled(!settings.value(IniKey_PathEditor).toString().isEmpty()); + ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_PathTerminal).toString().isEmpty()); } else if (!otherSideFolderView(view)->isVisible()) {