+#include "common.h"\r
+#include "version.h"\r
+#include "preferencedialog.h"\r
+#include "folderview.h"\r
+#include "searchbox.h"\r
+#include "locationbox.h"\r
#include "copymoveworker.h"\r
-#include "deleteworker.h"\r
-#include "mainwindow.h"\r
#include "operationdialog.h"\r
#include "overwritedialog.h"\r
-#include "renamemultidialog.h"\r
-#include "renamesingledialog.h"\r
+#include "deleteworker.h"\r
#include "renameworker.h"\r
+#include "renamesingledialog.h"\r
+#include "renamemultidialog.h"\r
+#include "historydialog.h"\r
+#include "sortdialog.h"\r
+#include "simpletextview.h"\r
+#include "simpleimageview.h"\r
+#include "mainwindow.h"\r
#include "ui_mainwindow.h"\r
-#include <QFileSystemModel>\r
+#include "bookmarkdialog.h"\r
+\r
+#include <QCheckBox>\r
+#include <QCloseEvent>\r
#include <QDebug>\r
-#include <QKeyEvent>\r
-#include <QDesktopServices>\r
-#include <QSettings>\r
-#include <QFileDialog>\r
+#include <QDesktopWidget>\r
#include <QMessageBox>\r
-#include <QProcess>\r
-#include <QThread>\r
+#include <QSettings>\r
+#include <QNetworkAccessManager>\r
+#include <QNetworkReply>\r
#include <QInputDialog>\r
+#include <QProcess>\r
+#include <QDesktopServices>\r
+#include <QClipboard>\r
+#include <QFileDialog>\r
+#include <folderpanel.h>\r
\r
MainWindow::MainWindow(QWidget *parent) :\r
QMainWindow(parent),\r
- ui(new Ui::MainWindow)\r
+ ui(new Ui::MainWindow),\r
+ m_focusedView(NULL),\r
+ m_overwriteDialog(NULL),\r
+ m_viewMode(ModeBasic)\r
{\r
+ qDebug() << ">>>>>>>>>> MainWindowの構築開始 <<<<<";\r
ui->setupUi(this);\r
\r
+ m_overwriteDialog = new OverWriteDialog(this);\r
+\r
+ initActionConnections();\r
+ connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(focusChange(QWidget*,QWidget*)));\r
+ connect(ui->pane3->textView(), SIGNAL(viewFinished()), this, SLOT(viewFinish()));\r
+ connect(ui->pane3->imageView(), SIGNAL(viewFinished()), this, SLOT(viewFinish()));\r
+ connect(ui->pane1->textView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+ connect(ui->pane2->textView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+ connect(ui->pane3->textView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+ connect(ui->pane1->imageView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+ connect(ui->pane2->imageView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+ connect(ui->pane3->imageView(), SIGNAL(fileInfo(QString)), this, SLOT(showFileInfo(QString)));\r
+\r
+ // ビューアは初期状態で非表示\r
+ ui->pane3->setVisible(false);\r
+\r
+ // ステータスバーにウィジェットを設定する\r
+ QLabel *label = new QLabel("", this);\r
+ label->setAlignment(Qt::AlignRight);\r
+ label->setObjectName("Right");\r
+ ui->statusBar->addPermanentWidget(label, 0);\r
+\r
+ for (int i = 1; i <= 2; i++) {\r
+ // pane1 or pane2\r
+ AnyView *anyView = findChild<AnyView*>(QString("pane%1").arg(i));\r
+ Q_CHECK_PTR(anyView);\r
+\r
+ FolderPanel *fp = anyView->findChild<FolderPanel*>("folderPanel");\r
+ Q_CHECK_PTR(fp);\r
+\r
+ // FolderPanelとFolderViewの名前を変更する\r
+ fp->setObjectName(QString("folderPanel%1").arg(i));\r
+ fp->folderView()->setObjectName(QString("folderView%1").arg(i));\r
+\r
+ fp->initialize(this, i == 1);\r
+ }\r
+\r
QSettings settings;\r
- bool checked = settings.value("Common/ShowHidden", false).toBool();\r
- ui->view_Hidden->setChecked(checked);\r
-\r
- // メニューのシグナル/スロットを設定する\r
- connect(ui->action_Command, SIGNAL(triggered()), this, SLOT(onActionCommand()));\r
- connect(ui->action_Exec, SIGNAL(triggered()), this, SLOT(onActionExec()));\r
- connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(onActionOpen()));\r
- connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(onActionQuit()));\r
- connect(ui->action_Setting, SIGNAL(triggered()), this, SLOT(onActionSetting()));\r
-\r
- connect(ui->mark_All, SIGNAL(triggered()), this, SLOT(onMarkAll()));\r
- connect(ui->mark_AllFiles, SIGNAL(triggered()), this, SLOT(onMarkAllFiles()));\r
- connect(ui->mark_AllOff, SIGNAL(triggered()), this, SLOT(onMarkAllOff()));\r
- connect(ui->mark_Invert, SIGNAL(triggered()), this, SLOT(onMarkInvert()));\r
- connect(ui->mark_Toggle, SIGNAL(triggered()), this, SLOT(onMarkToggle()));\r
-\r
- connect(ui->move_Down, SIGNAL(triggered()), this, SLOT(onMoveCursorDown()));\r
- connect(ui->move_Up, SIGNAL(triggered()), this, SLOT(onMoveCursorUp()));\r
- connect(ui->move_Begin, SIGNAL(triggered()), this, SLOT(onMoveCursorBegin()));\r
- connect(ui->move_End, SIGNAL(triggered()), this, SLOT(onMoveCursorEnd()));\r
- connect(ui->move_Back, SIGNAL(triggered()), this, SLOT(onMoveBack()));\r
- connect(ui->move_Forward, SIGNAL(triggered()), this, SLOT(onMoveForward()));\r
- connect(ui->move_Home, SIGNAL(triggered()), this, SLOT(onMoveHome()));\r
- connect(ui->move_Jump, SIGNAL(triggered()), this, SLOT(onMoveJump()));\r
- connect(ui->move_Parent, SIGNAL(triggered()), this, SLOT(onMoveParent()));\r
- connect(ui->move_Root, SIGNAL(triggered()), this, SLOT(onMoveRoot()));\r
-\r
- connect(ui->view_FromOther, SIGNAL(triggered()), this, SLOT(onViewFromOther()));\r
- connect(ui->view_ToOther, SIGNAL(triggered()), this, SLOT(onViewToOther()));\r
- connect(ui->view_Hidden, SIGNAL(triggered()), this, SLOT(onViewHidden()));\r
- connect(ui->view_Swap, SIGNAL(triggered()), this, SLOT(onViewSwap()));\r
-\r
- connect(ui->cmd_Copy, SIGNAL(triggered()), this, SLOT(onCmdCopy()));\r
- connect(ui->cmd_Delete, SIGNAL(triggered()), this, SLOT(onCmdDelete()));\r
- connect(ui->cmd_Move, SIGNAL(triggered()), this, SLOT(onCmdMove()));\r
- connect(ui->cmd_NewFile, SIGNAL(triggered()), this, SLOT(onCmdNewFile()));\r
- connect(ui->cmd_NewFolder, SIGNAL(triggered()), this, SLOT(onCmdNewFolder()));\r
- connect(ui->cmd_Rename, SIGNAL(triggered()), this, SLOT(onCmdRename()));\r
-\r
- connect(ui->help_About, SIGNAL(triggered()), this, SLOT(onHelpAbout()));\r
+ // ブックマークメニューを初期化する\r
+ initBookmark();\r
+\r
+ // メニュー項目の状態を初期化する\r
+ ui->view_Hidden->setChecked(settings.value(IniKey_ShowHidden).toBool());\r
+ ui->view_System->setChecked(settings.value(IniKey_ShowSystem).toBool());\r
+// ui->action_OpenEditor->setEnabled(!settings.value(IniKey_PathEditor).toString().isEmpty());\r
+// ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_PathTerminal).toString().isEmpty());\r
+\r
+ // 追加のショートカットキーを設定する\r
+ QList<QKeySequence> shortcuts;\r
+ shortcuts = ui->action_Open->shortcuts();\r
+ shortcuts.append(QKeySequence("M"));\r
+ ui->action_Open->setShortcuts(shortcuts);\r
+\r
+ shortcuts = ui->action_Exec->shortcuts();\r
+ shortcuts.append(QKeySequence("Shift+M"));\r
+ ui->action_Exec->setShortcuts(shortcuts);\r
+\r
+ // MacだとShift+の形で認識されてしまうもの\r
+ shortcuts = ui->view_FontSizeUp->shortcuts();\r
+ shortcuts.append(QKeySequence("Shift++"));\r
+ ui->view_FontSizeUp->setShortcuts(shortcuts);\r
+\r
+ shortcuts = ui->view_Filter->shortcuts();\r
+ shortcuts.append(QKeySequence("Shift+*"));\r
+ ui->view_Filter->setShortcuts(shortcuts);\r
+\r
+ shortcuts = ui->action_OpenTerminal->shortcuts();\r
+ shortcuts.append(QKeySequence("Shift+>"));\r
+ ui->action_OpenTerminal->setShortcuts(shortcuts);\r
+\r
+ shortcuts = ui->help_About->shortcuts();\r
+ shortcuts.append(QKeySequence("Shift+?"));\r
+ ui->help_About->setShortcuts(shortcuts);\r
\r
// ウィンドウタイトルを設定する\r
- setWindowTitle(tr("げふぅ v0.00"));\r
+ setWindowTitle(tr("げふぅ v%1").arg(VERSION_VALUE));\r
+\r
// ウィンドウアイコンを設定する\r
+#if defined(Q_OS_MAC)\r
+ setWindowIcon(QIcon(":/images/Gefu.icns"));\r
+#else\r
setWindowIcon(QIcon(":/images/Gefu.png"));\r
+#endif\r
+\r
+ //>>>>> ウィンドウサイズと位置を設定する\r
+ QString strValue;\r
+ QPoint point = this->geometry().topLeft();\r
+ QSize size = this->geometry().size();\r
+ //>>>> 前回の位置・サイズ・状態を復元する\r
+ if (!settings.value(IniKey_WindowGeometry, "").toString().isEmpty()) {\r
+ restoreGeometry(settings.value(IniKey_WindowGeometry).toByteArray());\r
+ restoreState(settings.value(iniKey_WindowState).toByteArray());\r
+ }\r
+ //>>>> INIファイルの設定から復元する\r
+ //>>> サイズ\r
+ strValue = settings.value(IniKey_BootSizeSpec).toString();\r
+ if (strValue == "sizeAbsolute") {\r
+ size = settings.value(IniKey_BootSizeAbs).toSize();\r
+ }\r
+ else if (strValue == "sizeRelative") {\r
+ size = settings.value(IniKey_BootSizeRel).toSize();\r
+ size.setWidth(size.width() * QApplication::desktop()->width() / 100.0);\r
+ size.setHeight(size.height() * QApplication::desktop()->height() / 100.0);\r
+ }\r
+ else if (strValue == "sizeLast") {\r
+ size = this->geometry().size();\r
+ }\r
+ //>>> 位置\r
+ strValue = settings.value(IniKey_BootPosSpec).toString();\r
+ if (strValue == "posAbsolute") {\r
+ point = settings.value(IniKey_BootPosAbs).toPoint();\r
+ }\r
+ else if (strValue == "posRelative") {\r
+ point = settings.value(IniKey_BootPosRel).toPoint();\r
+ point.setX(point.x() * QApplication::desktop()->width() / 100.0);\r
+ point.setY(point.y() * QApplication::desktop()->height() / 100.0);\r
+ }\r
+ else if (strValue == "posLast") {\r
+ point = this->geometry().topLeft();\r
+ }\r
+ else {\r
+ point.setX((QApplication::desktop()->width() - size.width()) / 2);\r
+ point.setY((QApplication::desktop()->height() - size.height()) / 2);\r
+ }\r
+ this->setGeometry(QRect(point, size));\r
\r
- // ウィンドウ初期サイズを設定する\r
- resize(800, 600);\r
+ // 最新バージョンをチェックする\r
+ if (settings.value(IniKey_CheckUpdates).toBool()) {\r
+ checkUpdate(true);\r
+ }\r
\r
- QString path;\r
+ ui->pane2->changeView(AnyView::ViewFolder);\r
+ ui->pane2->repaint();\r
\r
- path = settings.value("Left/dir", QDir::homePath()).toString();\r
- ui->folderPanel_L->setCurrentFolder(path);\r
+ ui->pane1->changeView(AnyView::ViewFolder);\r
+ ui->pane1->repaint();\r
\r
- path = settings.value("Right/dir", QDir::homePath()).toString();\r
- ui->folderPanel_R->setCurrentFolder(path);\r
+ qDebug() << ">>>>>>>>>> MainWindowの構築終了 <<<<<";\r
}\r
\r
MainWindow::~MainWindow()\r
{\r
- QSettings settings;\r
-\r
- settings.setValue("Left/dir", ui->folderPanel_L->dir()->absolutePath());\r
- settings.setValue("Right/dir", ui->folderPanel_R->dir()->absolutePath());\r
-\r
delete ui;\r
}\r
\r
-void MainWindow::setStatusText(const QString &str)\r
+void MainWindow::focusChange(QWidget *old, QWidget *now)\r
{\r
- ui->statusBar->showMessage(str);\r
-}\r
+ qDebug() << ">>>>> フォーカス変更";\r
+ if (old) qDebug() << "old is" << old->objectName();\r
+ if (now) qDebug() << "now is" << now->objectName();\r
\r
-FolderPanel* MainWindow::activePanel()\r
-{\r
- if (ui->folderPanel_L->fileTable()->hasFocus()) {\r
- return ui->folderPanel_L;\r
+ // 検索ボックスがフォーカスを失ったら、非表示にする\r
+ if (old == ui->pane1->folderPanel()->searchBox() ||\r
+ old == ui->pane2->folderPanel()->searchBox())\r
+ {\r
+ ui->action_Search->setChecked(false);\r
}\r
- if (ui->folderPanel_R->fileTable()->hasFocus()) {\r
- return ui->folderPanel_R;\r
- }\r
-\r
- return NULL;\r
-}\r
\r
-FolderPanel* MainWindow::inactivePanel()\r
-{\r
- FolderPanel *fp = activePanel();\r
- if (fp == ui->folderPanel_L) {\r
- return ui->folderPanel_R;\r
- }\r
- if (fp == ui->folderPanel_R) {\r
- return ui->folderPanel_L;\r
+ // フォルダビューにフォーカスが移ったら、ステータスバーの表示を更新する\r
+ if (now == ui->pane1->folderPanel()->folderView() ||\r
+ now == ui->pane2->folderPanel()->folderView())\r
+ {\r
+ FolderView *view = static_cast<FolderView*>(now);\r
+ ui->statusBar->showMessage(view->currentItem().absoluteFilePath());\r
}\r
\r
- return NULL;\r
+ if (now) {\r
+ updateActions();\r
+ }\r
}\r
\r
-///\r
-/// \brief MainWindow::onActionCommand\r
-///\r
-/// コマンドを実行します(X)\r
-///\r
-void MainWindow::onActionCommand()\r
+void MainWindow::executeCommand()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
-\r
- QString command = "";\r
- for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
- if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
- QString path = fp->fileTable()->item(n, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- path = QDir::cleanPath(path);\r
- path = QDir::toNativeSeparators(path);\r
-\r
- QFileInfo info(path);\r
- if (info.isExecutable()) {\r
- command = "\"" + path + "\" " + command;\r
- }\r
- else {\r
- command += " \"" + path + "\"";\r
- }\r
+ qDebug() << "MainWindow::executeCommand";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QFileInfoList list = view->selectedItems();\r
+ QString command = QString::null;\r
+ foreach (const QFileInfo &info, list) {\r
+#ifdef Q_OS_MAC\r
+ QString path = info.absoluteFilePath();\r
+#else\r
+ QString path = info.fileName();\r
+#endif\r
+ if (info.isExecutable()) {\r
+ command = QQ(path) + " " + command;\r
+ }\r
+ else {\r
+ command += " " + QQ(path);\r
}\r
- }\r
-\r
- if (command.isEmpty()) {\r
- int row = fp->fileTable()->currentRow();\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- path = QDir::cleanPath(path);\r
- path = QDir::toNativeSeparators(path);\r
-\r
- command = "\"" + path + "\"";\r
}\r
\r
QInputDialog dlg(this);\r
dlg.setInputMode(QInputDialog::TextInput);\r
- dlg.setLabelText(tr("コマンドを入力:"));\r
dlg.setWindowTitle(tr("コマンドを実行"));\r
+ dlg.setLabelText(tr("コマンド:"));\r
dlg.setTextValue(command);\r
- dlg.resize(500, 100);\r
+ dlg.resize(width() * 0.8, dlg.height());\r
+\r
int ret = dlg.exec();\r
command = dlg.textValue();\r
if (ret == QDialog::Accepted && !command.isEmpty()) {\r
- QProcess process(this);\r
- process.setWorkingDirectory(fp->dir()->absolutePath());\r
- if (!process.startDetached(command)) {\r
- QMessageBox::critical(\r
- this,\r
- tr("エラー"),\r
- tr("コマンドの実行に失敗しました。<br/>") + command);\r
- }\r
+ startProcess(command, view->dir(), tr("コマンドの実行に失敗しました。"));\r
}\r
}\r
\r
-///\r
-/// \brief MainWindow::onActionExec\r
-///\r
-/// アプリケーションで開きます(Shift + Enter)\r
-///\r
-void MainWindow::onActionExec()\r
+void MainWindow::expandLeft()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::expandLeft();";\r
\r
- QStringList list = selectedItems(fp);\r
- foreach (const QString &path, list) {\r
- QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(path)));\r
- }\r
-}\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ QList<int> newSizes;\r
\r
-///\r
-/// \brief MainWindow::onActionOpen\r
-///\r
-/// フォルダを開きます(Enter)\r
-///\r
-void MainWindow::onActionOpen()\r
-{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ newSizes << sizes[0] + 30;\r
+ newSizes << sizes[1] - 30;\r
\r
- int row = fp->fileTable()->currentRow();\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- QFileInfo info(path);\r
+ ui->splitter->setSizes(newSizes);\r
\r
- if (info.isDir()) {\r
- fp->setCurrentFolder(path);\r
- }\r
}\r
\r
-///\r
-/// \brief MainWindow::onActionQuit\r
-///\r
-/// アプリケーションを終了します(Q)\r
-///\r
-void MainWindow::onActionQuit()\r
+void MainWindow::expandRight()\r
{\r
- qApp->quit();\r
-}\r
+ qDebug() << "MainWindow::expandLeft();";\r
+\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ QList<int> newSizes;\r
+\r
+ newSizes << sizes[0] - 30;\r
+ newSizes << sizes[1] + 30;\r
+\r
+ ui->splitter->setSizes(newSizes);\r
\r
-///\r
-/// \brief MainWindow::onActionSetting\r
-///\r
-/// 環境設定ダイアログを表示します(Z)\r
-///\r
-void MainWindow::onActionSetting()\r
-{\r
- QMessageBox::information(this, tr("情報"), tr("環境設定機能は未実装です。"));\r
}\r
\r
-///\r
-/// \brief MainWindow::on_mark_All_triggered\r
-///\r
-/// すべてマークします(Shift + A)\r
-///\r
-void MainWindow::onMarkAll()\r
+void MainWindow::historyBack()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::historyBack();";\r
\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Checked);\r
+ if (view->historyBack()) {\r
+ updateActions();\r
}\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
}\r
\r
-///\r
-/// \brief MainWindow::onMarkAllFiles\r
-///\r
-/// すべての「ファイル」をマークします(A)\r
-///\r
-void MainWindow::onMarkAllFiles()\r
+void MainWindow::historyForward()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
-\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ qDebug() << "MainWindow::historyForward();";\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- QFileInfo info(path);\r
- if (info.isDir()) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Unchecked);\r
- }\r
- else {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Checked);\r
- }\r
+ if (view->historyForward()) {\r
+ updateActions();\r
}\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
}\r
\r
-///\r
-/// \brief MainWindow::onMarkAllOff\r
-///\r
-/// すべてのマークを解除します(U)\r
-///\r
-void MainWindow::onMarkAllOff()\r
+void MainWindow::markAll()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::markAll();";\r
\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Unchecked);\r
- }\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+ view->setCheckStateAll(Qt::Checked);\r
}\r
\r
-///\r
-/// \brief MainWindow::onMarkInvert\r
-///\r
-/// マークを反転します(I)\r
-///\r
-void MainWindow::onMarkInvert()\r
+void MainWindow::markAllFiles()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::markAllFiles();";\r
\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- QTableWidgetItem *item = fp->fileTable()->item(row, 0);\r
- if (item->checkState() == Qt::Checked) {\r
- item->setCheckState(Qt::Unchecked);\r
- }\r
- else {\r
- item->setCheckState(Qt::Checked);\r
- }\r
- }\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+ view->setCheckStateAllFiles();\r
}\r
\r
-///\r
-/// \brief MainWindow::onMarkToggle\r
-///\r
-/// マークを設定または解除します(Space)\r
-///\r
-void MainWindow::onMarkToggle()\r
+void MainWindow::markAllOff()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::markAllOff();";\r
\r
- int row = fp->fileTable()->currentRow();\r
- QTableWidgetItem *item = fp->fileTable()->item(row, 0);\r
- if (fp->fileTable()->item(row, 1)->text() != "..") {\r
- if (item->checkState() == Qt::Checked) {\r
- item->setCheckState(Qt::Unchecked);\r
- }\r
- else {\r
- item->setCheckState(Qt::Checked);\r
- }\r
- }\r
- // 最終行でなければ、次のアイテムに移動する\r
- if (row < fp->fileTable()->rowCount() - 1) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row + 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ view->setCheckStateAll(Qt::Unchecked);\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveCursorDown\r
-///\r
-/// カーソルを下に移動します(J)\r
-///\r
-void MainWindow::onMoveCursorDown()\r
+void MainWindow::markInvert()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::markInvert();";\r
\r
- int row = fp->fileTable()->currentRow();\r
- if (row < fp->fileTable()->rowCount() - 1) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row + 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ view->invertCheckState();\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveCursorUp\r
-///\r
-/// カーソルを上に移動します(K)\r
-///\r
-void MainWindow::onMoveCursorUp()\r
+void MainWindow::markToggle()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::markToggle();";\r
\r
- int row = fp->fileTable()->currentRow();\r
- if (row > 0) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row - 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ view->toggleCheckState(view->currentIndex());\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveCursorBegin\r
-///\r
-/// カーソルを先頭に移動します(G)\r
-///\r
-void MainWindow::onMoveCursorBegin()\r
+void MainWindow::moveItems()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
+ qDebug() << "MainWindow::moveItems";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QFileInfoList list = view->selectedItems();\r
+ if (list.isEmpty()) {\r
return;\r
}\r
\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(0, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
-}\r
+ QSettings settings;\r
+ if (settings.value(IniKey_ConfirmMove).toBool()) {\r
+ if (QMessageBox::question(this, tr("確認"), tr("移動を実行しますか?"))\r
+ != QMessageBox::Yes)\r
+ {\r
+ return;\r
+ }\r
+ }\r
\r
-///\r
-/// \brief MainWindow::onMoveCursorEnd\r
-///\r
-/// カーソルを末尾に移動します(Shift + G)\r
-void MainWindow::onMoveCursorEnd()\r
-{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
+ // 上書き確認ダイアログを初期化する\r
+ m_overwriteDialog->reset();\r
+\r
+ // ワーカースレッドを作成する\r
+ FolderView *other = otherSideFolderView(view);\r
+ CopyMoveWorker *worker = new CopyMoveWorker();\r
+ connect(worker, SIGNAL(askOverWrite(QString*,QString*,QString,QString)),\r
+ this, SLOT(askOverWrite(QString*,QString*,QString,QString)));\r
+ worker->setCopyList(&list);\r
+ worker->setTargetDir(other->dir());\r
+ worker->setMoveMode(true);\r
+\r
+ // 進捗ダイアログを表示して、処理を開始する\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("移動"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(settings.value(IniKey_AutoCloseMove).toBool());\r
+\r
+ int row = view->currentIndex().row();\r
+\r
+ opDlg.exec();\r
+\r
+ if (row >= view->model()->rowCount()) {\r
+ row = view->model()->rowCount() - 1;\r
}\r
+ //view->selectRow(row);\r
+ view->setCurrentIndex(view->model()->index(row, 1));\r
\r
- int row = fp->fileTable()->rowCount() - 1;\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
+ settings.setValue(IniKey_AutoCloseMove, opDlg.autoClose());\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveBack\r
-///\r
-/// 前の履歴に戻ります(Alt + ←)\r
-///\r
-void MainWindow::onMoveBack()\r
+void MainWindow::leftKeyPress()\r
{\r
- QMessageBox::information(this, tr("情報"), tr("履歴機能は未実装です。"));\r
+ qDebug() << "MainWindow::leftKeyPress();";\r
+\r
+ if (ui->pane3->textView()->hasFocus()) {\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageUp, Qt::NoModifier);\r
+ QApplication::sendEvent(ui->pane3->textView(), &event);\r
+ }\r
+ else if (ui->pane1->folderPanel()->folderView()->hasFocus()) {\r
+ setPathToParent();\r
+ }\r
+ else if (ui->pane2->folderPanel()->folderView()->hasFocus()) {\r
+ ui->pane1->folderPanel()->folderView()->setFocus();\r
+ }\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveForward\r
-///\r
-/// 次の履歴に進みます(Alt + →)\r
-///\r
-void MainWindow::onMoveForward()\r
+void MainWindow::rightKeyPress()\r
{\r
- QMessageBox::information(this, tr("情報"), tr("履歴機能は未実装です。"));\r
+ qDebug() << "MainWindow::rightKeyPress();";\r
\r
+ if (ui->pane3->textView()->hasFocus()) {\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageDown, Qt::NoModifier);\r
+ QApplication::sendEvent(ui->pane3->textView(), &event);\r
+ }\r
+ else if (ui->pane1->folderPanel()->folderView()->hasFocus()) {\r
+ ui->pane2->folderPanel()->folderView()->setFocus();\r
+ }\r
+ else if (ui->pane2->folderPanel()->folderView()->hasFocus()) {\r
+ setPathToParent();\r
+ }\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveHome\r
-///\r
-/// ホームフォルダに移動します(H)\r
-///\r
-void MainWindow::onMoveHome()\r
+void MainWindow::showFileInfo(const QString &str)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::showFileInfo();" << str;\r
+ QLabel *label = ui->statusBar->findChild<QLabel*>("Right");\r
+ Q_CHECK_PTR(label);\r
\r
- fp->setCurrentFolder(QDir::homePath());\r
+ label->setText(str);\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveJump\r
-///\r
-/// フォルダを選択して移動します(Shift + J)\r
-void MainWindow::onMoveJump()\r
+void MainWindow::chooseFolder()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::chooseFolder();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
QString path = QFileDialog::getExistingDirectory(\r
- this,\r
- tr("フォルダを選択"),\r
- fp->dir()->absolutePath());\r
+ this, tr("フォルダを選択"), view->dir());\r
if (!path.isEmpty()) {\r
- fp->setCurrentFolder(path);\r
+ view->setPath(path, true);\r
+ updateActions();\r
}\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveOther\r
-///\r
-/// キーボードフォーカスを他方のパネルに移動します(TAB)\r
-///\r
-void MainWindow::onMoveOther()\r
+void MainWindow::copyFilenameToClipboard()\r
{\r
- FolderPanel *fp = this->inactivePanel();\r
- if (fp) {\r
- fp->fileTable()->setFocus();\r
- }\r
-}\r
+ qDebug() << "MainWindow::copyFilenameToClipboard();";\r
\r
-///\r
-/// \brief MainWindow::onMoveParent\r
-///\r
-/// 親フォルダに移動します(Backspace)\r
-///\r
-void MainWindow::onMoveParent()\r
-{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- if (!fp->dir()->isRoot()) {\r
- QString path = fp->dir()->absoluteFilePath("..");\r
- fp->setCurrentFolder(path);\r
- }\r
+ QClipboard *clipboard = QApplication::clipboard();\r
+ clipboard->setText(view->currentItem().fileName());\r
}\r
\r
-///\r
-/// \brief MainWindow::onMoveRoot\r
-///\r
-/// ルートフォルダに移動します()\r
-void MainWindow::onMoveRoot()\r
+void MainWindow::copyFullpathTpClipboard()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::copyFullpathTpClipboard();";\r
\r
- if (!fp->dir()->isRoot()) {\r
- fp->setCurrentFolder(QDir::rootPath());\r
- }\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QClipboard *clipboard = QApplication::clipboard();\r
+ clipboard->setText(view->currentItem().absoluteFilePath());\r
}\r
\r
-///\r
-/// \brief MainWindow::onViewFromOther\r
-///\r
-/// 隣のパネルと同じフォルダを表示します(O)\r
-///\r
-void MainWindow::onViewFromOther()\r
+void MainWindow::askOverWrite(QString *copyMethod,\r
+ QString *alias,\r
+ const QString &srcPath,\r
+ const QString &tgtPath)\r
{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
- return;\r
+ qDebug() << "MainWindow::askOverWrite();";\r
+\r
+ CopyMoveWorker *worker = static_cast<CopyMoveWorker*>(sender());\r
+ if (!m_overwriteDialog->isKeepSetting() ||\r
+ m_overwriteDialog->copyMethod() == "rbRename")\r
+ {\r
+ m_overwriteDialog->setFileInfo(srcPath, tgtPath);\r
+ if (m_overwriteDialog->exec() == QDialog::Rejected) {\r
+ worker->requestStop();\r
+ }\r
}\r
+ *copyMethod = m_overwriteDialog->copyMethod();\r
+ *alias = m_overwriteDialog->alias();\r
\r
- fp1->setCurrentFolder(fp2->dir()->absolutePath());\r
+ worker->endAsking();\r
}\r
\r
-///\r
-/// \brief MainWindow::onViewToOther\r
-///\r
-/// 隣のパネルに同じフォルダを表示します(Shift + O)\r
-///\r
-void MainWindow::onViewToOther()\r
+void MainWindow::currentChange(const QFileInfo &info)\r
{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
+ qDebug() << ">>>>> カーソル変更 <<<<<";\r
+\r
+ FolderView *view = static_cast<FolderView*>(sender());\r
+ Q_CHECK_PTR(view);\r
+\r
+ if (!view->hasFocus()) {\r
return;\r
}\r
\r
- fp2->setCurrentFolder(fp1->dir()->absolutePath());\r
-}\r
+ // ステータスバーにカーソルのフルパスを表示する\r
+ ui->statusBar->showMessage(info.absoluteFilePath());\r
\r
-///\r
-/// \brief MainWindow::onViewHidden\r
-///\r
-/// 隠しファイルの表示/非表示を切り替えます(Shift + H)\r
-void MainWindow::onViewHidden()\r
-{\r
- QSettings settings;\r
- bool checked = !settings.value("Common/ShowHidden", false).toBool();\r
- settings.setValue("Common/ShowHidden", checked);\r
+ // ハーフモードで変更された場合\r
+ if (m_viewMode & ModeHalfView) {\r
+ AnyView *otherSide = static_cast<AnyView*>(\r
+ otherSideFolderView(view)->parent()->parent());\r
+ Q_CHECK_PTR(otherSide);\r
\r
- if (checked) {\r
- ui->folderPanel_L->dir()->setFilter(ui->folderPanel_L->dir()->filter() | QDir::Hidden);\r
- ui->folderPanel_R->dir()->setFilter(ui->folderPanel_R->dir()->filter() | QDir::Hidden);\r
- }\r
- else {\r
- ui->folderPanel_L->dir()->setFilter(ui->folderPanel_L->dir()->filter() ^ QDir::Hidden);\r
- ui->folderPanel_R->dir()->setFilter(ui->folderPanel_R->dir()->filter() ^ QDir::Hidden);\r
+ if (!otherSide->setViewItem(view->currentItem())) {\r
+ showFileInfo("");\r
+ }\r
}\r
\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
+ updateActions();\r
}\r
\r
-///\r
-/// \brief MainWindow::onViewSwap\r
-///\r
-/// パネルの表示内容を交換します(W)\r
-///\r
-void MainWindow::onViewSwap()\r
+void MainWindow::dropAccept(const QFileInfoList &list)\r
{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::dropAccept();";\r
\r
- QString path1 = fp1->dir()->absolutePath();\r
- QString path2 = fp2->dir()->absolutePath();\r
+ FolderView *view = static_cast<FolderView*>(sender());\r
+ Q_CHECK_PTR(view);\r
\r
- fp1->setCurrentFolder(path2);\r
- fp2->setCurrentFolder(path1);\r
+ copyItems(list, view->dir());\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdMove\r
-///\r
-/// ファイルを移動します(Ctrl + M)\r
-///\r
-void MainWindow::onCmdMove()\r
+void MainWindow::copyItems(const QFileInfoList &list, const QString &tgtDir)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::copyItems();";\r
\r
- QStringList list = selectedItems(fp);\r
- if (list.isEmpty()) {\r
- return;\r
+ QSettings settings;\r
+ if (settings.value(IniKey_ConfirmCopy).toBool()) {\r
+ if (QMessageBox::question(this, tr("確認"), tr("コピーを実行しますか?"))\r
+ != QMessageBox::Yes)\r
+ {\r
+ return;\r
+ }\r
}\r
\r
+ // 上書き確認ダイアログを初期化する\r
+ m_overwriteDialog->reset();\r
+\r
+ // ワーカースレッドを作成する\r
CopyMoveWorker *worker = new CopyMoveWorker();\r
- connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)),\r
- this, SLOT(onAskOverWrite(bool*,int*,int*,QString*,QString,QString)));\r
+ connect(worker, SIGNAL(askOverWrite(QString*,QString*,QString,QString)),\r
+ this, SLOT(askOverWrite(QString*,QString*,QString,QString)));\r
worker->setCopyList(&list);\r
- worker->setTargetDir(inactivePanel()->dir()->absolutePath());\r
- worker->setMoveMode(true);\r
+ worker->setTargetDir(tgtDir);\r
+ worker->setMoveMode(false);\r
\r
+ // 進捗ダイアログを表示して、処理を開始する\r
OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("移動"));\r
+ opDlg.setWindowTitle(tr("コピー"));\r
opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(settings.value(IniKey_AutoCloseCopy).toBool());\r
\r
- ui->folderPanel_L->UninstallWatcher();\r
- ui->folderPanel_R->UninstallWatcher();\r
opDlg.exec();\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
\r
+ settings.setValue(IniKey_AutoCloseCopy, opDlg.autoClose());\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdCopy\r
-///\r
-/// ファイルをコピーします(Ctrl + C)\r
-///\r
-void MainWindow::onCmdCopy()\r
+void MainWindow::copyItems()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::copyItems";\r
\r
- QStringList list = selectedItems(fp);\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QFileInfoList list = view->selectedItems();\r
if (list.isEmpty()) {\r
return;\r
}\r
\r
- CopyMoveWorker *worker = new CopyMoveWorker();\r
- connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)),\r
- this, SLOT(onAskOverWrite(bool*,int*,int*,QString*,QString,QString)));\r
- worker->setCopyList(&list);\r
- worker->setTargetDir(inactivePanel()->dir()->absolutePath());\r
- worker->setMoveMode(false);\r
+ QString tgtPath = otherSideFolderView(view)->dir();\r
+ copyItems(list, tgtPath);\r
+}\r
\r
- OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("コピー"));\r
- opDlg.setWorker(worker);\r
+void MainWindow::createFile()\r
+{\r
+ qDebug() << "MainWindow::createFile";\r
\r
- ui->folderPanel_L->UninstallWatcher();\r
- ui->folderPanel_R->UninstallWatcher();\r
- opDlg.exec();\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
-\r
-}\r
-\r
-///\r
-/// \brief MainWindow::onAskOverWrite\r
-/// \param bOk\r
-/// \param prevCopyMethod\r
-/// \param copyMethod\r
-/// \param alias\r
-/// \param srcPath\r
-/// \param tgtPath\r
-///\r
-/// 上書き処理の方法をユーザに問い合わせます\r
-///\r
-void MainWindow::onAskOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod,\r
- QString *alias, const QString srcPath,\r
- const QString tgtPath)\r
-{\r
- OverWriteDialog dlg;\r
- dlg.setCopyMethod(*prevCopyMethod);\r
- dlg.setSameMethodChecked(*copyMethod != OverWriteDialog::Undefined);\r
- dlg.setFileInfo(srcPath, tgtPath);\r
- if (dlg.exec() == QDialog::Rejected) {\r
- *bOk = false;\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ bool bOk;\r
+ QString name = QInputDialog::getText(\r
+ this, tr("ファイルを作成"), tr("ファイル名:"),\r
+ QLineEdit::Normal, "", &bOk);\r
+ if (!bOk || name.isEmpty()) {\r
+ return;\r
+ }\r
+\r
+ QDir dir(view->dir());\r
+ QFile file(dir.absoluteFilePath(name));\r
+ if (!file.open(QIODevice::WriteOnly)) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("ファイルの作成に失敗しました。"));\r
}\r
else {\r
- *prevCopyMethod = dlg.copyMethod();\r
- if (dlg.isSameMethodChecked()) {\r
- *copyMethod = *prevCopyMethod;\r
+ file.close();\r
+\r
+ QSettings settings;\r
+ if (settings.value(IniKey_OpenAfterCreateFile).toBool()) {\r
+ openEditor(dir.absoluteFilePath(name));\r
}\r
- *alias = dlg.alias();\r
- *bOk = true;\r
+\r
+ view->refresh();\r
+ view->searchItem(name);\r
}\r
- CopyMoveWorker *worker = static_cast<CopyMoveWorker*>(sender());\r
- worker->endAsking();\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdDelete\r
-///\r
-/// ファイルを削除します\r
-///\r
-void MainWindow::onCmdDelete()\r
+void MainWindow::createFolder()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::createFolder";\r
\r
- QStringList list = selectedItems(fp);\r
- if (list.isEmpty()) {\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ bool bOk;\r
+ QString name = QInputDialog::getText(\r
+ this, tr("フォルダを作成"), tr("フォルダ名:"),\r
+ QLineEdit::Normal, "", &bOk);\r
+ if (!bOk || name.isEmpty()) {\r
return;\r
}\r
\r
- QString msg;\r
- if (list.size() == 1) {\r
- msg = QFileInfo(list.at(0)).fileName();\r
+ QDir dir(view->dir());\r
+ if (!dir.mkpath(name)) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("フォルダの作成に失敗しました。"));\r
}\r
else {\r
- msg = tr("%1個のアイテム").arg(list.size());\r
- }\r
- int ret = QMessageBox::question(\r
- this,\r
- tr("確認"),\r
- msg + tr("を削除します<br/>よろしいですか?"));\r
- if (ret == QMessageBox::Yes) {\r
- DeleteWorker *worker = new DeleteWorker();\r
- worker->setDeleteList(&list);\r
-\r
- OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("削除"));\r
- opDlg.setWorker(worker);\r
+ QSettings settings;\r
+ if (settings.value(IniKey_MoveAfterCreateFolder).toBool()) {\r
+ view->setPath(dir.absoluteFilePath(name), true);\r
+ }\r
\r
- ui->folderPanel_L->UninstallWatcher();\r
- ui->folderPanel_R->UninstallWatcher();\r
- opDlg.exec();\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
+ view->refresh();\r
+ view->searchItem(name);\r
}\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdNewFile\r
-///\r
-/// ファイルを作成します\r
-///\r
-void MainWindow::onCmdNewFile()\r
+void MainWindow::deleteItems()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
+ qDebug() << "MainWindow::deleteItems";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QFileInfoList list = view->selectedItems();\r
+ if (list.isEmpty()) {\r
return;\r
}\r
\r
- bool bOk;\r
- QString name = QInputDialog::getText(\r
- this,\r
- tr("ファイルを作成"),\r
- tr("ファイル名"),\r
- QLineEdit::Normal,\r
- "",\r
- &bOk);\r
- if (bOk && !name.isEmpty()) {\r
- QFile file(fp->dir()->absoluteFilePath(name));\r
- if (!file.open(QIODevice::WriteOnly)) {\r
- QMessageBox::critical(this,\r
- tr("エラー"),\r
- tr("ファイルの作成に失敗しました。"));\r
+ QSettings settings;\r
+ if (settings.value(IniKey_ConfirmDelete).toBool()) {\r
+ QString msg;\r
+ if (list.size() == 1) {\r
+ msg = list[0].fileName();\r
}\r
else {\r
- file.close();\r
+ msg = tr("%1個のアイテム").arg(list.size());\r
}\r
+ int ret = QMessageBox::question(\r
+ this, tr("確認"),\r
+ msg + tr("を削除しますか?"));\r
+ if (ret != QMessageBox::Yes) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ DeleteWorker *worker = new DeleteWorker();\r
+ worker->setDeleteList(&list);\r
+\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("削除"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(settings.value(IniKey_AutoCloseDelete).toBool());\r
+\r
+ int row = view->currentIndex().row();\r
+\r
+ opDlg.exec();\r
+ view->refresh();\r
+\r
+ if (row >= view->model()->rowCount()) {\r
+ row = view->model()->rowCount() - 1;\r
}\r
+// view->selectRow(row);\r
+ view->setCurrentIndex(view->model()->index(row, 1));\r
+\r
+ settings.setValue(IniKey_AutoCloseDelete, opDlg.autoClose());\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdNewFolder\r
-///\r
-/// フォルダを作成します\r
-///\r
-void MainWindow::onCmdNewFolder()\r
+void MainWindow::open(const QModelIndex &index)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
+ Q_UNUSED(index);\r
+ qDebug() << "MainWindow::open";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QFileInfo info = view->currentItem();\r
+ if (info.isDir()) {\r
+ view->setPath(info.absoluteFilePath(), true);\r
+ updateActions();\r
return;\r
}\r
\r
- bool bOk;\r
- QString name = QInputDialog::getText(\r
- this,\r
- tr("フォルダを作成"),\r
- tr("フォルダ名"),\r
- QLineEdit::Normal,\r
- "",\r
- &bOk);\r
- if (bOk && !name.isEmpty()) {\r
- if (!fp->dir()->mkpath(name)) {\r
- QMessageBox::critical(this,\r
- tr("エラー"),\r
- tr("フォルダの作成に失敗しました。"));\r
- }\r
+ setUpdatesEnabled(false);\r
+\r
+ m_focusedView = view;\r
+ if (ui->pane3->setViewItem(info)) {\r
+ ui->pane3->setVisible(true);\r
+ ui->splitter->setVisible(false);\r
+\r
+ setViewMode(ModeFullView);\r
}\r
+ else {\r
+ ui->pane3->setVisible(false);\r
+ }\r
+\r
+ setUpdatesEnabled(true);\r
}\r
\r
-///\r
-/// \brief MainWindow::onCmdRename\r
-///\r
-/// 名前を変更します\r
-///\r
-void MainWindow::onCmdRename()\r
+void MainWindow::openEditor(const QString &path)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::openEditor";\r
\r
- QStringList list = selectedItems(fp);\r
- if (list.isEmpty()) {\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QSettings settings;\r
+ QString exe = settings.value(IniKey_PathEditor).toString();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("外部エディタのパスが未定義です。"));\r
return;\r
}\r
\r
- IRenameDialog *dlg;\r
- if (list.size() == 1) {\r
- dlg = new RenameSingleDialog(this);\r
+ QFileInfoList list;\r
+ if (path.isEmpty()) {\r
+ list = view->selectedItems();\r
}\r
else {\r
- dlg = new RenameMultiDialog(this);\r
+ list << path;\r
}\r
- dlg->setWorkingDirectory(fp->dir()->absolutePath());\r
- dlg->setNames(list);\r
- int dlgResult = dlg->exec();\r
- if (dlgResult == QDialog::Accepted && !dlg->renameMap().isEmpty()) {\r
- RenameWorker *worker = new RenameWorker();\r
- worker->setRenameMap(&dlg->renameMap());\r
\r
- OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("名前を変更"));\r
- opDlg.setWorker(worker);\r
-\r
- ui->folderPanel_L->UninstallWatcher();\r
- ui->folderPanel_R->UninstallWatcher();\r
- opDlg.exec();\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
+ QString files;\r
+ foreach (const QFileInfo &info, list) {\r
+ files += " " + QQ(info.absoluteFilePath());\r
+ }\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -a " + exe + files;\r
+#else\r
+ QString command = exe + files;\r
+#endif\r
+ if (!startProcess(command, view->dir(), tr("外部エディタの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
}\r
}\r
\r
-///\r
-/// \brief MainWindow::onHelpAbout\r
-///\r
-/// アプリケーションの概要を表示します(?)\r
-///\r
-void MainWindow::onHelpAbout()\r
+void MainWindow::openTerminal()\r
{\r
- QMessageBox::about(\r
- this,\r
- tr("げふぅ について"),\r
- tr("<h3>Gefu Ver%1</h3>").arg(VERSION_VALUE) +\r
- tr("<center>Gefu is Experimental File Utility.<br/>"\r
- "(げふぅは実験的なファイルユーティリティです)</center>"\r
- "<p>Copyright 2014 @miyabi_satoh All rights reserved.</p>"));\r
+ qDebug() << "MainWindow::openTerminal";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QSettings settings;\r
+ QString exe = settings.value(IniKey_PathTerminal).toString();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("ターミナルのパスが未定義です。"));\r
+ return;\r
+ }\r
+\r
+ QSet<QString> dirs;\r
+ foreach (const QFileInfo &info, view->selectedItems()) {\r
+ if (info.isDir()) {\r
+ dirs.insert(info.absoluteFilePath());\r
+ }\r
+ else {\r
+ dirs.insert(info.absolutePath());\r
+ }\r
+ }\r
+\r
+ foreach (const QString &dir, dirs) {\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -n -a " + exe + " " + QQ(dir);\r
+#else\r
+ QString command = exe + " " + QQ(dir);\r
+#endif\r
+ if (!startProcess(command, view->dir(), tr("ターミナルの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
+ break;\r
+ }\r
+ }\r
}\r
\r
-///\r
-/// \brief MainWindow::selectedItems\r
-/// \param fp フォルダパネルへのポインタ\r
-/// \return 選択アイテムのフルパスのリスト\r
-///\r
-/// 選択アイテムのフルパスのリストを取得します\r
-///\r
-QStringList MainWindow::selectedItems(FolderPanel *fp)\r
+void MainWindow::openArchiver()\r
{\r
- QStringList list;\r
- for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
- if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
- list << fp->dir()->absoluteFilePath(fp->fileTable()->item(n, 1)->text());\r
- }\r
+ qDebug() << "MainWindow::openArchiver";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QSettings settings;\r
+ QString exe = settings.value(IniKey_PathArchiver).toString();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("アーカイバのパスが未定義です。"));\r
+ return;\r
+ }\r
+\r
+ QString files;\r
+ foreach (const QFileInfo &info, view->selectedItems()) {\r
+ files += " " + QQ(info.absoluteFilePath());\r
}\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -a " + exe + files;\r
+#else\r
+ QString command = exe + files;\r
+#endif\r
+ if (!startProcess(command, view->dir(), tr("アーカイバの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
+ }\r
+}\r
+\r
+void MainWindow::openBookmark()\r
+{\r
+ qDebug() << "MainWindow::openBookmark();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QAction *action = qobject_cast<QAction*>(sender());\r
+ Q_CHECK_PTR(action);\r
+\r
+ QSettings settings;\r
+ int i = action->data().toInt();\r
+ view->setPath(settings.value(IniKey_BookmarkEntryPath(i)).toString(), true);\r
+}\r
+\r
+void MainWindow::refresh()\r
+{\r
+ qDebug() << "MainWindow::refresh();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ view->refresh();\r
+}\r
+\r
+void MainWindow::renameItems()\r
+{\r
+ qDebug() << "MainWindow::renameItems";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
+ QFileInfoList list = view->selectedItems();\r
if (list.isEmpty()) {\r
- int row = fp->fileTable()->currentRow();\r
- QString name = fp->fileTable()->item(row, 1)->text();\r
- if (name != "..") {\r
- list << fp->dir()->absoluteFilePath(name);\r
+ return;\r
+ }\r
+\r
+ IRenameDialog *dlg;\r
+ if (list.size() == 1) {\r
+ dlg = new RenameSingleDialog(this);\r
+ }\r
+ else {\r
+ dlg = new RenameMultiDialog(this);\r
+ }\r
+ dlg->setWorkingDirectory(view->dir());\r
+ dlg->setNames(list);\r
+ int dlgResult = dlg->exec();\r
+ if (dlgResult != QDialog::Accepted || dlg->renameMap().isEmpty()) {\r
+ return;\r
+ }\r
+\r
+ QSettings settings;\r
+ if (settings.value(IniKey_ConfirmRename).toBool()) {\r
+ int ret = QMessageBox::question(this, tr("確認"),\r
+ tr("名前の変更を実行しますか?"));\r
+ if (ret != QMessageBox::Yes) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ RenameWorker *worker = new RenameWorker();\r
+ worker->setRenameMap(&dlg->renameMap());\r
+\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("名前を変更"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(settings.value(IniKey_AutoCloseRename).toBool());\r
+\r
+ opDlg.exec();\r
+ view->refresh();\r
+\r
+ QFileInfo info(dlg->renameMap().first());\r
+ view->searchItem(info.fileName());\r
+\r
+ settings.setValue(IniKey_AutoCloseRename, opDlg.autoClose());\r
+}\r
+\r
+void MainWindow::shellExecute()\r
+{\r
+ qDebug() << "MainWindow::shellExecute";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ foreach (const QFileInfo &info, view->selectedItems()) {\r
+ QString path = QDir::toNativeSeparators(info.absoluteFilePath());\r
+ QDesktopServices::openUrl(QUrl("file:///" + path));\r
+ }\r
+}\r
+\r
+void MainWindow::showBookmarkDialog()\r
+{\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ BookmarkDialog dlg(this);\r
+ dlg.setEditMode(false);\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ int n = dlg.selectedIndex();\r
+\r
+ QSettings settings;\r
+ view->setPath(settings.value(IniKey_BookmarkEntryPath(n)).toString(), true);\r
+ }\r
+}\r
+\r
+void MainWindow::editBookmark()\r
+{\r
+ qDebug() << "MainWindow::showBookmarkDialog();";\r
+\r
+ BookmarkDialog dlg(this);\r
+ dlg.setEditMode(true);\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ initBookmark();\r
+ }\r
+}\r
+\r
+void MainWindow::showFilterDialog()\r
+{\r
+ qDebug() << "MainWindow::showFilterDialog();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QString filters = view->nameFilters().join(" ");\r
+\r
+ QInputDialog dlg(this);\r
+ dlg.setInputMode(QInputDialog::TextInput);\r
+ dlg.setWindowTitle(tr("フィルタを設定"));\r
+ dlg.setLabelText(tr("フィルタ:"));\r
+ dlg.setTextValue(filters);\r
+ dlg.resize(width() * 0.8, dlg.height());\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ static_cast<FolderPanel*>(view->parent())->setNameFilters(dlg.textValue());\r
+ int row = view->currentIndex().row();\r
+\r
+ view->refresh();\r
+\r
+ if (row >= view->model()->rowCount()) {\r
+ row = view->model()->rowCount() - 1;\r
+ }\r
+// view->selectRow(row);\r
+ view->setCurrentIndex(view->model()->index(row, 1));\r
+\r
+ }\r
+}\r
+\r
+void MainWindow::showHistoryDialog()\r
+{\r
+ qDebug() << "MainWindow::showHistoryDialog();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ FolderView *vOther = otherSideFolderView(view);\r
+\r
+ HistoryDialog dlg(this);\r
+ if (view->side() == "Left") {\r
+ dlg.setDefaultLeft(true);\r
+ dlg.setHistory(view->history(), vOther->history());\r
+ }\r
+ else {\r
+ dlg.setDefaultLeft(false);\r
+ dlg.setHistory(vOther->history(), view->history());\r
+ }\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ if (view->side() == dlg.selectedSide()) {\r
+ view->setHistoryIndexAt(dlg.selectedIndex());\r
+ }\r
+ else {\r
+ view->setPath(vOther->history()->at(dlg.selectedIndex()), true);\r
+ }\r
+ }\r
+}\r
+\r
+void MainWindow::showSortDialog()\r
+{\r
+ qDebug() << "MainWindow::showSortDialog();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ SortDialog dlg(this);\r
+ dlg.setRightOrLeft(view->side());\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ view->setSorting();\r
+ view->refresh();\r
+ }\r
+}\r
+\r
+void MainWindow::splitCenter()\r
+{\r
+ qDebug() << "MainWindow::splitCenter();";\r
+\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ int sizeTotal = sizes[0] + sizes[1];\r
+ sizes[0] = sizeTotal / 2;\r
+ sizes[1] = sizeTotal - sizes[0];\r
+ ui->splitter->setSizes(sizes);\r
+}\r
+\r
+void MainWindow::swapView()\r
+{\r
+ qDebug() << "MainWindow::swapView();";\r
+\r
+ QString dir1 = ui->pane1->folderPanel()->folderView()->dir();\r
+ QString dir2 = ui->pane2->folderPanel()->folderView()->dir();\r
+\r
+ ui->pane1->folderPanel()->folderView()->setPath(dir2, true);\r
+ ui->pane2->folderPanel()->folderView()->setPath(dir1, true);\r
+\r
+ updateActions();\r
+}\r
+\r
+void MainWindow::switchHalfMode(bool checked)\r
+{\r
+ qDebug() << "MainWindow::switchHalfMode();" << checked;\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ AnyView *pane = static_cast<AnyView*>(\r
+ otherSideFolderView(view)->parent()->parent());\r
+ Q_CHECK_PTR(pane);\r
+\r
+ if (checked) {\r
+ // ハーフモードへ移行する\r
+ setViewMode(ModeHalfView);\r
+ pane->setViewItem(view->currentItem());\r
+ }\r
+ else {\r
+ // ハーフモードを解除する\r
+ setViewMode(ModeBasic);\r
+ pane->changeView(AnyView::ViewFolder);\r
+ }\r
+ updateActions();\r
+}\r
+\r
+//void MainWindow::searchItem(const QString &text)\r
+//{\r
+// qDebug() << "MainWindow::searchItem" << text;\r
+\r
+// SearchBox *box = qobject_cast<SearchBox*>(qApp->focusWidget());\r
+// Q_CHECK_PTR(box);\r
+\r
+// if (text.right(1) == "/") {\r
+// // '/'が入力されたら、検索終了\r
+// box->setText(text.left(text.length() - 1));\r
+// ui->action_Search->setChecked(false);\r
+// }\r
+// else {\r
+// FolderPanel *fp = qobject_cast<FolderPanel*>(box->parent());\r
+// Q_CHECK_PTR(fp);\r
+\r
+// fp->folderView()->searchItem(box->text());\r
+// }\r
+//}\r
+\r
+void MainWindow::searchNext()\r
+{\r
+ qDebug() << "MainWindow::searchNext";\r
+\r
+ SearchBox *box = qobject_cast<SearchBox*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(box);\r
+\r
+ FolderPanel *fp = qobject_cast<FolderPanel*>(box->parent());\r
+ Q_CHECK_PTR(fp);\r
+\r
+ fp->folderView()->searchNext(box->text());\r
+}\r
+\r
+void MainWindow::searchPrev()\r
+{\r
+ qDebug() << "MainWindow::searchPrev";\r
+\r
+ SearchBox *box = qobject_cast<SearchBox*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(box);\r
+\r
+ FolderPanel *fp = qobject_cast<FolderPanel*>(box->parent());\r
+ Q_CHECK_PTR(fp);\r
+\r
+ fp->folderView()->searchPrev(box->text());\r
+}\r
+\r
+void MainWindow::setCursorToBegin()\r
+{\r
+ qDebug() << "MainWindow::setCursorToBegin();";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::NoModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::ControlModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event2);\r
+}\r
+\r
+void MainWindow::cursorDown()\r
+{\r
+ qDebug() << "MainWindow::cursorDown();";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event);\r
+}\r
+\r
+void MainWindow::cursorUp()\r
+{\r
+ qDebug() << "MainWindow::cursorUp();";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event);\r
+}\r
+\r
+void MainWindow::setCursorToEnd()\r
+{\r
+ qDebug() << "MainWindow::setCursorToEnd();";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier);\r
+ QApplication::sendEvent(QApplication::focusWidget(), &event2);\r
+}\r
+\r
+void MainWindow::setCursorToBeginOther()\r
+{\r
+ qDebug() << "MainWindow::setCursorToBeginOther();";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::NoModifier);\r
+ sendEventOther(&event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::ControlModifier);\r
+ sendEventOther(&event2);\r
+}\r
+\r
+void MainWindow::cursorDownOther()\r
+{\r
+ qDebug() << "MainWindow::cursorDownOther();";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);\r
+ sendEventOther(&event);\r
+}\r
+\r
+void MainWindow::cursorUpOther()\r
+{\r
+ qDebug() << "MainWindow::cursorUpOther();";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);\r
+ sendEventOther(&event);\r
+}\r
+\r
+void MainWindow::setCursorToEndOther()\r
+{\r
+ qDebug() << "MainWindow::setCursorToEndOther();";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier);\r
+ sendEventOther(&event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier);\r
+ sendEventOther(&event2);\r
+}\r
+\r
+void MainWindow::setFontSizeDown()\r
+{\r
+ qDebug() << "MainWindow::setFontSizeDown();";\r
+\r
+ changeFontSize(-1);\r
+}\r
+\r
+void MainWindow::setFontSizeUp()\r
+{\r
+ qDebug() << "MainWindow::setFontSizeUp();";\r
+\r
+ changeFontSize(1);\r
+}\r
+\r
+void MainWindow::changeFontSize(int diff)\r
+{\r
+ qDebug() << "MainWindow::changeFontSize(;";\r
+\r
+ QSettings settings;\r
+ QFont font;\r
+\r
+ // フォルダビューのフォントサイズ変更\r
+ if (ui->pane1->folderPanel()->folderView()->hasFocus() ||\r
+ ui->pane2->folderPanel()->folderView()->hasFocus())\r
+ {\r
+ font = settings.value(IniKey_ViewFont).value<QFont>();\r
+ font.setPointSize(font.pointSize() + diff);\r
+ settings.setValue(IniKey_ViewFont, font);\r
+\r
+ ui->pane1->folderPanel()->folderView()->updateAppearance();\r
+ ui->pane2->folderPanel()->folderView()->updateAppearance();\r
+ }\r
+\r
+ // テキストビューのフォントサイズ変更\r
+ if (ui->pane1->textView()->hasFocus() ||\r
+ ui->pane2->textView()->hasFocus() ||\r
+ ui->pane3->textView()->hasFocus())\r
+ {\r
+ font = settings.value(IniKey_ViewerFont).value<QFont>();\r
+ font.setPointSize(font.pointSize() + diff);\r
+ settings.setValue(IniKey_ViewerFont, font);\r
+\r
+ ui->pane1->textView()->updateAppearance();\r
+ ui->pane2->textView()->updateAppearance();\r
+ ui->pane3->textView()->updateAppearance();\r
+ }\r
+\r
+ if (ui->pane1->imageView()->hasFocus() ||\r
+ ui->pane2->imageView()->hasFocus() ||\r
+ ui->pane3->imageView()->hasFocus())\r
+ {\r
+ ui->pane1->imageView()->changeScale(diff > 0);\r
+ ui->pane2->imageView()->changeScale(diff > 0);\r
+ ui->pane3->imageView()->changeScale(diff > 0);\r
+ }\r
+}\r
+\r
+void MainWindow::initBookmark()\r
+{\r
+ QSettings settings;\r
+ QFileIconProvider iconProvider;\r
+\r
+ ui->menu_Bookmark->clear();\r
+ ui->menu_Bookmark->addAction(ui->bookmark_Edit);\r
+ ui->menu_Bookmark->addSeparator();\r
+ int i = 0;\r
+ while (!settings.value(IniKey_BookmarkEntryName(i), "").toString().isEmpty()) {\r
+ QString path = settings.value(IniKey_BookmarkEntryPath(i)).toString();\r
+ QAction *action = new QAction(this);\r
+ action->setText(settings.value(IniKey_BookmarkEntryName(i)).toString());\r
+ action->setData(i);\r
+ action->setIcon(iconProvider.icon(QFileInfo(path)));\r
+ ui->menu_Bookmark->addAction(action);\r
+ connect(action, SIGNAL(triggered()), this, SLOT(openBookmark()));\r
+ i++;\r
+ }\r
+}\r
+\r
+void MainWindow::sendEventOther(QEvent *event)\r
+{\r
+ qDebug() << "MainWindow::sendEventOther();";\r
+\r
+ QWidget *widget = NULL;\r
+\r
+ if (m_viewMode & ModeBasic) {\r
+ // 検索ボックスにフォーカスがある場合も考慮して、\r
+ // FolderPanalを介してViewを取得する\r
+ FolderPanel *fp = qobject_cast<FolderPanel*>(qApp->focusWidget()->parentWidget());\r
+ Q_CHECK_PTR(fp);\r
+\r
+ widget = otherSideFolderView(fp->folderView());\r
+ }\r
+ else if (m_viewMode & ModeHalfView) {\r
+ AnyView *focusedView = qobject_cast<AnyView*>(qApp->focusWidget()->parentWidget());\r
+ if (!focusedView) {\r
+ focusedView = qobject_cast<AnyView*>(qApp->focusWidget()->parentWidget()->parentWidget());\r
}\r
+ Q_CHECK_PTR(focusedView);\r
+\r
+ if (focusedView == ui->pane1) {\r
+ widget = ui->pane2->visibleView();\r
+ }\r
+ else {\r
+ Q_ASSERT(focusedView == ui->pane2);\r
+ widget = ui->pane1->visibleView();\r
+ }\r
+ }\r
+ else {\r
+ return;\r
+ }\r
+\r
+ Q_CHECK_PTR(widget);\r
+ QApplication::sendEvent(widget, event);\r
+}\r
+\r
+void MainWindow::setPathFromOther()\r
+{\r
+ qDebug() << "MainWindow::setPathFromOther();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ FolderView *other = otherSideFolderView(view);\r
+\r
+ view->setPath(other->dir(), true);\r
+}\r
+\r
+void MainWindow::setPathToHome()\r
+{\r
+ qDebug() << "MainWindow::setPathToHome();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ view->setPath(QDir::homePath(), true);\r
+}\r
+\r
+void MainWindow::setPathToOther()\r
+{\r
+ qDebug() << "MainWindow::setPathToOther();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ FolderView *other = otherSideFolderView(view);\r
+\r
+ other->setPath(view->dir(), true);\r
+}\r
+\r
+void MainWindow::setPathToParent()\r
+{\r
+ qDebug() << "MainWindow::setPathToParent();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QDir dir(view->dir());\r
+ if (!dir.isRoot()) {\r
+ dir.cdUp();\r
+ view->setPath(dir.absolutePath(), true);\r
}\r
+}\r
+\r
+void MainWindow::setPathToRoot()\r
+{\r
+ qDebug() << "MainWindow::setPathToRoot();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
\r
- return list;\r
+ view->setPath(QDir::rootPath(), true);\r
}\r
\r
-///\r
-/// \brief getMainWnd\r
-/// \return メインウィンドウのポインタ\r
-///\r
-/// メインウィンドウを取得します\r
-///\r
-MainWindow* getMainWnd()\r
+void MainWindow::toggleSearchBox(bool checked)\r
{\r
- foreach (QWidget *w, qApp->topLevelWidgets()) {\r
- if (w->objectName() == "MainWindow") {\r
- return static_cast<MainWindow*>(w);\r
+ qDebug() << "MainWindow::toggleSearchBox" << checked;\r
+\r
+ FolderView *view;\r
+ SearchBox *box;\r
+\r
+ if (checked) {\r
+ setViewMode(m_viewMode | ModeSearch);\r
+ view = static_cast<FolderView*>(qApp->focusWidget());\r
+ Q_CHECK_PTR(view);\r
+\r
+ box = view->parent()->findChild<SearchBox*>("searchBox");\r
+ Q_CHECK_PTR(box);\r
+\r
+ box->setVisible(true);\r
+ box->setFocus();\r
+ box->selectAll();\r
+ }\r
+ else {\r
+ setViewMode(m_viewMode ^ ModeSearch);\r
+ if (ui->pane1->folderPanel()->searchBox()->isVisible()) {\r
+ box = ui->pane1->folderPanel()->searchBox();\r
+ view = ui->pane1->folderPanel()->folderView();\r
}\r
+ else {\r
+ Q_ASSERT(ui->pane2->folderPanel()->searchBox()->isVisible());\r
+ box = ui->pane2->folderPanel()->searchBox();\r
+ view = ui->pane2->folderPanel()->folderView();\r
+ }\r
+\r
+ if (box->hasFocus()) {\r
+ view->setFocus();\r
+ }\r
+ box->setVisible(false);\r
+ }\r
+}\r
+\r
+void MainWindow::showPreferenceDialog()\r
+{\r
+ qDebug() << "MainWindow::showPreferenceDialog";\r
+\r
+ PreferenceDialog dlg(this);\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ bool dark1 = !ui->pane1->folderPanel()->folderView()->hasFocus();\r
+ bool dark2 = !ui->pane2->folderPanel()->folderView()->hasFocus();\r
+\r
+ ui->pane1->folderPanel()->locationBox()->updateAppearance(dark1);\r
+ ui->pane2->folderPanel()->locationBox()->updateAppearance(dark2);\r
+ ui->pane1->folderPanel()->folderView()->updateAppearance(dark1);\r
+ ui->pane2->folderPanel()->folderView()->updateAppearance(dark2);\r
+ ui->pane1->textView()->updateAppearance();\r
+ ui->pane2->textView()->updateAppearance();\r
+ ui->pane3->textView()->updateAppearance();\r
+\r
+ updateActions();\r
+ }\r
+}\r
+\r
+void MainWindow::toggleShowHiddenFiles(bool checked)\r
+{\r
+ qDebug() << "MainWindow::toggleShowHiddenFiles" << checked;\r
+\r
+ ui->pane1->folderPanel()->folderView()->setFilter(QDir::Hidden, checked);\r
+ ui->pane1->folderPanel()->folderView()->refresh();\r
+\r
+ ui->pane2->folderPanel()->folderView()->setFilter(QDir::Hidden, checked);\r
+ ui->pane2->folderPanel()->folderView()->refresh();\r
+}\r
+\r
+void MainWindow::toggleShowSystemFiles(bool checked)\r
+{\r
+ qDebug() << "MainWindow::toggleShowSystemFiles" << checked;\r
+\r
+ ui->pane1->folderPanel()->folderView()->setFilter(QDir::System, checked);\r
+ ui->pane1->folderPanel()->folderView()->refresh();\r
+\r
+ ui->pane2->folderPanel()->folderView()->setFilter(QDir::System, checked);\r
+ ui->pane2->folderPanel()->folderView()->refresh();\r
+}\r
+\r
+void MainWindow::showContextMenu(QContextMenuEvent *event)\r
+{\r
+ qDebug() << "MainWindow::showContextMenu();";\r
+\r
+ FolderView *view = static_cast<FolderView*>(sender());\r
+ Q_CHECK_PTR(view);\r
+\r
+ QModelIndex index = view->indexAt(event->pos());\r
+\r
+ QMenu menu(this);\r
+ if (index.isValid()) {\r
+ menu.addAction(ui->action_Open);\r
+ menu.addAction(ui->action_Exec);\r
+ menu.addAction(ui->action_OpenEditor);\r
+ menu.addAction(ui->action_OpenTerminal);\r
+ menu.addAction(ui->action_OpenArchiver);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->cmd_Copy);\r
+ menu.addAction(ui->cmd_Move);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->cmd_Delete);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->copy_Filename);\r
+ menu.addAction(ui->copy_Fullpath);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->cmd_Rename);\r
}\r
- qDebug() << "MainWindow not found !?";\r
- return NULL;\r
+ else {\r
+ menu.addAction(ui->move_Back);\r
+ menu.addAction(ui->move_Forward);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->move_Parent);\r
+ menu.addAction(ui->move_Home);\r
+ menu.addAction(ui->move_Root);\r
+ menu.addAction(ui->move_Jump);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->cmd_NewFile);\r
+ menu.addAction(ui->cmd_NewFolder);\r
+ }\r
+\r
+ menu.exec(event->globalPos());\r
+}\r
+\r
+void MainWindow::checkUpdate(bool silent)\r
+{\r
+ qDebug() << "MainWindow::checkUpdate()" << silent;\r
+\r
+ QNetworkAccessManager *manager = new QNetworkAccessManager(this);\r
+\r
+ if (silent) {\r
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkUpdateFinishedSilent(QNetworkReply*)));\r
+ }\r
+ else {\r
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkUpdateFinished(QNetworkReply*)));\r
+ }\r
+#ifdef Q_OS_WIN\r
+ manager->get(QNetworkRequest(QUrl("http://gefu.sourceforge.jp/gefu_latest_win.html")));\r
+#elif defined(Q_OS_MAC)\r
+ manager->get(QNetworkRequest(QUrl("http://gefu.sourceforge.jp/gefu_latest_mac.html")));\r
+#endif\r
+}\r
+\r
+void MainWindow::checkUpdateFinishedSilent(QNetworkReply *reply)\r
+{\r
+ qDebug() << "MainWindow::checkUpdateFinishedSilent";\r
+\r
+ checkUpdateFinished(reply, true);\r
+}\r
+\r
+void MainWindow::checkUpdateFinished(QNetworkReply *reply, bool silent)\r
+{\r
+ qDebug() << "MainWindow::checkUpdateFinished" << silent;\r
+\r
+ if (reply->error() == QNetworkReply::NoError) {\r
+ QString str = reply->readAll();\r
+ str = str.split(QRegExp("[\r\n]"), QString::SkipEmptyParts).at(0);\r
+ QRegExp rx("Gefu([0-9]+)");\r
+ rx.indexIn(str);\r
+ QString version = rx.cap(1);\r
+ if (version.toInt() > VERSION_VALUE * 100) {\r
+ QMessageBox::information(\r
+ this, tr("情報"),\r
+ tr("最新のバージョンが存在します。<br/>") +\r
+ tr("<a href='%1'>こちらからダウンロードしてください。</a>").arg(str));\r
+ }\r
+ else if (!silent) {\r
+ QMessageBox::information(\r
+ this, tr("情報"),\r
+ tr("お使いのバージョンは最新です。"));\r
+ }\r
+ }\r
+ else if (!silent){\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("最新バージョンのチェックに失敗しました。<br/>") +\r
+ reply->errorString());\r
+ }\r
+}\r
+\r
+void MainWindow::viewFinish()\r
+{\r
+ qDebug() << "MainWindow::viewFinish();" << sender()->objectName();\r
+\r
+ ui->statusBar->findChild<QLabel*>("Right")->setText("");\r
+ ui->pane3->setVisible(false);\r
+ ui->splitter->setVisible(true);\r
+ m_focusedView->setFocus();\r
+}\r
+\r
+void MainWindow::initActionConnections()\r
+{\r
+ qDebug() << "MainWindow::initActionConnections";\r
+\r
+ connect(ui->key_Left, SIGNAL(triggered()), this, SLOT(leftKeyPress()));\r
+ connect(ui->key_Right, SIGNAL(triggered()), this, SLOT(rightKeyPress()));\r
+\r
+ connect(ui->action_Command, SIGNAL(triggered()), this, SLOT(executeCommand()));\r
+ connect(ui->action_Exec, SIGNAL(triggered()), this, SLOT(shellExecute()));\r
+ connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(open()));\r
+ connect(ui->action_OpenEditor, SIGNAL(triggered()), this, SLOT(openEditor()));\r
+ connect(ui->action_OpenTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));\r
+ connect(ui->action_OpenArchiver, SIGNAL(triggered()), this, SLOT(openArchiver()));\r
+ connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close()));\r
+ connect(ui->action_Search, SIGNAL(toggled(bool)), this, SLOT(toggleSearchBox(bool)));\r
+ connect(ui->action_SearchNext, SIGNAL(triggered()), this, SLOT(searchNext()));\r
+ connect(ui->action_SearchPrev, SIGNAL(triggered()), this, SLOT(searchPrev()));\r
+ connect(ui->action_Setting, SIGNAL(triggered()), this, SLOT(showPreferenceDialog()));\r
+ connect(ui->check_Update, SIGNAL(triggered()), this, SLOT(checkUpdate()));\r
+ connect(ui->cmd_Copy, SIGNAL(triggered()), this, SLOT(copyItems()));\r
+ connect(ui->cmd_Delete, SIGNAL(triggered()), this, SLOT(deleteItems()));\r
+ connect(ui->cmd_Move, SIGNAL(triggered()), this, SLOT(moveItems()));\r
+ connect(ui->cmd_NewFile, SIGNAL(triggered()), this, SLOT(createFile()));\r
+ connect(ui->cmd_NewFolder, SIGNAL(triggered()), this, SLOT(createFolder()));\r
+ connect(ui->cmd_Rename, SIGNAL(triggered()), this, SLOT(renameItems()));\r
+ connect(ui->copy_Filename, SIGNAL(triggered()), this, SLOT(copyFilenameToClipboard()));\r
+ connect(ui->copy_Fullpath, SIGNAL(triggered()), this, SLOT(copyFullpathTpClipboard()));\r
+ connect(ui->help_About, SIGNAL(triggered()), this, SLOT(about()));\r
+ connect(ui->mark_All, SIGNAL(triggered()), this, SLOT(markAll()));\r
+ connect(ui->mark_AllFiles, SIGNAL(triggered()), this, SLOT(markAllFiles()));\r
+ connect(ui->mark_AllOff, SIGNAL(triggered()), this, SLOT(markAllOff()));\r
+ connect(ui->mark_Invert, SIGNAL(triggered()), this, SLOT(markInvert()));\r
+ connect(ui->mark_Toggle, SIGNAL(triggered()), this, SLOT(markToggle()));\r
+ connect(ui->move_Back, SIGNAL(triggered()), this, SLOT(historyBack()));\r
+ connect(ui->move_Begin, SIGNAL(triggered()), this, SLOT(setCursorToBegin()));\r
+ connect(ui->move_Down, SIGNAL(triggered()), this, SLOT(cursorDown()));\r
+ connect(ui->move_End, SIGNAL(triggered()), this, SLOT(setCursorToEnd()));\r
+ connect(ui->move_Up, SIGNAL(triggered()), this, SLOT(cursorUp()));\r
+ connect(ui->move_BeginOther, SIGNAL(triggered()), this, SLOT(setCursorToBeginOther()));\r
+ connect(ui->move_DownOther, SIGNAL(triggered()), this, SLOT(cursorDownOther()));\r
+ connect(ui->move_EndOther, SIGNAL(triggered()), this, SLOT(setCursorToEndOther()));\r
+ connect(ui->move_UpOther, SIGNAL(triggered()), this, SLOT(cursorUpOther()));\r
+ connect(ui->move_Forward, SIGNAL(triggered()), this, SLOT(historyForward()));\r
+ connect(ui->move_History, SIGNAL(triggered()), this, SLOT(showHistoryDialog()));\r
+ connect(ui->move_Home, SIGNAL(triggered()), this, SLOT(setPathToHome()));\r
+ connect(ui->move_Jump, SIGNAL(triggered()), this, SLOT(chooseFolder()));\r
+ connect(ui->move_Parent, SIGNAL(triggered()), this, SLOT(setPathToParent()));\r
+ connect(ui->move_Root, SIGNAL(triggered()), this, SLOT(setPathToRoot()));\r
+ connect(ui->view_Filter, SIGNAL(triggered()), this, SLOT(showFilterDialog()));\r
+ connect(ui->view_FontSizeDown, SIGNAL(triggered()), this, SLOT(setFontSizeDown()));\r
+ connect(ui->view_FontSizeUp, SIGNAL(triggered()), this, SLOT(setFontSizeUp()));\r
+ connect(ui->view_FromOther, SIGNAL(triggered()), this, SLOT(setPathFromOther()));\r
+ connect(ui->view_HalfMode, SIGNAL(toggled(bool)), this, SLOT(switchHalfMode(bool)));\r
+ connect(ui->view_Hidden, SIGNAL(toggled(bool)), this, SLOT(toggleShowHiddenFiles(bool)));\r
+ connect(ui->view_Refresh, SIGNAL(triggered()), this, SLOT(refresh()));\r
+ connect(ui->view_Sort, SIGNAL(triggered()), this, SLOT(showSortDialog()));\r
+ connect(ui->view_Swap, SIGNAL(triggered()), this, SLOT(swapView()));\r
+ connect(ui->view_System, SIGNAL(toggled(bool)), this, SLOT(toggleShowSystemFiles(bool)));\r
+ connect(ui->view_ToOther, SIGNAL(triggered()), this, SLOT(setPathToOther()));\r
+ connect(ui->bookmark_Edit, SIGNAL(triggered()), this, SLOT(editBookmark()));\r
+ connect(ui->bookmark_Show, SIGNAL(triggered()), this, SLOT(showBookmarkDialog()));\r
+ connect(ui->split_Center, SIGNAL(triggered()), this, SLOT(splitCenter()));\r
+ connect(ui->expand_Left, SIGNAL(triggered()), this, SLOT(expandLeft()));\r
+ connect(ui->expand_Right, SIGNAL(triggered()), this, SLOT(expandRight()));\r
+}\r
+\r
+void MainWindow::replaceVars(QString &str, const QFileInfo info)\r
+{\r
+ qDebug() << "MainWindow::replaceVars" << str;\r
+\r
+ str.replace("$B", info.completeBaseName());\r
+ str.replace("$E", info.suffix());\r
+ str.replace("$F", info.fileName());\r
+ if (info.isDir()) {\r
+ str.replace("$D", info.absoluteFilePath());\r
+ }\r
+ else {\r
+ str.replace("$D", info.absolutePath());\r
+ }\r
+ str.replace("$P", info.absoluteFilePath());\r
+}\r
+\r
+FolderView* MainWindow::otherSideFolderView(const FolderView *view) const\r
+{\r
+ qDebug() << "MainWindow::otherSideFolderView()";\r
+\r
+ if (view == ui->pane1->folderPanel()->folderView()) {\r
+ return ui->pane2->folderPanel()->folderView();\r
+ }\r
+ else {\r
+ Q_ASSERT(view == ui->pane2->folderPanel()->folderView());\r
+ return ui->pane1->folderPanel()->folderView();\r
+ }\r
+}\r
+\r
+void MainWindow::setViewMode(ModeFlags flags)\r
+{\r
+ qDebug() << "MainWindow::setViewMode();" << flags;\r
+ m_viewMode = flags;\r
+}\r
+\r
+bool MainWindow::startProcess(const QString &cmd, const QString &workDir, const QString &errMsg)\r
+{\r
+ qDebug() << "MainWindow::startProcess" << cmd << workDir << errMsg;\r
+\r
+ QProcess process(this);\r
+ process.setWorkingDirectory(workDir);\r
+ if (!process.startDetached(cmd)) {\r
+ QMessageBox::critical(this, tr("エラー"), errMsg + "<br/>" + cmd);\r
+ return false;\r
+ }\r
+ return true;\r
+}\r
+\r
+void MainWindow::updateActions()\r
+{\r
+ qDebug() << "MainWindow::updateActions" << m_viewMode;\r
+\r
+ QWidget *w = qApp->focusWidget();\r
+ FolderView *view;\r
+ if ((view = qobject_cast<FolderView*>(w))) {\r
+ setEnabledAllActions(true);\r
+ qDebug() << ">>>>> フォルダビューの共通メニュー設定 <<<<<";\r
+ ui->action_SearchNext->setEnabled(false);\r
+ ui->action_SearchPrev->setEnabled(false);\r
+\r
+ // 「開く」アクションを変更する\r
+ QFileInfo info(view->currentItem());\r
+ if (info.isDir()) {\r
+ ui->action_Open->setIcon(QIcon(":/images/Open.png"));\r
+ ui->action_Open->setText(tr("開く"));\r
+ ui->action_Open->setToolTip(tr("開く"));\r
+ }\r
+ else {\r
+ ui->action_Open->setIcon(QIcon(":/images/Search text.png"));\r
+ ui->action_Open->setText(tr("内蔵ビューアで開く"));\r
+ ui->action_Open->setToolTip(tr("内蔵ビューアで開く"));\r
+\r
+ QSettings settings;\r
+ if (!settings.value(IniKey_ViewerForceOpen).toBool()) {\r
+ QStringList list = settings.value(IniKey_ViewerIgnoreExt).toString().split(",");\r
+ foreach (const QString &ext, list) {\r
+ if (ext.toLower() == info.suffix().toLower()) {\r
+ ui->action_Open->setEnabled(false);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (info.fileName() == ".." && view->checkedItems().isEmpty()) {\r
+ // ファイル操作を抑止\r
+ ui->cmd_Copy->setEnabled(false);\r
+ ui->cmd_Delete->setEnabled(false);\r
+ ui->cmd_Move->setEnabled(false);\r
+ ui->cmd_Rename->setEnabled(false);\r
+ }\r
+\r
+ if (m_viewMode & ModeBasic) {\r
+ qDebug() << ">>>>> 通常モードのメニュー設定 <<<<<";\r
+ ui->action_SearchNext->setEnabled(false);\r
+ ui->action_SearchPrev->setEnabled(false);\r
+\r
+ ui->move_Back->setEnabled(!view->history()->isBegin());\r
+ ui->move_Forward->setEnabled(!view->history()->isEnd());\r
+\r
+ QSettings settings;\r
+ ui->action_OpenEditor->setEnabled(!settings.value(IniKey_PathEditor).toString().isEmpty());\r
+ ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_PathTerminal).toString().isEmpty());\r
+\r
+ }\r
+ else if (!otherSideFolderView(view)->isVisible()) {\r
+ qDebug() << ">>>>> ハーフモードのメニュー設定 <<<<<";\r
+ ui->view_FromOther->setEnabled(false);\r
+ ui->view_ToOther->setEnabled(false);\r
+ ui->cmd_Copy->setEnabled(false);\r
+ ui->cmd_Move->setEnabled(false);\r
+ }\r
+ }\r
+ else if (qobject_cast<SearchBox*>(w)) {\r
+ qDebug() << ">>>>> 検索モードのメニュー設定 <<<<<";\r
+ setEnabledAllActions(false);\r
+ ui->action_Search->setEnabled(true);\r
+ ui->action_SearchNext->setEnabled(true);\r
+ ui->action_SearchPrev->setEnabled(true);\r
+ ui->help_About->setEnabled(true);\r
+ }\r
+ else if (qobject_cast<SimpleImageView*>(w) ||\r
+ qobject_cast<SimpleTextView*>(w))\r
+ {\r
+ qDebug() << ">>>>> ビューアモードのメニュー設定 <<<<<";\r
+ setEnabledAllActions(false);\r
+ ui->action_Quit->setEnabled(true);\r
+ ui->action_Setting->setEnabled(true);\r
+ ui->check_Update->setEnabled(true);\r
+ ui->view_FontSizeDown->setEnabled(true);\r
+ ui->view_FontSizeUp->setEnabled(true);\r
+ ui->move_Begin->setEnabled(true);\r
+ ui->move_Down->setEnabled(true);\r
+ ui->move_End->setEnabled(true);\r
+ ui->move_Up->setEnabled(true);\r
+ ui->help_About->setEnabled(true);\r
+ ui->key_Left->setEnabled(true);\r
+ ui->key_Right->setEnabled(true);\r
+ if (m_viewMode & ModeHalfView) {\r
+ ui->view_HalfMode->setEnabled(true);\r
+ }\r
+ }\r
+}\r
+\r
+void MainWindow::setEnabledAllActions(bool enable)\r
+{\r
+ qDebug() << "MainWindow::setEnabledAllActions();" << enable;\r
+ foreach (QObject *obj, children()) {\r
+ QAction *action = qobject_cast<QAction*>(obj);\r
+ if (action) {\r
+ action->setEnabled(enable);\r
+ }\r
+ }\r
+}\r
+\r
+void MainWindow::about()\r
+{\r
+ qDebug() << ">>>>> about <<<<<";\r
+\r
+ QMessageBox::about(\r
+ this,\r
+ tr("げふぅ について"),\r
+ tr("<h3>Gefu Ver%1</h3>").arg(VERSION_VALUE) +\r
+ tr("<center>Gefu is an Experimental File Utility.<br/>"\r
+ "<small>(げふぅは実験的なファイルユーティリティです)</small></center>"\r
+ "<p>最新版の情報は<a href='https://sourceforge.jp/projects/gefu/'>プロジェクトサイト</a>で公開しています。</p>"\r
+ "<p><small>Copyright 2014 @miyabi_satoh All rights reserved.</small></p>"));\r
+}\r
+\r
+void MainWindow::closeEvent(QCloseEvent *event)\r
+{\r
+ qDebug() << "MainWindow::closeEvent();";\r
+ qDebug() << ">>>>> アプリケーションの終了要求 <<<<<";\r
+ QSettings settings;\r
+\r
+ if (settings.value(IniKey_ConfirmExit).toBool()) {\r
+ QMessageBox msgBox;\r
+ QCheckBox *checkBox = new QCheckBox();\r
+ checkBox->setText(tr("次回以降は確認しない"));\r
+ msgBox.setCheckBox(checkBox);\r
+ msgBox.setText(tr("終了しますか?"));\r
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);\r
+ msgBox.setIcon(QMessageBox::Question);\r
+\r
+ if (msgBox.exec() == QMessageBox::No) {\r
+ qDebug() << ">>>>> ユーザによりキャンセルされました <<<<<";\r
+ event->ignore();\r
+ return;\r
+ }\r
+ settings.setValue(IniKey_ConfirmExit, !checkBox->isChecked());\r
+ }\r
+\r
+ settings.setValue(QString("Left/") + IniKey_Dir, ui->pane1->folderPanel()->folderView()->dir());\r
+ settings.setValue(QString("Right/") + IniKey_Dir, ui->pane2->folderPanel()->folderView()->dir());\r
+ settings.setValue(IniKey_ShowHidden, ui->view_Hidden->isChecked());\r
+ settings.setValue(IniKey_ShowSystem, ui->view_System->isChecked());\r
+ settings.setValue(IniKey_WindowGeometry, saveGeometry());\r
+ settings.setValue(iniKey_WindowState, saveState());\r
+ QMainWindow::closeEvent(event);\r
+}\r
+\r
+\r
+void MainWindow::keyPressEvent(QKeyEvent *event)\r
+{\r
+\r
+ QString ksq = KeyEventToSequence(event);\r
+\r
+ qDebug() << ">>>>> キーイベントを受信(MainWindow)" << ksq << "<<<<<";\r
+ qDebug() << qApp->keyboardModifiers().testFlag(Qt::ShiftModifier);\r
+\r
+ if (ProcessShortcut(ksq, this)) {\r
+ event->accept();\r
+ return;\r
+ }\r
+\r
+ QMainWindow::keyPressEvent(event);\r
}\r