OSDN Git Service

Ver0.16
authorMasayuki Satoh <miyabi.satoh@gmail.com>
Thu, 28 Aug 2014 07:52:30 +0000 (16:52 +0900)
committerMasayuki Satoh <miyabi.satoh@gmail.com>
Thu, 28 Aug 2014 07:52:30 +0000 (16:52 +0900)
Gefu.pro
README.md
folderview.cpp
keybind.txt
main.cpp
mainwindow.cpp
mainwindow.ui
simpleimageview.cpp
simpleimageview.h
simpletextview.cpp
version.h

index e57c1cb..6ecb326 100644 (file)
--- a/Gefu.pro
+++ b/Gefu.pro
@@ -12,6 +12,11 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 TARGET = Gefu
 TEMPLATE = app
+VERSION = 0.1.6
+QMAKE_TARGET_COMPANY = gefu.sourceforge.jp
+QMAKE_TARGET_PRODUCT = Gefu
+QMAKE_TARGET_DESCRIPTION = Gefu is an Experimental File Utility.
+QMAKE_TARGET_COPYRIGHT = Copyright(c) 2014 @miyabi_satoh
 
 
 SOURCES += main.cpp\
index bd53413..72a1778 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,6 +11,20 @@ Gefu is an Experimental File Utility.
   * 簡易FTPクライアント
   * SNS連携(タイムライン表示とか) ← ファイラーの機能か?
 
+#### 2014/08/29 Ver0.16
+  * 設定ファイルの格納先を変更。
+  * 「片面ビューアモード」を「プレビューモード」に呼称変更。
+    合わせて、キーバインドを「P」に変更。
+  * 画像ビューアの背景色をフォルダビューと同一にした。
+  * ".."に対するコピー・移動・削除・リネームを禁止とした。
+  * リネーム時、変更後のファイルにカーソルを合わせるようにした。
+  * 移動・削除時、カーソル位置(行)を維持するようにした。
+  * ファイル・フォルダの作成時、作成したアイテムにカーソルを合わせるようにした。
+  * ツールバーのサイズを大きくした。
+  * デフォルトフォントをMSゴシック(Win)/Monaco(Mac)にした。
+  * 不具合修正
+    * スペースキーでのマークが正常に行われないケースがあったのを修正。
+
 #### 2014/08/28 Ver0.15
   * 簡易画像ビューアを実装。
   * 外部アプリを優先する拡張子のデフォルトから、対応画像フォーマットの拡張子を削除。
index 3584e74..105331d 100644 (file)
@@ -120,8 +120,8 @@ void FolderView::refresh()
     else if (row >= m_model.rowCount()) {
         row = m_model.rowCount() - 1;
     }
-    setCurrentIndex(m_model.index(row, 0));
-    selectRow(row);
+    setCurrentIndex(m_model.index(row, 1));
+//    selectRow(row);
 }
 
 void FolderView::searchItem(const QString &text)
