Sfoglia il codice sorgente

Use standart images: gnome-icon-theme

Kandrashin Denis 13 anni fa
parent
commit
3f639301d0

+ 17 - 11
source/fb2edit.qrc

@@ -1,15 +1,21 @@
 <RCC>
     <qresource prefix="/">
-        <file>images/copy.png</file>
-        <file>images/cut.png</file>
-        <file>images/new.png</file>
-        <file>images/open.png</file>
-        <file>images/paste.png</file>
-        <file>images/save.png</file>
-        <file>images/textunder.png</file>
-        <file>images/textbold.png</file>
-        <file>images/textitalic.png</file>
-        <file>images/editundo.png</file>
-        <file>images/editredo.png</file>
+        <file>images/application-exit.png</file>
+        <file>images/document-new.png</file>
+        <file>images/document-open.png</file>
+        <file>images/document-properties.png</file>
+        <file>images/document-save.png</file>
+        <file>images/edit-copy.png</file>
+        <file>images/edit-cut.png</file>
+        <file>images/edit-find.png</file>
+        <file>images/edit-find-replace.png</file>
+        <file>images/edit-paste.png</file>
+        <file>images/edit-redo.png</file>
+        <file>images/edit-undo.png</file>
+        <file>images/format-text-bold.png</file>
+        <file>images/format-text-italic.png</file>
+        <file>images/format-text-strikethrough.png</file>
+        <file>images/format-text-underline.png</file>
+        <file>images/window-close.png</file>
     </qresource>
 </RCC>

+ 24 - 36
source/fb2main.cpp

@@ -156,12 +156,14 @@ void MainWindow::init()
     setUnifiedTitleAndToolBarOnMac(true);
 }
 
-void MainWindow::createActions()
+QIcon MainWindow::icon(const QString &name)
 {
+    QString file = QString(":/images/%1.png").arg(name);
+    return QIcon::fromTheme(name, QIcon(file));
+}
 
