From cb33f51cb5589822ed22c0e39fb10e17ef3b8d6c Mon Sep 17 00:00:00 2001 From: Masayuki Satoh Date: Wed, 27 Aug 2014 16:45:10 +0900 Subject: [PATCH] Ver0.14 --- Gefu.pro | 15 +- README.md | 8 +- ReadMe.txt | 10 +- anyview.cpp | 118 +++++++++++++ anyview.h | 45 +++++ anyview.ui | 83 +++++++++ common.h | 4 +- folderpanel.cpp | 42 +++++ folderpanel.h | 36 ++++ folderpanel.ui | 117 +++++++++++++ folderview.cpp | 22 ++- folderview.h | 2 +- keybind.txt | 60 +++++++ main.cpp | 34 +++- mainwindow.cpp | 480 ++++++++++++++++++++++++++++++++--------------------- mainwindow.h | 5 +- mainwindow.ui | 352 +++++++-------------------------------- simpletextview.cpp | 53 +++--- version.h | 2 +- 19 files changed, 958 insertions(+), 530 deletions(-) create mode 100644 anyview.cpp create mode 100644 anyview.h create mode 100644 anyview.ui create mode 100644 folderpanel.cpp create mode 100644 folderpanel.h create mode 100644 folderpanel.ui create mode 100644 keybind.txt diff --git a/Gefu.pro b/Gefu.pro index 525b5d0..e57c1cb 100644 --- a/Gefu.pro +++ b/Gefu.pro @@ -35,7 +35,9 @@ SOURCES += main.cpp\ searchbox.cpp \ folderview.cpp \ locationbox.cpp \ - simpleimageview.cpp + simpleimageview.cpp \ + anyview.cpp \ + folderpanel.cpp HEADERS += mainwindow.h \ renamesingledialog.h \ @@ -59,7 +61,9 @@ HEADERS += mainwindow.h \ folderview.h \ locationbox.h \ version.h \ - simpleimageview.h + simpleimageview.h \ + anyview.h \ + folderpanel.h FORMS += mainwindow.ui \ renamesingledialog.ui \ @@ -68,7 +72,9 @@ FORMS += mainwindow.ui \ overwritedialog.ui \ sortdialog.ui \ historydialog.ui \ - preferencedialog.ui + preferencedialog.ui \ + anyview.ui \ + folderpanel.ui RESOURCES += \ resource.qrc @@ -76,7 +82,8 @@ RESOURCES += \ OTHER_FILES += \ Gefu.rc \ README.md \ - ReadMe.txt + ReadMe.txt \ + keybind.txt macx { ICON = ./images/Gefu.icns diff --git a/README.md b/README.md index 8ab6c8e..34e8375 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ Gefu is an Experimental File Utility. * 簡易FTPクライアント * SNS連携(タイムライン表示とか) ← ファイラーの機能か? +#### 2014/08/27 Ver0.14 + * テキストビューアで、左右矢印キーをPageUp/Downに割り当てた。 + * 「片面ビューアモード」を追加した。 + * 隣のペインがビューアモードになり、カーソル位置のアイテム内容を表示する。 + #### 2014/08/26 Ver0.13 公開 * 拡張子・サイズ・更新日時の列幅をフォントサイズに応じて調整するようにした。 * 「最新バージョンをチェック」を「アップデートの確認」に文言変更。 @@ -20,7 +25,8 @@ Gefu is an Experimental File Utility. * テキストビューアについても、メニューまたはキーボードで文字の大きさを変更できるようにした。 * テキストビューアについても、カーソル移動系アクションを有効にした。 * 不具合修正 - * 環境設定ダイアログで、「起動時のアップデート確認」の設定表示・変更ができていなかった。 + * 環境設定ダイアログで、「起動時のアップデート確認」の設定表示・変更ができていなかったのを修正。 + * アイテム移動時の確認・完了表示に関するオプションが無視されていたのを修正。 #### 2014/08/26 Ver0.12 公開 * コンテキストメニューを実装。 diff --git a/ReadMe.txt b/ReadMe.txt index 668fce6..f06cb2b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,8 +1,8 @@ =============================================================================== Gefu(げふぅ) - Gefu is an Experimental File Utility - - Version 0.13 + Version 0.14 =============================================================================== - 2014/08/26 @miyabi_satoh + 2014/08/27 @miyabi_satoh ◇ 概要 ◇ @@ -90,6 +90,12 @@ Twitter: https://twitter.com/miyabi_satoh ◇ 履歴 ◇ +#### 2014/08/27 Ver0.14 + * 外部アプリを優先する拡張子のデフォルトに「dmg」を追加。 + * テキストビューアで、左右矢印キーをPageUp/Downに割り当てた。 + * 「片面ビューアモード」を追加した。 + * 隣のペインがビューアモードになり、カーソル位置のアイテム内容を表示する。 + #### 2014/08/26 Ver0.13 * 拡張子・サイズ・更新日時の列幅をフォントサイズに応じて調整するようにした。 * 「最新バージョンをチェック」を「アップデートの確認」に文言変更。 diff --git a/anyview.cpp b/anyview.cpp new file mode 100644 index 0000000..0eff910 --- /dev/null +++ b/anyview.cpp @@ -0,0 +1,118 @@ +#include "common.h" +#include "folderview.h" +#include "anyview.h" +#include "ui_anyview.h" + +#include +#include + +AnyView::AnyView(QWidget *parent) : + QWidget(parent), + ui(new Ui::AnyView) +{ + ui->setupUi(this); + + // 初期状態では全て非表示 + ui->folderPanel->setVisible(false); + ui->graphicsView->setVisible(false); + ui->textView->setVisible(false); +} + +AnyView::~AnyView() +{ + delete ui; +} + +void AnyView::changeView(int viewType) +{ + qDebug() << "AnyView::changeView();" << viewType; + + // 一度すべてを非表示にする + ui->folderPanel->setVisible(false); + ui->graphicsView->setVisible(false); + ui->textView->setVisible(false); + + QWidget *w; + switch (viewType) { + case AnyView::ViewFolder: w = ui->folderPanel; break; + case AnyView::ViewImage: w = ui->graphicsView; break; + case AnyView::ViewText: w = ui->textView; break; + default: Q_ASSERT(false); w = NULL; break; + } + + this->setVisible(true); + w->setVisible(true); +} + +void AnyView::setViewItem(const QFileInfo &info) +{ + setUpdatesEnabled(false); + + if (info.isDir()) { + changeView(ViewFolder); + ui->folderPanel->folderView()->setPath(info.absoluteFilePath(), true); + } + else { + QSettings settings; + bool isBinary = false; + if (!settings.value(IniKey_ViewerForceOpen).toBool()) { + QStringList list = settings.value(IniKey_ViewerIgnoreExt).toString().split(","); + foreach (const QString &ext, list) { + if (ext.toLower() == info.suffix().toLower()) { + isBinary = true; + break; + } + } + } + + // TODO:画像ビューアで表示できるか? + + if (!isBinary) { + changeView(ViewText); + QFile file(info.absoluteFilePath()); + if (file.open(QIODevice::ReadOnly)) { + ui->textView->setSource(file.readAll()); + file.close(); + } + } + else { + changeView(ViewText); + ui->textView->setSource(""); + } + + } + + setUpdatesEnabled(true); +} + +FolderPanel *AnyView::folderPanel() const +{ + return ui->folderPanel; +} + +SimpleImageView *AnyView::imageView() const +{ + return ui->graphicsView; +} + +SimpleTextView *AnyView::textView() const +{ + return ui->textView; +} + + +void AnyView::focusInEvent(QFocusEvent *) +{ + qDebug() << "AnyView::focusInEvent();"; + + if (ui->folderPanel->isVisible()) { + ui->folderPanel->folderView()->setFocus(); + } + else if (ui->graphicsView->isVisible()) { + ui->graphicsView->setFocus(); + } + else { + Q_ASSERT(ui->textView->isVisible()); + ui->textView->setFocus(); + } +} diff --git a/anyview.h b/anyview.h new file mode 100644 index 0000000..da36753 --- /dev/null +++ b/anyview.h @@ -0,0 +1,45 @@ +#ifndef ANYVIEW_H +#define ANYVIEW_H + +#include +#include +class FolderPanel; +class SimpleTextView; +class SimpleImageView; + +namespace Ui { +class AnyView; +} + +class AnyView : public QWidget +{ + Q_OBJECT + +public: + enum { + ViewFolder = 1, + ViewText = 2, + ViewImage = 3, + }; + + explicit AnyView(QWidget *parent = 0); + ~AnyView(); + + // action + void changeView(int viewType); + void setViewItem(const QFileInfo &info); + + // getter + FolderPanel* folderPanel() const; + SimpleImageView* imageView() const; + SimpleTextView* textView() const; + +private: + Ui::AnyView *ui; + + // QWidget interface +protected: + void focusInEvent(QFocusEvent *); +}; + +#endif // ANYVIEW_H diff --git a/anyview.ui b/anyview.ui new file mode 100644 index 0000000..1def817 --- /dev/null +++ b/anyview.ui @@ -0,0 +1,83 @@ + + + AnyView + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + false + + + true + + + true + + + Simple Text View + + + + + + + + 0 + 0 + + + + + + + + + + + + SimpleTextView + QPlainTextEdit +
simpletextview.h
+
+ + SimpleImageView + QGraphicsView +
simpleimageview.h
+
+ + FolderPanel + QWidget +
folderpanel.h
+ 1 +
+
+ + +
diff --git a/common.h b/common.h index 1861f24..5bc1e0e 100644 --- a/common.h +++ b/common.h @@ -4,12 +4,14 @@ #include typedef QMap StringMap; -class MainWindow; +class QObject; class QKeyEvent; +class MainWindow; extern MainWindow* getMainWnd(); extern QString FilesizeToString(quint64 size); extern QString ViewerIgnoreExt(); extern QString KeyEventToSequence(const QKeyEvent *event); +extern bool ProcessShortcut(const QString &ksq, const QObject *object); #define slash QString("/") #define QQ(x) ("\"" + QString(x) + "\"") diff --git a/folderpanel.cpp b/folderpanel.cpp new file mode 100644 index 0000000..1420f80 --- /dev/null +++ b/folderpanel.cpp @@ -0,0 +1,42 @@ +#include "folderpanel.h" +#include "ui_folderpanel.h" + +FolderPanel::FolderPanel(QWidget *parent) : + QWidget(parent), + ui(new Ui::FolderPanel) +{ + ui->setupUi(this); + // 初期状態では検索ボックスは非表示 + ui->searchBox->setVisible(false); +} + +FolderPanel::~FolderPanel() +{ + delete ui; +} + +LocationBox *FolderPanel::locationBox() const +{ + return ui->locationBox; +} + +FolderView *FolderPanel::folderView() const +{ + return ui->folderView; +} + +SearchBox *FolderPanel::serachBox() const +{ + return ui->searchBox; +} + +QLabel *FolderPanel::filterLabel() const +{ + return ui->filterLabel; +} + + +void FolderPanel::focusInEvent(QFocusEvent *) +{ + ui->folderView->setFocus(); +} diff --git a/folderpanel.h b/folderpanel.h new file mode 100644 index 0000000..129fc60 --- /dev/null +++ b/folderpanel.h @@ -0,0 +1,36 @@ +#ifndef FOLDERPANEL_H +#define FOLDERPANEL_H + +#include +class QLabel; +class LocationBox; +class FolderView; +class SearchBox; + +namespace Ui { +class FolderPanel; +} + +class FolderPanel : public QWidget +{ + Q_OBJECT + +public: + explicit FolderPanel(QWidget *parent = 0); + ~FolderPanel(); + + // getter + LocationBox* locationBox() const; + FolderView* folderView() const; + SearchBox* serachBox() const; + QLabel* filterLabel() const; + +private: + Ui::FolderPanel *ui; + + // QWidget interface +protected: + void focusInEvent(QFocusEvent *); +}; + +#endif // FOLDERPANEL_H diff --git a/folderpanel.ui b/folderpanel.ui new file mode 100644 index 0000000..a3df706 --- /dev/null +++ b/folderpanel.ui @@ -0,0 +1,117 @@ + + + FolderPanel + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::ClickFocus + + + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + false + + + true + + + QAbstractItemView::DragDrop + + + Qt::CopyAction + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + Qt::ElideMiddle + + + false + + + false + + + false + + + false + + + + + + + Qt::ClickFocus + + + + + + + TextLabel + + + + + + + + SearchBox + QLineEdit +
searchbox.h
+
+ + FolderView + QTableView +
folderview.h
+
+ + LocationBox + QLineEdit +
locationbox.h
+
+
+ + +
diff --git a/folderview.cpp b/folderview.cpp index 3e9c41e..7282776 100644 --- a/folderview.cpp +++ b/folderview.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include "mainwindow.h" #include "folderview.h" #include @@ -347,14 +348,21 @@ void FolderView::keyPressEvent(QKeyEvent *event) { qDebug() << side() << "keyPressEvent"; - emit keyPressed(event); - - if (!event->isAccepted()) { - QTableView::keyPressEvent(event); - } - else { - qDebug() << "KeyEvent accepted."; +// emit keyPressed(event); + +// if (!event->isAccepted()) { +// QTableView::keyPressEvent(event); +// } +// else { +// qDebug() << "KeyEvent accepted."; +// } + QString ksq = KeyEventToSequence(event); + if (ProcessShortcut(ksq, getMainWnd())) { + event->accept(); + return; } + + QTableView::keyPressEvent(event); } void FolderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) diff --git a/folderview.h b/folderview.h index 201efb7..e25e503 100644 --- a/folderview.h +++ b/folderview.h @@ -62,7 +62,7 @@ signals: void retrieveStarted(const QString &path); void retrieveFinished(); void requestContextMenu(QContextMenuEvent *event); - void keyPressed(QKeyEvent *event); +// void keyPressed(QKeyEvent *event); public slots: diff --git a/keybind.txt b/keybind.txt new file mode 100644 index 0000000..99bde58 --- /dev/null +++ b/keybind.txt @@ -0,0 +1,60 @@ +== キーバインド一覧 += フォルダビュー +||キー ||装飾なし ||Shift ||Alt ||Ctrl(Command) ||覚え方 || +||A ||すべてのファイルをマーク ||すべてマーク || || ||All || +||C ||ファイル名をクリップボードにコピー ||フルパスをクリップボードにコピー || ||隣のペインにアイテムをコピー ||Copy || +||D || || || ||選択アイテムを削除 ||Delete || +||E ||外部エディタで開く || || ||ファイルを作成 ||Edit, newの「E」 || +||G ||カーソルを先頭に移動 ||カーソルを末尾に移動 || || ||Go || +||H ||ホームフォルダに移動 ||隠しファイルを表示/非表示 || || ||Home, Hide || +||I ||マークを反転 || || || ||Invert || +||J ||カーソルを下に移動 ||フォルダを選択して移動 || || ||viのキーバインド, Jump || +||K ||カーソルを上に移動 || || ||フォルダを作成 ||viのキーバインド, mkdirの「K」 || +||L ||最新の情報に更新 || || || ||Load || +||M ||開く ||アプリケーションで開く || ||隣のペインにアイテムを移動 ||viのキーバインド, Move || +||O ||隣のパネルと同じフォルダを表示 ||隣のパネルに同じフォルダを表示 || || ||Onaji(同じ) || +||Q ||終了 || || || ||Quit || +||R ||履歴を表示 || || ||名前の変更 ||Rireki, Rename || +||S ||ソート方法を選択 ||システムファイルを表示/非表示 || || ||Sort, System || +||U ||すべてのマークを解除 || || || ||Unmark || +||W ||表示フォルダを交換 || || || ||swapの「W」 || +||X ||コマンドを実行 || || || ||executeの「X」 || +||Z ||環境設定 ||アップデートを確認 || || || || +||TAB ||隣のパネルに移動 || || || || || +||SPACE ||マーク/解除 || || || || || +||ENTER ||フォルダを開く/内蔵ビューアで開く ||アプリケーションで開く || || || || +||BACKSPACE ||親フォルダに移動 ||ルートフォルダに移動 || || || || +||[ ||履歴を戻る || || || || || +||] ||履歴を進む || || || || || +||? ||げふぅ について || || || || || +||> ||ターミナルで開く || || || || || +||* ||フィルタを設定 || || || ||ワイルドカード(*) || +||/ ||ファイル検索開始/終了 || || || || || +||+ ||フォントサイズを大きく || || || || || +||- ||フォントサイズを小さく || || || || || +||↑ ||カーソルを上に移動 ||隣ペインのカーソルを上に移動 ||隣ペインのカーソルを先頭に移動 || +||↓ ||カーソルを下に移動 ||隣ペインのカーソルを下に移動 ||隣ペインのカーソルを末尾に移動 || +||← ||親フォルダに移動/隣のペインに移動 || +||→ ||親フォルダに移動/隣のペインに移動 || += テキストビュー +||キー ||装飾なし ||Shift ||Alt ||Ctrl(Command) ||覚え方 || +||C ||ファイル名をクリップボードにコピー ||フルパスをクリップボードにコピー || ||選択範囲をクリップボードにコピー ||Copy || +||E || ||EUC-JPで再読込 || || ||EUC-JP || +||G ||カーソルを先頭に移動 ||カーソルを末尾に移動 || || ||Go || +||I || ||UTF-16で再読込 || || ||U(UTF-8)の隣のキー || +||J ||カーソルを下に移動 ||ISO-2022-JPで再読込 || || ||JIS || +||K ||カーソルを上に移動 || || || ||viのキーバインド || +||O || ||UTF-16BEで再読込 || || ||I(UTF-16)の隣のキー || +||P || ||UTF-16LEで再読込 || || ||O(UTF-16BE)の隣のキー || +||Q ||終了 || || || ||Quit || +||S || ||Shift-JISで再読込 || || ||SJIS || +||U || ||UTF-8で再読込 || || ||UTF-8 || +||Z ||環境設定 ||アップデートを確認 || || || || +||ENTER ||フォルダビューに戻る || || || || || +||BACKSPACE ||フォルダビューに戻る || || || || || +||+ ||フォントサイズを大きく || || || || || +||- ||フォントサイズを小さく || || || || || +||↑ ||カーソルを上に移動 ||隣ペインのカーソルを上に移動 ||隣ペインのカーソルを先頭に移動 || +||↓ ||カーソルを下に移動 ||隣ペインのカーソルを下に移動 ||隣ペインのカーソルを末尾に移動 || +||← ||PageUp || +||→ ||PageDown || diff --git a/main.cpp b/main.cpp index 1465830..af7b1f4 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,41 @@ #include "common.h" #include "mainwindow.h" +#include #include #include #include +#include + +bool ProcessShortcut(const QString &ksq, const QObject *object) +{ + qDebug() << "ProcessShortcut()"; + + if (ksq.isEmpty()) { + return false; + } + + foreach (QObject *obj, object->children()) { + QAction *action = qobject_cast(obj); + if (!action || !action->isEnabled()) { + continue; + } + + foreach (const QKeySequence &k, action->shortcuts()) { + if (ksq == k.toString()) { + if (action->isCheckable()) { + action->setChecked(!action->isChecked()); + } + else { + emit action->triggered(); + } + qDebug() << "emit" << action->objectName(); + return true; + } + } + } + return false; +} int main(int argc, char *argv[]) { @@ -157,7 +189,7 @@ QString ViewerIgnoreExt() list << "o" << "obj" << "ocx" << "a" << "so" << "app"; // アーカイブ系 list << "lzh" << "zip" << "cab" << "tar" << "rar" << "gz" << "tgz"; - list << "bz2" << "xz" << "jar" << "7z"; + list << "bz2" << "xz" << "jar" << "7z" << "dmg"; // ドキュメント系 list << "pdf" << "doc" << "docx" << "xls" << "xlsx" << "ppt" << "pptx"; // フォント diff --git a/mainwindow.cpp b/mainwindow.cpp index 7bcbef7..3ab7d30 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -15,6 +15,7 @@ #include "renamemultidialog.h" #include "historydialog.h" #include "sortdialog.h" +#include "simpletextview.h" #include #include @@ -29,6 +30,7 @@ #include #include #include +#include MainWindow* getMainWnd() { @@ -53,21 +55,29 @@ MainWindow::MainWindow(QWidget *parent) : initActionConnections(); connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(focusChange(QWidget*,QWidget*))); - connect(ui->textView, SIGNAL(viewFinished(QWidget*)), this, SLOT(viewFinish(QWidget*))); + connect(ui->pane3->textView(), SIGNAL(viewFinished(QWidget*)), this, SLOT(viewFinish(QWidget*))); // ビューアは初期状態で非表示 - ui->textView->setVisible(false); - ui->graphicsView->setVisible(false); + ui->pane3->setVisible(false); for (int i = 1; i <= 2; i++) { - LocationBox *locationBox = findChild(QString("locationBox%1").arg(i)); - Q_CHECK_PTR(locationBox); + AnyView *anyView = findChild(QString("pane%1").arg(i)); + Q_CHECK_PTR(anyView); - FolderView *folderView = findChild(QString("folderView%1").arg(i)); - Q_CHECK_PTR(folderView); + FolderPanel *fp = anyView->findChild("folderPanel"); + Q_CHECK_PTR(fp); + fp->setObjectName(QString("folderPanel%1").arg(i)); - SearchBox *searchBox = findChild(QString("searchBox%1").arg(i)); - Q_CHECK_PTR(searchBox); + LocationBox *locationBox = fp->locationBox(); + FolderView *folderView = fp->folderView(); + SearchBox *searchBox = fp->serachBox(); + + if (i == 1) { + folderView->setObjectName("folderView1"); + } + else { + folderView->setObjectName("folderView2"); + } // シグナル&スロット connect(folderView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(open(QModelIndex))); @@ -76,7 +86,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(folderView, SIGNAL(currentChanged(QFileInfo)), this, SLOT(currentChange(QFileInfo))); connect(folderView, SIGNAL(itemFound()), this, SLOT(itemFound())); connect(folderView, SIGNAL(itemNotFound()), this, SLOT(itemNotFound())); - connect(folderView, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(keyPress(QKeyEvent*))); +// connect(folderView, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(keyPress(QKeyEvent*))); connect(folderView, SIGNAL(retrieveFinished()), this, SLOT(retrieveFinish())); connect(folderView, SIGNAL(retrieveStarted(QString)), this, SLOT(retrieveStart(QString))); connect(folderView, SIGNAL(requestContextMenu(QContextMenuEvent*)), this, SLOT(showContextMenu(QContextMenuEvent*))); @@ -190,8 +200,11 @@ MainWindow::MainWindow(QWidget *parent) : checkUpdate(true); } - ui->folderView1->refresh(); - ui->folderView2->refresh(); + ui->pane2->changeView(AnyView::ViewFolder); + ui->pane2->folderPanel()->folderView()->repaint(); + + ui->pane1->changeView(AnyView::ViewFolder); + ui->pane1->folderPanel()->folderView()->repaint(); } MainWindow::~MainWindow() @@ -203,24 +216,33 @@ FolderView* MainWindow::otherSideView(const FolderView *view) const { qDebug() << "MainWindow::otherSideView()" << view->objectName(); - if (view == ui->folderView1) { - return ui->folderView2; + if (view == ui->pane1->folderPanel()->folderView()) { + return ui->pane2->folderPanel()->folderView(); } - Q_ASSERT(view == ui->folderView2); - return ui->folderView1; + Q_ASSERT(view == ui->pane2->folderPanel()->folderView()); + return ui->pane1->folderPanel()->folderView(); } void MainWindow::focusChange(QWidget *old, QWidget *now) { Q_UNUSED(old); qDebug() << "MainWindow::focusChange"; + if (now != NULL) { + qDebug() << "Now Focus" << now->objectName(); + } - if (now == ui->folderView1 || now == ui->folderView2) { + if (now && + (now == ui->pane1->folderPanel()->folderView() || + now == ui->pane2->folderPanel()->folderView())) + { ui->statusBar->showMessage(folderView()->currentItem().absoluteFilePath()); } - if (old == ui->searchBox1 || old == ui->searchBox2) { + if (old && + (old == ui->pane1->folderPanel()->serachBox() || + old == ui->pane2->folderPanel()->serachBox())) + { old->setVisible(false); } @@ -379,56 +401,60 @@ void MainWindow::moveItems() settings.setValue(IniKey_AutoCloseMove, opDlg.autoClose()); // 念のため、リフレッシュ - ui->folderView1->refresh(); - ui->folderView2->refresh(); +// ui->folderView1->refresh(); +// ui->folderView2->refresh(); } -void MainWindow::keyPress(QKeyEvent *event) -{ - QString ksq = KeyEventToSequence(event); - if (ksq == "") { - event->ignore(); - return; - } +//void MainWindow::keyPress(QKeyEvent *event) +//{ +// QString ksq = KeyEventToSequence(event); +// if (ksq == "") { +// event->ignore(); +// return; +// } - qDebug() << "MainWindow::keyPress" << ksq; +// qDebug() << "MainWindow::keyPress" << ksq; - foreach (QObject *obj, children()) { - QAction *action = qobject_cast(obj); - if (!action) { - continue; - } +// if (ProcessShortcut(ksq, this)) { +// event->accept(); +// return; +// } - foreach (const QKeySequence &k, action->shortcuts()) { - if (ksq == k.toString()) { - if (action->isEnabled()) { - if (action->isCheckable()) { - action->setChecked(!action->isChecked()); - } - else { - emit action->triggered(); - } - qDebug() << "emit" << action->objectName(); - } - event->accept(); - return; - } - } - } +// event->ignore(); +//} - if (ksq == "Left" || ksq == "Right") { - FolderView *view = static_cast(sender()); - if (view->side() == ksq) { - setPathToParent(); - } - else { - otherSideView(view)->setFocus(); - } - event->accept(); - return; +void MainWindow::leftKeyPress() +{ + qDebug() << "MainWindow::leftKeyPress();"; + + if (ui->pane3->textView()->hasFocus()) { + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageUp, Qt::NoModifier); + QApplication::sendEvent(ui->pane3->textView(), &event); + } + else if (ui->pane1->folderPanel()->folderView()->hasFocus()) { + setPathToParent(); } + else if (ui->pane2->folderPanel()->folderView()->hasFocus()) { +// ui->folderView1->setFocus(); + ui->pane1->setFocus(); + } +} + +void MainWindow::rightKeyPress() +{ + qDebug() << "MainWindow::rightKeyPress();"; - event->ignore(); + if (ui->pane3->textView()->hasFocus()) { + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageDown, Qt::NoModifier); + QApplication::sendEvent(ui->pane3->textView(), &event); + } + else if (ui->pane1->folderPanel()->folderView()->hasFocus()) { + // ui->folderView2->setFocus(); + ui->pane2->setFocus(); + } + else if (ui->pane2->folderPanel()->folderView()->hasFocus()) { + setPathToParent(); + } } void MainWindow::returnPressInSearchBox() @@ -521,6 +547,21 @@ void MainWindow::currentChange(const QFileInfo &info) } } + if (ui->view_HalfMode->isChecked()) { + FolderView *view = static_cast(sender()); + if (!view->hasFocus()) { + return; + } + + if (ui->pane1->folderPanel()->folderView()->hasFocus()) { + ui->pane2->setViewItem(folderView()->currentItem()); + } + else { + Q_ASSERT(ui->pane2->folderPanel()->folderView()->hasFocus()); + ui->pane1->setViewItem(folderView()->currentItem()); + } + updateActions(); + } } void MainWindow::dataChange() @@ -600,8 +641,8 @@ void MainWindow::copyItems(const QFileInfoList &list, const QString &tgtDir) settings.setValue(IniKey_AutoCloseCopy, opDlg.autoClose()); // 念のため、リフレッシュ - ui->folderView1->refresh(); - ui->folderView2->refresh(); +// ui->folderView1->refresh(); +// ui->folderView2->refresh(); } void MainWindow::copyItems() @@ -750,8 +791,8 @@ void MainWindow::deleteItems() settings.setValue(IniKey_AutoCloseDelete, opDlg.autoClose()); // 念のため、リフレッシュ - ui->folderView1->refresh(); - ui->folderView2->refresh(); +// ui->folderView1->refresh(); +// ui->folderView2->refresh(); } void MainWindow::open(const QModelIndex &index) @@ -780,8 +821,6 @@ void MainWindow::open(const QModelIndex &index) } } - setUpdatesEnabled(false); - foreach (QObject *obj, this->children()) { QAction *action = qobject_cast(obj); if (action) { @@ -799,16 +838,8 @@ void MainWindow::open(const QModelIndex &index) } m_focusedView = folderView(); + ui->pane3->setViewItem(info); ui->splitter->setVisible(false); - ui->textView->setVisible(true); - ui->textView->setFocus(); - - setUpdatesEnabled(true); - - QFile file(info.absoluteFilePath()); - if (file.open(QIODevice::ReadOnly)) { - ui->textView->setSource(file.readAll()); - } } void MainWindow::openEditor(const QString &path) @@ -948,12 +979,12 @@ void MainWindow::retrieveStart(const QString &path) qDebug() << "MainWindow::retrieveStart();" << path; ui->statusBar->showMessage(tr("ファイルリストを取得しています...")); - if (sender() == ui->folderView1) { - ui->locationBox1->setText(path); + if (sender() == ui->pane1->folderPanel()->folderView()) { + ui->pane1->folderPanel()->locationBox()->setText(path); } else { - Q_ASSERT(sender() == ui->folderView2); - ui->locationBox2->setText(path); + Q_ASSERT(sender() == ui->pane2->folderPanel()->folderView()); + ui->pane2->folderPanel()->locationBox()->setText(path); } } @@ -1035,15 +1066,54 @@ void MainWindow::swapView() { qDebug() << "MainWindow::swapView();"; - QString dir1 = ui->folderView1->dir(); - QString dir2 = ui->folderView2->dir(); + QString dir1 = ui->pane1->folderPanel()->folderView()->dir(); + QString dir2 = ui->pane2->folderPanel()->folderView()->dir(); - ui->folderView1->setPath(dir2, true); - ui->folderView2->setPath(dir1, true); + ui->pane1->folderPanel()->folderView()->setPath(dir2, true); + ui->pane2->folderPanel()->folderView()->setPath(dir1, true); updateActions(); } +void MainWindow::switchHalfMode(bool checked) +{ + qDebug() << "MainWindow::switchHalfMode();" << checked; + + FolderView *view; + if (checked) { + view = ui->pane1->folderPanel()->folderView(); + if (view->hasFocus()) { + ui->pane2->setViewItem(view->currentItem()); + updateActions(); +// view->setFocus(); + return; + } + + view = ui->pane2->folderPanel()->folderView(); + if (view->hasFocus()) { + ui->pane1->setViewItem(view->currentItem()); + updateActions(); +// view->setFocus(); + return; + } + } + else { + view = ui->pane1->folderPanel()->folderView(); + if (view->isVisible()) { + ui->pane2->changeView(AnyView::ViewFolder); + updateActions(); + return; + } + + view = ui->pane2->folderPanel()->folderView(); + if (view->isVisible()) { + ui->pane1->changeView(AnyView::ViewFolder); + updateActions(); + return; + } + } +} + void MainWindow::setSorting(FolderView *view) { qDebug() << "MainWindow::setSorting();" << view->objectName(); @@ -1090,14 +1160,14 @@ void MainWindow::searchItem(const QString &text) FolderView *v; SearchBox *box; - if (ui->searchBox1->hasFocus()) { - v = ui->folderView1; - box = ui->searchBox1; + if (ui->pane1->folderPanel()->serachBox()->hasFocus()) { + v = ui->pane1->folderPanel()->folderView(); + box = ui->pane1->folderPanel()->serachBox(); } else { - Q_ASSERT(ui->searchBox2->hasFocus()); - v = ui->folderView2; - box = ui->searchBox2; + Q_ASSERT(ui->pane2->folderPanel()->serachBox()->hasFocus()); + v = ui->pane2->folderPanel()->folderView(); + box = ui->pane2->folderPanel()->serachBox(); } if (text.right(1) == "/") { @@ -1131,68 +1201,79 @@ void MainWindow::setCursorToBegin() { qDebug() << "MainWindow::setCursorToBegin();"; - if (ui->textView->hasFocus()) { - QTextCursor cursor = ui->textView->textCursor(); - cursor.movePosition(QTextCursor::Start); - ui->textView->setTextCursor(cursor); - } - else { - FolderView *v = folderView(); - int row = 0; - v->setCurrentIndex(v->model()->index(row, 0)); - } + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::ControlModifier); + QApplication::sendEvent(QApplication::focusWidget(), &event); +// if (ui->textView->hasFocus()) { +// QTextCursor cursor = ui->textView->textCursor(); +// cursor.movePosition(QTextCursor::Start); +// ui->textView->setTextCursor(cursor); +// } +// else { +// FolderView *v = folderView(); +// int row = 0; +// v->setCurrentIndex(v->model()->index(row, 0)); +// } } void MainWindow::cursorDown() { qDebug() << "MainWindow::cursorDown();"; - if (ui->textView->hasFocus()) { - QTextCursor cursor = ui->textView->textCursor(); - cursor.movePosition(QTextCursor::Down); - ui->textView->setTextCursor(cursor); - } - else { - FolderView *v = folderView(); - int row = v->currentIndex().row() + 1; - if (row < v->model()->rowCount()) { - v->setCurrentIndex(v->model()->index(row, 0)); - } - } + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::DownArrow, Qt::NoModifier); + QApplication::sendEvent(QApplication::focusWidget(), &event); + +// if (ui->textView->hasFocus()) { +// QTextCursor cursor = ui->textView->textCursor(); +// cursor.movePosition(QTextCursor::Down); +// ui->textView->setTextCursor(cursor); +// } +// else { +// FolderView *v = folderView(); +// int row = v->currentIndex().row() + 1; +// if (row < v->model()->rowCount()) { +// v->setCurrentIndex(v->model()->index(row, 0)); +// } +// } } void MainWindow::cursorUp() { qDebug() << "MainWindow::cursorUp();"; - if (ui->textView->hasFocus()) { - QTextCursor cursor = ui->textView->textCursor(); - cursor.movePosition(QTextCursor::Up); - ui->textView->setTextCursor(cursor); - } - else { - FolderView *v = folderView(); - int row = v->currentIndex().row() - 1; - if (row >= 0) { - v->setCurrentIndex(v->model()->index(row, 0)); - } - } + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); + QApplication::sendEvent(QApplication::focusWidget(), &event); + +// if (ui->textView->hasFocus()) { +// QTextCursor cursor = ui->textView->textCursor(); +// cursor.movePosition(QTextCursor::Up); +// ui->textView->setTextCursor(cursor); +// } +// else { +// FolderView *v = folderView(); +// int row = v->currentIndex().row() - 1; +// if (row >= 0) { +// v->setCurrentIndex(v->model()->index(row, 0)); +// } +// } } void MainWindow::setCursorToEnd() { qDebug() << "MainWindow::setCursorToEnd();"; - if (ui->textView->hasFocus()) { - QTextCursor cursor = ui->textView->textCursor(); - cursor.movePosition(QTextCursor::End); - ui->textView->setTextCursor(cursor); - } - else { - FolderView *v = folderView(); - int row = v->model()->rowCount() - 1; - v->setCurrentIndex(v->model()->index(row, 0)); - } + QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier); + QApplication::sendEvent(QApplication::focusWidget(), &event); + +// if (ui->textView->hasFocus()) { +// QTextCursor cursor = ui->textView->textCursor(); +// cursor.movePosition(QTextCursor::End); +// ui->textView->setTextCursor(cursor); +// } +// else { +// FolderView *v = folderView(); +// int row = v->model()->rowCount() - 1; +// v->setCurrentIndex(v->model()->index(row, 0)); +// } } void MainWindow::setFontSizeDown() @@ -1212,20 +1293,22 @@ void MainWindow::changeFontSize(int diff) { QSettings settings; QFont font; - if (ui->folderView1->hasFocus() || ui->folderView2->hasFocus()) { + if (ui->pane1->folderPanel()->folderView()->hasFocus() || + ui->pane2->folderPanel()->folderView()->hasFocus()) + { font = settings.value(IniKey_ViewFont).value(); font.setPointSize(font.pointSize() + diff); settings.setValue(IniKey_ViewFont, font); - ui->folderView1->updateAppearance(); - ui->folderView2->updateAppearance(); + ui->pane1->folderPanel()->folderView()->updateAppearance(); + ui->pane2->folderPanel()->folderView()->updateAppearance(); } - if (ui->textView->hasFocus()) { + if (ui->pane3->textView()->hasFocus()) { font = settings.value(IniKey_ViewerFont).value(); font.setPointSize(font.pointSize() + diff); settings.setValue(IniKey_ViewerFont, font); - ui->textView->updateAppearance(); + ui->pane3->textView()->updateAppearance(); } } @@ -1288,12 +1371,12 @@ void MainWindow::toggleSearchBox(bool checked) if (checked) { v = folderView(); - if (v == ui->folderView1) { - box = ui->searchBox1; + if (v == ui->pane1->folderPanel()->folderView()) { + box = ui->pane1->folderPanel()->serachBox(); } else { - Q_ASSERT(v == ui->folderView2); - box = ui->searchBox2; + Q_ASSERT(v == ui->pane2->folderPanel()->folderView()); + box = ui->pane2->folderPanel()->serachBox(); } box->setVisible(true); @@ -1301,14 +1384,14 @@ void MainWindow::toggleSearchBox(bool checked) box->selectAll(); } else { - if (ui->searchBox1->isVisible()) { - box = ui->searchBox1; - v = ui->folderView1; + if (ui->pane1->folderPanel()->serachBox()->isVisible()) { + box = ui->pane1->folderPanel()->serachBox(); + v = ui->pane1->folderPanel()->folderView(); } else { - Q_ASSERT(ui->searchBox2->isVisible()); - box = ui->searchBox2; - v = ui->folderView2; + Q_ASSERT(ui->pane2->folderPanel()->serachBox()->isVisible()); + box = ui->pane2->folderPanel()->serachBox(); + v = ui->pane2->folderPanel()->folderView(); } if (box->hasFocus()) { @@ -1325,9 +1408,10 @@ void MainWindow::openRequest(const QFileInfo &info) QFile file(info.absoluteFilePath()); if (file.open(QIODevice::ReadOnly)) { ui->splitter->setVisible(false); - ui->textView->setVisible(true); - ui->textView->setFocus(); - ui->textView->setSource(file.readAll()); +// ui->textView->setVisible(true); +// ui->textView->setFocus(); +// ui->textView->setSource(file.readAll()); + file.close(); } else { QMessageBox::critical( @@ -1342,11 +1426,13 @@ void MainWindow::showPreferenceDialog() PreferenceDialog dlg(this); if (dlg.exec() == QDialog::Accepted) { - ui->locationBox1->updateAppearance(); - ui->locationBox2->updateAppearance(); - ui->folderView1->updateAppearance(); - ui->folderView2->updateAppearance(); - ui->textView->updateAppearance(); + ui->pane1->folderPanel()->locationBox()->updateAppearance(); + ui->pane2->folderPanel()->locationBox()->updateAppearance(); + ui->pane1->folderPanel()->folderView()->updateAppearance(); + ui->pane2->folderPanel()->folderView()->updateAppearance(); + ui->pane1->textView()->updateAppearance(); + ui->pane2->textView()->updateAppearance(); + ui->pane3->textView()->updateAppearance(); updateActions(); } @@ -1356,22 +1442,22 @@ void MainWindow::toggleShowHiddenFiles(bool checked) { qDebug() << "MainWindow::toggleShowHiddenFiles" << checked; - ui->folderView1->setFilter(QDir::Hidden, checked); - ui->folderView1->refresh(); + ui->pane1->folderPanel()->folderView()->setFilter(QDir::Hidden, checked); + ui->pane1->folderPanel()->folderView()->refresh(); - ui->folderView2->setFilter(QDir::Hidden, checked); - ui->folderView2->refresh(); + ui->pane2->folderPanel()->folderView()->setFilter(QDir::Hidden, checked); + ui->pane2->folderPanel()->folderView()->refresh(); } void MainWindow::toggleShowSystemFiles(bool checked) { qDebug() << "MainWindow::toggleShowSystemFiles" << checked; - ui->folderView1->setFilter(QDir::System, checked); - ui->folderView1->refresh(); + ui->pane1->folderPanel()->folderView()->setFilter(QDir::System, checked); + ui->pane1->folderPanel()->folderView()->refresh(); - ui->folderView2->setFilter(QDir::System, checked); - ui->folderView2->refresh(); + ui->pane2->folderPanel()->folderView()->setFilter(QDir::System, checked); + ui->pane2->folderPanel()->folderView()->refresh(); } void MainWindow::showContextMenu(QContextMenuEvent *event) @@ -1465,7 +1551,8 @@ void MainWindow::viewFinish(QWidget *sender) { qDebug() << "MainWindow::viewFinish();" << sender->objectName(); - sender->setVisible(false); +// sender->setVisible(false); + ui->pane3->setVisible(false); ui->splitter->setVisible(true); m_focusedView->setFocus(); } @@ -1475,6 +1562,9 @@ void MainWindow::initActionConnections() { qDebug() << "MainWindow::initActionConnections"; + connect(ui->key_Left, SIGNAL(triggered()), this, SLOT(leftKeyPress())); + connect(ui->key_Right, SIGNAL(triggered()), this, SLOT(rightKeyPress())); + connect(ui->action_Command, SIGNAL(triggered()), this, SLOT(executeCommand())); connect(ui->action_Exec, SIGNAL(triggered()), this, SLOT(shellExecute())); connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(open())); @@ -1515,6 +1605,7 @@ void MainWindow::initActionConnections() connect(ui->view_FontSizeDown, SIGNAL(triggered()), this, SLOT(setFontSizeDown())); connect(ui->view_FontSizeUp, SIGNAL(triggered()), this, SLOT(setFontSizeUp())); connect(ui->view_FromOther, SIGNAL(triggered()), this, SLOT(setPathFromOther())); + connect(ui->view_HalfMode, SIGNAL(toggled(bool)), this, SLOT(switchHalfMode(bool))); connect(ui->view_Hidden, SIGNAL(toggled(bool)), this, SLOT(toggleShowHiddenFiles(bool))); connect(ui->view_Refresh, SIGNAL(triggered()), this, SLOT(refresh())); connect(ui->view_Sort, SIGNAL(triggered()), this, SLOT(showSortDialog())); @@ -1528,11 +1619,18 @@ FolderView *MainWindow::folderView() const qDebug() << "MainWindow::folderView"; QWidget *w = qApp->focusWidget(); - if (w == ui->folderView1 || w == ui->searchBox1 || w == ui->locationBox1) { - return ui->folderView1; + if (w == ui->pane1->folderPanel()->folderView() || + w == ui->pane1->folderPanel()->serachBox() || + w == ui->pane1->folderPanel()->locationBox()) + { + return ui->pane1->folderPanel()->folderView(); } - if (w == ui->folderView2 || w == ui->searchBox2 || w == ui->locationBox2) { - return ui->folderView2; + + if (w == ui->pane2->folderPanel()->folderView() || + w == ui->pane2->folderPanel()->serachBox() || + w == ui->pane2->folderPanel()->locationBox()) + { + return ui->pane2->folderPanel()->folderView(); } qDebug() << w->objectName(); @@ -1559,12 +1657,12 @@ SearchBox *MainWindow::searchBox(FolderView *view) const { qDebug() << "MainWindow::searchBox()" << view->objectName(); - if (view == ui->folderView1) { - return ui->searchBox1; + if (view == ui->pane1->folderPanel()->folderView()) { + return ui->pane1->folderPanel()->serachBox(); } else { - Q_ASSERT(view == ui->folderView2); - return ui->searchBox2; + Q_ASSERT(view == ui->pane1->folderPanel()->folderView()); + return ui->pane2->folderPanel()->serachBox(); } } @@ -1585,7 +1683,11 @@ void MainWindow::updateActions() { qDebug() << "MainWindow::updateActions"; - if (ui->textView->hasFocus()) { + QWidget *w = QApplication::focusWidget(); + if (qobject_cast(w) != NULL || + ui->pane1->textView()->isVisible() || + ui->pane2->textView()->isVisible()) + { // テキストビューア時 setEnabledAllActions(false); ui->action_Quit->setEnabled(true); @@ -1597,20 +1699,25 @@ void MainWindow::updateActions() ui->move_Down->setEnabled(true); ui->move_End->setEnabled(true); ui->move_Up->setEnabled(true); - ui->copy_Filename->setEnabled(true); - ui->copy_Fullpath->setEnabled(true); ui->help_About->setEnabled(true); + ui->key_Left->setEnabled(true); + ui->key_Right->setEnabled(true); + // 片面ビューアモード時 + if (ui->pane1->textView()->isVisible() || + ui->pane2->textView()->isVisible()) + { + ui->view_HalfMode->setEnabled(true); + } } - else if (ui->searchBox1->hasFocus() || ui->searchBox2->hasFocus()) { + else if (qobject_cast(w) != NULL) { // ファイル検索時 setEnabledAllActions(false); ui->action_Search->setEnabled(true); ui->action_SearchNext->setEnabled(true); ui->action_SearchPrev->setEnabled(true); ui->help_About->setEnabled(true); - ui->action_Quit->setEnabled(true); } - else if (ui->folderView1->hasFocus() || ui->folderView2->hasFocus()) { + else if (qobject_cast(w) != NULL) { // 通常時 setEnabledAllActions(true); ui->action_SearchNext->setEnabled(false); @@ -1623,6 +1730,9 @@ void MainWindow::updateActions() ui->action_OpenEditor->setEnabled(!settings.value(IniKey_EditorPath).toString().isEmpty()); ui->action_OpenTerminal->setEnabled(!settings.value(IniKey_TerminalPath).toString().isEmpty()); } + else if (w){ + qDebug() << w->objectName() << "has focus."; + } } void MainWindow::setEnabledAllActions(bool enable) @@ -1651,12 +1761,12 @@ void MainWindow::setNameFilters(FolderView *view, const QString &filters) QLabel *MainWindow::filterLabel(const FolderView *view) const { qDebug() << "MainWindow::filterLabel()" << view->objectName(); - if (view == ui->folderView1) { - return ui->filterLabel1; + if (view == ui->pane1->folderPanel()->folderView()) { + return ui->pane1->folderPanel()->filterLabel(); } else { - Q_ASSERT(view == ui->folderView2); - return ui->filterLabel2; + Q_ASSERT(view == ui->pane2->folderPanel()->folderView()); + return ui->pane2->folderPanel()->filterLabel(); } } @@ -1692,8 +1802,8 @@ void MainWindow::closeEvent(QCloseEvent *event) settings.setValue(IniKey_ConfirmExit, !checkBox->isChecked()); } - settings.setValue(QString("Left/") + IniKey_Dir, ui->folderView1->dir()); - settings.setValue(QString("Right/") + IniKey_Dir, ui->folderView2->dir()); + settings.setValue(QString("Left/") + IniKey_Dir, ui->pane1->folderPanel()->folderView()->dir()); + settings.setValue(QString("Right/") + IniKey_Dir, ui->pane2->folderPanel()->folderView()->dir()); settings.setValue(IniKey_ShowHidden, ui->view_Hidden->isChecked()); settings.setValue(IniKey_ShowSystem, ui->view_System->isChecked()); settings.setValue(IniKey_WindowGeometry, saveGeometry()); diff --git a/mainwindow.h b/mainwindow.h index 6e5613e..7bbbef8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -39,7 +39,9 @@ public slots: void dataChange(); void dropAccept(const QFileInfoList &list); void focusChange(QWidget * old, QWidget * now); - void keyPress(QKeyEvent *event); +// void keyPress(QKeyEvent *event); + void leftKeyPress(); + void rightKeyPress(); void returnPressInSearchBox(); void about(); @@ -91,6 +93,7 @@ public slots: void showPreferenceDialog(); void showSortDialog(); void swapView(); + void switchHalfMode(bool checked); void toggleSearchBox(bool checked); void toggleShowHiddenFiles(bool checked); void toggleShowSystemFiles(bool checked); diff --git a/mainwindow.ui b/mainwindow.ui index 5976040..43cbca9 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 828 - 531 + 365 @@ -45,143 +45,29 @@ 0 - - - Qt::ClickFocus - - - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - false - - - true - - - QAbstractItemView::DragDrop - - - Qt::CopyAction - - - false - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - Qt::ElideMiddle - - - false - - - false - - - false - - - false - - - - - - - Qt::ClickFocus - - - - - - - TextLabel + + + + 0 + 0 + - + 0 - - - Qt::ClickFocus - - - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - false - - - true - - - QAbstractItemView::DragDrop - - - Qt::CopyAction - - - false - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - Qt::ElideMiddle - - - false - - - false - - - false - - - false - - - - - - - Qt::ClickFocus - - - - - - - TextLabel + + + + 0 + 0 + @@ -190,150 +76,15 @@ - - - - - - Simple Text + + + + 0 + 0 + - - - - 0 - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - - - - 1 - 0 - - - - Qt::NoFocus - - - PushButton - - - - - @@ -361,6 +112,7 @@ + @@ -424,6 +176,7 @@ + @@ -1173,33 +926,48 @@ Alt+Down + + + key_Left + + + Left + + + + + key_Right + + + Right + + + + + true + + + + :/images/Preview.png:/images/Preview.png + + + 片面ビューアモード + + + 片面ビューアモード + + + V + + - SimpleTextView - QPlainTextEdit -
simpletextview.h
-
- - SearchBox - QLineEdit -
searchbox.h
-
- - FolderView - QTableView -
folderview.h
-
- - LocationBox - QLineEdit -
locationbox.h
-
- - SimpleImageView - QGraphicsView -
simpleimageview.h
+ AnyView + QWidget +
anyview.h
+ 1
diff --git a/simpletextview.cpp b/simpletextview.cpp index 1a55536..30c1c68 100644 --- a/simpletextview.cpp +++ b/simpletextview.cpp @@ -46,6 +46,16 @@ SimpleTextView::SimpleTextView(QWidget *parent) : m_copy = new QAction(tr("選択範囲をクリップボードにコピー"), this); m_back = new QAction(tr("戻る"), this); + m_convEUC->setObjectName("convertFromEUC"); + m_convJIS->setObjectName("convertFromJIS"); + m_convSJIS->setObjectName("convertFromSJIS"); + m_convUTF8->setObjectName("convertFromUTF8"); + m_convUTF16->setObjectName("convertFromUTF16"); + m_convUTF16BE->setObjectName("convertFromUTF16BE"); + m_convUTF16LE->setObjectName("convertFromUTF16LE"); + m_copy->setObjectName("copy"); + m_back->setObjectName("back"); + m_convEUC->setShortcut(QKeySequence("Shift+E")); m_convJIS->setShortcut(QKeySequence("Shift+J")); m_convSJIS->setShortcut(QKeySequence("Shift+S")); @@ -56,6 +66,11 @@ SimpleTextView::SimpleTextView(QWidget *parent) : m_copy->setShortcut(QKeySequence::Copy); m_back->setShortcut(QKeySequence("Return")); + QList shortcuts; + shortcuts = m_back->shortcuts(); + shortcuts.append(QKeySequence("Backspace")); + m_back->setShortcuts(shortcuts); + connect(m_convEUC, SIGNAL(triggered()), this, SLOT(convertFromEUC())); connect(m_convJIS, SIGNAL(triggered()), this, SLOT(convertFromJIS())); connect(m_convSJIS, SIGNAL(triggered()), this, SLOT(convertFromSJIS())); @@ -207,44 +222,14 @@ void SimpleTextView::keyPressEvent(QKeyEvent *event) { QString ksq = KeyEventToSequence(event); - if (ksq == "Return" || ksq == "Backspace" || ksq == "W") { - emit viewFinished(this); + if (ProcessShortcut(ksq, this)) { event->accept(); return; } - if (!ksq.isEmpty()) { - foreach (QObject *obj, this->children()) { - QAction *action = qobject_cast(obj); - if (action && action->isEnabled()) { - foreach (const QKeySequence &keySeq, action->shortcuts()) { - if (ksq == keySeq.toString()) { - qDebug() << "emit " << ksq << " " << action->objectName(); - emit action->triggered(); - event->accept(); - return; - } - } - } - } - - foreach (QObject *obj, getMainWnd()->children()) { - QAction *action = qobject_cast(obj); - if (action && action->isEnabled()) { - foreach (const QKeySequence &keySeq, action->shortcuts()) { - if (ksq == keySeq.toString()) { - qDebug() << "emit " << ksq << " " << action->objectName(); - emit action->triggered(); - event->accept(); - return; - } - } - } - } - } - - if (ksq != "Down" && ksq != "Up") { - qDebug() << ksq; + if (ProcessShortcut(ksq, getMainWnd())) { + event->accept(); + return; } QPlainTextEdit::keyPressEvent(event); diff --git a/version.h b/version.h index 89b6933..4e0344f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #ifndef VERSION_H #define VERSION_H -#define VERSION_VALUE 0.13 +#define VERSION_VALUE 0.14 #endif // VERSION_H -- 2.11.0