@@ -129,7 +129,7 @@ void FolderView::searchItem(const QString &text)
     qDebug() << side() << "searchItem" << text;
 
     for (int row = 0; row < m_model.rowCount(); row++) {
-        QModelIndex index = m_model.index(row, 0);
+        QModelIndex index = m_model.index(row, 1);
         QString name = m_model.fileInfo(index).fileName().toLower();
         if (name.indexOf(text.toLower()) != -1) {
             setCurrentIndex(index);
@@ -146,7 +146,7 @@ void FolderView::searchNext(const QString &text)
     qDebug() << side() << "searchNext" << text;
 
     for (int row = currentIndex().row() + 1; row < m_model.rowCount(); row++) {
-        QModelIndex index = m_model.index(row, 0);
+        QModelIndex index = m_model.index(row, 1);
         QString name = m_model.fileInfo(index).fileName().toLower();
         if (name.indexOf(text.toLower()) != -1) {
             setCurrentIndex(index);
@@ -163,7 +163,7 @@ void FolderView::searchPrev(const QString &text)
     qDebug() << side() << "searchPrev" << text;
 
     for (int row = currentIndex().row() - 1; row >= 0; row--) {
-        QModelIndex index = m_model.index(row, 0);
+        QModelIndex index = m_model.index(row, 1);
         QString name = m_model.fileInfo(index).fileName().toLower();
         if (name.indexOf(text.toLower()) != -1) {
             setCurrentIndex(index);
@@ -196,7 +196,7 @@ void FolderView::setCheckStateAllFiles()
 
     setUpdatesEnabled(false);
     for (int n = 0; n < m_model.rowCount(); n++) {
-        QModelIndex index = m_model.index(n, 0);
+        QModelIndex index = m_model.index(n, 1);
         QFileInfo info = m_model.fileInfo(index);
         if (info.isDir()) {
             m_model.setCheckState(index, Qt::Unchecked);
@@ -218,7 +218,7 @@ void FolderView::invertCheckState()
 
     setUpdatesEnabled(false);
     for (int n = 0; n < m_model.rowCount(); n++) {
-        QModelIndex index = m_model.index(n, 0);
+        QModelIndex index = m_model.index(n, 1);
         if (m_model.checkState(index) == Qt::Checked) {
             m_model.setCheckState(index, Qt::Unchecked);
         }
@@ -233,6 +233,8 @@ void FolderView::invertCheckState()
 
 void FolderView::toggleCheckState(const QModelIndex &index)
 {
+    qDebug() << side() << "toggleCheckState();" << index;
+
     QFileInfo info = m_model.fileInfo(index);
     if (info.fileName() != "..") {
         if (m_model.checkState(index) == Qt::Checked) {
@@ -308,7 +310,7 @@ void FolderView::setPath(const QString &path, bool addHistory)
 
     setUpdatesEnabled(false);
     m_model.setPath(path);
-    setCurrentIndex(m_model.index(0, 0));
+    setCurrentIndex(m_model.index(0, 1));
     setUpdatesEnabled(true);
 
     if (addHistory) {
@@ -397,7 +399,7 @@ void FolderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bott
 
 void FolderView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
 {
-    qDebug() << side() << "currentChanged();";
+    qDebug() << side() << "currentChanged();" << current;
 
     emit currentChanged(m_model.fileInfo(current));
 
index 99bde58..07a0744 100644 (file)
@@ -13,6 +13,7 @@
 ||L         ||最新の情報に更新                   ||                                 ||                               ||                             ||Load                           ||
 ||M         ||開く                               ||アプリケーションで開く           ||                               ||隣のペインにアイテムを移動   ||viのキーバインド, Move         ||
 ||O         ||隣のパネルと同じフォルダを表示     ||隣のパネルに同じフォルダを表示   ||                               ||                             ||Onaji(同じ)                    ||
+||P         ||プレビューモードに切り替え/解除   ||                                 ||                               ||                             ||Preview                        ||
 ||Q         ||終了                               ||                                 ||                               ||                             ||Quit                           ||
 ||R         ||履歴を表示                         ||                                 ||                               ||名前の変更                   ||Rireki, Rename                 ||
 ||S         ||ソート方法を選択                   ||システムファイルを表示/非表示    ||                               ||                             ||Sort, System                   ||
index 055606e..b2addf2 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -11,8 +11,8 @@
 int main(int argc, char *argv[])\r
 {\r
     QApplication a(argc, argv);\r
-    a.setOrganizationName("miyabi");\r
-    a.setOrganizationDomain("rakusaba.jp");\r
+    a.setOrganizationName("gefu");\r
+    a.setOrganizationDomain("sourceforge.jp");\r
     a.setApplicationName("Gefu");\r
 #if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACX)\r
     a.setWindowIcon(QIcon(":/images/Gefu.icns"));\r
@@ -26,14 +26,13 @@ int main(int argc, char *argv[])
         settings.clear();\r
     }\r
 \r
-    // オラはやっちまっただぁ…\r
-    QString strValue = settings.value("TerminalOption", "").toString();\r
-    if (!strValue.isEmpty()) {\r
-        settings.remove("TerminalOption");\r
-        settings.setValue(IniKey_TerminalOption, strValue);\r
-    }\r
-\r
     // 各オプションのデフォルト値を設定する\r
+    QFont font = a.font();\r
+#ifdef Q_OS_WIN\r
+    font.setFamily("MS ゴシック");\r
+#else\r
+    font.setFamily("Monaco");\r
+#endif\r
     //>>>>> 起動と終了\r
     if (settings.value(IniKey_ConfirmExit, "").toString().isEmpty()) {\r
         settings.setValue(IniKey_ConfirmExit, true);\r
@@ -46,12 +45,12 @@ int main(int argc, char *argv[])
     }\r
     //>>>>> 色とフォント\r
     if (settings.value(IniKey_BoxFont, "").toString().isEmpty()) {\r
-        settings.setValue(IniKey_BoxFont, a.font());\r
+        settings.setValue(IniKey_BoxFont, font);\r
         settings.setValue(IniKey_BoxColorBg, QPalette().base().color());\r
         settings.setValue(IniKey_BoxColorFg, QPalette().text().color());\r
     }\r
     if (settings.value(IniKey_ViewFont, "").toString().isEmpty()) {\r
-        settings.setValue(IniKey_ViewFont, a.font());\r
+        settings.setValue(IniKey_ViewFont, font);\r
         settings.setValue(IniKey_ViewColorBgMark, QColor(0,192,0));\r
         settings.setValue(IniKey_ViewColorBgNormal, QPalette().base().color());\r
         settings.setValue(IniKey_ViewColorFgHidden, QColor(128,128,128));\r
@@ -106,7 +105,7 @@ int main(int argc, char *argv[])
     if (settings.value(IniKey_ViewerFont, "").toString().isEmpty()) {\r
         settings.setValue(IniKey_ViewerColorBg, QPalette().base().color());\r
         settings.setValue(IniKey_ViewerColorFg, QPalette().text().color());\r
-        settings.setValue(IniKey_ViewerFont, a.font());\r
+        settings.setValue(IniKey_ViewerFont, font);\r
         settings.setValue(IniKey_ViewerForceOpen, false);\r
         settings.setValue(IniKey_ViewerInherit, true);\r
         settings.setValue(IniKey_ViewerIgnoreExt, ViewerIgnoreExt());\r
index 4eb248d..ca7cc32 100644 (file)
@@ -385,13 +385,17 @@ void MainWindow::moveItems()
     opDlg.setWorker(worker);\r
     opDlg.setAutoClose(settings.value(IniKey_AutoCloseMove).toBool());\r
 \r
+    int row = view->currentIndex().row();\r
+\r
     opDlg.exec();\r
 \r
-    settings.setValue(IniKey_AutoCloseMove, opDlg.autoClose());\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
-//    ui->folderView1->refresh();\r
-//    ui->folderView2->refresh();\r
+    settings.setValue(IniKey_AutoCloseMove, opDlg.autoClose());\r
 }\r
 \r
 void MainWindow::leftKeyPress()\r
@@ -579,10 +583,6 @@ void MainWindow::copyItems(const QFileInfoList &list, const QString &tgtDir)
     opDlg.exec();\r
 \r
     settings.setValue(IniKey_AutoCloseCopy, opDlg.autoClose());\r
-\r
-    // 念のため、リフレッシュ\r
-//    ui->folderView1->refresh();\r
-//    ui->folderView2->refresh();\r
 }\r
 \r
 void MainWindow::copyItems()\r
@@ -630,6 +630,9 @@ void MainWindow::createFile()
         if (settings.value(IniKey_OpenAfterCreateFile).toBool()) {\r
             openEditor(dir.absoluteFilePath(name));\r
         }\r
+\r
+        view->refresh();\r
+        view->searchItem(name);\r
     }\r
 }\r
 \r
@@ -659,6 +662,9 @@ void MainWindow::createFolder()
         if (settings.value(IniKey_MoveAfterCreateFolder).toBool()) {\r
             view->setPath(dir.absoluteFilePath(name), true);\r
         }\r
+\r
+        view->refresh();\r
+        view->searchItem(name);\r
     }\r
 }\r
 \r
@@ -699,13 +705,18 @@ void MainWindow::deleteItems()
     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
-    settings.setValue(IniKey_AutoCloseDelete, opDlg.autoClose());\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
-//    ui->folderView1->refresh();\r
-//    ui->folderView2->refresh();\r
+    settings.setValue(IniKey_AutoCloseDelete, opDlg.autoClose());\r
 }\r
 \r
 void MainWindow::open(const QModelIndex &index)\r
@@ -777,7 +788,6 @@ void MainWindow::openEditor(const QString &path)
         if (!startProcess(command, info.absolutePath(), tr("外部エディタの起動に失敗しました。"))) {\r
             break;\r
         }\r
-        Sleep(100);\r
     }\r
 }\r
 \r
@@ -809,7 +819,7 @@ void MainWindow::openTerminal()
         if (!startProcess(command, info.absolutePath(), tr("ターミナルの起動に失敗しました。"))) {\r
             break;\r
         }\r
-        Sleep(100);\r
+        Sleep(1000);\r
     }\r
 }\r
 \r
@@ -867,6 +877,10 @@ void MainWindow::renameItems()
     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
@@ -916,7 +930,16 @@ void MainWindow::showFilterDialog()
 \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
@@ -1222,25 +1245,6 @@ void MainWindow::toggleSearchBox(bool checked)
     }\r
 }\r
 \r
-//void MainWindow::openRequest(const QFileInfo &info)\r
-//{\r
-//    m_focusedView = QApplication::focusWidget();\r
-\r
-//    QFile file(info.absoluteFilePath());\r
-//    if (file.open(QIODevice::ReadOnly)) {\r
-//        ui->splitter->setVisible(false);\r
-//        ui->textView->setVisible(true);\r
-//        ui->textView->setFocus();\r
-//        ui->textView->setSource(file.readAll());\r
-//        file.close();\r
-//    }\r
-//    else {\r
-//        QMessageBox::critical(\r
-//                    this, tr("エラー"),\r
-//                    tr("ファイルの読み込みに失敗しました。"));\r
-//    }\r
-//}\r
-\r
 void MainWindow::showPreferenceDialog()\r
 {\r
     qDebug() << "MainWindow::showPreferenceDialog";\r
@@ -1491,6 +1495,7 @@ void MainWindow::updateActions()
     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
@@ -1518,6 +1523,14 @@ void MainWindow::updateActions()
             }\r
         }\r
 \r
+        if (info.fileName() == "..") {\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
index 43cbca9..80df178 100644 (file)
@@ -93,8 +93,8 @@
    </property>\r
    <property name="iconSize">\r
     <size>\r
-     <width>16</width>\r
-     <height>16</height>\r
+     <width>24</width>\r
+     <height>24</height>\r
     </size>\r
    </property>\r
    <attribute name="toolBarArea">\r
    <addaction name="move_Forward"/>\r
    <addaction name="move_Root"/>\r
    <addaction name="move_Home"/>\r
-   <addaction name="move_Jump"/>\r
    <addaction name="separator"/>\r
+   <addaction name="move_Jump"/>\r
    <addaction name="cmd_Copy"/>\r
    <addaction name="cmd_Move"/>\r
    <addaction name="cmd_Delete"/>\r
      <normaloff>:/images/Preview.png</normaloff>:/images/Preview.png</iconset>\r
    </property>\r
    <property name="text">\r
-    <string>片面ビューアモード</string>\r
+    <string>プレビューモード</string>\r
    </property>\r
    <property name="toolTip">\r
-    <string>片面ビューアモード</string>\r
+    <string>プレビューモード</string>\r
    </property>\r
    <property name="shortcut">\r
-    <string>V</string>\r
+    <string>P</string>\r
    </property>\r
   </action>\r
  </widget>\r
index 317d3d8..9635264 100644 (file)
@@ -5,6 +5,7 @@
 #include <QKeyEvent>
 #include <QAction>
 #include <QMenu>
+#include <QSettings>
 
 SimpleImageView::SimpleImageView(QWidget *parent) :
     QGraphicsView(parent),
@@ -27,7 +28,7 @@ bool SimpleImageView::setSource(const QString &path)
 {
     qDebug() << "SimpleImageView::setSource()";
 
-    m_img = QImage(path);
+    m_img = QPixmap(path);
 
     emit fileInfo(QString("%1x%2x%3bpp")
                   .arg(m_img.width())
@@ -47,7 +48,7 @@ void SimpleImageView::paintEvent(QPaintEvent *)
     qDebug() << "SimpleImageView::paintEvent();";
 
     QPainter painter(viewport());
-    QImage scaledImg;
+    QPixmap scaledImg;
 
     if (m_img.width() < viewport()->width() &&
         m_img.height() < viewport()->height())
@@ -60,7 +61,10 @@ void SimpleImageView::paintEvent(QPaintEvent *)
                                  Qt::SmoothTransformation);
     }
 
-    painter.drawImage(
+    QSettings settings;
+    painter.setBrush(settings.value(IniKey_ViewColorBgNormal).value<QColor>());
+    painter.drawRect(viewport()->rect());
+    painter.drawPixmap(
                 (viewport()->width() - scaledImg.width()) / 2,
                 (viewport()->height() - scaledImg.height()) / 2,
                 scaledImg);
index 62c5483..e181826 100644 (file)
@@ -12,7 +12,7 @@ public:
     bool setSource(const QString &path);
 
 private:
-    QImage m_img;
+    QPixmap m_img;
     QAction *m_back;
 
 signals:
@@ -22,7 +22,6 @@ signals:
 public slots:
     void back();
 
-
     // QWidget interface
 protected:
     void paintEvent(QPaintEvent *);
index 712a4d5..6b79ed6 100644 (file)
@@ -88,6 +88,11 @@ SimpleTextView::SimpleTextView(QWidget *parent) :
 void SimpleTextView::setSource(const QByteArray &source)
 {
     m_source = source;
+    if (m_source.size() == 0) {
+        setPlainText("");
+        emit fileInfo("");
+        return;
+    }
 
     std::string code = detectCode(m_source.left(1024));
     QTextCodec *codec = QTextCodec::codecForName(code.c_str());
index 5f2a2ca..284046e 100644 (file)
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
 #ifndef VERSION_H
 #define VERSION_H
 
-#define VERSION_VALUE   0.15
+#define VERSION_VALUE   0.16
 
 #endif // VERSION_H