-//  http://svn.gnome.org/viewvc/gnome-icon-theme/trunk/24x24/actions/
-
-    QIcon icon;
+void MainWindow::createActions()
+{
     QAction * act;
     QMenu * menu;
     QToolBar * tool;
@@ -169,8 +171,7 @@ void MainWindow::createActions()
     menu = menuBar()->addMenu(tr("&File"));
     tool = addToolBar(tr("File"));
 
-    icon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
-    act = new QAction(icon, tr("&New"), this);
+    act = new QAction(icon("document-new"), tr("&New"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcuts(QKeySequence::New);
     act->setStatusTip(tr("Create a new file"));
@@ -178,24 +179,21 @@ void MainWindow::createActions()
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
-    act = new QAction(icon, tr("&Open..."), this);
+    act = new QAction(icon("document-open"), tr("&Open..."), this);
     act->setShortcuts(QKeySequence::Open);
     act->setStatusTip(tr("Open an existing file"));
     connect(act, SIGNAL(triggered()), this, SLOT(fileOpen()));
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
-    act = new QAction(icon, tr("&Save"), this);
+    act = new QAction(icon("document-save"), tr("&Save"), this);
     act->setShortcuts(QKeySequence::Save);
     act->setStatusTip(tr("Save the document to disk"));
     connect(act, SIGNAL(triggered()), this, SLOT(fileSave()));
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("document-save-as");
-    act = new QAction(icon, tr("Save &As..."), this);
+    act = new QAction(icon("document-save-as"), tr("Save &As..."), this);
     act->setShortcuts(QKeySequence::SaveAs);
     act->setStatusTip(tr("Save the document under a new name"));
     connect(act, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
@@ -203,15 +201,13 @@ void MainWindow::createActions()
 
     menu->addSeparator();
 
-    icon = QIcon::fromTheme("window-close");
-    act = new QAction(icon, tr("&Close"), this);
+    act = new QAction(icon("window-close"), tr("&Close"), this);
     act->setShortcuts(QKeySequence::Close);
     act->setStatusTip(tr("Close this window"));
     connect(act, SIGNAL(triggered()), this, SLOT(close()));
     menu->addAction(act);
 
-    icon = QIcon::fromTheme("application-exit");
-    act = new QAction(icon, tr("E&xit"), this);
+    act = new QAction(icon("application-exit"), tr("E&xit"), this);
     act->setShortcuts(QKeySequence::Quit);
     act->setStatusTip(tr("Exit the application"));
     connect(act, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
@@ -222,15 +218,13 @@ void MainWindow::createActions()
 
     connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
 
-    icon = QIcon::fromTheme("edit-undo", QIcon(":/images/editundo.png"));
-    actionUndo = act = new QAction(icon, tr("&Undo"), this);
+    actionUndo = act = new QAction(icon("edit-undo"), tr("&Undo"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcut(QKeySequence::Undo);
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("edit-redo", QIcon(":/images/editredo.png"));
-    actionRedo = act = new QAction(icon, tr("&Redo"), this);
+    actionRedo = act = new QAction(icon("edit-redo"), tr("&Redo"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcut(QKeySequence::Redo);
     menu->addAction(act);
@@ -239,8 +233,7 @@ void MainWindow::createActions()
     menu->addSeparator();
     tool->addSeparator();
 
-    icon = QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png"));
-    actionCut = act = new QAction(icon, tr("Cu&t"), this);
+    actionCut = act = new QAction(icon("edit-cut"), tr("Cu&t"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcuts(QKeySequence::Cut);
     act->setStatusTip(tr("Cut the current selection's contents to the clipboard"));
@@ -248,8 +241,7 @@ void MainWindow::createActions()
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
-    actionCopy = act = new QAction(icon, tr("&Copy"), this);
+    actionCopy = act = new QAction(icon("edit-copy"), tr("&Copy"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcuts(QKeySequence::Copy);
     act->setStatusTip(tr("Copy the current selection's contents to the clipboard"));
@@ -257,8 +249,7 @@ void MainWindow::createActions()
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png"));
-    actionPaste = act = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
+    actionPaste = act = new QAction(icon("edit-paste"), tr("&Paste"), this);
     act->setPriority(QAction::LowPriority);
     act->setShortcuts(QKeySequence::Paste);
     act->setStatusTip(tr("Paste the clipboard's contents into the current selection"));
@@ -269,32 +260,28 @@ void MainWindow::createActions()
     menu = menuBar()->addMenu(tr("Format"));
     tool = addToolBar(tr("Format"));
 
-    icon = QIcon::fromTheme("format-text-bold", QIcon(":/images/textbold.png"));
-    actionTextBold = act = new QAction(icon, tr("Bold"), this);
+    actionTextBold = act = new QAction(icon("format-text-bold"), tr("Bold"), this);
     act->setShortcuts(QKeySequence::Bold);
     act->setCheckable(true);
     connect(act, SIGNAL(triggered()), this, SLOT(textBold()));
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("format-text-italic", QIcon(":/images/textitalic.png"));
-    actionTextItalic = act = new QAction(icon, tr("Italic"), this);
+    actionTextItalic = act = new QAction(icon("format-text-italic"), tr("Italic"), this);
     act->setShortcuts(QKeySequence::Italic);
     act->setCheckable(true);
     connect(act, SIGNAL(triggered()), this, SLOT(textItalic()));
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("format-text-underline", QIcon(":/images/textunderline.png"));
-    actionTextUnder = act = new QAction(icon, tr("Underline"), this);
+    actionTextUnder = act = new QAction(icon("format-text-underline"), tr("Underline"), this);
     act->setShortcuts(QKeySequence::Underline);
     act->setCheckable(true);
     connect(act, SIGNAL(triggered()), this, SLOT(textUnder()));
     menu->addAction(act);
     tool->addAction(act);
 
-    icon = QIcon::fromTheme("format-text-strikethrough", QIcon(":/images/textstrike.png"));
-    actionTextStrike = act = new QAction(icon, tr("Strikethrough"), this);
+    actionTextStrike = act = new QAction(icon("format-text-strikethrough"), tr("Strikethrough"), this);
     act->setCheckable(true);
     connect(act, SIGNAL(triggered()), this, SLOT(textStrike()));
     menu->addAction(act);
@@ -324,8 +311,7 @@ void MainWindow::createActions()
 
     menu = menuBar()->addMenu(tr("&Help"));
 
-    icon = QIcon::fromTheme("help-about");
-    act = new QAction(icon, tr("&About"), this);
+    act = new QAction(icon("help-about"), tr("&About"), this);
     act->setStatusTip(tr("Show the application's About box"));
     connect(act, SIGNAL(triggered()), this, SLOT(about()));
     menu->addAction(act);
@@ -584,8 +570,10 @@ void MainWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
 {
     if (!textEdit) return;
     QTextCursor cursor = textEdit->textCursor();
+    cursor.beginEditBlock();
     if (!cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
     cursor.mergeCharFormat(format);
     textEdit->mergeCurrentCharFormat(format);
+    cursor.endEditBlock();
 }
 

+ 1 - 0
source/fb2main.h

@@ -51,6 +51,7 @@ private:
     static Fb2MainDocument * loadFB2(const QString &filename);
     bool loadXML(const QString &filename);
     void connectTextDocument(QTextDocument * document);
+    QIcon MainWindow::icon(const QString &name);
 
 private:
     void init();

BIN
source/images/application-exit.png


BIN
source/images/copy.png


BIN
source/images/cut.png


BIN
source/images/document-new.png


BIN
source/images/document-open.png


BIN
source/images/document-properties.png


BIN
source/images/document-save.png


BIN
source/images/edit-copy.png


BIN
source/images/edit-cut.png


BIN
source/images/edit-find-replace.png


BIN
source/images/edit-find.png


BIN
source/images/edit-paste.png


BIN
source/images/edit-redo.png


BIN
source/images/edit-undo.png


BIN
source/images/editcopy.png


BIN
source/images/editcut.png


BIN
source/images/editpaste.png


BIN
source/images/editredo.png


BIN
source/images/editundo.png


BIN
source/images/exportpdf.png


BIN
source/images/filenew.png


BIN
source/images/fileopen.png


BIN
source/images/fileprint.png


BIN
source/images/filesave.png


BIN
source/images/format-text-bold.png


BIN
source/images/format-text-italic.png


BIN
source/images/format-text-strikethrough.png


BIN
source/images/format-text-underline.png


BIN
source/images/new.png


BIN
source/images/open.png


BIN
source/images/paste.png


BIN
source/images/save.png


BIN
source/images/textbold.png


BIN
source/images/textitalic.png


BIN
source/images/textunder.png


BIN
source/images/window-close.png