m_history(),\r
m_historyPos(-1),\r
m_pixmapCache(),\r
- m_pixmapCacheMutex()\r
+ m_pixmapCacheMutex(),\r
+ m_Palette(),\r
+ m_font()\r
{\r
connect(&m_fsWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(fsWatcher_directoryChanged(QString)));\r
}\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
+/// \brief FolderModel::updateAppearance\r
+///\r
+/// 外観を変更します。\r
+///\r
+void FolderModel::updateAppearance(const Preferences &prefs)\r
+{\r
+ qDebug() << "FolderModel::updateAppearance()";\r
+\r
+ m_font = prefs.getFolderViewFont();\r
+ m_Palette.setColor(QPalette::Base, prefs.folderViewBgColor(isActive()));\r
+ m_Palette.setColor(QPalette::Text, prefs.folderViewFgColor(isActive()));\r
+ m_Palette.setColor(QPalette::Highlight, prefs.folderViewMarkedBgColor(isActive()));\r
+ m_Palette.setColor(QPalette::HighlightedText, prefs.folderViewMarkedFgColor(isActive()));\r
+ m_Palette.setColor(QPalette::Dark, prefs.folderViewHiddenColor(isActive()));\r
+ m_Palette.setColor(QPalette::Light, prefs.folderViewReadOnlyColor(isActive()));\r
+ m_Palette.setColor(QPalette::Mid, prefs.folderViewSystemColor(isActive()));\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
/// \brief FolderModel::activeModel\r
/// \return アクティブなモデルを返します。\r
///\r
return QVariant();\r
}\r
\r
- Preferences prefs(const_cast<FolderModel*>(this));\r
-\r
switch (role) {\r
case Qt::DisplayRole:\r
switch (index.column()) {\r
break;\r
\r
case Qt::FontRole:\r
- return prefs.getFolderViewFont();\r
+ return m_font;\r
\r
case Qt::TextAlignmentRole:\r
switch (index.column()) {\r
\r
case Qt::BackgroundRole:\r
if (isMarked(index)) {\r
- return QBrush(prefs.folderViewMarkedBgColor(isActive()));\r
+ return marked();\r
}\r
- return QBrush(prefs.folderViewBgColor(isActive()));\r
+ return base();\r
\r
case Qt::ForegroundRole:\r
if (isMarked(index)) {\r
- return QBrush(prefs.folderViewMarkedFgColor(isActive()));\r
+ return markedText();\r
}\r
if (fileName(index) != ".." && Win32::hasSystemAttribute(filePath(index))) {\r
- return QBrush(prefs.folderViewSystemColor(isActive()));\r
+ return system();\r
}\r
if (fileName(index) != ".." && fileInfo(index).isHidden()) {\r
- return QBrush(prefs.folderViewHiddenColor(isActive()));\r
+ return hidden();\r
}\r
if (fileName(index) != ".." && !fileInfo(index).isWritable()) {\r
- return QBrush(prefs.folderViewReadOnlyColor(isActive()));\r
+ return readOnly();\r
}\r
- return QBrush(prefs.folderViewFgColor(isActive()));\r
+ return text();\r
\r
case Qt::CheckStateRole:\r
if (index.column() == Name && fileName(index) != "..") {\r
#include <QBrush>\r
#include <QFont>\r
#include <QMutex>\r
+#include <QPalette>\r
+class Preferences;\r
\r
class FolderModel : public QAbstractTableModel\r
{\r
void setSorting(QDir::SortFlags sort);\r
QDir::SortFlags sorting() const;\r
QModelIndex touch(const QString &name);\r
+ void updateAppearance(const Preferences &prefs);\r
\r
static FolderModel* activeModel();\r
\r
int m_historyPos;\r
PixmapContainer m_pixmapCache;\r
QMutex m_pixmapCacheMutex;\r
+ QPalette m_Palette;\r
+ QFont m_font;\r
\r
bool isDotFile(const QModelIndex &index) const;\r
void setError(const QString &error = QString());\r
\r
+ const QBrush& base() const;\r
+ const QBrush& text() const;\r
+ const QBrush& marked() const;\r
+ const QBrush& markedText() const;\r
+ const QBrush& hidden() const;\r
+ const QBrush& readOnly() const;\r
+ const QBrush& system() const;\r
+\r
// QAbstractItemModel interface\r
public:\r
int rowCount(const QModelIndex &parent = QModelIndex()) const;\r
refresh();\r
}\r
\r
+inline const QBrush& FolderModel::base() const\r
+{\r
+ return m_Palette.base();\r
+}\r
+inline const QBrush& FolderModel::text() const\r
+{\r
+ return m_Palette.text();\r
+}\r
+inline const QBrush& FolderModel::marked() const\r
+{\r
+ return m_Palette.highlight();\r
+}\r
+inline const QBrush& FolderModel::markedText() const\r
+{\r
+ return m_Palette.highlightedText();\r
+}\r
+inline const QBrush& FolderModel::hidden() const\r
+{\r
+ return m_Palette.dark();\r
+}\r
+inline const QBrush& FolderModel::readOnly() const\r
+{\r
+ return m_Palette.light();\r
+}\r
+inline const QBrush& FolderModel::system() const\r
+{\r
+ return m_Palette.mid();\r
+}\r
#endif // FOLDERMODEL_H\r
///
/// 外観を変更します。
///
-void FolderPanel::updateAppearance()
+void FolderPanel::updateAppearance(const Preferences &prefs)
{
qDebug() << "FolderPanel::updateAppearance()";
- Preferences prefs(this);
QPalette pal;
pal = ui->locationBox->palette();
#include <QAbstractItemView>
class FolderModel;
class MainWindow;
-
+class Preferences;
namespace Ui {
class FolderPanel;
void setModel(FolderModel *m);
void toggleSearch(bool checked);
void toggleView(bool checked);
- void updateAppearance();
+ void updateAppearance(const Preferences &prefs);
private:
Ui::FolderPanel *ui;
qDebug() << "FolderView::initialize()";
connect(this, SIGNAL(doubleClicked(QModelIndex)), w, SLOT(onOpen(QModelIndex)));
- connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- w, SLOT(view_currentChanged(QModelIndex,QModelIndex)));
+// connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+// w, SLOT(view_currentChanged(QModelIndex,QModelIndex)));
installEventFilter(w);
viewport()->installEventFilter(w);
ui(new Ui::MainWindow),\r
m_overwriteDialog(this),\r
m_viewMode(ModeBasic),\r
- m_prevMode(ModeBasic)\r
+ m_prevMode(ModeBasic),\r
+ m_actions()\r
{\r
ui->setupUi(this);\r
connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(app_focusChange(QWidget*,QWidget*)));\r
if (prefs.isCheckUpdate()) {\r
onCheckUpdate(true);\r
}\r
+\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
if (now && (now->objectName() == "folderView" ||\r
now->objectName() == "thumbnailView"))\r
{\r
+ connect(focusItemView()->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),\r
+ this, SLOT(view_currentChanged(QModelIndex,QModelIndex)));\r
FolderModel *m = static_cast<FolderModel*>(focusItemView()->model());\r
setActiveModel(m);\r
ui->statusBar->showMessage(m->filePath(focusItemView()->currentIndex()));\r
view->scaleDown();\r
}\r
\r
- ui->LPanel->updateAppearance();\r
- ui->RPanel->updateAppearance();\r
- ui->FPanel->updateAppearance();\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
view->scaleUp();\r
}\r
\r
- ui->LPanel->updateAppearance();\r
- ui->RPanel->updateAppearance();\r
- ui->FPanel->updateAppearance();\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
SLOT(onOpenBookmark()));\r
action->setData(n);\r
}\r
+\r
+ m_actions = findChildren<QAction*>();\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
\r
PreferenceDialog dlg(this);\r
if (dlg.exec() == QDialog::Accepted) {\r
- ui->LPanel->updateAppearance();\r
- ui->RPanel->updateAppearance();\r
- ui->FPanel->updateAppearance();\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
}\r
}\r
\r
connect(ui->action_MarkInvert, SIGNAL(triggered()), activeModel(), SLOT(onMarkInvert()));\r
connect(ui->action_Refresh, SIGNAL(triggered()), activeModel(), SLOT(refresh()));\r
\r
- ui->LPanel->updateAppearance();\r
- ui->RPanel->updateAppearance();\r
- ui->FPanel->updateAppearance();\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
\r
ui->action_historyBack->setEnabled(!activeModel()->isHistoryBegin());\r
ui->action_HistoryForward->setEnabled(!activeModel()->isHistoryEnd());\r
-\r
-#if 0\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(activeModel()->fileInfo(view->currentIndex()));\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() == ".." && activeModel()->markedItems().isEmpty()) {\r
- // ファイル操作を抑止\r
- ui->action_Copy->setEnabled(false);\r
- ui->action_Delete->setEnabled(false);\r
- ui->action_Move->setEnabled(false);\r
- ui->action_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->action_historyBack->setEnabled(!activeModel()->isHistoryBegin());\r
- ui->action_HistoryForward->setEnabled(!activeModel()->isHistoryEnd());\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->action_SyncPanel->setEnabled(false);\r
- ui->action_SyncPanelTo->setEnabled(false);\r
- ui->action_Copy->setEnabled(false);\r
- ui->action_Move->setEnabled(false);\r
- }\r
- }\r
- else if (qobject_cast<SearchBox*>(w)) {\r
- qDebug() << ">>>>> 検索モードのメニュー設定 <<<<<";\r
- setEnabledAllActions(false);\r
- ui->toggle_Search->setEnabled(true);\r
- ui->action_SearchNext->setEnabled(true);\r
- ui->action_SearchPrev->setEnabled(true);\r
- ui->action_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->action_CheckUpdate->setEnabled(true);\r
- ui->view_FontSizeDown->setEnabled(true);\r
- ui->view_FontSizeUp->setEnabled(true);\r
- ui->action_KeyDown->setEnabled(true);\r
- ui->action_KeyEnd->setEnabled(true);\r
- ui->action_KeyHome->setEnabled(true);\r
- ui->action_KeyUp->setEnabled(true);\r
- ui->action_About->setEnabled(true);\r
- ui->key_Left->setEnabled(true);\r
- ui->key_Right->setEnabled(true);\r
- if (m_viewMode == ModePreview) {\r
- ui->view_HalfMode->setEnabled(true);\r
- }\r
- }\r
-#endif\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
void MainWindow::setEnabledAllActions(bool enable)\r
{\r
qDebug() << "MainWindow::setEnabledAllActions()" << enable;\r
- foreach (QAction *action, findChildren<QAction*>()) {\r
+ foreach (QAction *action, m_actions) {\r
action->setEnabled(enable);\r
}\r
}\r
void view_statusChanged(const QString &text);\r
\r
private:\r
+ typedef QList<QAction*> ActionList;\r
enum Mode {\r
ModeBasic, // 二画面モード\r
ModeFull, // 単画面モード\r
OverWriteDialog m_overwriteDialog;\r
Mode m_viewMode;\r
Mode m_prevMode;\r
+ ActionList m_actions;\r
\r
FolderModel* activeModel() const;\r
Panel* activePanel() const;\r
///
/// 外観を変更します。
///
-void Panel::updateAppearance()
+void Panel::updateAppearance(const Preferences &prefs)
{
qDebug() << "Panel::updateAppearance()";
- Preferences prefs(this);
QPalette pal;
pal = ui->imageView->palette();
ui->textView->setPalette(pal);
ui->textView->setFont(prefs.getTextViewFont());
- ui->folderPanel->updateAppearance();
+ ui->folderPanel->updateAppearance(prefs);
}
///////////////////////////////////////////////////////////////////////////////
class MainWindow;
class FolderPanel;
class FolderModel;
+class Preferences;
namespace Ui {
class Panel;
FolderModel* model() const;
void setModel(FolderModel *m);
void setViewItem(const QModelIndex &index = QModelIndex());
- void updateAppearance();
+ void updateAppearance(const Preferences &prefs);
QWidget* visibleView() const;
private:
return value(Key_BookmarkPath(n)).toString();
}
-QColor Preferences::folderViewFgColor(bool active)
+QColor Preferences::folderViewFgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewFgColor().darker(darkFactor);
}
-QColor Preferences::folderViewBgColor(bool active)
+QColor Preferences::folderViewBgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewBgColor().darker(darkFactor);
}
-QColor Preferences::folderViewMarkedFgColor(bool active)
+QColor Preferences::folderViewMarkedFgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewMarkedFgColor().darker(darkFactor);
}
-QColor Preferences::folderViewMarkedBgColor(bool active)
+QColor Preferences::folderViewMarkedBgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewMarkedBgColor().darker(darkFactor);
}
-QColor Preferences::folderViewSystemColor(bool active)
+QColor Preferences::folderViewSystemColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewSystemColor().darker(darkFactor);
}
-QColor Preferences::folderViewHiddenColor(bool active)
+QColor Preferences::folderViewHiddenColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewHiddenColor().darker(darkFactor);
}
-QColor Preferences::folderViewReadOnlyColor(bool active)
+QColor Preferences::folderViewReadOnlyColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getFolderViewReadOnlyColor().darker(darkFactor);
}
-QColor Preferences::locationBoxFgColor(bool active)
+QColor Preferences::locationBoxFgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
return getLocationBoxFgColor().darker(darkFactor);
}
-QColor Preferences::locationBoxBgColor(bool active)
+QColor Preferences::locationBoxBgColor(bool active) const
{
int darkFactor = 100;
if (!active) {
QString getBookmarkEntry(int n) const;
QString getBookmarkPath(int n) const;
- QColor folderViewFgColor(bool active);
- QColor folderViewBgColor(bool active);
- QColor folderViewMarkedFgColor(bool active);
- QColor folderViewMarkedBgColor(bool active);
- QColor folderViewSystemColor(bool active);
- QColor folderViewHiddenColor(bool active);
- QColor folderViewReadOnlyColor(bool active);
- QColor locationBoxFgColor(bool active);
- QColor locationBoxBgColor(bool active);
+ QColor folderViewFgColor(bool active) const;
+ QColor folderViewBgColor(bool active) const;
+ QColor folderViewMarkedFgColor(bool active) const;
+ QColor folderViewMarkedBgColor(bool active) const;
+ QColor folderViewSystemColor(bool active) const;
+ QColor folderViewHiddenColor(bool active) const;
+ QColor folderViewReadOnlyColor(bool active) const;
+ QColor locationBoxFgColor(bool active) const;
+ QColor locationBoxBgColor(bool active) const;
DECLARE_BOOL(CheckUpdate);
DECLARE_BOOL(ConfirmQuit);
DECLARE_OBJECT(QFont, SearchBoxFont);
DECLARE_OBJECT(QFont, TextViewFont);
-
-
signals:
public slots:
qDebug() << "ThumbnailView::initialize()";
connect(this, SIGNAL(doubleClicked(QModelIndex)), w, SLOT(onOpen(QModelIndex)));
- connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- w, SLOT(view_currentChanged(QModelIndex,QModelIndex)));
+// connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+// w, SLOT(view_currentChanged(QModelIndex,QModelIndex)));
installEventFilter(w);
viewport()->installEventFilter(w);